Custom relation extraction model using Stanford Co

2019-07-08 12:11发布

I trained a custom model for relation extraction using Stanford Core NLP's example. But when I run the model, it doesn't find any relations -- even when I use sentences directly from my training set. I used a verrrry small training set (20 examples) just to make sure I could get the model to train. Even though my training set is ridiculously small, I would still expect the model to work, just very poorly. Why isn't the model able to find any relations?

Also, I wanted to name my relation "affordance", but when I try to do so in my dataset, I get a NullPointerException when I try to train. If I change the name of my relation in the dataset to "kill" it suddenly works. I'm assuming that since "kill" is one of the examples relations Stanford gives, it's been added to some file. Does anyone know how I could rename my relation?

Thank you so much!


Example Training Set:

3   Peop    0   O   NNP Alice   O   O   O
3   O   1   O   VBD was O   O   O
3   O   2   O   VBG beginning   O   O   O
3   O   3   O   TO  to  O   O   O
3   O   4   O   VB  get O   O   O
3   O   5   O   RB  very    O   O   O
3   O   6   O   JJ  tired   O   O   O
3   O   7   O   IN  of  O   O   O
3   O   8   O   VBG sitting O   O   O
3   O   9   O   IN  by  O   O   O
3   O   10  O   PRP$    her O   O   O
3   O   11  O   NN  sister  O   O   O
3   O   12  O   IN  on  O   O   O
3   O   13  O   DT  the O   O   O
3   O   14  O   NN  bank    O   O   O
3   O   15  O   .   .   O   O   O

8   14  kill

4   O   0   O   RB  Once    O   O   O
4   O   1   O   CC  or  O   O   O
4   O   2   O   RB  twice   O   O   O
4   O   3   O   PRP she O   O   O
4   O   4   O   VBD had O   O   O
4   O   5   O   VBN peeped  O   O   O
4   O   6   O   IN  into    O   O   O
4   O   7   O   DT  the O   O   O
4   O   8   O   NN  book    O   O   O
4   O   9   O   PRP$    her O   O   O
4   O   10  O   NN  sister  O   O   O
4   O   11  O   VBD was O   O   O
4   O   12  O   VBG reading O   O   O
4   O   13  O   ,   ,   O   O   O
4   O   14  O   CC  but O   O   O
4   O   15  O   PRP it  O   O   O
4   O   16  O   VBD had O   O   O
4   O   17  O   DT  no  O   O   O
4   O   18  O   NNS pictures    O   O   O
4   O   19  O   CC  or  O   O   O
4   O   20  O   NN  conversation    O   O   O
4   O   21  O   .   .   O   O   O

12  8   kill

5   O   0   O   IN  So  O   O   O
5   O   1   O   PRP she O   O   O
5   O   2   O   VBD was O   O   O
5   O   3   O   VBG considering O   O   O
5   O   4   O   IN  in  O   O   O
5   O   5   O   PRP$    her O   O   O
5   O   6   O   JJ  own O   O   O
5   O   7   O   NN  mind    O   O   O
5   O   8   O   ,   ,   O   O   O
5   O   9   O   IN  whether O   O   O
5   O   10  O   DT  the O   O   O
5   O   11  O   NN  pleasure    O   O   O
5   O   12  O   IN  of  O   O   O
5   O   13  O   VBG making  O   O   O
5   O   14  O   DT  a   O   O   O
5   O   15  O   NN  daisy-chain O   O   O
5   O   16  O   MD  would   O   O   O
5   O   17  O   VB  be  O   O   O
5   O   18  O   JJ  worth   O   O   O
5   O   19  O   DT  the O   O   O
5   O   20  O   NN  trouble O   O   O
5   O   21  O   IN  of  O   O   O
5   O   22  O   VBG getting O   O   O
5   O   23  O   RB  up  O   O   O
5   O   24  O   CC  and O   O   O
5   O   25  O   VBG picking O   O   O
5   O   26  O   DT  the O   O   O
5   O   27  O   NNS daisies O   O   O
5   O   28  O   .   .   O   O   O

25  27  kill

6   Peop    0   O   NNP Alice   O   O   O
6   O   1   O   VBD opened  O   O   O
6   O   2   O   DT  the O   O   O
6   O   3   O   NN  door    O   O   O
6   O   4   O   CC  and O   O   O
6   O   5   O   VBD found   O   O   O
6   O   6   O   IN  that    O   O   O
6   O   7   O   PRP it  O   O   O
6   O   8   O   VBD led O   O   O
6   O   9   O   IN  into    O   O   O
6   O   10  O   DT  a   O   O   O
6   O   11  O   JJ  small   O   O   O
6   O   12  O   NN  passage O   O   O
6   O   13  O   ,   ,   O   O   O
6   O   14  O   RB  not O   O   O
6   O   15  O   RB  much    O   O   O
6   O   16  O   JJR larger  O   O   O
6   O   17  O   IN  than    O   O   O
6   O   18  O   DT  a   O   O   O
6   O   19  O   NN  rat-hole    O   O   O
6   O   20  O   .   .   O   O   O

1   3   kill

1条回答
相关推荐>>
2楼-- · 2019-07-08 12:51

I figured out the problem with my data set in case anyone else on the internet runs into the same problem.. the relation entity lines e.g. 8 14 kill have to be referencing words that have ner tags in column 2! Not being able to name my relations was just a symptom of this as well.

查看更多
登录 后发表回答