U C^_@s&dZddlmZddlZddlZddlZddlZddlZddlm Z z ddl Z Wne k rlddl Z YnXz ddl Z Wne k rddlZ YnXzddlmZWne k rdZYnXz ddlZWne k rdZYnXzddlmZWn"e k rddlmZYnXe Z e Z eZeZe Z eedeZejd Zejd Zejd kZejdd kZejdd kZ epe oejddkZ!ere"Z#e$Z%e&Z'e(Z)ddZ*e+ej,fZ-n2e re.Z#e"Z%e"Z'e/Z)ddZ*e!re+ej,fne+Z-ddZ0ddZ1ddZ2dddZ3ddZ4ddZ5dS) z Helpers for Python and platform compatibility. To distinguish them from the builtin functions, replacement functions are suffixed with an underscore, e.g. `unicode_`. DOCS: https://spacy.io/api/top-level#compat )unicode_literalsN) copy_array)Stream) Optimizer)AdamizipwinlinuxdarwincCst|dS)Nutf8)strdecodepathr//tmp/pip-install-6_kvzl1k/spacy/spacy/compat.pyArcCst|S)N)rrrrrrIrcCstr|St|ddS)zConvert a bytes object to a string. b_str (bytes): The object to convert. RETURNS (unicode): The converted string. r)encoding) is_python2r)Zb_strrrrb_to_strMsrcCs:tr,ddl}|jddt|t|gddn ||dS)zCreate a symlink. Used for model shortcut links. orig (unicode / Path): The origin path. dest (unicode / Path): The destination path of the symlink. rNZmklinkz/dT)shell) is_windows subprocess check_callpath2str symlink_to)origdestrrrrr Ysr cCs6tjt|r$tr$tt|ntt|dS)zjRemove a symlink. Used for model shortcut links. link (unicode / Path): The path to the symlink. N)osrisdirrrrmdirunlink)linkrrrsymlink_removeisr(cCs<|dtfko:|dtfko:|dtfko:|dtfko:|dtfkS)a$Check if a specific configuration of Python version and operating system matches the user's setup. Mostly used to display targeted error messages. python2 (bool): spaCy is executed with Python 2.x. python3 (bool): spaCy is executed with Python 3.x. windows (bool): spaCy is executed on Windows. linux (bool): spaCy is executed on Linux. osx (bool): spaCy is executed on OS X or macOS. RETURNS (bool): Whether the configuration matches the user's platform. DOCS: https://spacy.io/api/top-level#compat.is_config N)r is_python3ris_linuxis_osx)Zpython2Zpython3Zwindowsr Zosxrrr is_configvs     r,cCsZt|}tr ddl}|||Sddl}|j|t|}|j|}|j ||SdS)zImport module from a file. Used to load models from a directory. name (unicode): Name of module to load. loc (unicode / Path): Path to the file. RETURNS: The loaded module. rN) ris_python_pre_3_5impZ load_sourceimportlib.utilutilspec_from_file_locationrmodule_from_specloader exec_module)namelocr. importlibspecmodulerrr import_files   r:cCsB|dkr |S|dd}|dd}|dd}td|d S) awPython2.7's re module chokes when compiling patterns that have ranges between escaped unicode codepoints if the two codepoints are unrecognised in the unicode database. For instance: re.compile('[\uAA77-\uAA79]').findall("hello") Ends up matching every character (on Python 2). This problem doesn't occur if we're dealing with unicode literals. N\z\\z\\uz\uz\\Uz\Uzu'''z''')replaceast literal_eval)stringrrrunescape_unicodes    r@)NNNNN)6__doc__ __future__rr#sys itertoolsr=typesZthinc.neural.utilrcPicklepickle ImportErrorcopy_regcopyregZcupy.cuda.streamrZ CudaStreamZcupyZthinc.neural.optimizersrrgetattrziprplatform startswithrr*r+ version_inforr)r-rZbytes_unicodeZunicode_ basestringZ basestring_ raw_inputZinput_rtypeZ ClassType class_typesbytesinputrr r(r,r:r@rrrrsv