Skip to main content

Posts

Showing posts from 2017

How Sweet It Is

Just like that, I've managed to program something (to a very loose approximation) like intelligence into my parser.  The problem whose solution eluded me yesterday was how to get the right position of the stem using find() (or some variant thereof).  I had mentioned the possibility of using len()  to figure out which part of the string to look in.  I thought about the problem more today, and this is what I came up with -- basically, a test to see whether the stem I'm looking for is in the right part of the string: def parse(verb):     for conj in conjugations:         if verb.rfind(conj) == len(verb)-len(conj):             return(stems[conj])         else:             continue What I realized is that I need to start at the end of the string and go back to the beginning of the stem.  So it's actually pretty simple: if parse ()   finds the beginn...

Searching For the Conjugation

stems = { "o" : "first person singular", "as" : "second person singular", "at" : "third person singular", "amus" : "first person plural", "atis" : "second person plural", "ant" : "third person plural", }  conjugations = list() for key in stems:     conjugations.append(key) def parse(verb):     for conj in conjugations:         if verb.count(conj) == 1:             return(stems[conj])         else:             continue  while True:     entry = input("Enter a Latin verb: ")     if parse(entry) != None:         print(parse(entry))     else:         print("Verb form not found.") One major problem with the last iteration of the conjugation finder: I entered the plural forms as singular in the dictionary! I believe the search tool will be more effective if it isn't tied to any particular ...

First Project (First Iteration)

NOTE: Major error in the dictionary -- plural forms identified as singular.  (12/30/17, 8:10 PM) This is the first version of my first project.  The overall goal would be to create a fully functional application that can parse any Latin verb the user enters.  This represents my first baby steps towards that goal.  Here is the code: stems = { "o" : "first person singular", "as" : "second person singular", "at" : "third person singular", "amus" : "first person singular", "atis" : "second person singular", "ant" : "third person singular", }  def parse(verb):     stem = verb[len("am"):]     try:         return(stems[stem])     except:         print("Verb form not found.")  while True:     entry = input("Enter a Latin verb: ")     if parse(entry) != None:         print(parse(entry)) Right now, the parser has pretty severe limitation...