mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 16:07:41 +03:00 
			
		
		
		
	
		
			
				
	
	
		
			21 lines
		
	
	
		
			652 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			652 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import pytest
 | |
| 
 | |
| 
 | |
| from spacy.matcher import Matcher
 | |
| 
 | |
| @pytest.mark.xfail
 | |
| def test_overlap_issue118(EN):
 | |
|     '''Test a bug that arose from having overlapping matches'''
 | |
|     doc = EN.tokenizer(u'how many points did lebron james score against the boston celtics last night')
 | |
|     ORG = doc.vocab.strings['ORG']
 | |
|     matcher = Matcher(EN.vocab, {'BostonCeltics': ('ORG', {}, [[{'lower': 'boston'}, {'lower': 'celtics'}], [{'lower': 'celtics'}]])})
 | |
|     
 | |
|     matches = matcher(doc)
 | |
|     assert matches == [(ORG, 9, 11)]
 | |
|     ents = list(doc.ents)
 | |
|     assert len(ents) == 1
 | |
|     assert ents[0].label == ORG
 | |
|     assert ents[0].start == 9
 | |
|     assert ents[0].end == 11
 | |
| 
 |