mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 09:57:26 +03:00 
			
		
		
		
	Use consistent test names
This commit is contained in:
		
							parent
							
								
									33800c9367
								
							
						
					
					
						commit
						7262421bb2
					
				| 
						 | 
					@ -7,7 +7,7 @@ from ..util import get_doc
 | 
				
			||||||
import pytest
 | 
					import pytest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_add_entities_set_ents_iob(en_vocab):
 | 
					def test_doc_add_entities_set_ents_iob(en_vocab):
 | 
				
			||||||
    text = ["This", "is", "a", "lion"]
 | 
					    text = ["This", "is", "a", "lion"]
 | 
				
			||||||
    doc = get_doc(en_vocab, text)
 | 
					    doc = get_doc(en_vocab, text)
 | 
				
			||||||
    ner = EntityRecognizer(en_vocab, features=[(2,), (3,)])
 | 
					    ner = EntityRecognizer(en_vocab, features=[(2,), (3,)])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,7 @@ from ..util import get_doc
 | 
				
			||||||
import pytest
 | 
					import pytest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_array_attr_of_token(en_tokenizer, en_vocab):
 | 
					def test_doc_array_attr_of_token(en_tokenizer, en_vocab):
 | 
				
			||||||
    text = "An example sentence"
 | 
					    text = "An example sentence"
 | 
				
			||||||
    tokens = en_tokenizer(text)
 | 
					    tokens = en_tokenizer(text)
 | 
				
			||||||
    example = tokens.vocab["example"]
 | 
					    example = tokens.vocab["example"]
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@ def test_array_attr_of_token(en_tokenizer, en_vocab):
 | 
				
			||||||
    assert feats_array[0][0] != feats_array[0][1]
 | 
					    assert feats_array[0][0] != feats_array[0][1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_array_tag(en_tokenizer):
 | 
					def test_doc_array_tag(en_tokenizer):
 | 
				
			||||||
    text = "A nice sentence."
 | 
					    text = "A nice sentence."
 | 
				
			||||||
    tags = ['DET', 'ADJ', 'NOUN', 'PUNCT']
 | 
					    tags = ['DET', 'ADJ', 'NOUN', 'PUNCT']
 | 
				
			||||||
    tokens = en_tokenizer(text)
 | 
					    tokens = en_tokenizer(text)
 | 
				
			||||||
| 
						 | 
					@ -30,7 +30,7 @@ def test_array_tag(en_tokenizer):
 | 
				
			||||||
    assert feats_array[3][1] == doc[3].pos
 | 
					    assert feats_array[3][1] == doc[3].pos
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_array_dep(en_tokenizer):
 | 
					def test_doc_array_dep(en_tokenizer):
 | 
				
			||||||
    text = "A nice sentence."
 | 
					    text = "A nice sentence."
 | 
				
			||||||
    deps = ['det', 'amod', 'ROOT', 'punct']
 | 
					    deps = ['det', 'amod', 'ROOT', 'punct']
 | 
				
			||||||
    tokens = en_tokenizer(text)
 | 
					    tokens = en_tokenizer(text)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,7 +9,7 @@ from ..util import get_doc
 | 
				
			||||||
import numpy
 | 
					import numpy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_noun_chunks_not_nested(en_tokenizer):
 | 
					def test_doc_noun_chunks_not_nested(en_tokenizer):
 | 
				
			||||||
    text = "Peter has chronic command and control issues"
 | 
					    text = "Peter has chronic command and control issues"
 | 
				
			||||||
    heads = [1, 0, 4, 3, -1, -2, -5]
 | 
					    heads = [1, 0, 4, 3, -1, -2, -5]
 | 
				
			||||||
    deps = ['nsubj', 'ROOT', 'amod', 'nmod', 'cc', 'conj', 'dobj']
 | 
					    deps = ['nsubj', 'ROOT', 'amod', 'nmod', 'cc', 'conj', 'dobj']
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@ import pytest
 | 
				
			||||||
import numpy
 | 
					import numpy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_token_api_strings(en_tokenizer):
 | 
					def test_doc_token_api_strings(en_tokenizer):
 | 
				
			||||||
    text = "Give it back! He pleaded."
 | 
					    text = "Give it back! He pleaded."
 | 
				
			||||||
    tags = ['VERB', 'PRON', 'PART', 'PUNCT', 'PRON', 'VERB', 'PUNCT']
 | 
					    tags = ['VERB', 'PRON', 'PART', 'PUNCT', 'PRON', 'VERB', 'PUNCT']
 | 
				
			||||||
    heads = [0, -1, -2, -3, 1, 0, -1]
 | 
					    heads = [0, -1, -2, -3, 1, 0, -1]
 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,7 @@ def test_token_api_strings(en_tokenizer):
 | 
				
			||||||
    assert doc[0].dep_ == 'ROOT'
 | 
					    assert doc[0].dep_ == 'ROOT'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_token_api_flags(en_tokenizer):
 | 
					def test_doc_token_api_flags(en_tokenizer):
 | 
				
			||||||
    text = "Give it back! He pleaded."
 | 
					    text = "Give it back! He pleaded."
 | 
				
			||||||
    tokens = en_tokenizer(text)
 | 
					    tokens = en_tokenizer(text)
 | 
				
			||||||
    assert tokens[0].check_flag(IS_ALPHA)
 | 
					    assert tokens[0].check_flag(IS_ALPHA)
 | 
				
			||||||
| 
						 | 
					@ -41,7 +41,7 @@ def test_token_api_flags(en_tokenizer):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@pytest.mark.parametrize('text', ["Give it back! He pleaded."])
 | 
					@pytest.mark.parametrize('text', ["Give it back! He pleaded."])
 | 
				
			||||||
def test_token_api_prob_inherited_from_vocab(en_tokenizer, text):
 | 
					def test_doc_token_api_prob_inherited_from_vocab(en_tokenizer, text):
 | 
				
			||||||
    word = text.split()[0]
 | 
					    word = text.split()[0]
 | 
				
			||||||
    en_tokenizer.vocab[word].prob = -1
 | 
					    en_tokenizer.vocab[word].prob = -1
 | 
				
			||||||
    tokens = en_tokenizer(text)
 | 
					    tokens = en_tokenizer(text)
 | 
				
			||||||
| 
						 | 
					@ -49,13 +49,13 @@ def test_token_api_prob_inherited_from_vocab(en_tokenizer, text):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@pytest.mark.parametrize('text', ["one two"])
 | 
					@pytest.mark.parametrize('text', ["one two"])
 | 
				
			||||||
def test_token_api_str_builtin(en_tokenizer, text):
 | 
					def test_doc_token_api_str_builtin(en_tokenizer, text):
 | 
				
			||||||
    tokens = en_tokenizer(text)
 | 
					    tokens = en_tokenizer(text)
 | 
				
			||||||
    assert str(tokens[0]) == text.split(' ')[0]
 | 
					    assert str(tokens[0]) == text.split(' ')[0]
 | 
				
			||||||
    assert str(tokens[1]) == text.split(' ')[1]
 | 
					    assert str(tokens[1]) == text.split(' ')[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_token_api_is_properties(en_vocab):
 | 
					def test_doc_token_api_is_properties(en_vocab):
 | 
				
			||||||
    text = ["Hi", ",", "my", "email", "is", "test@me.com"]
 | 
					    text = ["Hi", ",", "my", "email", "is", "test@me.com"]
 | 
				
			||||||
    doc = get_doc(en_vocab, text)
 | 
					    doc = get_doc(en_vocab, text)
 | 
				
			||||||
    assert doc[0].is_title
 | 
					    assert doc[0].is_title
 | 
				
			||||||
| 
						 | 
					@ -71,7 +71,7 @@ def test_token_api_is_properties(en_vocab):
 | 
				
			||||||
@pytest.mark.parametrize('text,vectors', [
 | 
					@pytest.mark.parametrize('text,vectors', [
 | 
				
			||||||
    ("apples oranges ldskbjls", ["apples -1 -1 -1", "oranges -1 -1 0"])
 | 
					    ("apples oranges ldskbjls", ["apples -1 -1 -1", "oranges -1 -1 0"])
 | 
				
			||||||
])
 | 
					])
 | 
				
			||||||
def test_token_api_vectors(en_tokenizer, text_file, text, vectors):
 | 
					def test_doc_token_api_vectors(en_tokenizer, text_file, text, vectors):
 | 
				
			||||||
    text_file.write('\n'.join(vectors))
 | 
					    text_file.write('\n'.join(vectors))
 | 
				
			||||||
    text_file.seek(0)
 | 
					    text_file.seek(0)
 | 
				
			||||||
    vector_length = en_tokenizer.vocab.load_vectors(text_file)
 | 
					    vector_length = en_tokenizer.vocab.load_vectors(text_file)
 | 
				
			||||||
| 
						 | 
					@ -89,7 +89,7 @@ def test_token_api_vectors(en_tokenizer, text_file, text, vectors):
 | 
				
			||||||
                numpy.sqrt(numpy.dot(tokens[0].vector, tokens[0].vector)))
 | 
					                numpy.sqrt(numpy.dot(tokens[0].vector, tokens[0].vector)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_token_api_ancestors(en_tokenizer):
 | 
					def test_doc_token_api_ancestors(en_tokenizer):
 | 
				
			||||||
    # the structure of this sentence depends on the English annotation scheme
 | 
					    # the structure of this sentence depends on the English annotation scheme
 | 
				
			||||||
    text = "Yesterday I saw a dog that barked loudly."
 | 
					    text = "Yesterday I saw a dog that barked loudly."
 | 
				
			||||||
    heads = [2, 1, 0, 1, -2, 1, -2, -1, -6]
 | 
					    heads = [2, 1, 0, 1, -2, 1, -2, -1, -6]
 | 
				
			||||||
| 
						 | 
					@ -103,7 +103,7 @@ def test_token_api_ancestors(en_tokenizer):
 | 
				
			||||||
    assert not doc[6].is_ancestor_of(doc[2])
 | 
					    assert not doc[6].is_ancestor_of(doc[2])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_token_api_head_setter(en_tokenizer):
 | 
					def test_doc_token_api_head_setter(en_tokenizer):
 | 
				
			||||||
    # the structure of this sentence depends on the English annotation scheme
 | 
					    # the structure of this sentence depends on the English annotation scheme
 | 
				
			||||||
    text = "Yesterday I saw a dog that barked loudly."
 | 
					    text = "Yesterday I saw a dog that barked loudly."
 | 
				
			||||||
    heads = [2, 1, 0, 1, -2, 1, -2, -1, -6]
 | 
					    heads = [2, 1, 0, 1, -2, 1, -2, -1, -6]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user