Conjugate a Latin verb: Difference between revisions

Add ed example
(Added 11l)
(Add ed example)
 
(11 intermediate revisions by 8 users not shown)
Line 223:
auditis
audiunt</pre>
=={{header|AWK}}==
{{works with|gawk|5.1.0 }}
<syntaxhighlight lang="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
}
</syntaxhighlight>
Run, assuming the code is in the <tt>clv.awk</tt>
<syntaxhighlight lang="shell">
#!/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
</syntaxhighlight>
{{out}}
<pre>
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
</pre>
=={{header|BQN}}==
{{trans|Nim}}
Line 242 ⟶ 369:
"audire" ⟨ "audio" "audis" "audit" "audimus" "auditis" "audiunt" ⟩
┘</syntaxhighlight>
 
=={{header|EasyLang}}==
<syntaxhighlight>
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 ""
.
</syntaxhighlight>
 
=={{header|ed}}==
 
Input file is supposed to have the infinitive verb as the only line.
 
<syntaxhighlight lang="sed">
H
p
t0
t0
t0
t0
t0
1s/(are|ere)$/o/
2s/are$/as/
3s/are$/at/
4s/are$/amus/
5s/are$/atis/
6s/are$/ant/
 
1s/ēre$/eo/
2s/ēre$/es/
3s/ēre$/et/
4s/ēre$/emus/
5s/ēre$/etis/
6s/ēre$/ent/
 
1s/ire$/io/
6s/ire$/iunt/
6s/ere$/unt/
 
2s/(ere|ire)$/is/
3s/(ere|ire)$/it/
4s/(ere|ire)$/imus/
5s/(ere|ire)$/itis/
,p
Q
</syntaxhighlight>
 
{{out}}
 
<pre>$ cat roman-conjugations.ed | ed -lEGs roman-conjugations.input
Newline appended
amare
...
amo
amas
amat
amamus
amatis
amant</pre>
 
=={{header|EMal}}==
<syntaxhighlight lang="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
</syntaxhighlight>
{{out}}
<pre>
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
</pre>
 
=={{header|F_Sharp|F#}}==
<syntaxhighlight lang="fsharp">
Line 373 ⟶ 633:
'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}}==
{{trans|Wren}}
Line 556 ⟶ 898:
</pre>
 
=={{header|Koka}}==
{{trans|Ruby}}
<syntaxhighlight lang="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
</syntaxhighlight>
 
{{out}}
<pre>
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
</pre>
=={{header|Nim}}==
{{trans|Go}}
Line 875 ⟶ 1,284:
datis
dant
</pre>
 
=={{header|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'''
≫ ≫ '<span style="color:blue">CONJV</span>' STO
 
≪ { "amare" "vidEre" "tegere" "venire" "abcdef" } → cases
≪ {} 1 cases SIZE '''FOR''' j cases j GET <span style="color:blue">CONJV</span> '''NEXT''' ≫ ≫ EVAL
{{out}}
<pre>
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"
</pre>
 
=={{header|Ruby}}==
<syntaxhighlight lang="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
</syntaxhighlight>
{{out}}
<pre>
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
</pre>
 
Line 972 ⟶ 1,474:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">var conjugate = Fn.new { |infinitive|
if (!infinitive.endsWith("are")) Fiber.abort("Not a first conjugation verb.")
var stem = infinitive[0...-3]
Line 1,006 ⟶ 1,508:
{{libheader|Wren-fmt}}
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.
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var endings = [
110

edits