miotto / treetagger-python

A Python module for interfacing with the Treetagger by Helmut Schmid.
Other
77 stars 29 forks source link

TreeTagger.tag() return empty array #16

Closed harisw closed 5 years ago

harisw commented 6 years ago

I've installed the TreeTagger and treetagger-python from pip. I want to tag my sentence with this package. But, it only return empty array, i've tried some other sentence and it goes same. Here is my code. It has no error.

from treetagger import TreeTagger
tt = TreeTagger(language='english')
        row = row[0]
        sentence = "When I am alone in a room with no contact with anyone - a loneliness draines me."
        print(sentence)
        tt.tag(sentence)

Please help, Thanks

zascode commented 6 years ago

Same issue here...

miotto commented 6 years ago

Sorry for the late reply.

I have reworked the treetagger.py program, please try the new version. In the README.rst file you can see which software versions and operating systems it has been tested with. Which software versions and operating system do you use? Please also check if Helmut Schmid's Treetagger program is installed correctly.

Previously in the Linux bash

export TREETAGGER_HOME='/path/to/TreeTagger/'

In Python 3 the following code works for me

from treetagger import TreeTagger
tt = TreeTagger()
sentence = "When I am alone in a room with no contact with anyone - a loneliness draines me."
tt.tag(sentence)

The result is

[['When', 'WRB', 'when'], ['I', 'PP', 'I'], ['am', 'VBP', 'be'], ['alone', 'RB', 'alone'], ['in', 'IN', 'in'], ['a', 'DT', 'a'], ['room', 'NN', 'room'], ['with', 'IN', 'with'], ['no', 'DT', 'no'], ['contact', 'NN', 'contact'], ['with', 'IN', 'with'], ['anyone', 'NN', 'anyone'], ['-', ':', '-'], ['a', 'DT', 'a'], ['loneliness', 'NN', 'loneliness'], ['draines', 'VBZ', '<unknown>'], ['me', 'PP', 'me'], ['.', 'SENT', '.']]
Jchandar commented 3 years ago

Hi miotto im returning empty array as output

from treetagger import TreeTagger tt = TreeTagger(language='english') sentence = "When I am alone in a room with no contact with anyone - a loneliness draines me." from pprint import pprint pprint(tt.tag(sentence))

miotto commented 3 years ago

Hi Jchandar, did you enter the path to the TreeTagger programme correctly?

Set the environment variable in the Linux bash

export TREETAGGER_HOME='/path/to/TreeTagger/'

or specify it as a parameter in the Python program.

tt = TreeTagger(path_to_treetagger='/path/to/TreeTagger/', language='english')

For me it looks like this.

from treetagger import TreeTagger
tt = TreeTagger(path_to_treetagger='/path/to/TreeTagger/', language='english')
sentence = "When I am alone in a room with no contact with anyone - a loneliness draines me."
from pprint import pprint
pprint(tt.tag(sentence))

[['When', 'WRB', 'when'],
 ['I', 'PP', 'I'],
 ['am', 'VBP', 'be'],
 ['alone', 'RB', 'alone'],
 ['in', 'IN', 'in'],
 ['a', 'DT', 'a'],
 ['room', 'NN', 'room'],
 ['with', 'IN', 'with'],
 ['no', 'DT', 'no'],
 ['contact', 'NN', 'contact'],
 ['with', 'IN', 'with'],
 ['anyone', 'NN', 'anyone'],
 ['-', 'NN', '<unknown>'],
 ['a', 'DT', 'a'],
 ['loneliness', 'NN', 'loneliness'],
 ['draines', 'VBZ', '<unknown>'],
 ['me', 'PP', 'me'],
 ['.', 'SENT', '.']]

Otherwise, you would have to give more precise information so that I can recreate it. Was there an error message? Which operating system are you using, which Python version, which TreeTagger version etc.

Jchandar commented 3 years ago

Hi miotto,

Linux I'm using python 3.8


From: miotto @.> Sent: Wednesday, October 13, 2021 4:19 PM To: miotto/treetagger-python @.> Cc: Jeychandar KR @.>; Comment @.> Subject: Re: [miotto/treetagger-python] TreeTagger.tag() return empty array (#16)

Hi Jchandar, did you enter the path to the TreeTagger programme correctly?

Set the environment variable in the Linux bash

export TREETAGGER_HOME='/path/to/TreeTagger/'

or specify it as a parameter in the Python program.

tt = TreeTagger(path_to_treetagger='/path/to/TreeTagger/', language='english')

For me it looks like this.

from treetagger import TreeTagger tt = TreeTagger(path_to_treetagger='/path/to/TreeTagger/', language='english') sentence = "When I am alone in a room with no contact with anyone - a loneliness draines me." from pprint import pprint pprint(tt.tag(sentence))

[['When', 'WRB', 'when'], ['I', 'PP', 'I'], ['am', 'VBP', 'be'], ['alone', 'RB', 'alone'], ['in', 'IN', 'in'], ['a', 'DT', 'a'], ['room', 'NN', 'room'], ['with', 'IN', 'with'], ['no', 'DT', 'no'], ['contact', 'NN', 'contact'], ['with', 'IN', 'with'], ['anyone', 'NN', 'anyone'], ['-', 'NN', ''], ['a', 'DT', 'a'], ['loneliness', 'NN', 'loneliness'], ['draines', 'VBZ', ''], ['me', 'PP', 'me'], ['.', 'SENT', '.']]

Otherwise, you would have to give more precise information so that I can recreate it. Was there an error message? Which operating system are you using, which Python version, which TreeTagger version etc.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/miotto/treetagger-python/issues/16#issuecomment-942172971, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AV7CCXXKGCDHG5ZPLJTD3NDUGVP3XANCNFSM4E5OWH5Q. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

miotto commented 3 years ago

Hi Jchandar, have you installed the TreeTagger and is it working as described at the following URL? https://www.cis.lmu.de/~schmid/tools/TreeTagger/

Is there any error message?