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'
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)