【问题标题】:Parsing the sentence in natural language processing (NLP)在自然语言处理 (NLP) 中解析句子
【发布时间】:2015-04-21 16:08:51
【问题描述】:

由于我是机器学习的初学者,我对解析给定的句子感到困惑。 “我在河的左边。” 尝试了很多,但确实无法得到确切的解决方案。

【问题讨论】:

  • “解析”是什么意思?语法分析?语义解析?还是别的?你能把你的问题具体化吗?
  • 那么您的问题到底是什么?
  • 你用的是什么解析器?相关的语法规则是什么?顺便说一句,那句话不是正确的英语。应该是“河”,或者河应该指地名,在这种情况下应该大写。

标签: machine-learning artificial-intelligence


【解决方案1】:

有不同的语言解析器可用,但这取决于您的要求。查看其中的一些内容以开始使用

  1. http://www.nltk.org/howto/parse.html
  2. http://nlp.stanford.edu/software/lex-parser.shtml

谷歌sentence parser,你会得到大名单

这是使用斯坦福解析器的结果:

NLP> I am in the left side of river.
Sentence #1 (9 tokens):
I am in the left side of river.
[Text=I CharacterOffsetBegin=0 CharacterOffsetEnd=1 PartOfSpeech=PRP Lemma=I NamedEntityTag=O] [Text=am CharacterOffsetBegin=2 CharacterOffsetEnd=4 PartOfSpeech=VBP Lemma=be NamedEntityTag=O] [Text=in CharacterOffsetBegin=5 CharacterOffsetEnd=7 PartOfSpeech=IN Lemma=in NamedEntityTag=O] [Text=the CharacterOffsetBegin=8 CharacterOffsetEnd=11 PartOfSpeech=DT Lemma=the NamedEntityTag=O] [Text=left CharacterOffsetBegin=12 CharacterOffsetEnd=16 PartOfSpeech=JJ Lemma=left NamedEntityTag=O] [Text=side CharacterOffsetBegin=17 CharacterOffsetEnd=21 PartOfSpeech=NN Lemma=side NamedEntityTag=O] [Text=of CharacterOffsetBegin=22 CharacterOffsetEnd=24 PartOfSpeech=IN Lemma=of NamedEntityTag=O] [Text=river CharacterOffsetBegin=25 CharacterOffsetEnd=30 PartOfSpeech=NN Lemma=river NamedEntityTag=O] [Text=. CharacterOffsetBegin=30 CharacterOffsetEnd=31 PartOfSpeech=. Lemma=. NamedEntityTag=O] 
(ROOT
  (S
    (NP (PRP I))
    (VP (VBP am)
      (PP (IN in)
        (NP
          (NP (DT the) (JJ left) (NN side))
          (PP (IN of)
            (NP (NN river))))))
    (. .)))

root(ROOT-0, am-2)
nsubj(am-2, I-1)
det(side-6, the-4)
amod(side-6, left-5)
prep_in(am-2, side-6)
prep_of(side-6, river-8)

nltk 解析器:

>>> nltk.parse.chart.demo(3, print_times=False, trace=0,
...                       sent='I saw John with a dog', numparses=2)
* Sentence:
I saw John with a dog
['I', 'saw', 'John', 'with', 'a', 'dog']

* Strategy: Bottom-up left-corner

Nr edges in chart: 36
(S
  (NP I)
  (VP (VP (Verb saw) (NP John)) (PP with (NP (Det a) (Noun dog)))))
(S
  (NP I)
  (VP (Verb saw) (NP (NP John) (PP with (NP (Det a) (Noun dog))))))

【讨论】:

    猜你喜欢
    • 2012-06-24
    • 2014-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-17
    • 2013-09-12
    相关资源
    最近更新 更多