mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 01:48:04 +03:00 
			
		
		
		
	* replace unicode categories with raw list of code points * simplifying ranges * fixing variable length quotes * removing redundant regular expression * small cleanup of regexp notations * quotes and alpha as ranges instead of alterations * removed most regexp dependencies and features * exponential backtracking - unit tests * rewrote expression with pathological backtracking * disabling double hyphen tests for now * test additional variants of repeating punctuation * remove regex and redundant backslashes from load_reddit script * small typo fixes * disable double punctuation test for russian * clean up old comments * format block code * final cleanup * naming consistency * french strings as unicode for python 2 support * french regular expression case insensitive
		
			
				
	
	
		
			34 lines
		
	
	
		
			942 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			942 B
		
	
	
	
		
			Python
		
	
	
	
	
	
# coding: utf8
 | 
						||
from __future__ import unicode_literals
 | 
						||
 | 
						||
from ..char_classes import LIST_ELLIPSES, LIST_ICONS
 | 
						||
from ..char_classes import CONCAT_QUOTES, ALPHA, ALPHA_LOWER, ALPHA_UPPER
 | 
						||
from ..punctuation import TOKENIZER_SUFFIXES
 | 
						||
 | 
						||
# Punctuation stolen from Danish
 | 
						||
_quotes = CONCAT_QUOTES.replace("'", "")
 | 
						||
 | 
						||
_infixes = (
 | 
						||
    LIST_ELLIPSES
 | 
						||
    + LIST_ICONS
 | 
						||
    + [
 | 
						||
        r"(?<=[{al}])\.(?=[{au}])".format(al=ALPHA_LOWER, au=ALPHA_UPPER),
 | 
						||
        r"(?<=[{a}])[,!?](?=[{a}])".format(a=ALPHA),
 | 
						||
        r'(?<=[{a}])[:<>=](?=[{a}])'.format(a=ALPHA),
 | 
						||
        r"(?<=[{a}]),(?=[{a}])".format(a=ALPHA),
 | 
						||
        r"(?<=[{a}])([{q}\)\]\(\[])(?=[{a}])".format(a=ALPHA, q=_quotes),
 | 
						||
        r"(?<=[{a}])--(?=[{a}])".format(a=ALPHA),
 | 
						||
    ]
 | 
						||
)
 | 
						||
 | 
						||
_suffixes = [
 | 
						||
    suffix
 | 
						||
    for suffix in TOKENIZER_SUFFIXES
 | 
						||
    if suffix not in ["'s", "'S", "’s", "’S", r"\'"]
 | 
						||
]
 | 
						||
_suffixes += [r"(?<=[^sSxXzZ])\'"]
 | 
						||
 | 
						||
 | 
						||
TOKENIZER_INFIXES = _infixes
 | 
						||
TOKENIZER_SUFFIXES = _suffixes
 |