Code Monkey home page Code Monkey logo

gcn_ner's Introduction

NER that uses Graph Conv Nets

This is an implementation of a named entity recognizer that uses Graph Convolutional Networks. The reference article is Graph Convolutional Networks for Named Entity Recognition.

This code uses GCNs and POS tagging to boost the entity recognition of a bidirectional LSTM. It scores ~81% on the Ontonotes 5 test dataset, which can be retrieved from the LDC website.

The system currently uses the word vectors that come with spacy's "en_core_web_md" model.

Installation

git clone https://github.com/contextscout/gcn_ner.git

cd gcn_ner

virtualenv --python=/usr/bin/python3 .env

source .env/bin/activate

pip install -r requirements.txt

python -m spacy download en

python -m spacy download en_core_web_md

if you want to install Tensorflow with GPU capabilities please use

pip install -r requirements_gpu.txt

Test NER on a text

Execute the file

python test_ner.py < data/random_text.txt

Train NER from a dataset

You will need to put your 'train.conll' into the 'data/' directory, then execute the file

python train.py

Test the dataset F1 score

You will need to put your 'dev.conll' or 'test.conll' into the 'data/' directory, then execute the file

python test_dataset.py

CONLL format

The training/testing conll files must be in the conll format, as in the following example. Only the fourth, fifth, and eleventh columns are used.

source_file_name   1    0              New   NNP    (TOP(S(NP*         -    -   -   Speaker#1    (GPE*      *       (ARG1*   (ARG1*   (19
source_file_name   1    1             York   NNP             *)        -    -   -   Speaker#1        *)     *            *)       *)   19)
source_file_name   1    2              was   VBD          (VP*         be  03   -   Speaker#1        *    (V*)           *        *     -
source_file_name   1    3        developed   VBN          (VP*    develop  02   -   Speaker#1        *      *          (V*)       *     -
source_file_name   1    4             from    IN          (PP*         -    -   -   Speaker#1        *      *       (ARG2*        *     -
source_file_name   1    5                a    DT          (NP*         -    -   -   Speaker#1        *      *            *        *     -
source_file_name   1    6          hunting    NN             *         -    -   -   Speaker#1        *      *            *        *     -
source_file_name   1    7           harbor    NN            *))        -    -   -   Speaker#1        *      *            *)       *     -
source_file_name   1    8              one    CD  (ADVP(NP(QP*         -    -   -   Speaker#1   (DATE*      *   (ARGM-TMP*        *     -
source_file_name   1    9          million    CD             *)        -    -   -   Speaker#1        *      *            *        *     -
source_file_name   1   10            years   NNS             *)        -    -   -   Speaker#1        *      *            *        *     -
source_file_name   1   11              ago    RB             *)        -    -   -   Speaker#1        *)     *            *)       *     -
source_file_name   1   12               to    TO        (S(VP*         -    -   -   Speaker#1        *      *   (ARGM-PRP*        *     -
source_file_name   1   13           become    VB          (VP*     become  01   1   Speaker#1        *      *            *      (V*)    -
source_file_name   1   14            today    NN       (NP(NP*         -    -   -   Speaker#1    (DATE)     *            *   (ARG2*     -
source_file_name   1   15               's   POS             *)        -    -   -   Speaker#1        *      *            *        *     -
source_file_name   1   16    international    JJ             *         -    -   -   Speaker#1        *      *            *        *     -
source_file_name   1   17       metropolis   NNS        *))))))        -    -   -   Speaker#1        *      *            *)       *)    -

gcn_ner's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gcn_ner's Issues

Issue in from .nl import SpacyTagger as Tagger, SpacyParser as Parser

Hi,

The code is not running because of this line:
from .nl import SpacyTagger as Tagger, SpacyParser as Parser

Where is .nl defined?
I have downloaded all the requirements in requirements.txt also.

Looking for a quick reply as I have a project deadline depending on this.

Thanks

the function of the transition matrix

Hi,
could you please explain the function of the transition matrix?
It took me many time to get the matrix but i don't know what it exactly used for. Thanks

Invalid continue error

For some sentences, it print 'invalid continue' on the console. I'm not sure where this is getting printed from or what error occurred. Could you please help me out with what is causing this error?

Thanks.

spacy parser

When i use spacy.parser to get the dependency parsing tree of a sentence, the number of parser.parsed is not correct.

For example, the word '256G' was splitted into '256' and 'G'.

Suppose i have a sentence with 5 words, i want to get a matrix of (5,5). But i got the wrong matrix
of (6,6) . How should i deal with it ? I want to let the parer splitting sentence only by spaces

Cannot process the following sentence

Hi!
Why I can't run error for your code?can your give me some idea?Thanks!
"Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
Cannot process the following sentence: Google was started in early 1996 by Larry Page and Sergey Brin , two students at Stanford University , USA .

Training the gcn on my own conell data, no error but the model not trained, column mapping

Hi,

Thank you for creating a solution like this and maintaining the repo and answering the quarries.
I'm trying the train the model in my own conell data, where the training is getting completed without any error. But i think the column being considered for the model from the conell file are he fourth, fifth, and eleventh.

How do i modify the column reference so that it gets train properly. Sample data from my training set is attached.

for my training set, the text is in column 1, and column 3 has NER tags (Bio)

With debugging I can guess that I do have to map the column somewhere in aux/init file, but fail to identify accurately on how to. Any help is highly appreciated.

Example train data:
-DOCSTART- -X- O
CiO -X- _ O
Echo2 -X- _ B-vendor_name
Echo3 -X- _ I-vendor_name
ECHO 4 -X- _ I-vendor_name
Echo5 -X- _ I-vendor_name
PTE. -X- _ I-vendor_name
LTD. -X- _ I-vendor_name
For -X- _ O
Billing -X- _ O
Enquiries -X- _ O
: -X- _ O
Echo -X- _ O
commercial -X- _ O
10 -X- _ B-address
Pasir -X- _ I-address
Panjang -X- _ I-address
Road, -X- _ I-address
#13-01, -X- _ I-address
Name -X- _ O
lease -X- _ O
Admin -X- _ O
CONNN -X- _ B-address
GSGS -X- _ I-address
City -X- _ I-address
YYYY -X- _ I-address
XXXXX8 -X- _ I-address
Tel -X- _ O
(As -X- _ O
Property -X- _ O
Manager -X- _ O
for -X- _ O
CYX -X- _ O
LLL -X- _ O
Trust) -X- _ O
Email -X- _ O
Received -X- _ O
on -X- _ O
20 -X- _ O
Oct -X- _ O
20 -X- _ O
RRR -X- _ B-vendor_name
TRUSTEE -X- _ I-vendor_name
LIMITED -X- _ I-vendor_name
AS -X- _ O
TRUSTEE -X- _ O
OF -X- _ O
ZZZ -X- _ O
COMMERCIAL -X- _ O
TRUST -X- _ O
Inv -X- _ O
Tracking -X- _ O

-X- _ O

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.