Package org.maltparserx.parser.guide

Examples of org.maltparserx.parser.guide.GuideException


    return getAtomicModel().extract();
  }
 
  private AtomicModel getAtomicModel() throws MaltChainedException {
    if (getGuide().getGuideMode() == ClassifierGuide.GuideMode.BATCH) {
      throw new GuideException("Can only predict during parsing. ");
    } else if (!(divideFeature.getFeatureValue() instanceof SingleFeatureValue)) {
      throw new GuideException("The divide feature does not have a single value. ");
    }
   
    if (divideModels != null && divideModels.containsKey(((SingleFeatureValue)divideFeature.getFeatureValue()).getIndexCode())) {
      return divideModels.get(((SingleFeatureValue)divideFeature.getFeatureValue()).getIndexCode());
    } else if (masterModel != null && masterModel.getFrequency() > 0) {
View Full Code Here


   * @throws MaltChainedException
   */
  protected void initSplitParam(FeatureVector featureVector) throws MaltChainedException {
    if (getGuide().getConfiguration().getOptionValue("guide", "data_split_column") == null
        || getGuide().getConfiguration().getOptionValue("guide", "data_split_column").toString().length() == 0) {
      throw new GuideException("The option '--guide-data_split_column' cannot be found, when initializing the data split. ");
    }
    if (getGuide().getConfiguration().getOptionValue("guide", "data_split_structure") == null
        || getGuide().getConfiguration().getOptionValue("guide", "data_split_structure").toString().length() == 0) {
      throw new GuideException("The option '--guide-data_split_structure' cannot be found, when initializing the data split. ");
    }
    try {
      final String spec = "InputColumn(" + getGuide().getConfiguration().getOptionValue("guide", "data_split_column").toString().trim()+
              ", "+getGuide().getConfiguration().getOptionValue("guide", "data_split_structure").toString().trim() +")";
      divideFeature = featureVector.getFeatureModel().identifyFeature(spec);
    } catch (FeatureException e) {
      throw new GuideException("The data split feature 'InputColumn("+getGuide().getConfiguration().getOptionValue("guide", "data_split_column").toString()+", "+getGuide().getConfiguration().getOptionValue("guide", "data_split_structure").toString()+") cannot be initialized. ", e);
    }
    if (!(divideFeature instanceof Modifiable)) {
      throw new GuideException("The data split feature 'InputColumn("+getGuide().getConfiguration().getOptionValue("guide", "data_split_column").toString()+", "+getGuide().getConfiguration().getOptionValue("guide", "data_split_structure").toString()+") does not implement Modifiable interface. ");
    }
    divideFeatureIndexVector = new ArrayList<Integer>();
    for (int i = 0; i < featureVector.size(); i++) {
      if (featureVector.get(i).equals(divideFeature)) {
        divideFeatureIndexVector.add(i);
      }
    }
   
//    if ((Boolean)getGuide().getConfiguration().getOptionValue("malt0.4", "behavior") == true) {
//      /* MaltParser 0.4 removes the divide feature for all divide models. For the "Sum-up" model or
//       * master model adds the divide feature in the end of the feature vector.
//       */
//      masterFeatureVector = (FeatureVector)featureVector.clone();
//      for (Integer i : divideFeatureIndexVector) {
//        masterFeatureVector.remove(masterFeatureVector.get(i));
//      }
//      for (Integer i : divideFeatureIndexVector) {
//        masterFeatureVector.add(featureVector.get(i));
//      }
//   
//      divideFeatureVector = (FeatureVector)featureVector.clone();
//      for (Integer i : divideFeatureIndexVector) {
//        divideFeatureVector.remove(divideFeatureVector.get(i));
//      }
//    } else {
      masterFeatureVector = featureVector;
      divideFeatureVector = (FeatureVector)featureVector.clone();
      for (Integer i : divideFeatureIndexVector) {
        divideFeatureVector.remove(divideFeatureVector.get(i));
      }
//    }
    try {
      if (getGuide().getConfiguration().getOptionValue("guide", "data_split_threshold").toString() != null) {
        divideThreshold = Integer.parseInt(getGuide().getConfiguration().getOptionValue("guide", "data_split_threshold").toString());
      } else {
        divideThreshold = 0;
      }
    } catch (NumberFormatException e) {
      throw new GuideException("The --guide-data_split_threshold option is not an integer value. ", e);
    }
  }
View Full Code Here

          out.write(divideModel.getIndex() + "\t" + divideModel.getFrequency() + "\n");
            }
      }
      out.close();
    } catch (IOException e) {
      throw new GuideException("Could not write to the guide model settings file '"+getModelName()+".dsm"+"', when " +
          "saving the guide model settings to file. ", e);
    }
  }
