clips / pattern

Web mining module for Python, with tools for scraping, natural language processing, machine learning, network analysis and visualization.
https://github.com/clips/pattern/wiki
BSD 3-Clause "New" or "Revised" License
8.74k stars 1.58k forks source link

Match : does not match a NP-group ? #287

Open vsraptor opened 5 years ago

vsraptor commented 5 years ago

For some reason MATCHING cant find the third {NP} ? As you can see there is 3 NP chunks, so it should work !! Any idea ?


In [120]: s1 = Sentence(parse('The students consider the course a challenge'))

In [121]: s1.string
Out[121]: u'The students consider the course a challenge'

In [122]: m = match('{NP} {VB*} {NP} {NP}', s1)

In [123]: m.constituents()
Out[123]: [Chunk('The students/NP'), Chunk('consider/VP'), Chunk('the course/NP')]

In [125]: s1.chunks
Out[125]: 
 [Chunk('The students/NP'),
  Chunk('consider/VP'),
 Chunk('the course/NP'),
 Chunk('a challenge/NP')]

 In [126]: pprint(s1)

      WORD   TAG    CHUNK   ROLE   ID     PNP    LEMMA   

       The   DT     NP      -      -      -      -       
  students   NNS    NP ^    -      -      -      -       
  consider   VB     VP      -      -      -      -       
       the   DT     NP      -      -      -      -       
    course   NN     NP ^    -      -      -      -       
         a   DT     NP      -      -      -      -       
 challenge   NN     NP ^    -      -      -      -