Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pythainlp/word_vector/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def doesnt_match(words: List[str]) -> str:

>>> from pythainlp.word_vector import doesnt_match
>>>
>>> words = ['อาหารเช้า','อาหารเที่ยง','อาหารเย็น','พริกไทย']
>>> words = ['อาหารเช้า', 'อาหารเที่ยง', 'อาหารเย็น', 'พริกไทย']
>>> doesnt_match(words)
พริกไทย

Expand Down Expand Up @@ -188,15 +188,15 @@ def similarity(word1: str, word2: str) -> float:
(train and electric train).

>>> from pythainlp.word_vector import similarity
>>> similarity('รถไฟ','รถไฟฟ้า')
>>> similarity('รถไฟ', 'รถไฟฟ้า')
0.43387136


Compute consine similarity between two words: "เสือดาว" and "รถไฟฟ้า"
(leopard and electric train).

>>> from pythainlp.word_vector import similarity
>>> similarity('เสือดาว','รถไฟฟ้า')
>>> similarity('เสือดาว', 'รถไฟฟ้า')
0.04300258

"""
Expand Down Expand Up @@ -258,7 +258,7 @@ def sentence_vectorizer(text: str, use_mean: bool = True) -> ndarray:
word = _TK_EOL

if word in _MODEL.index_to_key:
vec += _MODEL.word_vec(word)
vec += _MODEL.get_vector(word)

if use_mean:
vec /= len_words
Expand Down