Treetagger with java

Closed
informaticienne - Apr 7, 2016 at 09:25 AM
 informaticienne - Apr 7, 2016 at 09:36 AM
Hello,

I am creating a Twitter Sentiment Analysis tool in Java. I am using the Twitter4J API to search tweets via the hashtag feature in twitter and then provide sentiment analysis on these tweets. Through research, I have found that the best solution to doing this will be using a POS and TreeTagger for Java.

At the moment, I am using the examples provided to see how the code works, although I am encountering some problems .

This is the code





import org.annolab.tt4j.*;
import static java.util.Arrays.asList;

public class Example {
    public static void main(String[] args) throws Exception {
            // Point TT4J to the TreeTagger installation directory. The executable is expected
            // in the "bin" subdirectory - in this example at "/opt/treetagger/bin/tree-tagger"
            System.setProperty("treetagger.home", "/opt/treetagger");
            TreeTaggerWrapper tt = new TreeTaggerWrapper<String>();
            try {
                    tt.setModel("/opt/treetagger/models/english.par:iso8859-1");
                    tt.setHandler(new TokenHandler<String>() {
                            public void token(String token, String pos, String lemma) {
                                    System.out.println(token + "\t" + pos + "\t" + lemma);
                            }
                    });
                    tt.process(asList(new String[] { "This", "is", "a", "test", "." }));
            }
            finally {
                    tt.destroy();
            }
    }




At the moment, when this is run, I receive an error which says

TreeTaggerWrapper cannot be resolved to a type
TokenHandler cannot be resolved to a type

I will be grateful for any help given

Thank you

Related:

1 response

BunoCS Posts 15495 Registration date Monday July 11, 2005 Status Moderator Last seen October 23, 2024 1,533
Apr 7, 2016 at 09:32 AM
Hello,

It seems you don't include the correct packages.

https://github.com/reckart/tt4j
0
informaticienne
Apr 7, 2016 at 09:36 AM
no i include the cooreect ^package please any other help
0