Ejemplo n.º 1
0
 def setUp(self):
     self.ex = Extractor()
     self.text = u"2番目に重要な物を選んでください。"
     # 予測されるデータ
     self.correct = (
             ("2番目", 0),
             ("重要", 4)
         )
Ejemplo n.º 2
0
class TestExtractor(unittest.TestCase):
    
    def setUp(self):
        self.ex = Extractor()
        self.text = u"2番目に重要な物を選んでください。"
        # 予測されるデータ
        self.correct = (
                ("2番目", 0),
                ("重要", 4)
            )
    
    def test_parse(self):
        emsg = "Not Match!"
        for i, pair in enumerate(self.ex.parse(self.text)):
            word, location = pair
            pre_word, pre_location = self.correct[i]
            self.assertEqual(word, pre_word, emsg)
            self.assertEqual(location, pre_location, emsg)
        self.assertEqual(i + 1, len(self.correct), "Not match the number of term.")
Ejemplo n.º 3
0
def main():
    import sys
    query = sys.argv[1]
    ex = Extractor()
    for word, location in ex.parse(query):
        print "word: %s, location:%d" % (word, location)