clips / clips/pattern

nltk_tree(sentence) throws NameError

Open
#123 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.9k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

A pattern.text.Sentence can't be converted into an nltk.tree.Tree, at least not
with nltk version 3.0.4.

>>> import pattern
>>> from pattern.de import parsetree
>>> sentence = parsetree('Hans liebt Maria.')[0]
>>> pattern.text.tree.nltk_tree(sentence)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-13-7bbd6533ae36> in <module>()
----> 1 pattern.text.tree.nltk_tree(sentence)

/usr/local/lib/python2.7/dist-packages/Pattern-2.6-py2.7.egg/pattern/text/tree.pyc in nltk_tree(sentence)
   1592             v.append(ch.pnp)
   1593     T.append(')')
-> 1594     return tree.bracket_parse(' '.join(T))
   1595 
   1596 ### GRAPHVIZ DOT ###################################################################################

/usr/local/lib/python2.7/dist-packages/nltk-3.0.4-py2.7.egg/nltk/tree.pyc in bracket_parse(s)
   1488     Use Tree.read(s, remove_empty_top_bracketing=True) instead.
   1489     """
-> 1490     raise NameError("Use Tree.read(s, remove_empty_top_bracketing=True) instead.")
   1491 
   1492 def sinica_parse(s):

NameError: Use Tree.read(s, remove_empty_top_bracketing=True) instead.

>>> import nltk
>>> nltk.__version__
'3.0.4'

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pattern/text/tree.py at nltk_tree, using the traceback and the NLTK 3.0.4 version as context. Check the current NLTK tree parsing API and verify that converting the example pattern.text.Sentence completes without the reported NameError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.