Prototype machine translator
From dandi08
This code creates the 2nd line of an IGT for a Latin phrase.
It will crash if any input is not found in the dictionary.
Also, we need to find a way to differentiate between endings that occur in more than one grammatical case.
Please ignore the blue boxes. This is a subtlety of wiki formatting I have yet to grasp. If you copy and past the entire code below into the Python editor, it should run.
VerbBaseDict = {"vid":"\"see\"", "or":"\"pray\"","ven":"\"come\"", "dic":"\"say\""}
VerbGramDict = {"o":"1P SG", "eo":"1P SG", "io":"1P SG", "as":"2P SING", "es":"2P SG", "is":"2P SG", "at":"3P SING", "et":"3P SG", "it":"3P SG", "amus":"1P PL", "emus":"1P PL", "imus":"1P PL", "atis":"2P PL", "etis":"2P PL", "itis":"2P PL", "ant":"3P PL", "ent":"3P PL", "unt":"3P PL", "iunt":"3P PL"}
NounBaseDict = {"puell":"\"girl\"","mens":"\"table\"", "terr":"\"earth\"", "agricol":"\"farmer\"", "stell":"\"star\"", "mund":"\"world\"", "ocul":"\"eye\"", "cibus":"\"food\"", "vin":"\"wine\"", "tect":"\"roof\"","multitud":"\"crowd\"", "di":"\"day\""}
NounGramDict = {"a":"NOM SG or NOM PL or ACC PL", "ae":"NOM PL", "am":"ACC SG", "as":"ACC SG", "us":"NOM SG", "i":"NOM PL", "um":"ACC SG", "os":"ACC PL", "er":"NOM SG","es":"NOM SG or NOM PL or ACC PL", "em":"ACC SG"}
def Morphemizer(word,wordlen,phrase):
sentry = True while sentry: for x in range(wordlen+1): s = (wordlen-(wordlen-x)) substring = word[:s]
if substring in NounBaseDict: root = substring affix = word [s:] entries = NounBaseDict[root]+NounGramDict[affix]+" " sentry = False if substring in VerbBaseDict: root = substring affix = word [s:] entries = VerbBaseDict[root]+VerbGramDict[affix]+" " sentry = False
else: sentry = False return entries
def main():
phrase = raw_input("type your Latin phrase here: ")
words = phrase.split() line2 ="" for word in words: wordlen = len(word) entries = Morphemizer(word,wordlen,phrase) line2 = line2 + entries print phrase print line2
main()