-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from zaibacu/shortcuts-module
Shortcuts module
- Loading branch information
Showing
9 changed files
with
144 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added shortcuts module to simplify injecting into spaCy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import rita | ||
|
||
|
||
def setup_spacy(model, patterns=None, rules_path=None, rules_string=None, override_ents=True): | ||
from spacy.pipeline import EntityRuler | ||
ruler = EntityRuler(model, overwrite_ents=override_ents) | ||
if not patterns: | ||
if rules_path: | ||
patterns = rita.compile(rules_path, use_engine="spacy") | ||
elif rules_string: | ||
patterns = rita.compile_string(rules_string, use_engine="spacy") | ||
else: | ||
raise RuntimeError("Please provides rules. Either `patterns`, `rules_path` or `rules_string`") | ||
|
||
ruler.add_patterns(patterns) | ||
else: | ||
ruler.from_disk(patterns) | ||
|
||
model.add_pipe(ruler) | ||
return model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters