Conjugate a Latin verb: Difference between revisions
Initial submission for Conjugate a Latin Verb |
|||
Line 582: | Line 582: | ||
'are' non satis diu conjugatus</pre> |
'are' non satis diu conjugatus</pre> |
||
=={{header|FutureBasic}}== |
|||
<syntaxhighlight lang="futurebasic"> |
|||
include "NSLog.incl" |
|||
local fn Conjugate( infinitive as CFStringRef ) as CFArrayRef |
|||
if ( len(infinitive) < 4 ) then exit fn = @[fn StringWithFormat( @"[Can not conjugate %@.]", infinitive)] |
|||
CFStringRef conjugation |
|||
CFStringRef ending = fn StringSubstringFromIndex( infinitive, len(infinitive) - 3 ) |
|||
CFMutableArrayRef conjugations = fn MutableArrayNew |
|||
CFMutableArrayRef result = fn MutableArrayNew |
|||
if fn StringIsEqual( ending, @"are" ) then MutableArrayAddObjectsFromArray( conjugations, @[@"o", @"as", @"at", @"amus", @"atis", @"ant"] ) |
|||
if fn StringIsEqual( ending, @"ēre" ) then MutableArrayAddObjectsFromArray( conjugations, @[@"eo", @"es", @"et", @"emus", @"etis", @"ent"] ) |
|||
if fn StringIsEqual( ending, @"ere" ) then MutableArrayAddObjectsFromArray( conjugations, @[@"o", @"is", @"it", @"imus", @"itis", @"unt"] ) |
|||
if fn StringIsEqual( ending, @"ire" ) then MutableArrayAddObjectsFromArray( conjugations, @[@"io", @"is", @"it", @"imus", @"itis", @"iunt"] ) |
|||
if fn ArrayCount( conjugations ) < 1 then exit fn = @[fn StringWithFormat( @"[Can not conjugate %@.]", infinitive )] |
|||
for conjugation in conjugations |
|||
MutableArrayAddObject( result, fn StringWithFormat( @"%@%@", fn StringSubstringToIndex( infinitive, len(infinitive) - 3 ), conjugation ) ) |
|||
next |
|||
end fn = result |
|||
local fn DoConjugations |
|||
CFStringRef infinitive, conjugation |
|||
CFArrayRef infinitives = @[@"amare", @"videre", @"ducere", @"audire", @"qwerty", @"are"] |
|||
for infinitive in infinitives |
|||
NSLog( @"\nConjugation of: %@", infinitive ) |
|||
CFArrayRef conjugations = fn Conjugate( infinitive ) |
|||
for conjugation in conjugations |
|||
NSLog( @"%@", conjugation ) |
|||
next |
|||
next |
|||
end fn |
|||
fn DoConjugations |
|||
HandleEvents |
|||
</syntaxhighlight> |
|||
<pre> |
|||
Conjugation of: amare |
|||
amo |
|||
amas |
|||
amat |
|||
amamus |
|||
amatis |
|||
amant |
|||
Conjugation of: videre |
|||
vido |
|||
vidis |
|||
vidit |
|||
vidimus |
|||
viditis |
|||
vidunt |
|||
Conjugation of: ducere |
|||
duco |
|||
ducis |
|||
ducit |
|||
ducimus |
|||
ducitis |
|||
ducunt |
|||
Conjugation of: audire |
|||
audio |
|||
audis |
|||
audit |
|||
audimus |
|||
auditis |
|||
audiunt |
|||
Conjugation of: qwerty |
|||
[Can not conjugate qwerty.] |
|||
Conjugation of: are |
|||
[Can not conjugate are.] |
|||
</pre> |
|||
=={{header|Go}}== |
=={{header|Go}}== |
||
{{trans|Wren}} |
{{trans|Wren}} |
Revision as of 11:56, 18 June 2024
Basic Data Operation
This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:
Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |
Comparison |
Matching
Memory Operations
Pointers & references |
Addresses
- Task
- Create a program that can take a Latin verb and conjugate it, displaying in the following order:
1st person singular 2nd person singular 3rd person singular 1st person plural 2nd person plural 3rd person plural
- Each should be on its own line.
- Have at least one example from each of the 4 conjugations.
- Irregular verbs are not required.
- Translation into English is optional.
- Metrics
- Counting
- Word frequency
- Letter frequency
- Jewels and stones
- I before E except after C
- Bioinformatics/base count
- Count occurrences of a substring
- Count how many vowels and consonants occur in a string
- Remove/replace
- XXXX redacted
- Conjugate a Latin verb
- Remove vowels from a string
- String interpolation (included)
- Strip block comments
- Strip comments from a string
- Strip a set of characters from a string
- Strip whitespace from a string -- top and tail
- Strip control codes and extended characters from a string
- Anagrams/Derangements/shuffling
- Word wheel
- ABC problem
- Sattolo cycle
- Knuth shuffle
- Ordered words
- Superpermutation minimisation
- Textonyms (using a phone text pad)
- Anagrams
- Anagrams/Deranged anagrams
- Permutations/Derangements
- Find/Search/Determine
- ABC words
- Odd words
- Word ladder
- Semordnilap
- Word search
- Wordiff (game)
- String matching
- Tea cup rim text
- Alternade words
- Changeable words
- State name puzzle
- String comparison
- Unique characters
- Unique characters in each string
- Extract file extension
- Levenshtein distance
- Palindrome detection
- Common list elements
- Longest common suffix
- Longest common prefix
- Compare a list of strings
- Longest common substring
- Find common directory path
- Words from neighbour ones
- Change e letters to i in words
- Non-continuous subsequences
- Longest common subsequence
- Longest palindromic substrings
- Longest increasing subsequence
- Words containing "the" substring
- Sum of the digits of n is substring of n
- Determine if a string is numeric
- Determine if a string is collapsible
- Determine if a string is squeezable
- Determine if a string has all unique characters
- Determine if a string has all the same characters
- Longest substrings without repeating characters
- Find words which contains all the vowels
- Find words which contain the most consonants
- Find words which contains more than 3 vowels
- Find words whose first and last three letters are equal
- Find words with alternating vowels and consonants
- Formatting
- Substring
- Rep-string
- Word wrap
- String case
- Align columns
- Literals/String
- Repeat a string
- Brace expansion
- Brace expansion using ranges
- Reverse a string
- Phrase reversals
- Comma quibbling
- Special characters
- String concatenation
- Substring/Top and tail
- Commatizing numbers
- Reverse words in a string
- Suffixation of decimal numbers
- Long literals, with continuations
- Numerical and alphabetical suffixes
- Abbreviations, easy
- Abbreviations, simple
- Abbreviations, automatic
- Song lyrics/poems/Mad Libs/phrases
- Mad Libs
- Magic 8-ball
- 99 bottles of beer
- The Name Game (a song)
- The Old lady swallowed a fly
- The Twelve Days of Christmas
- Tokenize
- Text between
- Tokenize a string
- Word break problem
- Tokenize a string with escaping
- Split a character string based on change of character
- Sequences
- See also
11l
F conjugate(infinitive)
I !(infinitive[(len)-3..] == ‘are’)
print(‘'’infinitive"' non prima coniugatio verbi.\n")
R
V stem = infinitive[0 .< (len)-3]
I stem.empty
print("\'"infinitive"\' non satis diu conjugatus\n")
R
print(‘Praesens indicativi temporis of '’infinitive‘':’)
L(ending) (‘o’, ‘as’, ‘at’, ‘amus’, ‘atis’, ‘ant’)
print(‘ ’stem‘’ending)
print()
L(infinitive) (‘amare’, ‘dare’, ‘qwerty’, ‘are’)
conjugate(infinitive)
- Output:
Praesens indicativi temporis of 'amare': amo amas amat amamus amatis amant Praesens indicativi temporis of 'dare': do das dat damus datis dant 'qwerty' non prima coniugatio verbi. 'are' non satis diu conjugatus
ALGOL 68
BEGIN # print some Latin verb conjugations #
PROC s length = ( STRING s )INT: ( UPB s + 1 ) - LWB s; # calculates the length of s #
# prints the cojugations of lv or an error message if we don't know how to conjugate lv #
PROC print conjugations = ( STRING lv )VOID:
IF []STRING ending = ( "are", "ēre", "ere", "ire" );
INT length = s length( lv );
INT conjugation := 0;
INT ending length := 0;
BOOL long enough := FALSE;
FOR i FROM LWB ending TO UPB ending WHILE conjugation = 0 DO
ending length := s length( ending[ i ] );
IF ending length < length
THEN
# the word is long enough for at least one ending #
long enough := TRUE;
IF lv[ ( UPB lv + 1 ) - ending length : ] = ending[ i ]
THEN
conjugation := i
FI
FI
OD;
NOT long enough
THEN
print( ( """", lv, """ is not long enough to conjugate", newline ) )
ELIF conjugation = 0
THEN
print( ( "Don't know how to conjugate """, lv, """", newline ) )
ELSE
[,]STRING suffix = ( ( "o", "as", "at", "amus", "atis", "ant" )
, ( "eo", "es", "et", "emus", "etis", "ent" )
, ( "o", "is", "it", "imus", "itis", "unt" )
, ( "io", "is", "it", "imus", "itis", "iunt" )
);
STRING prefix = lv[ : UPB lv - ending length ];
print( ( " Conjugations of """, lv, """:", newline ) );
FOR i FROM 2 LWB suffix TO 2 UPB suffix DO
print( ( " ", prefix, suffix[ conjugation, i ], newline ) )
OD
FI # print confugations # ;
print( ( "Present Indicative conjugation:", newline ) );
print conjugations( "amare" );
print conjugations( "monēre" );
print conjugations( "tegere" );
print conjugations( "venire" );
print conjugations( "qwerty" );
print conjugations( "are" )
END
- Output:
Present Indicative conjugation: Conjugations of "amare": amo amas amat amamus amatis amant Conjugations of "monēre": moneo mones monet monemus monetis monent Conjugations of "tegere": tego tegis tegit tegimus tegitis tegunt Conjugations of "venire": venio venis venit venimus venitis veniunt Don't know how to conjugate "qwerty" "are" is not long enough to conjugate
Arturo
endings: #[
{are}: ["o" "as" "at" "amus" "atis" "ant"]
{ēre}: ["eo" "es" "et" "emus" "etis" "ent"]
{ere}: ["o" "is" "it" "imus" "itis" "unt"]
{ire}: ["io" "is" "it" "imus" "itis" "iunt"]
]
conjugate: function [v][
suff: join last.n:3 split v
stem: slice v 0 (size v)-4
map endings\[suff] 'x -> stem ++ x
]
loop ["amare" "vidēre" "ducere" "audire"] 'verb [
print repeat "=" 20
print verb
print repeat "=" 20
loop conjugate verb 'row [
print row
]
print ""
]
- Output:
==================== amare ==================== amo amas amat amamus amatis amant ==================== vidēre ==================== video vides videt videmus videtis vident ==================== ducere ==================== duco ducis ducit ducimus ducitis ducunt ==================== audire ==================== audio audis audit audimus auditis audiunt
AWK
#!/usr/bin/env -S gawk -f
BEGIN {
ENDINGS["āre"]=1
ENDINGS["are"]=1
ENDINGS["ēre"]=2
ENDINGS["ere"]=3
ENDINGS["īre"]=4
ENDINGS["ire"]=4
first_person_singular=1
RULE[first_person_singular][1]="ō"
RULE[first_person_singular][2]="eō"
RULE[first_person_singular][3]="ō"
RULE[first_person_singular][4]="iō"
second_person_singular=2
RULE[second_person_singular][1]="ās"
RULE[second_person_singular][2]="ēs"
RULE[second_person_singular][3]="is"
RULE[second_person_singular][4]="īs"
third_person_singular=3
RULE[third_person_singular][1]="at"
RULE[third_person_singular][2]="et"
RULE[third_person_singular][3]="it"
RULE[third_person_singular][4]="it"
first_person_plural=4
RULE[first_person_plural][1]="āmus"
RULE[first_person_plural][2]="ēmus"
RULE[first_person_plural][3]="imus"
RULE[first_person_plural][4]="īmus"
second_person_plural=5
RULE[second_person_plural][1]="ātis"
RULE[second_person_plural][2]="ētis"
RULE[second_person_plural][3]="itis"
RULE[second_person_plural][4]="ītis"
third_person_plural=6
RULE[third_person_plural][1]="ant"
RULE[third_person_plural][2]="ent"
RULE[third_person_plural][3]="unt"
RULE[third_person_plural][4]="iunt"
print \
"infinitive│ ╭─person─╮ ╭─person─╮ \n"\
" │╭─────────── singular ──────────╮╭────────── plural ────────────╮\n"\
" ││ 1st 2nd 3rd ││ 1st 2nd 3rd │"
}
NF==0 || $1=="#" || index($1,"#")==1 {next}
1 {
printf "%-12s", $1
stem=substr($1,1,length($1)-3)
if (stem=="") { printf "%s\n", "* Can not conjugate"; next }
endn=substr($1,length($1)-2)
if (endn in ENDINGS) {
kind=ENDINGS[endn]
printf "%-11s", stem RULE[first_person_singular][kind]
printf "%-11s", stem RULE[second_person_singular][kind]
printf "%-11s", stem RULE[third_person_singular][kind]
printf "%-11s", stem RULE[first_person_plural][kind]
printf "%-11s", stem RULE[second_person_plural][kind]
printf "%-11s", stem RULE[third_person_plural][kind]
}
else {
printf "%s", "* Can not conjugate"
}
printf "\n"
next
}
Run, assuming the code is in the clv.awk
#!/bin/sh
printf '
# "āre" Verbs (1st Conjugation):
amare (to love)
laudare (to praise)
vocare (to call)
# "ēre" Verbs (2nd Conjugation):
vidēre (to see)
docēre (to teach)
legere (to read)
# "ere" Verbs (3rd Conjugation):
ducere (to lead)
capere (to take)
facere (to do/make)
# "īre" Verbs (4th Conjugation):
audire (to hear)
venire (to come)
ire (to go)
# incorrect verbs
qwerty
' '' | LANG=en_US.UTF-8 gawk -f ./clv.awk
- Output:
infinitive│ ╭─person─╮ ╭─person─╮ │╭─────────── singular ──────────╮╭────────── plural ────────────╮ ││ 1st 2nd 3rd ││ 1st 2nd 3rd │ amare amō amās amat amāmus amātis amant laudare laudō laudās laudat laudāmus laudātis laudant vocare vocō vocās vocat vocāmus vocātis vocant vidēre videō vidēs videt vidēmus vidētis vident docēre doceō docēs docet docēmus docētis docent legere legō legis legit legimus legitis legunt ducere ducō ducis ducit ducimus ducitis ducunt capere capō capis capit capimus capitis capunt facere facō facis facit facimus facitis facunt audire audiō audīs audit audīmus audītis audiunt venire veniō venīs venit venīmus venītis veniunt ire * Can not conjugate qwerty * Can not conjugate
BQN
end←⟨"are","ēre","ere","ire"⟩
eCnj←⟨
⟨"o","as","at","amus","atis","ant"⟩
⟨"eo","es","et","emus","etis","ent"⟩
⟨"o","is","it","imus","itis","unt"⟩
⟨"io","is","it","imus","itis","iunt"⟩
⟩
Conj←{(¯3↓𝕩)⊸∾¨eCnj⊑˜⊑end⊐<¯3↑𝕩}
•Show >⋈⟜Conj¨⟨"amare","vidēre","ducere","audire"⟩
┌─
╵ "amare" ⟨ "amo" "amas" "amat" "amamus" "amatis" "amant" ⟩
"vidēre" ⟨ "video" "vides" "videt" "videmus" "videtis" "vident" ⟩
"ducere" ⟨ "duco" "ducis" "ducit" "ducimus" "ducitis" "ducunt" ⟩
"audire" ⟨ "audio" "audis" "audit" "audimus" "auditis" "audiunt" ⟩
┘
EasyLang
proc conj inf$ . .
if substr inf$ -3 3 <> "are"
print "Not a first conjugation verb."
return
.
stem$ = substr inf$ 1 (len inf$ - 3)
if stem$ = ""
print "Stem cannot be empty."
return
.
print "Present indicative tense of " & inf$ & ":"
for en$ in [ "o" "as" "at" "amus" "atis" "ant" ]
print stem$ & en$
.
.
for s$ in [ "amare" "dare" ]
conj s$
print ""
.
EMal
List patterns = List[
text["ō", "ās", "ăt", "āmus", "ātis", "ant"],
text["ěō", "ēs", "ĕt", "ēmus", "ētis", "ent"],
text["ō", "ĭs", "ĭt", "ĭmus", "ĭtis", "unt"],
text["ĭō", "īs", "it", "īmus", "ītis", "ĭunt"]]
fun getVerbInfo = Pair by text verb
if verb.endsWith("āre") do return int%text(0 => verb.replace("āre", ""))
else if verb.endsWith("ēre") do return int%text(1 => verb.replace("ēre", ""))
else if verb.endsWith("ĕre") do return int%text(2 => verb.replace("ĕre", ""))
else if verb.endsWith("īre") do return int%text(3 => verb.replace("īre", ""))
else do error(1, "unknown coniugation")
end
end
fun coniugatePresentActive = void by Pair verbInfo
for each text pattern in patterns[verbInfo.key]
writeLine(verbInfo.value + pattern)
end
end
List verbs = text["laudāre", "monēre", "legĕre", "audīre"]
for each text verb in verbs
writeLine("Praesens indicativi temporis of '" + verb + "':")
coniugatePresentActive(getVerbInfo(verb))
end
- Output:
Praesens indicativi temporis of 'laudāre': laudō laudās laudăt laudāmus laudātis laudant Praesens indicativi temporis of 'monēre': moněō monēs monĕt monēmus monētis monent Praesens indicativi temporis of 'legĕre': legō legĭs legĭt legĭmus legĭtis legunt Praesens indicativi temporis of 'audīre': audĭō audīs audit audīmus audītis audĭunt
F#
// Conjugate a Latin Verb. Nigel Galloway: September 17th., 2021
let myLatin (n:string)=printfn "Rogatus sum iungere verbum %s" n
match n.Length>3,n.[-3..]="are" with
(false,_)|(_,false)->printfn " facis quod"
|_->["o";"as";"at";"amus";"atis";"ant"]|>List.iter(fun g->printfn " %s%s" n.[0.. -4] g)
myLatin "amare"
myLatin "creo"
- Output:
Rogatus sum iungere verbum amare amo amas amat amamus amatis amant Rogatus sum iungere verbum creo facis quod
Factor
USING: formatting io kernel math qw sequences ;
CONSTANT: pronouns {
"I"
"you"
"he, she, it"
"we"
"you all"
"they"
}
CONSTANT: endings qw{ ō ās at āmus ātis ant }
: first-conjugation? ( str -- ? )
qw{ are āre } [ tail? ] with any? ;
: check-first-conjugation ( str -- )
first-conjugation?
[ "Input must end with 'are' or 'āre'." throw ] unless ;
: check-length ( str -- )
length 3 >
[ "Input too short to conjugate." throw ] unless ;
: check-input ( str -- )
[ check-first-conjugation ] [ check-length ] bi ;
: conjugate ( str -- seq )
dup check-input 3 head* endings [ append ] with map ;
: he/she/it ( str -- newstr )
"s" append dup dup "he %s, she %s, it %s" sprintf ;
: english ( str -- seq )
pronouns [ 2 = [ nip he/she/it ] [ " " glue ] if ] with
map-index ;
:: conjugate. ( la en -- )
la en "Present active indicative conjugations of %s (%s):\n"
printf la conjugate en english [ " %-10s%s\n" printf ] 2each ;
"amāre" "love" conjugate. nl
"dāre" "give" conjugate.
- Output:
Present active indicative conjugations of amāre (love): amō I love amās you love amat he loves, she loves, it loves amāmus we love amātis you all love amant they love Present active indicative conjugations of dāre (give): dō I give dās you give dat he gives, she gives, it gives dāmus we give dātis you all give dant they give
FreeBASIC
Sub conjugate(infinitive As String)
Dim As String ending(1 To 6) => {"o", "as", "at", "amus", "atis", "ant"}
If Not (Right(infinitive, 3) = "are") Then Print "'"; infinitive; !"' non prima coniugatio verbi.\n" : Exit Sub
Dim As String stem = Left(infinitive, Len(infinitive)-3)
If Len(stem) = 0 Then Print !"\'"; infinitive; !"\' non satis diu conjugatus\n" : Exit Sub
Print Using "Praesens indicativi temporis of '&':"; infinitive
For i As Byte = 1 To 6
Print Spc(5); stem; ending(i)
Next i
Print
End Sub
conjugate("amare")
conjugate("dare")
conjugate("qwerty")
conjugate("are")
Sleep
- Output:
Praesens indicativi temporis of 'amare': amo amas amat amamus amatis amant Praesens indicativi temporis of 'dare': do das dat damus datis dant 'qwerty' non prima coniugatio verbi. 'are' non satis diu conjugatus
FutureBasic
include "NSLog.incl"
local fn Conjugate( infinitive as CFStringRef ) as CFArrayRef
if ( len(infinitive) < 4 ) then exit fn = @[fn StringWithFormat( @"[Can not conjugate %@.]", infinitive)]
CFStringRef conjugation
CFStringRef ending = fn StringSubstringFromIndex( infinitive, len(infinitive) - 3 )
CFMutableArrayRef conjugations = fn MutableArrayNew
CFMutableArrayRef result = fn MutableArrayNew
if fn StringIsEqual( ending, @"are" ) then MutableArrayAddObjectsFromArray( conjugations, @[@"o", @"as", @"at", @"amus", @"atis", @"ant"] )
if fn StringIsEqual( ending, @"ēre" ) then MutableArrayAddObjectsFromArray( conjugations, @[@"eo", @"es", @"et", @"emus", @"etis", @"ent"] )
if fn StringIsEqual( ending, @"ere" ) then MutableArrayAddObjectsFromArray( conjugations, @[@"o", @"is", @"it", @"imus", @"itis", @"unt"] )
if fn StringIsEqual( ending, @"ire" ) then MutableArrayAddObjectsFromArray( conjugations, @[@"io", @"is", @"it", @"imus", @"itis", @"iunt"] )
if fn ArrayCount( conjugations ) < 1 then exit fn = @[fn StringWithFormat( @"[Can not conjugate %@.]", infinitive )]
for conjugation in conjugations
MutableArrayAddObject( result, fn StringWithFormat( @"%@%@", fn StringSubstringToIndex( infinitive, len(infinitive) - 3 ), conjugation ) )
next
end fn = result
local fn DoConjugations
CFStringRef infinitive, conjugation
CFArrayRef infinitives = @[@"amare", @"videre", @"ducere", @"audire", @"qwerty", @"are"]
for infinitive in infinitives
NSLog( @"\nConjugation of: %@", infinitive )
CFArrayRef conjugations = fn Conjugate( infinitive )
for conjugation in conjugations
NSLog( @"%@", conjugation )
next
next
end fn
fn DoConjugations
HandleEvents
Conjugation of: amare amo amas amat amamus amatis amant Conjugation of: videre vido vidis vidit vidimus viditis vidunt Conjugation of: ducere duco ducis ducit ducimus ducitis ducunt Conjugation of: audire audio audis audit audimus auditis audiunt Conjugation of: qwerty [Can not conjugate qwerty.] Conjugation of: are [Can not conjugate are.]
Go
The 'extended' version.
package main
import (
"fmt"
"log"
)
var endings = [][]string{
{"o", "as", "at", "amus", "atis", "ant"},
{"eo", "es", "et", "emus", "etis", "ent"},
{"o", "is", "it", "imus", "itis", "unt"},
{"io", "is", "it", "imus", "itis", "iunt"},
}
var infinEndings = []string{"are", "ēre", "ere", "ire"}
var pronouns = []string{"I", "you (singular)", "he, she or it", "we", "you (plural)", "they"}
var englishEndings = []string{"", "", "s", "", "", ""}
func conjugate(infinitive, english string) {
letters := []rune(infinitive)
le := len(letters)
if le < 4 {
log.Fatal("Infinitive is too short for a regular verb.")
}
infinEnding := string(letters[le-3:])
conj := -1
for i, s := range infinEndings {
if s == infinEnding {
conj = i
break
}
}
if conj == -1 {
log.Fatalf("Infinitive ending -%s not recognized.", infinEnding)
}
stem := string(letters[:le-3])
fmt.Printf("Present indicative tense, active voice, of '%s' to '%s':\n", infinitive, english)
for i, ending := range endings[conj] {
fmt.Printf(" %s%-4s %s %s%s\n", stem, ending, pronouns[i], english, englishEndings[i])
}
fmt.Println()
}
func main() {
pairs := [][2]string{{"amare", "love"}, {"vidēre", "see"}, {"ducere", "lead"}, {"audire", "hear"}}
for _, pair := range pairs {
conjugate(pair[0], pair[1])
}
}
- Output:
Present indicative tense, active voice, of 'amare' to 'love': amo I love amas you (singular) love amat he, she or it loves amamus we love amatis you (plural) love amant they love Present indicative tense, active voice, of 'vidēre' to 'see': video I see vides you (singular) see videt he, she or it sees videmus we see videtis you (plural) see vident they see Present indicative tense, active voice, of 'ducere' to 'lead': duco I lead ducis you (singular) lead ducit he, she or it leads ducimus we lead ducitis you (plural) lead ducunt they lead Present indicative tense, active voice, of 'audire' to 'hear': audio I hear audis you (singular) hear audit he, she or it hears audimus we hear auditis you (plural) hear audiunt they hear
jq
Works with gojq, the Go implementation of jq
Part 1
def conjugate:
if endswith("are") | not
then "\(.) is not a first conjugation verb." | error
else .[0:-3] as $stem
| if $stem|length == 0 then "Stem cannot be empty." | error
else "Present indicative tense of '\(.)':",
( "o", "as", "at", "amus", "atis", "ant"
| " " + $stem + .),
""
end
end;
("amare", "dare")
| conjugate
- Output:
As for #Wren.
Part 2
def rpad($len): tostring | ($len - length) as $l | . + (" " * $l)[:$l];
def endings: [
[ "o", "as", "at", "amus", "atis", "ant"],
["eo", "es", "et", "emus", "etis", "ent"],
[ "o", "is", "it", "imus", "itis", "unt"],
["io", "is", "it", "imus", "itis", "iunt"]
];
def infinEndings: ["are", "ēre", "ere", "ire"];
def pronouns: ["I", "you (singular)", "he, she or it", "we", "you (plural)", "they"];
def englishEndings: [ "", "", "s", "", "", "" ];
def conjugate($infinitive; $english):
def letters: [explode[] | [.] | implode];
($infinitive|letters) as $letters
| if $letters|length < 4 then "Infinitive is too short for a regular verb." | error
else ($letters[-3:]|join("")) as $infinEnding
| (infinEndings | index($infinEnding)) as $conj
| if $conj == null then "Infinitive ending -\($infinEnding) not recognized." | error
else ($letters[:-3]|join("")) as $stem
| "Present indicative tense, active voice, of '\(infinitive)' to '\($english)':",
foreach endings[$conj][] as $ending (-1; .+1;
" \($stem + $ending|rpad(8)) \(pronouns[.]) \($english)\(englishEndings[.])" )
end
end;
def pairs: [["amare", "love"], ["vidēre", "see"], ["ducere", "lead"], ["audire", "hear"]];
pairs[]
| conjugate(.[0]; .[1])
- Output:
As for #Wren.
Julia
const conjugators = ["ō", "ās", "at", "āmus", "ātis", "ant"]
conjugate(w, gregex = r"[aā]re$") = (r = replace(w, gregex => ""); [r * s for s in conjugators])
function testregularconjugation(verbvector)
for verb in verbvector
println("\nPresent active indicative conjugation of $verb:")
for result in conjugate(verb)
println(result)
end
end
end
testregularconjugation(["amāre", "dare"])
- Output:
Present active indicative conjugation of amāre: amō amās amat amāmus amātis amant Present active indicative conjugation of dare: dō dās dat dāmus dātis dant
Koka
effect yield<a>
ctl yield(a: a): ()
fun conjugate(infinitive: string)
if infinitive.count < 4 then
yield("Can not conjugate \"" ++ infinitive ++ "\" not long enough for a regular verb")
return ()
val ending = infinitive.last(3)
val conjugations = match ending.string
"are" -> ["o", "as", "at", "amus", "atis", "ant"]
"ēre" -> ["eo", "es", "et", "emus", "etis", "ent"]
"ere" -> ["o", "is", "it", "imus", "itis", "unt"]
"ire" -> ["io", "is", "it", "imus", "itis", "iunt"]
_ ->
yield("Can not conjugate \"" ++ infinitive ++ "\" not a regular verb ending")
[]
val root = ending.before.string
conjugations.foreach fn(c)
yield(root ++ c)
fun main()
with handler
fun yield(a: string)
println(a)
["amare", "vidēre", "ducere", "audire", "qwerty", "are"].foreach fn(word)
(word ++ ":").println
word.conjugate
- Output:
amare: amo amas amat amamus amatis amant vidēre: video vides videt videmus videtis vident ducere: duco ducis ducit ducimus ducitis ducunt audire: audio audis audit audimus auditis audiunt qwerty: Can not conjugate "qwerty" not a regular verb ending are: Can not conjugate "are" not long enough for a regular verb
Nim
import std/[strformat, unicode]
const
Endings = [["o", "as", "at", "amus", "atis", "ant"],
["eo", "es", "et", "emus", "etis", "ent"],
["o", "is", "it", "imus", "itis", "unt"],
["io", "is", "it", "imus", "itis", "iunt"]]
InfinEndings = ["are", "ēre", "ere", "ire"]
Pronouns = ["I", "you (singular)", "he, she or it", "we", "you (plural)", "they"]
EnglishEndings = ["", "", "s", "", "", ""]
proc conjugate(infinitive, english: string) =
let letters = infinitive.toRunes()
if letters.len < 4:
raise newException(ValueError, "infinitive is too short for a regular verb.")
let infinEnding = $letters[^3..^1]
let conj = InfinEndings.find(infinEnding)
if conj == -1:
raise newException(ValueError, &"infinitive ending -{infinEnding} not recognized.")
let stem = $letters[0..^4]
echo &"Present indicative tense, active voice, of '{infinitive}' to '{english}':"
for i, ending in Endings[conj]:
echo &" {stem}{ending:4} {Pronouns[i]} {english}{EnglishEndings[i]}"
echo()
for (infinitive, english) in {"amare": "love", "vidēre": "see", "ducere": "lead", "audire": "hear"}:
conjugate(infinitive, english)
- Output:
Present indicative tense, active voice, of 'amare' to 'love': amo I love amas you (singular) love amat he, she or it loves amamus we love amatis you (plural) love amant they love Present indicative tense, active voice, of 'vidēre' to 'see': video I see vides you (singular) see videt he, she or it sees videmus we see videtis you (plural) see vident they see Present indicative tense, active voice, of 'ducere' to 'lead': duco I lead ducis you (singular) lead ducit he, she or it leads ducimus we lead ducitis you (plural) lead ducunt they lead Present indicative tense, active voice, of 'audire' to 'hear': audio I hear audis you (singular) hear audit he, she or it hears audimus we hear auditis you (plural) hear audiunt they hear
Perl
use strict;
use warnings;
use feature 'say';
use utf8;
binmode STDOUT, ':utf8';
sub conjugate {
my($verb) = shift;
join "\n", map { $verb . $_ } qw<ō ās at āmus ātis ant>;
}
for my $infinitive ('amāre', 'dare') {
say "\nPresent active indicative conjugation of infinitive $infinitive.";
my($verb) = $infinitive =~ /^ (\w+) [aā] re $/x;
say $verb ? conjugate $verb : "Sorry, don't know how to conjugate $infinitive"
- Output:
Present active indicative conjugation of infinitive amāre. amō amās amat amāmus amātis amant Present active indicative conjugation of infinitive dare. dō dās dat dāmus dātis dant
Phix
TL; DR: Did just one term of Latin, right before posting this realised 'dāre' should probably be 'dare', left as an exercise...
with javascript_semantics constant {ending,endings} = columnize({{"āre",split("ō ās at āmus ātis ant")}, {"ēre",split("eō ēs et ēmus ētis ent")}, {"ere",split("ō is it imus itis unt")}, {"īre",split("iō īs it īmus ītis iunt")}}), pronouns = {"I %s", "you %s", "he %ss, she %ss, it %ss", "we %s", "you all %s", "they %s"} procedure conjugate(sequence ie) string {infinitive,english} = ie sequence utf32 = utf8_to_utf32(infinitive) assert(length(utf32)>3,"Infinitive is too short for a regular verb.") string stem = utf32_to_utf8(utf32[1..-4]), last3 = utf32_to_utf8(utf32[-3..-1]) integer edx = find(last3,ending) assert(edx!=0,"Infinitive ending -%s not recognized.",{last3}) printf(1,"Present active indicative conjugations of '%s' (%s):\n",ie) for i=1 to length(endings[edx]) do string c = sprintf("%s%s",{stem,endings[edx][i]}), e = substitute(pronouns[i],"%s",english) printf(1," %-7s %s\n",{c,e}) end for printf(1,"\n") end procedure printf(0,"",{"unicode_align",true}) papply({{"amāre","love"},{"dāre","give"},{"vidēre","see"},{"dūcere","lead"},{"audīre","hear"}},conjugate)
- Output:
Present active indicative conjugations of 'amāre' (love): amō I love amās you love amat he loves, she loves, it loves amāmus we love amātis you all love amant they love Present active indicative conjugations of 'dāre' (give): dō I give dās you give dat he gives, she gives, it gives dāmus we give dātis you all give dant they give Present active indicative conjugations of 'vidēre' (see): videō I see vidēs you see videt he sees, she sees, it sees vidēmus we see vidētis you all see vident they see Present active indicative conjugations of 'dūcere' (lead): dūcō I lead dūcis you lead dūcit he leads, she leads, it leads dūcimus we lead dūcitis you all lead dūcunt they lead Present active indicative conjugations of 'audīre' (hear): audiō I hear audīs you hear audit he hears, she hears, it hears audīmus we hear audītis you all hear audiunt they hear
Phixmonti
/# Rosetta Code problem: http://rosettacode.org/wiki/Conjugate_a_Latin_verb
by Galileo, 10/2022 #/
include ..\Utilitys.pmt
( ( "are" "ere" "ire" )
( ( "o" "as" "at" "amus" "atis" "ant" )
( "o" "is" "it" "imus" "itis" "unt" )
( "io" "is" "it" "imus" "itis" "iunt" ) ) )
( "amare" "ducere" "audire" ) len for
get dup print ":" ?
len 2 - snip swap >ps rot swap
getd
len for
get tps swap chain ?
endfor
cps drop swap nl
endfor
- Output:
amare: amo amas amat amamus amatis amant
ducere: duco ducis ducit ducimus ducitis ducunt
audire: audio audis audit audimus auditis audiunt
=== Press any key to exit ===
Python
#!/usr/bin/python
def conjugate(infinitive):
if not infinitive[-3:] == "are":
print("'", infinitive, "' non prima coniugatio verbi.\n", sep='')
return False
stem = infinitive[0:-3]
if len(stem) == 0:
print("\'", infinitive, "\' non satis diu conjugatus\n", sep='')
return False
print("Praesens indicativi temporis of '", infinitive, "':", sep='')
for ending in ("o", "as", "at", "amus", "atis", "ant"):
print(" ", stem, ending, sep='')
print()
if __name__ == '__main__':
for infinitive in ("amare", "dare", "qwerty", "are"):
conjugate(infinitive)
Raku
for <amāre dare> -> $infinitive {
say "\nPresent active indicative conjugation of infinitive $infinitive.";
my $verb = ($infinitive ~~ /^ (\w+) ['a'|'ā'] 're' $/)[0];
say $verb ?? (conjugate $verb) !! "Sorry, don't know how to conjugate $infinitive"
}
sub conjugate ($verb) { ($verb X~ <ō ās at āmus ātis ant>).join: "\n" }
- Output:
Present active indicative conjugation of infinitive amāre. amō amās amat amāmus amātis amant Present active indicative conjugation of infinitive dare. dō dās dat dāmus dātis dant
REXX
Checks were also made to ensure the Latin verb has only Latin letters (upper and/or lower case).
/*REXX pgm conjugates (to the terminal) a Latin verb when given a first conjugation verb*/
parse arg verbs
if verbs='' | verbs="," then verbs= 'amare dare'
suffix= 'o as at amus atis ant' /*a list of six Latin verb suffixes. */
#= words(verbs) /*obtain the # of Latin verbs specified*/
do j=1 for #; say /*process each " " " */
$= word(verbs, j); $$= $; upper $$ /*obtain one of the " " " */
if \datatype($, 'M') then call ser "the following isn't a Latin verb: " $
L= length($) /*obtain the length of a Latin verb. */
if L<4 then call ser 'length of Latin verb is too short: ' $
if right($$, 3)\=='ARE' then call ser "the following isn't a Latin verb: " $
stem= left($, length($) - 3) /*obtain the stem of the Latin verb. */
say center(' present indicative tense of "'$'"', 50, "─")
do k=1 for words(suffix) /*display each of the verb suffixes. */
say left('',21) stem || word(suffix, k) /*display a Latin verb stem with auffix*/
end /*k*/
say
end /*j*/
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
ser: say; say '***error*** ' arg(1); say; exit 13
- output when using the default inputs:
─────── present indicative tense of "amare"─────── amo amas amat amamus amatis amant ─────── present indicative tense of "dare"──────── do das dat damus datis dant
RPL
≪ DUP SIZE
DUP2 "aEei" ROT ROT 2 - DUP SUB POS
→ verb length group
≪ IF group length 3 > AND verb length 1 - length SUB "re" == AND THEN
{ }
1 6 FOR t
verb 1 length 3 - SUB
IF t 1 == THEN
{ "" "e" "" "i" } group GET + "o" +
ELSE
{ "a" "e" "i" "i" } group GET +
IF t 6 == THEN
IF group 3 == THEN 1 OVER SIZE 1 - SUB END
IF group 2 > THEN "u" + END
END
{ "" "s" "t" "mus" "tis" "nt" } t GET +
END
+
NEXT
ELSE "Can't conjugate " verb + END
≫ ≫ 'CONJV' STO
≪ { "amare" "vidEre" "tegere" "venire" "abcdef" } → cases
≪ {} 1 cases SIZE FOR j cases j GET CONJV NEXT ≫ ≫ EVAL
- Output:
5: { "amo" "amas" "amat" "amamus" "amatis" "amant" } 4: { "video" "vides" "videt" "videmus" "videtis" "vident" } 3: { "tego" "tegis" "tegit" "tegimus" "tegitis" "tegunt" } 2: { "audio" "audis" "audit" "audimus" "auditis" "audiunt" } 1: "Can't conjugate abcdef"
Ruby
def conjugate(infinitive)
return ["Can not conjugate #{infinitive}"] if infinitive.size < 4
conjugations = case infinitive[-3..-1]
when "are" then ["o", "as", "at", "amus", "atis", "ant"]
when "ēre" then ["eo", "es", "et", "emus", "etis", "ent"]
when "ere" then ["o", "is", "it", "imus", "itis", "unt"]
when "ire" then ["io", "is", "it", "imus", "itis", "iunt"]
else return ["Can not conjugate #{infinitive}"]
end
conjugations.map{|c| infinitive[0..-4] + c}
end
["amare", "vidēre", "ducere", "audire","qwerty", "are"].each do |inf|
puts "\n" + inf + ":"
puts conjugate inf
end
- Output:
amare: amo amas amat amamus amatis amant vidēre: video vides videt videmus videtis vident ducere: duco ducis ducit ducimus ducitis ducunt audire: audio audis audit audimus auditis audiunt qwerty: Can not conjugate qwerty are: Can not conjugate are
V (Vlang)
The 'extended' version.
import log
const
(
endings = [
["o", "as", "at", "amus", "atis", "ant"],
["eo", "es", "et", "emus", "etis", "ent"],
["o", "is", "it", "imus", "itis", "unt"],
["io", "is", "it", "imus", "itis", "iunt"]
]
infin_endings = ["are", "ēre", "ere", "ire"]
pronouns = ["I", "you (singular)", "he, she or it", "we", "you (plural)", "they"]
english_endings = ["", "", "s", "", "", ""]
)
fn main() {
pairs := [["amare", "love"], ["vidēre", "see"], ["ducere", "lead"], ["audire", "hear"]] // add to check errors
for _, pair in pairs {
conjugate(pair[0], pair[1])
}
}
fn conjugate(infinitive string, english string) {
letters := infinitive.runes()
le := letters.len
mut lg := log.Log{}
mut infin_ending, mut stem := '', ''
mut conj := 0
lg.set_level(.error)
lg.set_full_logpath('./info.log')
if le < 4 {
lg.error("Infinitive (${letters.string()}) is too short for a regular verb.")
exit(1)
}
infin_ending = letters[le - 3..].string()
conj = -1
for i, s in infin_endings {
if s == infin_ending {
conj = i
break
}
}
if conj == -1 {
lg.error("Infinitive ending -${infin_ending} not recognized.")
exit(1)
}
stem = letters[..le - 3].string()
print("Present indicative tense, active voice, of ${infinitive} to '${english}':\n")
for i, ending in endings[conj] {
print(" ${stem}${ending} ${pronouns[i]} ${english}${english_endings[i]}\n")
}
println('')
}
- Output:
Present indicative tense, active voice, of amare to 'love': amo I love amas you (singular) love amat he, she or it loves amamus we love amatis you (plural) love amant they love Present indicative tense, active voice, of vidēre to 'see': video I see vides you (singular) see videt he, she or it sees videmus we see videtis you (plural) see vident they see Present indicative tense, active voice, of ducere to 'lead': duco I lead ducis you (singular) lead ducit he, she or it leads ducimus we lead ducitis you (plural) lead ducunt they lead Present indicative tense, active voice, of audire to 'hear': audio I hear audis you (singular) hear audit he, she or it hears audimus we hear auditis you (plural) hear audiunt they hear
Wren
var conjugate = Fn.new { |infinitive|
if (!infinitive.endsWith("are")) Fiber.abort("Not a first conjugation verb.")
var stem = infinitive[0...-3]
if (stem.count == 0) Fiber.abort("Stem cannot be empty.")
System.print("Present indicative tense of '%(infinitive)':")
for (ending in ["o", "as", "at", "amus", "atis", "ant"]) {
System.print(" " + stem + ending)
}
System.print()
}
for (infinitive in ["amare", "dare"]) conjugate.call(infinitive)
- Output:
Present indicative tense of 'amare': amo amas amat amamus amatis amant Present indicative tense of 'dare': do das dat damus datis dant
The following extended version can deal with regular verbs of all four conjugations. To distinguish 2nd and 3rd conjugations, a bar is placed above the penultimate 'e' in a second conjugation infinitive but accents are otherwise ignored. English meanings have also been added.
import "./fmt" for Fmt
var endings = [
[ "o", "as", "at", "amus", "atis", "ant"],
["eo", "es", "et", "emus", "etis", "ent"],
[ "o", "is", "it", "imus", "itis", "unt"],
["io", "is", "it", "imus", "itis", "iunt"]
]
var infinEndings = ["are", "ēre", "ere", "ire"]
var pronouns = ["I", "you (singular)", "he, she or it", "we", "you (plural)", "they"]
var englishEndings = [ "", "", "s", "", "", "" ]
var conjugate = Fn.new { |infinitive, english|
var letters = infinitive.toList
if (letters.count < 4) Fiber.abort("Infinitive is too short for a regular verb.")
var infinEnding = letters[-3..-1].join()
var conj = infinEndings.indexOf(infinEnding)
if (conj == -1) Fiber.abort("Infinitive ending -%(infinEnding) not recognized.")
var stem = letters[0..-4].join()
System.print("Present indicative tense, active voice, of '%(infinitive)' to '%(english)':")
var i = 0
for (ending in endings[conj]) {
Fmt.print(" $s$-4s $s $s$s", stem, ending, pronouns[i], english, englishEndings[i])
i = i + 1
}
System.print()
}
var pairs = [["amare", "love"], ["vidēre", "see"], ["ducere", "lead"], ["audire", "hear"]]
for (pair in pairs) conjugate.call(pair[0], pair[1])
- Output:
Present indicative tense, active voice, of 'amare' to 'love': amo I love amas you (singular) love amat he, she or it loves amamus we love amatis you (plural) love amant they love Present indicative tense, active voice, of 'vidēre' to 'see': video I see vides you (singular) see videt he, she or it sees videmus we see videtis you (plural) see vident they see Present indicative tense, active voice, of 'ducere' to 'lead': duco I lead ducis you (singular) lead ducit he, she or it leads ducimus we lead ducitis you (plural) lead ducunt they lead Present indicative tense, active voice, of 'audire' to 'hear': audio I hear audis you (singular) hear audit he, she or it hears audimus we hear auditis you (plural) hear audiunt they hear