Commit Graph

124 Commits

Author SHA1 Message Date
adrianeboyd
faaa832518 Generalize handling of tokenizer special cases (#4259)
* Generalize handling of tokenizer special cases

Handle tokenizer special cases more generally by using the Matcher
internally to match special cases after the affix/token_match
tokenization is complete.

Instead of only matching special cases while processing balanced or
nearly balanced prefixes and suffixes, this recognizes special cases in
a wider range of contexts:

* Allows arbitrary numbers of prefixes/affixes around special cases
* Allows special cases separated by infixes

Existing tests/settings that couldn't be preserved as before:

* The emoticon '")' is no longer a supported special case
* The emoticon ':)' in "example:)" is a false positive again

When merged with #4258 (or the relevant cache bugfix), the affix and
token_match properties should be modified to flush and reload all
special cases to use the updated internal tokenization with the Matcher.

* Remove accidentally added test case

* Really remove accidentally added test

* Reload special cases when necessary

Reload special cases when affixes or token_match are modified. Skip
reloading during initialization.

* Update error code number

* Fix offset and whitespace in Matcher special cases

* Fix offset bugs when merging and splitting tokens
* Set final whitespace on final token in inserted special case

* Improve cache flushing in tokenizer

* Separate cache and specials memory (temporarily)
* Flush cache when adding special cases
* Repeated `self._cache = PreshMap()` and `self._specials = PreshMap()`
are necessary due to this bug:
https://github.com/explosion/preshed/issues/21

* Remove reinitialized PreshMaps on cache flush

* Update UD bin scripts

* Update imports for `bin/`
* Add all currently supported languages
* Update subtok merger for new Matcher validation
* Modify blinded check to look at tokens instead of lemmas (for corpora
with tokens but not lemmas like Telugu)

* Use special Matcher only for cases with affixes

* Reinsert specials cache checks during normal tokenization for special
cases as much as possible
  * Additionally include specials cache checks while splitting on infixes
  * Since the special Matcher needs consistent affix-only tokenization
    for the special cases themselves, introduce the argument
    `with_special_cases` in order to do tokenization with or without
    specials cache checks
* After normal tokenization, postprocess with special cases Matcher for
special cases containing affixes

* Replace PhraseMatcher with Aho-Corasick

Replace PhraseMatcher with the Aho-Corasick algorithm over numpy arrays
of the hash values for the relevant attribute. The implementation is
based on FlashText.

The speed should be similar to the previous PhraseMatcher. It is now
possible to easily remove match IDs and matches don't go missing with
large keyword lists / vocabularies.

Fixes #4308.

* Restore support for pickling

* Fix internal keyword add/remove for numpy arrays

* Add test for #4248, clean up test

* Improve efficiency of special cases handling

* Use PhraseMatcher instead of Matcher
* Improve efficiency of merging/splitting special cases in document
  * Process merge/splits in one pass without repeated token shifting
  * Merge in place if no splits

* Update error message number

* Remove UD script modifications

Only used for timing/testing, should be a separate PR

* Remove final traces of UD script modifications

* Update UD bin scripts

* Update imports for `bin/`
* Add all currently supported languages
* Update subtok merger for new Matcher validation
* Modify blinded check to look at tokens instead of lemmas (for corpora
with tokens but not lemmas like Telugu)

* Add missing loop for match ID set in search loop

* Remove cruft in matching loop for partial matches

There was a bit of unnecessary code left over from FlashText in the
matching loop to handle partial token matches, which we don't have with
PhraseMatcher.

* Replace dict trie with MapStruct trie

* Fix how match ID hash is stored/added

* Update fix for match ID vocab

* Switch from map_get_unless_missing to map_get

* Switch from numpy array to Token.get_struct_attr

Access token attributes directly in Doc instead of making a copy of the
relevant values in a numpy array.

Add unsatisfactory warning for hash collision with reserved terminal
hash key. (Ideally it would change the reserved terminal hash and redo
the whole trie, but for now, I'm hoping there won't be collisions.)

* Restructure imports to export find_matches

* Implement full remove()

Remove unnecessary trie paths and free unused maps.

Parallel to Matcher, raise KeyError when attempting to remove a match ID
that has not been added.

* Switch to PhraseMatcher.find_matches

* Switch to local cdef functions for span filtering

* Switch special case reload threshold to variable

Refer to variable instead of hard-coded threshold

* Move more of special case retokenize to cdef nogil

Move as much of the special case retokenization to nogil as possible.

* Rewrap sort as stdsort for OS X

* Rewrap stdsort with specific types

* Switch to qsort

* Fix merge

* Improve cmp functions

* Fix realloc

* Fix realloc again

* Initialize span struct while retokenizing

* Temporarily skip retokenizing

* Revert "Move more of special case retokenize to cdef nogil"

This reverts commit 0b7e52c797.

* Revert "Switch to qsort"

This reverts commit a98d71a942.

* Fix specials check while caching

* Modify URL test with emoticons

The multiple suffix tests result in the emoticon `:>`, which is now
retokenized into one token as a special case after the suffixes are
split off.

* Refactor _apply_special_cases()

* Use cdef ints for span info used in multiple spots

* Modify _filter_special_spans() to prefer earlier

Parallel to #4414, modify _filter_special_spans() so that the earlier
span is preferred for overlapping spans of the same length.

* Replace MatchStruct with Entity

Replace MatchStruct with Entity since the existing Entity struct is
nearly identical.

* Replace Entity with more general SpanC

* Replace MatchStruct with SpanC

* Add error in debug-data if no dev docs are available (see #4575)

* Update azure-pipelines.yml

* Revert "Update azure-pipelines.yml"

This reverts commit ed1060cf59.

* Use latest wasabi

* Reorganise install_requires

* add dframcy to universe.json (#4580)

* Update universe.json [ci skip]

* Fix multiprocessing for as_tuples=True (#4582)

* Fix conllu script (#4579)

* force extensions to avoid clash between example scripts

* fix arg order and default file encoding

* add example config for conllu script

* newline

* move extension definitions to main function

* few more encodings fixes

* Add load_from_docbin example [ci skip]

TODO: upload the file somewhere

* Update README.md

* Add warnings about 3.8 (resolves #4593) [ci skip]

* Fixed typo: Added space between "recognize" and "various" (#4600)

* Fix DocBin.merge() example (#4599)

* Replace function registries with catalogue (#4584)

* Replace functions registries with catalogue

* Update __init__.py

* Fix test

* Revert unrelated flag [ci skip]

* Bugfix/dep matcher issue 4590 (#4601)

* add contributor agreement for prilopes

* add test for issue #4590

* fix on_match params for DependencyMacther (#4590)

* Minor updates to language example sentences (#4608)

* Add punctuation to Spanish example sentences

* Combine multilanguage examples for lang xx

* Add punctuation to nb examples

* Always realloc to a larger size

Avoid potential (unlikely) edge case and cymem error seen in #4604.

* Add error in debug-data if no dev docs are available (see #4575)

* Update debug-data for GoldCorpus / Example

* Ignore None label in misaligned NER data
2019-11-13 21:24:35 +01:00
Ines Montani
828ef27a32 Add warnings about 3.8 (resolves #4593) [ci skip] 2019-11-05 18:30:11 +01:00
Ines Montani
fed53b1552 Update README.md 2019-11-05 18:26:47 +01:00
Ines Montani
828108a57f Update README.md [ci skip] 2019-10-31 13:23:25 +01:00
Ines Montani
5e59c9b3ee Fix unicode strings in examples [ci skip] 2019-10-18 18:47:59 +02:00
Ines Montani
4159936720 Update README.md [ci skip] 2019-10-02 19:15:22 +02:00
Ines Montani
e4782feae9 Update README.md [ci skip] 2019-10-02 18:49:55 +02:00
Ines Montani
f8e606c303 Update README.md [ci skip] 2019-10-02 16:47:10 +02:00
Ines Montani
b6670bf0c2 Use consistent spelling 2019-10-02 10:37:39 +02:00
Ines Montani
208629615d Auto-format 2019-10-02 10:37:04 +02:00
Ines Montani
3d8fd4b461 Revert #4334 2019-09-29 17:32:12 +02:00
Ines Montani
c9cd516d96 Move tests out of package (#4334)
* Move tests out of package

* Fix typo
2019-09-28 18:05:00 +02:00
Ines Montani
38de08c7a9 Update README.md [ci skip] 2019-09-24 14:31:09 +02:00
Ines Montani
c1030b1ad2 Update README.md [ci skip] 2019-09-19 13:35:12 +02:00
Ines Montani
0f9e253a69 Update README.md [ci skip] 2019-09-19 13:34:37 +02:00
Ines Montani
f2d224756b Update README.md [ci skip] 2019-09-19 12:52:26 +02:00
Ines Montani
63a584c6d4 Update README.md [ci skip] 2019-09-18 21:34:24 +02:00
Ines Montani
9c940eab94 Update version in examples [ci skip] 2019-09-18 21:23:26 +02:00
Ines Montani
bcbb9f5119 Update README.md [ci skip] 2019-09-14 12:57:45 +02:00
Ines Montani
f4012ba054 Update README.md [ci skip] 2019-08-26 12:32:52 +02:00
Ines Montani
36ac044937 Update README.md [ci skip] 2019-08-07 13:38:59 +02:00
Ines Montani
fe0e1873a3 Update README.md [ci skip] 2019-07-17 12:34:31 +02:00
Ines Montani
7ac5bb0a7b Update landing and feature overview 2019-04-19 15:23:08 +02:00
ivigamberdiev
5e5641616d Update links and http -> https (#3532)
* update links and http -> https

* SCA
2019-04-02 17:36:22 +02:00
Ines Montani
0712efc6b3 Update version requirements [ci skip] 2019-03-21 10:23:54 +01:00
Ines Montani
08284f3a11
💫 v2.1.0 launch updates (only merge on launch!) (#3414)
* Update README.md

* Use production docsearch [ci skip]

* Add option to exclude pages from search
2019-03-18 16:07:26 +01:00
Ines Montani
a611b32fbf Update model docs [ci skip] 2019-03-17 11:48:18 +01:00
Ines Montani
146dc2766a Update README.md 2019-03-16 13:34:23 +01:00
Ines Montani
68454246a8 Update README.md 2019-03-16 13:34:01 +01:00
Ines Montani
d12af4c92c Update README.md 2019-03-09 13:07:35 +01:00
Ines Montani
b65e2f554f Update CI
Only keep Travis for Python 2.7 for now until we've sorted out unicode build in Azure Pipelines
2019-03-09 13:06:18 +01:00
Ines Montani
cd4bc6757b Update README.md [ci skip] 2019-02-24 17:40:01 +01:00
Ines Montani
3ef4da3503 Update and auto-format README [ci skip] 2019-02-24 13:12:13 +01:00
Ines Montani
db7d250924 Update README.md 2018-12-02 04:22:23 +01:00
Ines Montani
3832c8a2c1 💫 Use README.md instead of README.rst (#2968)
* Auto-format setup.py

* Use README.md instead of README.rst
2018-11-26 22:04:35 +01:00
Henning Peters
5701686272 cleanup 2016-03-12 13:47:10 +01:00
Henning Peters
1501ef58e0 Update README.md 2016-02-19 19:36:47 +01:00
Henning Peters
7e0d1dd8d3 remove appveyor 2016-02-10 11:28:55 +01:00
Henning Peters
73251eddac Update README.md 2016-02-10 11:05:08 +01:00
Henning Peters
7c0aa60ca7 Update README.md 2016-02-08 18:48:16 +01:00
Henning Peters
ab59d6ca91 Update README.md 2016-02-08 18:47:37 +01:00
Henning Peters
4ac755b0fb Update README.md 2016-02-08 18:42:38 +01:00
Henning Peters
f3e73c4ca4 spaCy now passes all tests for visual studio
Visual Studio Express Community 2015 running on Windows Server 2012 Standard:

https://ci.spacy.io/builders/win64-0/builds/38/steps/shell_1/logs/stdio
2015-12-18 13:09:39 +01:00
Hugo
7d71759355 Add Python 3.5 2015-11-26 16:08:22 +02:00
Matthew Honnibal
2c80dcc684 Update README.md 2015-10-27 01:32:40 +11:00
Henning Peters
63af820609 add travis ci build status 2015-10-24 10:28:37 +02:00
Maxim Samsonov
6cff3533b5 Update README.md 2015-10-16 00:01:03 +03:00
Maxim Samsonov
e6e6018356 Update README.md 2015-10-16 00:00:47 +03:00
Maxim Samsonov
da7426d198 Update README.md 2015-10-15 23:56:28 +03:00
Maxim Samsonov
6ee1c03f51 Update README.md 2015-10-15 23:53:47 +03:00
Maxim Samsonov
ffeb0aed82 Added Windows build status to README.md 2015-10-15 23:52:20 +03:00
Matthew Honnibal
69f0c2cd26 * Fix typo in README 2015-09-29 23:02:08 +10:00
Matthew Honnibal
6982ed74ab * Update readme with license change 2015-09-28 07:38:12 +10:00
Matthew Honnibal
be3e935bd5 * Upd readme 2015-07-01 15:39:38 +02:00
Matthew Honnibal
a96f1c26a3 * Upd readme 2015-07-01 15:38:55 +02:00
Matthew Honnibal
d8ef2d6b61 * Upd README.md 2015-07-01 15:27:37 +02:00
Matthew Honnibal
91c97009e2 * Declare new release in docs 2015-06-24 05:05:33 +02:00
Matthew Honnibal
3a1ab85a76 * Tweak readme.md 2015-05-12 03:32:53 +02:00
Matthew Honnibal
b9da330d8e * Fix updates description for v0.84 2015-05-12 03:30:56 +02:00
Jordan Suchow
1b79d947b9 Minor copyediting 2015-04-19 13:01:38 -07:00
Jordan Suchow
3a8d9b37a6 Remove trailing whitespace 2015-04-19 13:01:38 -07:00
Matthew Honnibal
49c2e72112 * Upd README 2015-04-13 06:23:30 +02:00
honnibal
d7df4aeb1d Update README.md 2015-02-01 18:38:22 +11:00
honnibal
5199af89a8 Update README.md 2015-02-01 18:37:48 +11:00
honnibal
57a7fabc7a Update README.md 2015-02-01 18:36:52 +11:00
honnibal
9f76b94582 Update README.md 2015-02-01 14:47:18 +11:00
honnibal
a6ead1f35e Update README.md 2015-02-01 14:42:35 +11:00
honnibal
10f2e9cfdc Update README.md 2015-02-01 14:35:19 +11:00
honnibal
cc216c2012 Update README.md 2015-01-31 23:26:12 +11:00
honnibal
97d91ada3a Update README.md 2015-01-27 21:55:36 +11:00
honnibal
51ca3a285d Update README.md 2015-01-27 21:55:23 +11:00
honnibal
824be0f3a5 Update README.md 2015-01-26 03:03:50 +11:00
honnibal
8a2851869c Update README.md 2015-01-26 03:03:24 +11:00
honnibal
e3fad681c5 Initial commit 2014-07-04 01:15:40 +10:00