<isol>


Listing 1: Verwendung eines POS-Taggers für englische Sprache

import java.io.*;

import opennlp.maxent.*;
import opennlp.maxent.io.*;
import opennlp.tools.ngram.*;
import opennlp.tools.postag.*;


public class MyPOSTagger extends POSTaggerME {

  public MyPOSTagger(String modelFile, Dictionary dict) {
    super(getModel(modelFile), new DefaultPOSContextGenerator(dict));
  }

  private static MaxentModel getModel(String name) {
    try {

      return new SuffixSensitiveGISModelReader(new File(name)).getModel();
    }
    catch (IOException e) {

      e.printStackTrace();
      return null;
    }
  }

  public static void main(String[] args) throws IOException {
    String myMEModel = "G:/EnglishPOS.bin.gz";
    POSTaggerME myTagger = new MyPOSTagger(myMEModel, null);

    System.out.println(
      "Geben Sie einen englischen Satz ein, bestätigt durch <ENTER>:");
    System.out.flush();

    BufferedReader in =
      new BufferedReader(new InputStreamReader(System.in));

    for (String line = in.readLine(); line != null; line = in.readLine())
      System.out.println(myTagger.tag(line));
  }
}
