def test_recognition_1_level(self):
     text = u"济南杨铭宇餐饮管理有限公司是由杨先生创办的餐饮企业"
     self.gen_word(text)
     # vertexs = persion_recognition.recognition(vertexs, word_net_optimum, word_net)
     # word_net_optimum = WordNet(text, vertexs=vertexs)
     organization_recognition.recognition(self.vertexs, self.word_net_optimum, self.word_net)
     vertexs = viterbi(self.word_net_optimum.vertexs)
     self.assertIn(Vertex(u"济南杨铭宇餐饮管理有限公司", attribute=u"nt 1"), vertexs)
 def test_recognition_1_level(self):
     text = u"济南杨铭宇餐饮管理有限公司是由杨先生创办的餐饮企业"
     self.gen_word(text)
     # vertexs = persion_recognition.recognition(vertexs, word_net_optimum, word_net)
     # word_net_optimum = WordNet(text, vertexs=vertexs)
     organization_recognition.recognition(self.vertexs,
                                          self.word_net_optimum,
                                          self.word_net)
     vertexs = viterbi(self.word_net_optimum.vertexs)
     self.assertIn(Vertex(u"济南杨铭宇餐饮管理有限公司", attribute=u"nt 1"), vertexs)
 def test_recognition_2_level(self):
     person_recognition.recognition(self.vertexs, self.word_net_optimum, self.word_net)
     place_recognition.recognition(self.vertexs, self.word_net_optimum, self.word_net)
     word_net_optimum = WordNet(self.text, vertexs=self.vertexs)
     vertexs = organization_recognition.recognition(self.vertexs, word_net_optimum, self.word_net)
     # viterbi(word_net_optimum.vertexs)
     dump_vertexs(vertexs)
     self.assertIn(Vertex(u"济南杨铭宇餐饮管理有限公司", attribute=u"nt 1"), vertexs)
 def test_organization_recognition(self):
     text = traditional_to_simplified(u"馬總統上午前往陸軍航空601旅,")
     Config.debug = True
     self.gen_word(text)
     person_recognition.recognition(self.vertexs, self.word_net_optimum, self.word_net)
     place_recognition.recognition(self.vertexs, self.word_net_optimum, self.word_net)
     word_net_optimum = WordNet(self.text, vertexs=self.vertexs)
     vertexs = organization_recognition.recognition(self.vertexs, word_net_optimum, self.word_net)
     dump_vertexs(vertexs)
     self.assertIn(Vertex(u"陆军航空601旅", attribute=u"nt 1"), vertexs)
 def test_organization_recognition(self):
     text = traditional_to_simplified(u"馬總統上午前往陸軍航空601旅,")
     Config.debug = True
     self.gen_word(text)
     person_recognition.recognition(self.vertexs, self.word_net_optimum,
                                    self.word_net)
     place_recognition.recognition(self.vertexs, self.word_net_optimum,
                                   self.word_net)
     word_net_optimum = WordNet(self.text, vertexs=self.vertexs)
     vertexs = organization_recognition.recognition(self.vertexs,
                                                    word_net_optimum,
                                                    self.word_net)
     dump_vertexs(vertexs)
     self.assertIn(Vertex(u"陆军航空601旅", attribute=u"nt 1"), vertexs)
 def test_recognition_2_level(self):
     text = u"济南杨铭宇餐饮管理有限公司是由杨先生创办的餐饮企业"
     self.gen_word(text)
     person_recognition.recognition(self.vertexs, self.word_net_optimum,
                                    self.word_net)
     place_recognition.recognition(self.vertexs, self.word_net_optimum,
                                   self.word_net)
     word_net_optimum = WordNet(self.text, vertexs=self.vertexs)
     vertexs = organization_recognition.recognition(self.vertexs,
                                                    word_net_optimum,
                                                    self.word_net)
     # viterbi(word_net_optimum.vertexs)
     dump_vertexs(vertexs)
     self.assertIn(Vertex(u"济南杨铭宇餐饮管理有限公司", attribute=u"nt 1"), vertexs)
示例#7
0
def seg_to_vertexs(text):
    word_net = WordNet(text)

    # 粗分词网
    gen_word_net(text, word_net)

    if Config.debug:
        print(u"打印粗分词网:")
        print(unicode(word_net))

    # 维特比
    vertexs = viterbi(word_net.vertexs)
    if Config.use_custom_dict:
        vertexs = combine_by_custom_dict(vertexs)
    word_net_optimum = WordNet(text, vertexs=vertexs)

    if Config.name_recognize:
        person_recognition.recognition(vertexs, word_net_optimum, word_net)

    if Config.place_recognize:
        place_recognition.recognition(vertexs, word_net_optimum, word_net)

    if Config.debug:
        print(u"打印人名、地名识别词网:")
        print(unicode(word_net_optimum))

    vertexs = viterbi(word_net_optimum.vertexs)

    if Config.org_recognize:
        word_net_optimum = WordNet(text, vertexs=vertexs)
        vertexs = organization_recognition.recognition(vertexs, word_net_optimum, word_net)

    if Config.debug:
        print(u"打印人组织识别词网:")
        print(unicode(word_net_optimum))
    return vertexs