mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 07:57:35 +03:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			656 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			656 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| # coding: utf-8
 | |
| from __future__ import unicode_literals
 | |
| 
 | |
| from ...matcher import Matcher
 | |
| 
 | |
| import pytest
 | |
| 
 | |
| 
 | |
| @pytest.mark.models
 | |
| def test_issue429(EN):
 | |
|     def merge_phrases(matcher, doc, i, matches):
 | |
|       if i != len(matches) - 1:
 | |
|         return None
 | |
|       spans = [(ent_id, ent_id, doc[start:end]) for ent_id, start, end in matches]
 | |
|       for ent_id, label, span in spans:
 | |
|         span.merge('NNP' if label else span.root.tag_, span.text, EN.vocab.strings[label])
 | |
| 
 | |
|     doc = EN('a')
 | |
|     matcher = Matcher(EN.vocab)
 | |
|     matcher.add('TEST', merge_phrases, [{'ORTH': 'a'}])
 | |
|     doc = EN.make_doc('a b c')
 | |
|     EN.tagger(doc)
 | |
|     matcher(doc)
 | |
|     EN.entity(doc)
 |