Package org.maltparserx.parser.guide

Examples of org.maltparserx.parser.guide.GuideException


    }
  }
 
  public void noMoreInstances() throws MaltChainedException {
    if (guide.getGuideMode() == ClassifierGuide.GuideMode.CLASSIFY) {
      throw new GuideException("The decision model could not create it's model. ");
    }
    if (instanceModel != null) {
      instanceModel.noMoreInstances();
      instanceModel.train();
    }
View Full Code Here


    }
  }
 
  public void addInstance(GuideDecision decision) throws MaltChainedException {
    if (decision instanceof SingleDecision) {
      throw new GuideException("A sequantial decision model expect a sequence of decisions, not a single decision. ");
    }
    featureModel.update();
    final SingleDecision singleDecision = ((MultipleDecision)decision).getSingleDecision(decisionIndex);
    if (instanceModel == null) {
      initInstanceModel(singleDecision.getTableContainer().getTableContainerName());
View Full Code Here

    }
  }
 
  public boolean predict(GuideDecision decision) throws MaltChainedException {
    if (decision instanceof SingleDecision) {
      throw new GuideException("A sequantial decision model expect a sequence of decisions, not a single decision. ");
    }
    featureModel.update();
    final SingleDecision singleDecision = ((MultipleDecision)decision).getSingleDecision(decisionIndex);
    if (instanceModel == null) {
      initInstanceModel(singleDecision.getTableContainer().getTableContainerName());
View Full Code Here

    return success;
  }
 
  public FeatureVector predictExtract(GuideDecision decision) throws MaltChainedException {
    if (decision instanceof SingleDecision) {
      throw new GuideException("A sequantial decision model expect a sequence of decisions, not a single decision. ");
    }
    featureModel.update();
    final SingleDecision singleDecision = ((MultipleDecision)decision).getSingleDecision(decisionIndex);
    if (instanceModel == null) {
      initInstanceModel(singleDecision.getTableContainer().getTableContainerName());
View Full Code Here

    return instanceModel.extract(); // TODO handle many feature vectors
  }
 
  public boolean predictFromKBestList(GuideDecision decision) throws MaltChainedException {
    if (decision instanceof SingleDecision) {
      throw new GuideException("A sequantial decision model expect a sequence of decisions, not a single decision. ");
    }
   
    boolean success = false;
    final SingleDecision singleDecision = ((MultipleDecision)decision).getSingleDecision(decisionIndex);
    // TODO develop different strategies for resolving which kBestlist that should be used
View Full Code Here

    } else if (decision.getRelationToNextDecision() == RelationToNextDecision.NONE) {
      decisionModelClass = org.maltparserx.parser.guide.decision.OneDecisionModel.class;
    }

    if (decisionModelClass == null) {
      throw new GuideException("Could not find an appropriate decision model for the relation to the next decision");
    }
   
    try {
      Class<?>[] argTypes = { org.maltparserx.parser.guide.ClassifierGuide.class, org.maltparserx.parser.guide.decision.DecisionModel.class,
                  java.lang.String.class };
      Object[] arguments = new Object[3];
      arguments[0] = getGuide();
      arguments[1] = this;
      arguments[2] = branchedDecisionSymbol;
      Constructor<?> constructor = decisionModelClass.getConstructor(argTypes);
      setNextDecisionModel((DecisionModel)constructor.newInstance(arguments));
    } catch (NoSuchMethodException e) {
      throw new GuideException("The decision model class '"+decisionModelClass.getName()+"' cannot be initialized. ", e);
    } catch (InstantiationException e) {
      throw new GuideException("The decision model class '"+decisionModelClass.getName()+"' cannot be initialized. ", e);
    } catch (IllegalAccessException e) {
      throw new GuideException("The decision model class '"+decisionModelClass.getName()+"' cannot be initialized. ", e);
    } catch (InvocationTargetException e) {
      throw new GuideException("The decision model class '"+decisionModelClass.getName()+"' cannot be initialized. ", e);
    }
  }
View Full Code Here

    }
  }
 
  public void addInstance(SingleDecision decision) throws MaltChainedException {
    if (getGuide().getGuideMode() == ClassifierGuide.GuideMode.CLASSIFY) {
      throw new GuideException("Can only add instance during learning. ");
    } else if (!(divideFeature.getFeatureValue() instanceof SingleFeatureValue)) {
      throw new GuideException("The divide feature does not have a single value. ");
    }
   
    divideFeature.update();
    if (divideModels != null) {
      if (!divideModels.containsKey(((SingleFeatureValue)divideFeature.getFeatureValue()).getIndexCode())) {
        divideModels.put(((SingleFeatureValue)divideFeature.getFeatureValue()).getIndexCode(), new AtomicModel(((SingleFeatureValue)divideFeature.getFeatureValue()).getIndexCode(), divideFeatureVector, this));
      }
      divideModels.get(((SingleFeatureValue)divideFeature.getFeatureValue()).getIndexCode()).addInstance(decision);
    } else {
      throw new GuideException("The feature divide models cannot be found. ");
    }
  }
View Full Code Here

        divideModels.remove(index);
      }
      masterModel.noMoreInstances();

    } else {
      throw new GuideException("The feature divide models cannot be found. ");
    }
  }
View Full Code Here

    if (divideModels != null) {
      for (AtomicModel divideModel : divideModels.values()) {
        divideModel.finalizeSentence(dependencyGraph);
      }
    } else {
      throw new GuideException("The feature divide models cannot be found. ");
    }
  }
View Full Code Here

    }
  }

  public boolean predict(SingleDecision decision) 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. ");
    }
   
    //divideFeature.update();
    if (divideModels != null && divideModels.containsKey(((SingleFeatureValue)divideFeature.getFeatureValue()).getIndexCode())) {
      return divideModels.get(((SingleFeatureValue)divideFeature.getFeatureValue()).getIndexCode()).predict(decision);
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.