/usr/local/lib/python3.6/site-packages/sacremoses/__pycache__
Edit: /usr/local/lib/python3.6/site-packages/sacremoses/__pycache__/normalize.cpython-36.pyc (4829B)
3
Eg @ s: d dl Z d dlZd dlmZ d dlmZ G dd dZdS ) N) text_type)chainc % @ s e Zd ZdZddddddddddg
ZddgZdddddddddddddddgZddddddgZddddddddddg
ZdgZ ddgZ
dgZdgZddddddddddddddddddddddddddddddddddddg$Z
dddZdd Zdd Zdd ZdS )MosesPunctNormalizerz
This is a Python port of the Moses punctuation normalizer from
https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/normalize-punctuation.perl
\r \( (\)) +
\) ([.!:?;,]))\g<1>\( ( \))(\d) %\g<1>% :: ;;`''' " „" “ ” –- — - ´ ([a-zA-Z])‘([a-zA-Z])\g<1>'\g<2> ([a-zA-Z])’([a-zA-Z]) ‘ ‚ ’ ´´ …... « « « » » » %% nº nº : ºC ºC cm cm \?? \!! ; , , "([,.]+)\g<1>","",(\.+)"(\s*[^<])"\g<1>\g<2>
(\d) (\d)\g<1>,\g<2>\g<1>.\g<2> ,, 。\s*. 、 ∶ : ? 《 》 ) ! ( ; 」 「 00 11 22 33 44 55 66 77 88 99 .\s* ~~ ━ 〈< 〉> 【[ 】] %enTFc C s | j | j| j| jg| _|r*| jjd| j |r\|dkrF| jj| j n|d kr\| jj| j |r|d
krx| jj| j
n| jj| j tt
| j | _|| _|| _dS )ah
:param language: The two-letter language code.
:type lang: str
:param penn: Normalize Penn Treebank style quotations.
:type penn: bool
:param norm_quote_commas: Normalize quotations and commas
:type norm_quote_commas: bool
:param norm_numbers: Normalize numbers
:type norm_numbers: bool
r deesfrczcsN)r r r )r r r r r )EXTRA_WHITESPACENORMALIZE_UNICODE
FRENCH_QUOTESHANDLE_PSEUDO_SPACES
substitutionsinsertNORMALIZE_UNICODE_IF_NOT_PENNappendEN_QUOTATION_FOLLOWED_BY_COMMA$DE_ES_FR_QUOTATION_FOLLOWED_BY_COMMADE_ES_CZ_CS_FROTHERlistr pre_replace_unicode_punctpost_remove_control_chars)selflangZpennZnorm_quote_commasZnorm_numbersr r r >/usr/local/lib/python3.6/site-packages/sacremoses/normalize.py__init__ s$
zMosesPunctNormalizer.__init__c C sN | j r| j|}x$| jD ]\}}tj||t|}qW | jrF| j|}|j S )z?
Returns a string with normalized punctuation.
) r replace_unicode_punctr resubr r remove_control_charsstrip)r textregexpsubstitutionr r r normalize s
zMosesPunctNormalizer.normalizec C s* x$| j D ]\}}tj||t|}qW |S )N)REPLACE_UNICODE_PUNCTUATIONr r r )r r r r r r r r s z*MosesPunctNormalizer.replace_unicode_punctc C s t jdd|S )Nz\p{C}r )regexr )r r r r r r s z)MosesPunctNormalizer.remove_control_charsN)r r )r r )r r
)r r )r
r )r r )r r )r r )r r )r r )r r )r r )r r )r r )r r )r! r" )r# r$ )r r )r% r )r&