Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentiment Load does not take optional path #33

Closed
william-richard opened this issue Feb 18, 2013 · 1 comment
Closed

Sentiment Load does not take optional path #33

william-richard opened this issue Feb 18, 2013 · 1 comment

Comments

@william-richard
Copy link

When the load function in pattern.text.en.parser.sentiment is given an optional path, it sets the '_path' attribute of the Lexicon object, whereas in all other locations the 'path' attribute (without the underscore) is referenced. If the underscore is removed from load, everything works as expected. I posted a more detailed explanation to a relevant google groups thread, which should hopefully be approved soon.

Here is the load function:
def load(self, path=None):
# Backwards compatibility with pattern.en.wordnet.Sentiment.
if path is not None:
self._path = path
self._parse()

Here is where the path attribute is intended to be used, in SentiWordNet._parse_path:
def _parse_path(self):
""" For backwards compatibility, look for SentiWordNet*.txt in:
pattern/en/parser/, patter/en/wordnet/, or the given path.
"""
try: f = (
glob(os.path.join(self.path)) +
glob(os.path.join(MODULE, self.path)) +
glob(os.path.join(MODULE, "..", "wordnet", self.path)))[0]
except IndexError:
raise ImportError, "can't find SentiWordnet data file"
return f

A quick search reveals that load() is the only place where _path is referenced.

I don't want to be stepping on anyone's toes or overstepping by bounds by pointing this out, but it does seem like load() has a typo. When '_path' in load() is changed to 'path', everything behaves as expected.

@dnstanciu
Copy link

I can confirm that the above fix works (using Pattern 2.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants