wow.grep
– Semantic Grep#
Semantic Grep – or wow.grep
– is the command line utility provided by the eot-wowool-sdk
Python package allowing you to easily use the functionality of the Semantic Grep application.
Example#
wow.grep -p "english,entity" -e "Adj Nn" -i "i have a green house."
Your output shows how many times we have encountered that pattern in your texts/
Match:
1 | green house
Another example using capture groups to capture persons’ names and their descriptions:
wow.grep -p "english,entity" \
-e "{Person}=MyPerson 'be' (Det)? {Adj (Nn)?}=Description" \
-i "John Doe is a good person but he is a terrible liar"
The default output looks like this:
Match:
1 | John Doe is a good person
1 | John Doe is a terrible liar
Group: MyPerson
2 | John Doe
Group: Description
1 | good person
1 | terrible liar
Collocations: {Person}=MyPerson 'be' (Det)? {Adj (Nn)?}=Description
cnt | MyPerson | Description
-------+------------+---------------
1 | John Doe | good person
1 | John Doe | terrible liar
- Where:
Match shows the matches of the whole expression preceded by the total number of occurrences in the corpus.
Group shows the matches of the capture groups preceded by the total number of occurrences in the corpus.
Collocations shows the collocations of the capture groups preceded by the total number of occurrences in the corpus.
For more information on the json output, refer to the JSON schema.
Usage#
usage: wow.grep [-h] [-f FILE] [-i TEXT] -p PIPELINE -e EXPRESSION [--stem] [-t TABLE_FORMAT]Named Arguments#
- -f, --file
folder or file
- -i, --text
The input text to process
- -p, --pipeline
pipeline description
- -e, --expression
pipeline description
- --stem
will return the grep result using the stem.
Default: False
- -t, --table-format
table format see python tabulate module for the different formats or set a environment variable EOT_TABLE_FORMAT choices=[‘plain’, ‘github’, ‘grid’, ‘fancy_grid’, ‘pipe’, ‘presto’, ‘pretty’, ‘rst’, ‘html’]