MCPcopy Create free account
hub / github.com/baidu/lac / LacModel

Class LacModel

python/LAC/models.py:230–246  ·  view source on GitHub ↗

Docstring for LAC Model

Source from the content-addressed store, hash-verified

228 self.predictor = create_paddle_predictor(config)
229
230class LacModel(Model):
231 """Docstring for LAC Model"""
232 def __init__(self, model_path, mode, use_cuda):
233 super(LacModel, self).__init__(model_path, mode, use_cuda)
234
235 seg_dict_path = os.path.join(model_path, "conf", "small_seg.dic")
236 self.segment_tool = Segment(dict_path=seg_dict_path)
237
238 def run(self, texts):
239 crf_result = super(LacModel, self).run(texts)['crf_result']
240 result = [[word, tag] for word, tag, tag_for_rank in crf_result] if self.batch else crf_result[0][:-1]
241 return result
242
243 def call_run(self, texts):
244 """lac被rank模型调用时返回的结果"""
245 lac_result = super(LacModel, self).run(texts)
246 return lac_result
247
248class SegModel(Model):
249 """Docstring for Seg Model"""

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected