Running Pipelines#

Pipeline are an easy way to generate the output data you like by adding languages, domains and apps. In this tutorial we will show some examples of how to use them.

Entities#

In this example, we are going to pass the english-entity domain to the pipeline. Note that when we have a language prefix (like english), we can skip it in the pipeline, and just use ‘entity’:

wow -p english,entity \
        -i "Always forgive your enemies. Nothing annoys them more. Oscar Wilde."
app=’eot_analysis’#
        S:(  0, 28)
        C:(  0, 28): Sentence
        T:(  0,  6): Always,{+init-cap, +init-token},[always:Adv-Std]
        C:(  7, 14): VP,@(negation='false' voice='active' )
        T:(  7, 14): forgive,[forgive:V-Pres]
        C:( 15, 27): NP
        T:( 15, 19): your,[your:Det-Poss]
        T:( 20, 27): enemies,[enemy:Nn-Pl]
        T:( 27, 28): .,[.:Punct-Sent]
        S:( 29, 54)
        C:( 29, 54): Sentence
        T:( 29, 36): Nothing,{+init-cap, +init-token},[nothing:Pron-Std]
        C:( 37, 43): VP,@(negation='false' voice='active' )
        T:( 37, 43): annoys,[annoy:V-Pres-3-Sg]
        T:( 44, 48): them,{+3p, +pl},[they:Pron-Pers]
        T:( 49, 53): more,[more:Pron-Std]
        T:( 53, 54): .,[.:Punct-Sent]
        S:( 55, 67)
        C:( 55, 67): Sentence
        C:( 55, 66): Person,@(canonical='Oscar Wilde' family='Wilde' gender='male' given='Oscar' )
        C:( 55, 66): NP
        C:( 55, 60): PersonGiv
        C:( 55, 60): GivenName,@(gender='male' standalone='Yes' )
        T:( 55, 60): Oscar,{+giv, +init-cap, +init-token},[Oscar:Prop-Std]
        C:( 61, 66): PersonFam
        T:( 61, 66): Wilde,{+init-cap, +nf},[Wilde:Prop-Std]
        T:( 66, 67): .,[.:Punct-Sent]

Topic Identifier#

This app displays the topics of the document:

wow -p english,topics.app \
        -i "NFT scams, toxic mines and lost life savings: the cryptocurrency dream is fading fast"
app=’eot_topics’#
[
        ["NFT scam", 1.0],
        ["cryptocurrency dream", 0.71],
        ["lost life saving", 0.71],
        ["toxic mine", 0.71]
]

Semantic Themes#

The themes gives you the categories to which your document belong. For better results, you can add the topics.app to the pipeline, so that the calculus can promote the categories to which the topics belong to:

wow -p english,semantic-theme,topics.app,themes.app \
        -i "Supermassive black hole at centre of Milky Way seen for first time"
app=’eot_semantic_themes’#
[
        {
                "theme": "astronomy",
                "relevancy": 100,
                "count": 2,
                "words": ["black hole", "milky way"],
                "uris": ["Theme:black hole", "Theme:MilkyWay"]
        }
]

Entity Mapper#

The entity mapper app produces a csv file or json file that contains one (lhs: left hand side) or two expressions (lhs and rhs) and their relations.

In this example, we want to find Persons and relate them to the Positions found in the sentence:

wow -p 'english,entity,mapper(lhs="Person", rhs=["Company"] ).app' \
        -i "Philippe Forest works for Eyeontext. He used to work for Tesla."

Results:

app=’eot_entity_mapper’#
[
        { "Person": "Philippe Forest", "Company": "Eyeontext"},
        { "Person": "Philippe Forest", "Company": "Tesla"}
]

Phones#

The phones app normalizes phone numbers and adds location information if available. To run it, make sure you have installed the python package phonenumbers.

wow -p "english,contact-info,phones.app" \
-i "In Australia call  +61 2 8076 8599"
app=’eot_phones’#
[
        {
                "phonenr": "+61280768599",
                "country_code": 61,
                "country": "Australia",
                "location": "Sydney"
        }
]

Snippet#

The snippets allow you to quickly run your code without creating a domain:

wow -p 'english,healthcare,snippet("rule:{ Drug .. HealthIssue }= DrugHealth;").app' \
        -i "Fluvoxamine is approved to treat obsessive - compulsive disorder"
app=’eot_snippet’#
C:(  0, 64): Sentence
C:(  0, 64): DrugHealth
C:(  0, 11): Drug
T:(  0, 11): Fluvoxamine,{+init-cap, +init-token, +nf},[Fluvoxamine:Prop-Std]
T:( 12, 14): is,[be:V-Pres-Sg-be]
T:( 15, 23): approved,[approve:V-PaPart]
T:( 24, 26): to,[to:Part-Inf]
T:( 27, 32): treat,[treat:V-Pres]
C:( 33, 64): HealthIssue
T:( 33, 42): obsessive,[obsessive:Adj-Std]
T:( 43, 44): -,[-:Punct]
T:( 45, 55): compulsive,[compulsive:Adj-Std]
T:( 56, 64): disorder,[disorder:Nn-Sg]

Semantic Grep#

Those familiar with linux or unix will probably know grep. Grep is a command line tool to search for regular expressions in text. The semantic grep performs a similar app, but this app allows you to search for any wowool expression. It is an easy wayt to perform corpus analysis and test your rules.

The wowool expressions usually contain quotes and that poses a problem to use the command line sometimes, so we suggest to create a file called test.pipeline to pass our pipeline to the tool.

As you can see in the arguments we are asking to give us one or more proper nouns that follow the lemma ‘kill’:

english,entity,grep( 'kill' (Prop)+ ).app

Now we pass the name of the file as the pipeline. We add the tool ‘grep’ at the end, so that we get some statistics on our results:

wow -p test.pipeline \
                -i "Brutus killed Julius Caesar." --tool grep
Grep Results:
[
        [1,"kill Julius Caesar", ["killed Julius Caesar"] ],
        [1,"TOTAL_COUNT" ]
]