View Full Code Here

      while(true) {
        String line = in.readLine();
        if(line == null) break;
        String[] cols = tabPattern.split(line);
        if (cols.length != 2) {
          throw new GuideException("");
        }
        int code = -1;
        int freq = 0;
        try {
          code = Integer.parseInt(cols[0]);
          freq = Integer.parseInt(cols[1]);
        } catch (NumberFormatException e) {
          throw new GuideException("Could not convert a string value into an integer value when loading the feature divide model settings (.fsm). ", e);
        }
        if (code == -1) {
          masterModel = new AtomicModel(-1, masterFeatureVector, this);
          masterModel.setFrequency(freq);
        } else if (divideModels != null) {
          divideModels.put(code, new AtomicModel(code, divideFeatureVector, this));
          divideModels.get(code).setFrequency(freq);
        }
        setFrequency(getFrequency()+freq);
      }
      in.close();
    } catch (IOException e) {
      throw new GuideException("Could not read from the guide model settings file '"+getModelName()+".dsm"+"', when " +
          "loading the guide model settings. ", e);
   
  }
View Full Code Here

  public String getModelName() throws MaltChainedException {
    try {
      return parent.getModelName();
    } catch (NullPointerException e) {
      throw new GuideException("The parent guide model cannot be found. ", e);
    }
  }
View Full Code Here

    if (getGuide().getGuideMode() == ClassifierGuide.GuideMode.BATCH && index == -1 && getGuide().getConfiguration().getConfigurationDir().getInfoFileWriter() != null) {
      try {
        getGuide().getConfiguration().getConfigurationDir().getInfoFileWriter().write(method.toString());
        getGuide().getConfiguration().getConfigurationDir().getInfoFileWriter().flush();
      } catch (IOException e) {
        throw new GuideException("Could not write learner settings to the information file. ", e);
      }
    }
  }
View Full Code Here

 
  public void addInstance(SingleDecision decision) throws MaltChainedException {
    try {
      method.addInstance(decision, featureVector);
    } catch (NullPointerException e) {
      throw new GuideException("The learner cannot be found. ", e);
    }
  }
View Full Code Here

 
  public void noMoreInstances() throws MaltChainedException {
    try {
      method.noMoreInstances();
    } catch (NullPointerException e) {
      throw new GuideException("The learner cannot be found. ", e);
    }
  }
View Full Code Here

 
  public void finalizeSentence(DependencyStructure dependencyGraph) throws MaltChainedException {
    try {
      method.finalizeSentence(dependencyGraph);
    } catch (NullPointerException e) {
      throw new GuideException("The learner cannot be found. ", e);
    }
  }
View Full Code Here

//      if (getGuide().getGuideMode() == ClassifierGuide.GuideMode.BATCH) {
//        throw new GuideException("Cannot predict during batch training. ");
//      }
      return method.predict(featureVector, decision);
    } catch (NullPointerException e) {
      throw new GuideException("The learner cannot be found. ", e);
    }
  }
View Full Code Here

TOP

Related Classes of org.maltparserx.parser.guide.GuideException

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.