mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 07:57:35 +03:00 
			
		
		
		
	Filter W036 for entity ruler, etc. (#8424)
This commit is contained in:
		
							parent
							
								
									e3f1d4a7d0
								
							
						
					
					
						commit
						c78eb28dfa
					
				|  | @ -3,6 +3,7 @@ from typing import Optional, Union, List, Dict, Tuple, Iterable, Any, Callable, | |||
| from collections import defaultdict | ||||
| from pathlib import Path | ||||
| import srsly | ||||
| import warnings | ||||
| 
 | ||||
| from .pipe import Pipe | ||||
| from ..training import Example | ||||
|  | @ -141,6 +142,8 @@ class EntityRuler(Pipe): | |||
| 
 | ||||
|     def match(self, doc: Doc): | ||||
|         self._require_patterns() | ||||
|         with warnings.catch_warnings(): | ||||
|             warnings.filterwarnings("ignore", message="\\[W036") | ||||
|             matches = list(self.matcher(doc)) + list(self.phrase_matcher(doc)) | ||||
|         matches = set( | ||||
|             [(m_id, start, end) for m_id, start, end in matches if start != end] | ||||
|  | @ -276,7 +279,7 @@ class EntityRuler(Pipe): | |||
|                     current_index = i | ||||
|                     break | ||||
|             subsequent_pipes = [ | ||||
|                 pipe for pipe in self.nlp.pipe_names[current_index + 1 :] | ||||
|                 pipe for pipe in self.nlp.pipe_names[current_index :] | ||||
|             ] | ||||
|         except ValueError: | ||||
|             subsequent_pipes = [] | ||||
|  |  | |||
|  | @ -481,6 +481,7 @@ def test_matcher_schema_token_attributes(en_vocab, pattern, text): | |||
|     assert len(matches) == 1 | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.filterwarnings("ignore:\\[W036") | ||||
| def test_matcher_valid_callback(en_vocab): | ||||
|     """Test that on_match can only be None or callable.""" | ||||
|     matcher = Matcher(en_vocab) | ||||
|  |  | |||
|  | @ -180,6 +180,7 @@ def test_matcher_sets_return_correct_tokens(en_vocab): | |||
|     assert texts == ["zero", "one", "two"] | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.filterwarnings("ignore:\\[W036") | ||||
| def test_matcher_remove(): | ||||
|     nlp = English() | ||||
|     matcher = Matcher(nlp.vocab) | ||||
|  |  | |||
|  | @ -324,6 +324,7 @@ def test_append_alias(nlp): | |||
|     assert len(mykb.get_alias_candidates("douglas")) == 3 | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.filterwarnings("ignore:\\[W036") | ||||
| def test_append_invalid_alias(nlp): | ||||
|     """Test that append an alias will throw an error if prior probs are exceeding 1""" | ||||
|     mykb = KnowledgeBase(nlp.vocab, entity_vector_length=1) | ||||
|  | @ -342,6 +343,7 @@ def test_append_invalid_alias(nlp): | |||
|         mykb.append_alias(alias="douglas", entity="Q1", prior_prob=0.2) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.filterwarnings("ignore:\\[W036") | ||||
| def test_preserving_links_asdoc(nlp): | ||||
|     """Test that Span.as_doc preserves the existing entity links""" | ||||
|     vector_length = 1 | ||||
|  |  | |||
|  | @ -98,6 +98,7 @@ def test_entity_ruler_clear(nlp, patterns): | |||
|     assert len(doc.ents) == 1 | ||||
|     ruler.clear() | ||||
|     assert len(ruler.labels) == 0 | ||||
|     with pytest.warns(UserWarning): | ||||
|         doc = nlp("hello world") | ||||
|     assert len(doc.ents) == 0 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user