def __is_clause_pattern3(self, the_clause, seg_result):
for a_phrase in self.__phrase_dict:
keys = a_phrase.keys()
to_compile = a_phrase["key"].replace("……", "[\u4e00-\u9fa5]*")
if "start" in keys:
to_compile = to_compile.replace("*", "{" + a_phrase["start"] + "," + a_phrase["end"] + "}")
if "head" in keys:
to_compile = a_phrase["head"] + to_compile
match = re.compile(to_compile).search(the_clause)
if match is not None:
can_continue = True
pos = [flag for word, flag in posseg.cut(match.group())]
if "between_tag" in keys:
if a_phrase["between_tag"] not in pos and len(pos) > 2:
can_continue = False
if can_continue:
for i in range(len(seg_result)):
if seg_result[i].word in match.group():
try:
if seg_result[i + 1].word in match.group():
return self.__emotional_word_analysis(
a_phrase["key"] + ":" + match.group(), a_phrase["value"],
[x for x, y in seg_result], i)
except IndexError:
return self.__emotional_word_analysis(
a_phrase["key"] + ":" + match.group(), a_phrase["value"],
[x for x, y in seg_result], i)
return ""
classifiers.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录