def _read_matches_from_db(self, client_context, matched_context, matchid): matchnodedaos = self._storage_engine.session.query(MatchNodeDAO). \ filter(MatchNodeDAO.matchid == matchid) for matchnodedao in matchnodedaos: YLogger.debug(client_context, "Loading match node %s", matchnodedao) match = Match(None, None, None) match._matched_node_type = Match.string_to_type(matchnodedao.matchtype) match._matched_node_str = matchnodedao.matchnode match._matched_node_words = client_context.brain.tokenizer.texts_to_words(matchnodedao.matchstr) match._matched_node_multi_word = matchnodedao.multiword matched_context.matched_nodes.append(match)
def test_string_to_type(self): self.assertEquals(0, Match.string_to_type("Word")) self.assertEquals(2, Match.string_to_type("Topic")) self.assertEquals(3, Match.string_to_type("That")) self.assertEquals(-1, Match.string_to_type("Other"))