mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-01 00:17:44 +03:00 
			
		
		
		
	
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from ..char_classes import LIST_ELLIPSES, LIST_PUNCT, LIST_HYPHENS
 | ||
| from ..char_classes import LIST_ICONS, LIST_QUOTES, CURRENCY, UNITS, PUNCT
 | ||
| from ..char_classes import CONCAT_QUOTES, ALPHA, ALPHA_LOWER, ALPHA_UPPER
 | ||
| from ..punctuation import TOKENIZER_PREFIXES as BASE_TOKENIZER_PREFIXES
 | ||
| 
 | ||
| _quotes = CONCAT_QUOTES.replace("'", "")
 | ||
| 
 | ||
| _prefixes = _prefixes = [
 | ||
|     r"(długo|krótko|jedno|dwu|trzy|cztero)-"
 | ||
| ] + BASE_TOKENIZER_PREFIXES
 | ||
| 
 | ||
| _infixes = (
 | ||
|     LIST_ELLIPSES
 | ||
|     + LIST_ICONS
 | ||
|     + LIST_HYPHENS
 | ||
|     + [
 | ||
|         r"(?<=[0-9{al}])\.(?=[0-9{au}])".format(al=ALPHA, 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),
 | ||
|     ]
 | ||
| )
 | ||
| 
 | ||
| _suffixes = (
 | ||
|     ["''", "’’", r"\.", "…"]
 | ||
|     + LIST_PUNCT
 | ||
|     + LIST_QUOTES
 | ||
|     + LIST_ICONS
 | ||
|     + [
 | ||
|         r"(?<=[0-9])\+",
 | ||
|         r"(?<=°[FfCcKk])\.",
 | ||
|         r"(?<=[0-9])(?:{c})".format(c=CURRENCY),
 | ||
|         r"(?<=[0-9])(?:{u})".format(u=UNITS),
 | ||
|         r"(?<=[0-9{al}{e}{p}(?:{q})])\.".format(
 | ||
|             al=ALPHA_LOWER, e=r"%²\-\+", q=CONCAT_QUOTES, p=PUNCT
 | ||
|         ),
 | ||
|         r"(?<=[{au}])\.".format(au=ALPHA_UPPER),
 | ||
|     ]
 | ||
| )
 | ||
| 
 | ||
| 
 | ||
| TOKENIZER_PREFIXES = _prefixes
 | ||
| TOKENIZER_INFIXES = _infixes
 | ||
| TOKENIZER_SUFFIXES = _suffixes
 |