@@ -0,0 +1,1681 @@
+/*%0A * To change this license header, choose License Headers in Project Properties.%0A * To change this template file, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage de.hsbo.fbg.sm4c.classifier.filter;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport opennlp.tools.postag.POSModel;%0Aimport opennlp.tools.postag.POSTagger;%0Aimport opennlp.tools.postag.POSTaggerME;%0Aimport org.apache.logging.log4j.LogManager;%0A%0A/**%0A * Class for identifying the part of speech of a text%0A *%0A * @author Sebastian Drost%0A */%0Apublic class PartOfSpeechTagger %7B%0A%0A    private static final org.apache.logging.log4j.Logger LOGGER = LogManager.getLogger(PartOfSpeechTagger.class);%0A%0A    public static final String DEFAULT_POS_MODEL = %22de-pos-maxent.bin%22;%0A%0A    private POSModel posModel;%0A    private POSTagger posTagger;%0A%0A    /**%0A     * Trains the part of speech tagger with a given POS Model.%0A     *%0A     * @param modelPath path starting from the classpath to the model%0A     */%0A    public void trainPOSModel(String modelPath) %7B%0A        try (InputStream in = this.getClass().getClassLoader().getResourceAsStream(modelPath)) %7B%0A            posModel = new POSModel(in);%0A            posTagger = new POSTaggerME(posModel);%0A        %7D catch (IOException ex) %7B%0A            LOGGER.error(%22Could not load tokenizer model%22, ex);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Tags the part of speech for given tokens.%0A     *%0A     * @param tokens Tokens to tag%0A     * @return List of tags for the tokens%0A     */%0A    public List%3CString%3E tagTokens(List%3CString%3E tokens) %7B%0A        return Arrays.asList(posTagger.tag(tokens.toArray(new String%5B0%5D)));%0A    %7D%0A%0A%7D%0A

introduce part of speech tagger