1 Star 0 Fork 7

tyree.tan/SaberNLP

forked from HDT3213/SaberNLP 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test.py 2.00 KB
一键复制 编辑 原始数据 按行查看 历史
TanLi 提交于 2017-07-20 12:14 . daily
# encoding=utf-8
from recognize import tag
from segment import cut, hmm_cut, dict_cut, dag_segger
from abstract import get_abstract
from word2vec import Word2Vec
import os
def data_path(filename):
return os.path.join(os.path.dirname(__file__), "%s" % filename)
def test_seg():
cases = [
"给你们传授一点人生的经验",
"我来到北京清华大学",
"长春市长春节讲话",
"我们在野生动物园玩",
"我只是做了一些微小的工作",
"国庆节我在研究中文分词",
"比起生存还是死亡来忠诚与背叛可能更是一个问题"
]
for case in cases:
result = dict_cut(case)
print(result)
def test_tag():
cases = [
"给你们传授一点人生的经验",
"我来到北京清华大学",
"长春市长春节讲话",
"我们在野生动物园玩",
"我只是做了一些微小的工作",
"国庆节我在研究中文分词",
"比起生存还是死亡来忠诚与背叛可能更是一个问题"
]
for case in cases:
result = tag(case)
print(result)
def test_abstract():
fr = open(data_path('tmp/news.txt'), encoding='utf-8')
case = ''
for line in fr:
line = line.strip()
if line == '####':
result = get_abstract(case)
print(result)
case = ''
else:
case += line
def test_word2vec():
data = [
'Merge multiple sorted inputs into a single sorted output',
'The API below differs from textbook heap algorithms in two aspects'
]
wv = Word2Vec(vec_len=50)
wv.train(data, model='cbow')
print(wv['into'])
def test():
print("test seg:")
test_seg()
print("==========")
#print("test tag:")
#test_tag()
#print("==========")
#print("test abstract:")
#test_abstract()
#print("==========")
#print("test word2vec:")
#test_word2vec()
#print("==========")
if __name__ == '__main__':
test()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/cosastro/SaberNLP.git
git@gitee.com:cosastro/SaberNLP.git
cosastro
SaberNLP
SaberNLP
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385