Browse Source

分词优化

master
wangsheng 3 years ago
parent
commit
240016d1ff
3 changed files with 6 additions and 4 deletions
  1. +2
    -2
      自然语言处理/data_and_result/compare.py
  2. +1
    -1
      自然语言处理/中文分词/flashtext_cut.py
  3. +3
    -1
      自然语言处理/短语挖掘与新词发现/苏剑林/main_sujianlin.py

+ 2
- 2
自然语言处理/data_and_result/compare.py View File

@@ -28,13 +28,13 @@ chaji=chaji[chaji==1]
chaji.to_csv('./compare-chaji-result.txt', header = False)
'''

data1 = pd.read_table('./result-艺术-7字-标点符号混乱化.txt',
data1 = pd.read_table('./result-艺术-7字.txt',
header=None, # 表示不要导入原文件内的表头
names=['keyword','count'], #自定义列名
sep=',', # 原文件的分隔符是'::',此处是按此分隔符将数据导入
engine= 'python')

data2 = pd.read_table('./result-艺术-7字-去重.txt',
data2 = pd.read_table('./result-所有-7字.txt',
header=None, # 表示不要导入原文件内的表头
names=['keyword','count'], #自定义列名
sep=',', # 原文件的分隔符是'::',此处是按此分隔符将数据导入


+ 1
- 1
自然语言处理/中文分词/flashtext_cut.py View File

@@ -6,7 +6,7 @@ import pandas as pd
def loadKeyWord(keyword_processor):
data = pd.read_table('./result.txt',
header=None, # 表示不要导入原文件内的表头
names=['keyword','count'], #自定义列名
names=['index','keyword'], #自定义列名
sep=',', # 原文件的分隔符是'::',此处是按此分隔符将数据导入
engine= 'python')
keywords = data['keyword']


+ 3
- 1
自然语言处理/短语挖掘与新词发现/苏剑林/main_sujianlin.py View File

@@ -33,7 +33,9 @@ def isChinese(word):
notStartChar = ['》', '」', '】', ')', ']', '·', '・', '•']
notEndChar = ['《', '「', '【', '(', '[', '·', '・', '•']
def notStartEnd(word):
if word[0] not in notStartChar and word[-1] not in notEndChar:
if (word[0] == '《' and word[-1] != '》') or (word[0] != '《' and word[-1] == '》'):
return False
elif word[0] not in notStartChar and word[-1] not in notEndChar:
return True
return False



Loading…
Cancel
Save