Examples of GISModel


Examples of opennlp.maxent.GISModel

    Parser parser = new ChunkParser(chunker, tagger);
    AnswerTypeContextGenerator actg = new AnswerTypeContextGenerator(new File(wordnetDir));
    //<start id="atc.train"/>
    AnswerTypeEventStream es = new AnswerTypeEventStream(trainFile,
            actg, parser);
    GISModel model = GIS.trainModel(100, new TwoPassDataIndexer(es, 3));//<co id="atc.train.do"/>
    new DoccatModel("en", model).serialize(new FileOutputStream(outFile));
    /*
    <calloutlist>
        <callout arearefs="atc.train.do"><para>Using the event stream, which feeds us training examples, do the actual training using OpenNLP's Maxent classifier.</para></callout>
    </calloutlist>
View Full Code Here

Examples of opennlp.maxent.GISModel

    String[] outcomeLabels = getOutcomes();
    int[][] outcomePatterns = getOutcomePatterns();
    String[] predLabels = getPredicates();
    Context[] params = getParameters(outcomePatterns);

    return new GISModel(params, predLabels, outcomeLabels, correctionConstant,
        correctionParam);
  }
View Full Code Here

Examples of opennlp.maxent.GISModel

   * during IO operations on a temp file which is created during training occur.
   */
  public static POSModel train(String languageCode, ObjectStream<POSSample> samples, POSDictionary tagDictionary,
      Dictionary ngramDictionary, int cutoff, int iterations) throws IOException {

    GISModel posModel = opennlp.maxent.GIS.trainModel(iterations,
        new TwoPassDataIndexer(new POSSampleEventStream(samples,
        new DefaultPOSContextGenerator(ngramDictionary)), cutoff));

    return new POSModel(languageCode, posModel, tagDictionary, ngramDictionary);
  }
View Full Code Here

Examples of opennlp.maxent.GISModel

          }
        }
      }
      File inFile = new File(args[ai++]);
      File outFile = new File(args[ai++]);
      GISModel mod;

      EventStream es = new NameFinderEventStream(new PlainTextByLineDataStream(new InputStreamReader(new FileInputStream(inFile),encoding)));
      if (args.length > ai)
        mod = train(es, Integer.parseInt(args[ai++]), Integer.parseInt(args[ai++]));
      else
View Full Code Here

Examples of opennlp.maxent.GISModel

        }
      }
    }
    File inFile = new File(args[ai++]);
    File outFile = new File(args[ai++]);
    GISModel mod;
   
    try {
      EventStream es = new SDEventStream(new PlainTextByLineDataStream(new InputStreamReader(new FileInputStream(inFile),encoding)));

      if (args.length > ai)
View Full Code Here

Examples of opennlp.maxent.GISModel

      int iterations = 100;
      if (args.length > ai) {
        cutoff = Integer.parseInt(args[ai++]);
        iterations = Integer.parseInt(args[ai++]);
      }
      GISModel mod;
      if (dict != null) {
        System.err.println("Building dictionary");
        MutableDictionary mdict = new MutableDictionary(cutoff);
        DataStream data = new opennlp.maxent.PlainTextByLineDataStream(new java.io.FileReader(inFile));
        while(data.hasNext()) {
View Full Code Here

Examples of opennlp.maxent.GISModel

      System.err.println("space-delimited triple of \"word pos outcome\".  Sentence breaks are indicated by blank lines.");
      System.exit(1);
    }
    java.io.File inFile = new java.io.File(args[0]);
    java.io.File outFile = new java.io.File(args[1]);
    GISModel mod;
    opennlp.maxent.EventStream es = new ChunkerEventStream(new opennlp.maxent.PlainTextByLineDataStream(new java.io.FileReader(inFile)));
    if (args.length > 3)
      mod = train(es, Integer.parseInt(args[2]), Integer.parseInt(args[3]));
    else
      mod = train(es, 100, 5);
View Full Code Here

Examples of opennlp.maxent.GISModel

    if (tag || all) {
      System.err.println("Training tagger");
      System.err.println("Loading Dictionary");
      Dictionary tridict = new Dictionary(dictFile.toString());
      opennlp.maxent.EventStream tes = new ParserEventStream(new opennlp.maxent.PlainTextByLineDataStream(new java.io.FileReader(inFile)), rules, EventTypeEnum.TAG,tridict);
      GISModel tagModel = train(tes, iterations, cutoff);
      System.out.println("Saving the tagger model as: " + tagFile);
      new opennlp.maxent.io.SuffixSensitiveGISModelWriter(tagModel, tagFile).persist();
    }

    if (chunk || all) {
      System.err.println("Training chunker");
      opennlp.maxent.EventStream ces = new ParserEventStream(new opennlp.maxent.PlainTextByLineDataStream(new java.io.FileReader(inFile)), rules, EventTypeEnum.CHUNK);
      GISModel chunkModel = train(ces, iterations, cutoff);
      System.out.println("Saving the chunker model as: " + chunkFile);
      new opennlp.maxent.io.SuffixSensitiveGISModelWriter(chunkModel, chunkFile).persist();
    }

    if (build || all) {
      System.err.println("Loading Dictionary");
      Dictionary tridict = new Dictionary(dictFile.toString());
      System.err.println("Training builder");
      opennlp.maxent.EventStream bes = new ParserEventStream(new opennlp.maxent.PlainTextByLineDataStream(new java.io.FileReader(inFile)), rules, EventTypeEnum.BUILD,tridict);
      GISModel buildModel = train(bes, iterations, cutoff);
      System.out.println("Saving the build model as: " + buildFile);
      new opennlp.maxent.io.SuffixSensitiveGISModelWriter(buildModel, buildFile).persist();
    }

    if (check || all) {
      System.err.println("Training checker");
      opennlp.maxent.EventStream kes = new ParserEventStream(new opennlp.maxent.PlainTextByLineDataStream(new java.io.FileReader(inFile)), rules, EventTypeEnum.CHECK);
      GISModel checkModel = train(kes, iterations, cutoff);
      System.out.println("Saving the check model as: " + checkFile);
      new opennlp.maxent.io.SuffixSensitiveGISModelWriter(checkModel, checkFile).persist();
    }
  }
View Full Code Here

Examples of opennlp.maxent.GISModel

    }
    return (Span[]) tokens.toArray(new Span[tokens.size()]);
  }

  public static void train(EventStream evc, File output) throws IOException {
    GISModel tokModel = opennlp.maxent.GIS.trainModel(100,new TwoPassDataIndexer(evc, 5),true);
    new SuffixSensitiveGISModelWriter(tokModel, output).persist();
  }
View Full Code Here

Examples of opennlp.maxent.GISModel

   
    for(NamedEntity entity : entities) {
      List<String> features = fe.getFeatures(entity);
      String type = entity.getType();
      if(modelsByType.containsKey(type)) {
        GISModel model = modelsByType.get(type);
        if(model.getNumOutcomes() == 2) {
          double prob = model.eval(features.toArray(new String[0]))[model.getIndex("T")];
          entity.setConfidence(prob);
        }
      }
    }
  }
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.