Back to LanguageTool Homepage - Privacy - Imprint

How to use pos tagging only programmaticly?


#1

Hello,

In command line, I do :

java -jar languagetool-commandline.jar -l fr --taggeronly document.txt > document-tagged.txt

Now I would like to use "tagger only" with xml document.
So I want to use LT programmaticly when parsing my xml.
Can you tell me how to do so ?

Thank you :slight_smile:


(Daniel Naber) #2

Try this:

    JLanguageTool lt = new JLanguageTool(Languages.getLanguageForShortName("en"));
    List<AnalyzedSentence> sentences = lt.analyzeText("This is a test.");
    for (AnalyzedSentence sentence : sentences) {
      AnalyzedTokenReadings[] tokens = sentence.getTokensWithoutWhitespace();
      for (AnalyzedTokenReadings token : tokens) {
        System.out.println(token.getToken() + ": " + token.getReadings());
      }
    }

You'll need to remove the XML tags first.


#3

Perfect, thank you very much Daniel :wink:


(Glenn Allen Hefley) #4

@dnaber ? I'm an old Perl monk, and I've been out of that (other than like a one-liner to kill spam or something once in awhile) for a few years. I got into Python because it seems like the best to use for Semantic on-the-fly experiments. That doesn't look like either .. what is the code you use for LT?


(Knorr) #5

LT's source is mostly Java-code.


(Glenn Allen Hefley) #6

Thanks... I'm never going there.... just saying... I'll crawl back under the couch now.