roomylee / cnn-relation-extraction

Tensorflow Implementation of Convolutional Neural Network for Relation Extraction (COLING 2014, NAACL 2015)
http://www.aclweb.org/anthology/W15-1506
MIT License
220 stars 62 forks source link

deriving values for e1 e2 #3

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi , I was able to get the classification label , based on the approach you suggested , But i am not able to figure out how to get the relation label ?

i inverted the labelsmapping and was able to pass all_predictions in an iterator , to get the labels out .

for prediction in all_predictions: labelsMapping = { 0:'Other', 1 : 'Message-Topic(e1,e2)', 2 :'Message-Topic(e2,e1)', 3 : 'Product-Producer(e1,e2)', 4 :'Product-Producer(e2,e1)', 5 : 'Instrument-Agency(e1,e2)', 6 :'Instrument-Agency(e2,e1)', 7 : 'Entity-Destination(e1,e2)', 8 : 'Entity-Destination(e2,e1)', 9 : 'Cause-Effect(e1,e2)', 10 : 'Cause-Effect(e2,e1)', 11 : 'Component-Whole(e1,e2)', 12 :'Component-Whole(e2,e1)', 13 : 'Entity-Origin(e1,e2)', 14 :'Entity-Origin(e2,e1)', 15 : 'Member-Collection(e1,e2)', 16 : 'Member-Collection(e2,e1)', 17 : 'Content-Container(e1,e2)', 18 : 'Content-Container(e2,e1)'} print(labelsMapping[int(prediction)])

but i am not able to figure out how to get into the values for effect e1, e2 etc .. could you help me out with this ?

roomylee commented 6 years ago

@neo2603 I'm really sorry, but I can not fully understand your question. I understand that you want to know which words in the input sentence correspond to e1 and e2 of the predictive label, right? For example, when model predicts a sentence "The company fabricates plastic chairs." as "Product-Producer(e2,e1)", do you wonder what is equivalent to e1, e2 in Product-Producer(e2,e1) ?

roomylee commented 6 years ago

@neo2603 Newly updated code might be helpful... https://github.com/roomylee/cnn-relation-extraction/blob/412411fdfc11c6e2a477a56b4edba2e0b62ec74e/eval.py#L82 Here is new description about official evaluation of SemEval 2010 Task #8 https://github.com/roomylee/cnn-relation-extraction#evalutation