コード例 #1
0
def main(line):
    c = classify.Classifier(QMTypes.inputDict, QMTypes.outputDict)
    
    inputTokenList = iostream.parse(line) # parse input
    classList = []
    for token in inputTokenList:
        qmClass = c.toClass(token) # convert input into classes
        classList.append(qmClass)
    print classList # display all classes that were identified

    outputTokenList = []
    for qmClass in classList:
        token = c.toToken(qmClass) # create token for each class
        outputTokenList.append(token)
    outputString = iostream.assemble(outputTokenList)
    print outputString, '\n'
コード例 #2
0
 def testParseKnownStrings(self):
     """parse should separate known strings into known tokens"""
     for expression, terms in self.knownStrings:
         result = iostream.parse(expression)
         self.assertEqual(terms, result)