Python Forum
[nltk] Relations Extractor
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[nltk] Relations Extractor
#1
Hello

I use nltk.sem.relextract to extract relations in text. I have a problem.

What I do:

1. Tools:

import nltk
import re 
from nltk.chunk import ne_chunk_sents
from nltk.sem import relextract
2. Take simple sentence and prepare it

sent = "China is in Asia"
sent = chunker(nltk.pos_tag(sent.split())) // tokenizing, tagging, chunking in NEs
sent
Tree('S', [Tree('GPE', [('China', 'NNP')]), ('in', 'IN'), Tree('GPE', [('Asia', 'NNP')])])
3. Pattern:

IN = re.compile (r'.*\bin\b(?!\b.+ing)')
4. Processing:

for rel in  nltk.sem.extract_rels('GPE','GPE',sent,corpus='ace',pattern=IN):
   print(nltk.sem.relextract.rtuple(rel))
[]
Fail! What is wrong?
Reply


Messages In This Thread
[nltk] Relations Extractor - by constantin01 - Jun-27-2019, 07:35 PM
RE: [nltk] Relations Extractor - by scidam - Jun-28-2019, 02:42 AM
RE: [nltk] Relations Extractor - by constantin01 - Jun-28-2019, 09:05 AM
RE: [nltk] Relations Extractor - by constantin01 - Jun-28-2019, 10:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error on trying to use NLTK Punkt PythonDE 1 2,097 Oct-22-2020, 07:17 PM
Last Post: PythonDE
  [nltk] Parsing with CFG constantin01 1 2,134 Jul-05-2019, 11:11 PM
Last Post: Larz60+
  [nltk] Naive Bayes Classifier constantin01 0 2,022 Jun-24-2019, 10:36 AM
Last Post: constantin01
  NLTK Download Attribute error laila1a 1 8,648 Jan-27-2019, 12:03 AM
Last Post: Larz60+
  [split] serious n00b.. NLTK in python 2.7 and 3.5 kevindenman 3 4,567 Feb-22-2018, 09:05 PM
Last Post: kevindenman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020