Пример #1
0
def matchGrammarRule(setOfRules, sentance):
    #Matching the pattern to the sentance
    #This function should loop through all of the grammar rules given
    #and decide which ones to use:
    #--If there is just one match, or if several non over lapping matches, then use
    #  All of those matches 
    #  --Need to decide on a datastructure to return with
    #--if there are conflicting matches, decide which one take precident. 
    #  Note: any over lapping matches that can occur should have a specified
    #  priority.
    #
    #Essentially this function will return with what subsitutions to make

    #Looping through all of the rules in the set. all of the rules should be in order
    #of priority.
    for grammarRule in setOfRules:
        matchResult = matchPattern(grammarRule[0], sentance)

        if matchResult != None:
            return [grammarRule[1], matchResult]
    #None of the results above found anything
    return None
Пример #2
0
def testInput(inputList):
    for i in inputList:
        print "Input: " + str(i) + "\nOutput: " + str(matcher.matchPattern(i[0][0], i[1])) + "\n\n"