mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
82277f63a3
This patch improves tokenizer speed by about 10%, and reduces memory usage in the `Vocab` by removing a redundant index. The `vocab._by_orth` and `vocab._by_hash` indexed on different data in v1, but in v2 the orth and the hash are identical. The patch also fixes an uninitialized variable in the tokenizer, the `has_special` flag. This checks whether a chunk we're tokenizing triggers a special-case rule. If it does, then we avoid caching within the chunk. This check led to incorrectly rejecting some chunks from the cache. With the `en_core_web_md` model, we now tokenize the IMDB train data at 503,104k words per second. Prior to this patch, we had 465,764k words per second. Before switching to the regex library and supporting more languages, we had 1.3m words per second for the tokenizer. In order to recover the missing speed, we need to: * Fix the variable-length lookarounds in the suffix, infix and `token_match` rules * Improve the performance of the `token_match` regex * Switch back from the `regex` library to the `re` library. ## Checklist <!--- Before you submit the PR, go over this checklist and make sure you can tick off all the boxes. [] -> [x] --> - [x] I have submitted the spaCy Contributor Agreement. - [x] I ran the tests, and all new and existing tests passed. - [x] My changes don't require a change to the documentation, or if they do, I've added all required information. |
||
---|---|---|
.. | ||
cli | ||
data | ||
displacy | ||
lang | ||
syntax | ||
tests | ||
tokens | ||
__init__.pxd | ||
__init__.py | ||
__main__.py | ||
_align.pyx | ||
_matcher2_notes.py | ||
_ml.py | ||
about.py | ||
attrs.pxd | ||
attrs.pyx | ||
compat.py | ||
errors.py | ||
glossary.py | ||
gold.pxd | ||
gold.pyx | ||
language.py | ||
lemmatizer.py | ||
lexeme.pxd | ||
lexeme.pyx | ||
matcher.pyx | ||
morphology.pxd | ||
morphology.pyx | ||
parts_of_speech.pxd | ||
parts_of_speech.pyx | ||
pipeline.pxd | ||
pipeline.pyx | ||
scorer.py | ||
strings.pxd | ||
strings.pyx | ||
structs.pxd | ||
symbols.pxd | ||
symbols.pyx | ||
tokenizer.pxd | ||
tokenizer.pyx | ||
typedefs.pxd | ||
typedefs.pyx | ||
util.py | ||
vectors.pyx | ||
vocab.pxd | ||
vocab.pyx |