Examples of POSTaggerME


Examples of opennlp.tools.postag.POSTaggerME

        UimaUtil.BEAM_SIZE_PARAMETER);

    if (beamSize == null)
      beamSize = POSTaggerME.DEFAULT_BEAM_SIZE;

    this.posTagger = new POSTaggerME(model, beamSize, 0);
  }
View Full Code Here

Examples of opennlp.tools.postag.POSTaggerME

      throw new TerminateToolException(1);
    }
   
    POSModel model = new POSModelLoader().load(new File(args[0]));
   
    POSTaggerME tagger = new POSTaggerME(model);
   
    ObjectStream<String> lineStream =
      new PlainTextByLineStream(new InputStreamReader(System.in));
   
    PerformanceMonitor perfMon = new PerformanceMonitor(System.err, "sent");
    perfMon.start();
   
    try {
      String line;
      while ((line = lineStream.read()) != null) {
       
        String whitespaceTokenizerLine[] = WhitespaceTokenizer.INSTANCE.tokenize(line);
        String[] tags = tagger.tag(whitespaceTokenizerLine);
       
        POSSample sample = new POSSample(whitespaceTokenizerLine, tags);
        System.out.println(sample.toString());
       
        perfMon.incrementCounter();
View Full Code Here

Examples of opennlp.tools.postag.POSTaggerME

      else if (args[ai].equals("-td")) {
        tagdict = args[ai+1];
        ai+=2;
      }
    }
    POSTaggerME tagger;
    String modelFile = args[ai++];
    if (tagdict != null) {
      tagger = new PosTagger(modelFile, new POSDictionary(tagdict));
    }
    else {
      tagger = new PosTagger(modelFile);
    }
    if (test) {
      System.out.println(tagger.tag(args[ai]));
    }
    else {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in,"ISO-8859-1"));
      PrintStream out = new PrintStream(System.out,true,"ISO-8859-1");
      for (String line = in.readLine(); line != null; line = in.readLine()) {
        out.println(tagger.tag(line));
      }
    }
  }
View Full Code Here

Examples of opennlp.tools.postag.POSTaggerME

        tagdict = args[ai+1];
        ai+=2;
        caseSensitive = false;
      }
    }
    POSTaggerME tagger;
    String model = args[ai++];
    String dictFile = null;
    if (ai < args.length) {
      dictFile = args[ai++];
    }
   
    if (tagdict != null) {
      if (dictFile != null) {
        tagger = new PosTagger(model,new Dictionary(dictFile),new POSDictionary(tagdict,caseSensitive));
      }
      else {
        tagger = new PosTagger(model,new POSDictionary(tagdict,caseSensitive));
      }
    }
    else {
      if (dictFile != null) {
        tagger = new PosTagger(model,new Dictionary(dictFile));
      }
      else {
        tagger = new PosTagger(model,(Dictionary)null);
      }
    }
    if (test) {
      System.out.println(tagger.tag(args[ai]));
    }
    else {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
     
      for (String line = in.readLine(); line != null; line = in.readLine()) {
        System.out.println(tagger.tag(line));
      }
    }
  }
View Full Code Here

Examples of opennlp.tools.postag.POSTaggerME

  private int completeIndex;
  private int incompleteIndex;

  public Parser(ParserModel model, int beamSize, double advancePercentage) {
    this(model.getBuildModel(), model.getCheckModel(),
        new POSTaggerME(model.getParserTaggerModel(), 10, 0),
        new ChunkerME(model.getParserChunkerModel(),
            ChunkerME.DEFAULT_BEAM_SIZE,
            new ParserChunkerSequenceValidator(model.getParserChunkerModel()),
            new ChunkContextGenerator(ChunkerME.DEFAULT_BEAM_SIZE)),
            model.getHeadRules(), beamSize, advancePercentage);
View Full Code Here

Examples of opennlp.tools.postag.POSTaggerME

      System.out.println(getHelp());
    } else {
   
      POSModel model = new POSModelLoader().load(new File(args[0]));

      POSTaggerME tagger = new POSTaggerME(model);

      ObjectStream<String> lineStream =
        new PlainTextByLineStream(new InputStreamReader(System.in));

      PerformanceMonitor perfMon = new PerformanceMonitor(System.err, "sent");
      perfMon.start();

      try {
        String line;
        while ((line = lineStream.read()) != null) {

          String whitespaceTokenizerLine[] = WhitespaceTokenizer.INSTANCE.tokenize(line);
          String[] tags = tagger.tag(whitespaceTokenizerLine);

          POSSample sample = new POSSample(whitespaceTokenizerLine, tags);
          System.out.println(sample.toString());

          perfMon.incrementCounter();
View Full Code Here

Examples of opennlp.tools.postag.POSTaggerME

  private int[] attachments;

  public Parser(ParserModel model, int beamSize, double advancePercentage) {
    this(model.getBuildModel(), model.getAttachModel(), model.getCheckModel(),
        new POSTaggerME(model.getParserTaggerModel()),
        new ChunkerME(model.getParserChunkerModel(),
        ChunkerME.DEFAULT_BEAM_SIZE,
        new ParserChunkerSequenceValidator(model.getParserChunkerModel()),
        new ChunkContextGenerator(ChunkerME.DEFAULT_BEAM_SIZE)),
        model.getHeadRules(),
View Full Code Here

Examples of opennlp.tools.postag.POSTaggerME

    // model.getFile() +
    // " dictionary: "+dictionary.getFile());
    try {
      BufferedReader dictionaryReader = new BomStrippingInputStreamReader(dictionary.openStream(),
              dictionaryEncoding);
      pos = new POSTaggerME(getModel(model), new POSDictionary(
          dictionaryReader, true));
    } catch (IOException e) {
      e.printStackTrace();
      logger.error("OpenNLP POS can not be initialized!");
      throw new RuntimeException("OpenNLP POS can not be initialized!", e);
View Full Code Here

Examples of opennlp.tools.postag.POSTaggerME

        }
        if(posTagger == null && !posTaggerNotAvailable){
            try {
                POSModel posModel = openNLP.getPartOfSpeachModel(language);
                if(posModel != null){
                    posTagger = new POSTaggerME(posModel);
                } else {
                    log.debug("No POS Model for language '{}'",language);
                    posTaggerNotAvailable = true;
                }
            } catch (IOException e) {
View Full Code Here

Examples of opennlp.tools.postag.POSTaggerME

                throw new IllegalArgumentException(
                    "The parsed offset MUST NOT be a negative number (offset="+offset+")");
            }
            this.offset = offset;
            Span[] tokenSpans = getTokenizer().tokenizePos(sentence);
            POSTaggerME tagger = getPosTagger();
            ChunkerME chunker = getChunker();
            PosTypeChunker posTypeChunker = getPosTypeChunker();
            String[] tokens = new String[tokenSpans.length];
            for(int ti = 0; ti<tokenSpans.length;ti++) {
                tokens[ti] = tokenSpans[ti].getCoveredText(sentence).toString();
            }
            String[][] posTags;
            double[][] posProbs;
            Span[] chunkSpans;
            double[] chunkProps;
            if(tagger != null){
                posTags = new String[tokens.length][];
                posProbs = new double[tokens.length][];
                //get the topK POS tags and props and copy it over to the 2dim Arrays
                Sequence[] posSequences = tagger.topKSequences(tokens);
                //extract the POS tags and props for the current token from the
                //posSequences.
                //NOTE: Sequence includes always POS tags for all Tokens. If
                //      less then posSequences.length are available it adds the
                //      best match for all followings.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.