hadf
September 6, 2016, 9:47am
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
dnaber
(Daniel Naber)
September 6, 2016, 7:00pm
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.
1 Like
hadf
September 6, 2016, 8:04pm
3
Perfect, thank you very much Daniel
glennhefley
(Glenn Allen Hefley)
July 17, 2017, 4:17pm
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
(Knorr)
July 17, 2017, 4:19pm
5
LT’s source is mostly Java-code.
1 Like
glennhefley
(Glenn Allen Hefley)
July 17, 2017, 4:30pm
6
Thanks… I’m never going there… just saying… I’ll crawl back under the couch now.