-
-
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 #103 from rolandmueller/feature/tag_word
Add TAG_WORD macro to Tag module
- Loading branch information
Showing
7 changed files
with
120 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Additional macro for `tag` module, allowing to tag specific word/list of words | ||
|
||
Implemented by: Roland M. Mueller (https://github.com/rolandmueller) |
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
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 |
---|---|---|
@@ -1,9 +1,24 @@ | ||
from rita.macros import resolve_value | ||
|
||
|
||
def TAG(name, config, op=None): | ||
def TAG(tag, config, op=None): | ||
""" | ||
For generating POS/TAG patterns based on a Regex | ||
e.g. TAG("^NN|^JJ") for nouns or adjectives | ||
""" | ||
return "tag", resolve_value(name, config=config), op | ||
values = {"tag": tag} | ||
return "tag", values, op | ||
|
||
|
||
def TAG_WORD(tag, value, config, op=None): | ||
""" | ||
For generating TAG patterns with a word or a list | ||
e.g. match only "proposed" when it is in the sentence a verb (and not an adjective): | ||
TAG_WORD("^VB", "proposed") | ||
e.g. match a list of words only to verbs | ||
words = {"percived", "proposed"} | ||
{TAG_WORD("^VB", words)?}->MARK("LABEL") | ||
""" | ||
values = {"tag": tag} | ||
if type(value) == list: | ||
values["list"] = value | ||
else: | ||
values["word"] = value | ||
return "tag", values, op |
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