knowledge-base-population

NLTK relation extraction returns nothing

雨燕双飞 提交于 2019-12-21 12:34:09
问题 I am recently working on using nltk to extract relation from text. so i build a sample text:" Tom is the cofounder of Microsoft." and using following program to test and return nothing. I cannot figure out why. I'm using NLTK version: 3.2.1, python version: 3.5.2. Here is my code: import re import nltk from nltk.sem.relextract import extract_rels, rtuple from nltk.tokenize import sent_tokenize, word_tokenize def test(): with open('sample.txt', 'r') as f: sample = f.read() # "Tom is the

NLTK relation extraction returns nothing

浪子不回头ぞ 提交于 2019-12-04 06:20:23
I am recently working on using nltk to extract relation from text. so i build a sample text:" Tom is the cofounder of Microsoft." and using following program to test and return nothing. I cannot figure out why. I'm using NLTK version: 3.2.1, python version: 3.5.2. Here is my code: import re import nltk from nltk.sem.relextract import extract_rels, rtuple from nltk.tokenize import sent_tokenize, word_tokenize def test(): with open('sample.txt', 'r') as f: sample = f.read() # "Tom is the cofounder of Microsoft" sentences = sent_tokenize(sample) tokenized_sentences = [word_tokenize(sentence) for