Package com.clearnlp.classification.model

Examples of com.clearnlp.classification.model.StringModel


   * @param labelCutoff the label count cutoff (exclusive).
   * @param featureCutoff the feature count cutoff (exclusive).
   */
  public StringTrainSpace(boolean hasWeight, int labelCutoff, int featureCutoff)
  {
    super(new StringModel(), hasWeight);
   
    s_model     = (StringModel)m_model;
    l_cutoff    = labelCutoff;
    f_cutoff    = featureCutoff;
    s_instances = Lists.newArrayList();
View Full Code Here


  {
    BufferedReader    fin = UTInput.createBufferedFileReader(testFile);
    PrintStream      fout = UTOutput.createPrintBufferedFileStream(outputFile);
    ObjectInputStream  in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(modelFile)));
    SparseModel    pModel = null;
    StringModel    sModel = null;
   
    switch (vectorType)
    {
    case AbstractTrainSpace.VECTOR_SPARSE:
      pModel = (SparseModel)in.readObject(); break;
    case AbstractTrainSpace.VECTOR_STRING:
      sModel = (StringModel)in.readObject(); break;
    }
   
    in.close();
   
    boolean hasWeight = AbstractTrainSpace.hasWeight(vectorType, testFile);
    int correct = 0, total = 0;
    StringPrediction r = null;
    String line, label = null;
   
    System.out.print("Predicting");
   
    while ((line = fin.readLine()) != null)
    {
      if (vectorType == AbstractTrainSpace.VECTOR_SPARSE)
      {
        Pair<String,SparseFeatureVector> sp = SparseTrainSpace.toInstance(line, hasWeight);
        r = pModel.predictBest(sp.o2);
        label = sp.o1;
      }
      else
      {
        StringInstance ss = StringTrainSpace.toInstance(line, hasWeight);
        r = sModel.predictBest(ss.getFeatureVector());
        label = ss.getLabel();
      }
     
      fout.println(r.label+" "+r.score);
      if (r.label.equals(label))  correct++;
View Full Code Here

   * @param labelCutoff the label count cutoff (exclusive).
   * @param featureCutoff the feature count cutoff (exclusive).
   */
  public StringTrainSpace(boolean hasWeight, int labelCutoff, int featureCutoff)
  {
    super(new StringModel(), hasWeight);
   
    s_model     = (StringModel)m_model;
    l_cutoff    = labelCutoff;
    f_cutoff    = featureCutoff;
    s_instances = Lists.newArrayList();
View Full Code Here

  {
    BufferedReader    fin = UTInput.createBufferedFileReader(testFile);
    PrintStream      fout = UTOutput.createPrintBufferedFileStream(outputFile);
    ObjectInputStream  in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(modelFile)));
    SparseModel    pModel = null;
    StringModel    sModel = null;
   
    switch (vectorType)
    {
    case AbstractTrainSpace.VECTOR_SPARSE:
      pModel = (SparseModel)in.readObject(); break;
    case AbstractTrainSpace.VECTOR_STRING:
      sModel = (StringModel)in.readObject(); break;
    }
   
    in.close();
   
    boolean hasWeight = AbstractTrainSpace.hasWeight(vectorType, testFile);
    int correct = 0, total = 0;
    StringPrediction r = null;
    String line, label = null;
   
    System.out.print("Predicting");
   
    while ((line = fin.readLine()) != null)
    {
      if (vectorType == AbstractTrainSpace.VECTOR_SPARSE)
      {
        Pair<String,SparseFeatureVector> sp = SparseTrainSpace.toInstance(line, hasWeight);
        r = pModel.predictBest(sp.o2);
        label = sp.o1;
      }
      else
      {
        StringInstance ss = StringTrainSpace.toInstance(line, hasWeight);
        r = sModel.predictBest(ss.getFeatureVector());
        label = ss.getLabel();
      }
     
      fout.println(r.label+" "+r.score);
      if (r.label.equals(label))  correct++;
View Full Code Here

TOP

Related Classes of com.clearnlp.classification.model.StringModel

Copyright © 2018 www.massapicom. 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.