Expose sentence to vector fn

This commit is contained in:
Hai Liang Wang 2018-09-21 21:58:02 +08:00
parent 5a37ca5235
commit 9979984773
4 changed files with 29 additions and 1 deletions

View File

@ -1,4 +1,14 @@
# 3.8
* 获得一个分词后句子的向量向量以BoW方式组成
```
sentence: 句子是分词后通过空格联合起来
ignore: 是否忽略OOVFalse时随机生成一个向量
```
# 3.7
* change import path of utils in word2vec.py to local path
* expose vector fn

View File

@ -127,6 +127,15 @@ array([-2.412167 , 2.2628384 , -7.0214124 , 3.9381874 , 0.8219283 ,
dtype=float32)
```
### synonyms#sv(sentence, ignore=False)
获得一个分词后句子的向量向量以BoW方式组成
```
sentence: 句子是分词后通过空格联合起来
ignore: 是否忽略OOVFalse时随机生成一个向量
```
## PCA
以“人脸”为例主要成分分析:

View File

@ -13,7 +13,7 @@ Welcome
setup(
name='synonyms',
version='3.7.0',
version='3.8.0',
description='Chinese Synonyms for Natural Language Processing and Understanding',
long_description=LONGDOC,
author='Hai Liang Wang, Hu Ying Xi',

View File

@ -206,6 +206,15 @@ def _levenshtein_distance(sentence1, sentence2):
# print("smoothing[%s| %s]: %s -> %s" % (sentence1, sentence2, d, s))
return s
def sv(sentence, ignore=False):
'''
获得一个分词后句子的向量向量以BoW方式组成
sentence: 句子是分词后通过空格联合起来
ignore: 是否忽略OOVFalse时随机生成一个向量
'''
return _get_wv(sentence, ignore = ignore)
def v(word):
'''
获得一个词语的向量OOV时抛出 KeyError 异常