mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
9b49a40f4e
Test and fix for Issue #2219: Token.similarity() failed if single letter
19 lines
503 B
Python
19 lines
503 B
Python
# coding: utf8
|
|
from __future__ import unicode_literals
|
|
from ..util import add_vecs_to_vocab, get_doc
|
|
import pytest
|
|
|
|
@pytest.fixture
|
|
def vectors():
|
|
return [("a", [1, 2, 3]), ("letter", [4, 5, 6])]
|
|
|
|
@pytest.fixture
|
|
def vocab(en_vocab, vectors):
|
|
add_vecs_to_vocab(en_vocab, vectors)
|
|
return en_vocab
|
|
|
|
def test_issue2219(vocab, vectors):
|
|
[(word1, vec1), (word2, vec2)] = vectors
|
|
doc = get_doc(vocab, words=[word1, word2])
|
|
assert doc[0].similarity(doc[1]) == doc[1].similarity(doc[0])
|