Examples of GISModel


Examples of opennlp.maxent.GISModel

      }
      if(events.size() < 2) continue;
      DataIndexer di = null;
      di = new TwoPassDataIndexer(new EventCollectorAsStream(new SimpleEventCollector(events)), 1);
      if(Oscar3Props.getInstance().verbose) System.out.println(di);
      GISModel gm = GIS.trainModel(100, di);
      classifiers.put(type, gm);
    }
  }
View Full Code Here

Examples of opennlp.maxent.GISModel

    List<Event> trainData = events.subList(0, events.size()/2);
    List<Event> testData = events.subList(events.size()/2, events.size());
   
    if(trainData.size() == 1) trainData.add(trainData.get(0));
    DataIndexer di = new TwoPassDataIndexer(new EventCollectorAsStream(new SimpleEventCollector(trainData)), 1);
    GISModel gm = GIS.trainModel(100, di);
   
    ClassificationEvaluator ce = new ClassificationEvaluator();
   
    for(Event event : testData) {
      double [] results = gm.eval(event.getContext());
      String result = gm.getBestOutcome(results);
      System.out.println(event.getOutcome() + "\t" + result + "\t" + results[gm.getIndex(event.getOutcome())] + "\t" + StringTools.arrayToList(event.getContext()));
      ce.logEvent(event.getOutcome(), result);
    }
    System.out.println(ce.getAccuracy());
    System.out.println(ce.getKappa());
    ce.pprintConfusionMatrix();
View Full Code Here

Examples of opennlp.maxent.GISModel

      }
      for(BagEvent be : testBagEvents) {
        testEvents.add(new Event(be.getClassLabel(), be.getFeatures().getSet().toArray(new String[0])));
      }
      DataIndexer di = new TwoPassDataIndexer(new EventCollectorAsStream(new SimpleEventCollector(trainEvents)), 1);
      GISModel gm = GIS.trainModel(100, di);
     
      //ClassificationEvaluator ce = new ClassificationEvaluator();
     
      for(Event event : testEvents) {
        double [] results = gm.eval(event.getContext());
        String result = results[gm.getIndex("TRUE")] > 0.5 ? "TRUE" : "FALSE";
        //String result = gm.getBestOutcome(results);
        //System.out.println(event.getOutcome() + "\t" + result + "\t" + results[gm.getIndex(event.getOutcome())] + "\t" + StringTools.arrayToList(event.getContext()));
        ce.logEvent(event.getOutcome(), result);
      }
      System.out.println(ce.getAccuracy());
View Full Code Here

Examples of opennlp.maxent.GISModel

      events.add(docToEvent(ir, i, c));
    }
   
    DataIndexer di = null;
    di = new TwoPassDataIndexer(new EventCollectorAsStream(new SimpleEventCollector(events)), 3);
    GISModel gm = GIS.trainModel(100, di);
 
    Map<String,Double> byProb = new HashMap<String,Double>();
    Map<String,String> res = new HashMap<String,String>();
    int mp = 0;
    int mn = 0;
    for(int i=numDocs/2;i<numDocs;i++) {
      Event e = docToEvent(ir, i, c);
      //System.out.println(gm.getBestOutcome(gm.eval(e.getContext())));
      double prob = gm.eval(e.getContext())[gm.getIndex("TRUE")];
      //System.out.println(ir.document(i).getField("filename").stringValue().replaceAll("markedup", "source"));
      String name = ir.document(i).getField("filename").stringValue().replaceAll("markedup", "source");
      byProb.put(name, prob);
      res.put(name, e.getOutcome());
      if(e.getOutcome().equals("TRUE")) {
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

public class WekaClassifierConfFunctionTest {

    @Test
    public void testGetConf() throws Exception {
        BooleanFeatureSet<String> features = StringFeatures.featureSet;
        GISModel model = GIS.trainModel(
                new ListEventStream(StringFeatures.dataSet.getInstances()), 100, 0);
        OpenNlpConfFunction<String> conf = new OpenNlpConfFunction<String>(model, features);
        double janeConf = conf.getConf("jane");
        double ofConf = conf.getConf("of");
        System.out.println(ofConf);
View Full Code Here

Examples of opennlp.maxent.GISModel

public class OpenNlpClassifierConfFunctionTest {

    @Test
    public void testGetConf() throws Exception {
        BooleanFeatureSet<String> features = StringFeatures.featureSet;
        GISModel model = GIS.trainModel(
                new ListEventStream(StringFeatures.dataSet.getInstances()), 100, 0);
        OpenNlpConfFunction<String> conf = new OpenNlpConfFunction<String>(model, features);
        double janeConf = conf.getConf("jane");
        double ofConf = conf.getConf("of");
        System.out.println(ofConf);
View Full Code Here

Examples of opennlp.maxent.GISModel

        InputStream in = new FileInputStream(args[0]);
        LabeledBinaryExtractionReader reader = new LabeledBinaryExtractionReader(
                in);
        ReVerbOpenNlpClassifierTrainer trainer = new ReVerbOpenNlpClassifierTrainer(
                reader.readExtractions());
        GISModel model = trainer.getModel();

        File outputFile = new File(args[1]);
        GISModelWriter writer = new SuffixSensitiveGISModelWriter(model, outputFile);
        writer.persist();
    }
View Full Code Here

Examples of opennlp.maxent.GISModel

     * @throws IOException
     */
    public ReVerbOpenNlpConfFunction(URL url) throws IOException {
        InputStream is = url.openStream();
        try {
            GISModel model;
            try {
                model = (GISModel) new PlainTextGISModelReader(
                        new BufferedReader(new InputStreamReader(
                                new GZIPInputStream(is)))).getModel();
            } catch (Exception e) {
View Full Code Here

Examples of opennlp.maxent.GISModel

      EventStream eventStream = new SDEventStream(samples,
          factory.createSentenceContextGenerator(languageCode),
          factory.createEndOfSentenceScanner(languageCode));
     
      HashSumEventStream hses = new HashSumEventStream(eventStream);
      GISModel sentModel = GIS.trainModel(hses, iterations, cutoff);

      manifestInfoEntries.put(BaseModel.TRAINING_EVENTHASH_PROPERTY,
          hses.calculateHashSum().toString(16));
     
      return new SentenceModel(languageCode, sentModel,
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.