mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 01:48:04 +03:00 
			
		
		
		
	make the code less cryptic
This commit is contained in:
		
							parent
							
								
									a06fca9fdf
								
							
						
					
					
						commit
						5bf2fd1f78
					
				| 
						 | 
				
			
			@ -32,9 +32,10 @@ def german_noun_chunks(doc):
 | 
			
		|||
    np_deps = set(doc.vocab.strings[label] for label in labels)
 | 
			
		||||
    close_app = doc.vocab.strings['nk']
 | 
			
		||||
 | 
			
		||||
    i = 0
 | 
			
		||||
    while i  < len(doc):
 | 
			
		||||
        word = doc[i]
 | 
			
		||||
    rbracket = 0
 | 
			
		||||
    for i, word in enumerate(doc):
 | 
			
		||||
        if i < rbracket:
 | 
			
		||||
            continue
 | 
			
		||||
        if word.pos == NOUN and word.dep in np_deps:
 | 
			
		||||
            rbracket = word.i+1
 | 
			
		||||
            # try to extend the span to the right
 | 
			
		||||
| 
						 | 
				
			
			@ -43,8 +44,5 @@ def german_noun_chunks(doc):
 | 
			
		|||
                if rdep.pos == NOUN and rdep.dep == close_app:
 | 
			
		||||
                    rbracket = rdep.i+1
 | 
			
		||||
            yield word.left_edge.i, rbracket, np_label            
 | 
			
		||||
            i = rbracket
 | 
			
		||||
            continue
 | 
			
		||||
        i += 1
 | 
			
		||||
 | 
			
		||||
CHUNKERS = {'en': english_noun_chunks, 'de': german_noun_chunks}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user