Entity Graph#

Prerequisites#

You need to install the following: python library, the license file, the domain you want to run and the test environment (eot-wowool-test) which contains a small corpus and some rules

Using the sdk entity_graph:

pip install eot-wowool-sdk eot-wowool-domain-english-entity eot-wowool-apps eot-wowool-topic-identifier eot-wowool-test eot-wowool-community-license neo4j

Configuration#

See the API Entity Graph Configuration

From text to Graph#

We will use a small corpus with some abstracts of movies. From these abstracts we will extract the titles, characters and weapons and the relations between them. We will then store them in the neo4j database.

To find out where your files have been downloaded, type

pip list -v | grep eot-wowool-test  | awk '{printf("%s/eot/wowool/test", $3)}'

You can link it to your current directory for convenience using the following command:

ln -s `pip list -v | grep eot-wowool-test  | awk '{printf("%s/eot/wowool/test", $3)}'`  test

Now you will find the directory ‘test’ in your current directory.

Run the driver by passing as arguments the language, the link file (movies.lnk), the domain (rules) and the folder with the corpus (movies). The ‘-p’ option is our pipeline. There you need to pass the domains that you used in your lnk file.

entity_graph -p english,entity,test/projects/movies/rules,topics.app -x ./test/projects/movies/movies_with_topics.lnk  -f ./test/corpus/english/movies

The link file (movies.lnk) specifies how the entities will be linked in the neo4j graph:

{

    "slots" : [
        {"uri": "Title" },
        {"label" : "Type", "content" : "{Path(document.id).parts[-2]}" }
    ],
    "links" :[
        {
            "from"      : { "slot": "Type" },
            "to"        : { "uri": "Title" },
            "relation"  : { "label": "genre" }
        },
        {
            "from"      : { "uri": "Character" , "attributes": ["type"] },
            "to"        : { "slot": "Title" },
            "relation"  : { "label": "plays_in"}
        },
        {
            "from"      : { "uri": "Weapon" },
            "to"        : { "slot": "Title" },
            "relation"  : { "label": "appears" }
        },
        {
            "from"      : { "uri": "Event" },
            "to"        : { "slot": "Title" },
            "relation"  : { "label": "event" }
        },
        {
            "from"      : { "uri": "Character" },
            "to"        : { "uri": "Character", "label": "Victim" },
            "relation"  : { "uri": "Harm" }
        }
        {
            "from"      : { "uri": "Character" },
            "to"        : { "uri": "PersonMention", "label": "Victim" },
            "relation"  : { "uri": "Harm" }
        }

    ]
}