Skip to content
/ brave Public

Brave is a simple visualisation library for NLP information extraction, built on top of embedded BRAT.

License

Notifications You must be signed in to change notification settings

chorusai/brave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brave

Built on top of BRAT, Brave is a high-level library which allows simple and beautiful NLP data visualisation. Brave supports full integration with Jupyter notebooks.

Brave is a project led by Chorus.ai Research Team.

Table of contents

Quick start options

Clone the repo

git clone https://github.com/chorusai/brave.git

Install with setup.py

python setup.py install

Usage

Initialisation

Applications should initialise Brave using:

from brave import brave

For visualising data in Jupyter notebooks:

from brave import brave, start_notebook_mode
start_notebook_mode()

Example: brave()

Brave requires two Python objects as inputs.

First argument is the document, with the following data structure:

doc_data = {
    "text": "Ed O'Kelley was the man who shot the man who shot Jesse James.",
    "entities": [
        [
            "T1",
            "Person",
            [ ( 0, 11 ) ]
        ],
        [
            "T2",
            "Person",
            [ ( 20, 23 ) ] 
        ],
        [
            "T3",
            "Person",
            [ ( 37, 40 ) ] 
        ],
        [
            "T4",
            "Person",
            [ ( 50, 61 ) ] 
        ]
    ],
    "relations": [
        [
            "R1",
            "Anaphora",
            [ [ "Anaphor", "T2" ], [ "Entity", "T1" ] ]
        ]
    ]
}

Second (can be optional) argument is the collection, which has the following data structure:

coll_data = {
      "entity_types": [
        {
            "type": "Person",
            "labels": [ "Person", "Per" ],
            "bgColor": "#7fa2ff",
            "borderColor": "darken"
        }
    ],
    "relation_types": [
        {
            "type": "Anaphora",
            "labels": [ "Anaphora", "Ana" ],
            "dashArray": "3,3",
            "color": "purple",
            "args": [
                {
                    "role": "Anaphor",
                    "targets": [ "Person" ]
                },
                {
                    "role": "Entity",
                    "targets": [ "Person" ]
                }
            ]
        }
    ]
}

Both structures can be imported calling :

from examples.brave_example import coll_data, doc_data

Then call brave() function to load the HTML within the notebook:

brave(doc_data, coll_data)

Example: brave_simple()

The document object can be called without the collection. Using the brave_simple() function automatically generates relations and entities:

from brave import brave_simple
brave_simple(doc_data)

Example: brave_compare()

The brave_compare() function lets you compare true extractions and predicted extractions.

from brave import brave_compare
brave_compare(doc_data, pred_doc_data)

Creators

  • Ilana Tuil
  • Karen Assaraf
  • Orgad Keller
  • Raphael Cohen
  • Amit Ashkenazi
  • Romain Ammar

Notes

MIT Licensed files (brat) are automatically downloaded as part of the normal operation of this library.

About

Brave is a simple visualisation library for NLP information extraction, built on top of embedded BRAT.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published