Package ivory.core.exception

Examples of ivory.core.exception.ConfigurationException


    Preconditions.checkNotNull(model);

    // Get model type.
    String modelType = XMLTools.getAttributeValue(model, "type", null);
    if (modelType == null) {
      throw new ConfigurationException("Model type must be specified!");
    }

    // Dynamically construct importance model.
    ConceptImportanceModel importanceModel = null;
    try {
      Class<? extends ConceptImportanceModel> clz =
        (Class<? extends ConceptImportanceModel>) Class.forName(modelType);
      importanceModel = clz.newInstance();
      importanceModel.configure(model);
    } catch (Exception e) {
      throw new ConfigurationException("Error instantiating ConceptImportanceModel! " + e);
    }

    return importanceModel;
  }
View Full Code Here


        // collection_freq, document_freq, clue_cf, or enwiki_cf
        String metaFeatureName = XMLTools.getAttributeValue(child, "id", "");
        float metaFeatureWeight = XMLTools.getAttributeValue(child, "weight", -1.0f);

        if (metaFeatureName == "" || metaFeatureWeight == -1) {
          throw new ConfigurationException("Must specify metafeature name and weight.");
        }

        MetaFeature mf = new MetaFeature(metaFeatureName, metaFeatureWeight);
        metafeatures.add(mf);

        totalMetaFeatureWeight += metaFeatureWeight;

        String file = XMLTools.getAttributeValue(child, "file", null);
        if (file == null) {
          throw new ConfigurationException(
              "Must specify the location of the metafeature stats file.");
        }

        try {
          metafeatureValues.put(mf, readDataStats(file));
View Full Code Here

      ExpressionGenerator f = clz.newInstance();
      f.configure(domNode);

      return f;
    } catch (Exception e) {
      throw new ConfigurationException(
          "Unable to instantiate ExpressionGenerator \"" + type + "\"!", e);
    }
  }
View Full Code Here

      } else if ("GreedyConstrained".equals(modelType)) {
        builder = new GreedyConstrainedMRFBuilder(env, model);
      } else if (modelType.equals("New")) {
        builder = new CascadeFeatureBasedMRFBuilder(env, model);
      } else {
        throw new ConfigurationException("Unrecognized model type: " + modelType);
      }
    } catch (IOException e) {
      throw new RetrievalException("Error getting MRFBuilder: " + e);
    }
View Full Code Here

   * ConfigurationException with the specified message.
   */
  public static String getAttributeValueOrThrowException(Node node, String name, String errMsg)
      throws ConfigurationException {
    if (node == null || !node.hasAttributes()) {
      throw new ConfigurationException(errMsg);
    }

    NamedNodeMap attributes = node.getAttributes();
    if (attributes.getNamedItem(name) == null) {
      throw new ConfigurationException(errMsg);
    }

    return attributes.getNamedItem(name).getNodeValue();
  }
View Full Code Here

        builder = MRFBuilder.get(env, child);
      }
    }

    if (builder == null) {
      throw new ConfigurationException(
          "ConstrainedMRFBuilder is missing required constrainedModel node!");
    }
  }
View Full Code Here

    // Initialize clique set.
    clearCliques();

    if ("sequential".equals(dependenceType)) {
      throw new ConfigurationException(
          "Unsupported operation: there are no unordered cliques within a sequentially dependent graph.");
    } else if ("full".equals(dependenceType)) {
      addCliques(CliqueFactory.getFullDependenceCliques(env, queryTerms, domNode, false,
          docDependent));
    } else {
      throw new ConfigurationException("Unrecognized UnorderedCliqueSet type: " + dependenceType);
    }
  }
View Full Code Here

      CliqueSet f = clz.newInstance();
      f.configure(env, queryTerms, domNode);

      return f;
    } catch (Exception e) {
      throw new ConfigurationException("Unable to instantiate CliqueSet type " + type, e);
    }
  }
View Full Code Here

          docDependent));
    } else if ("full".equals(dependenceType)) {
      addCliques(CliqueFactory.getFullDependenceCliques(env, queryTerms, domNode, true,
          docDependent));
    } else {
      throw new ConfigurationException(
          "Unrecognized OrderedCliqueSet type \"" + dependenceType + "\"!");
    }
  }
View Full Code Here

        }
      }

      // Make sure there's at least one expansion model specified.
      if (scoreFunctionNodes.size() == 0) {
        throw new ConfigurationException("No conceptscore specified!");
      }

      // Create the expander.
      expander = new UnigramLatentConceptExpander(env, fbDocs, fbTerms, expanderWeight, parameters,
          scoreFunctionNodes, importanceModels);

      // Maximum number of candidate expansion terms to consider per query.
      int maxCandidates = XMLTools.getAttributeValue(model, "maxCandidates", 0);
      if (maxCandidates > 0) {
        expander.setMaxCandidates(maxCandidates);
      }
    } else if ("latentconcept".equals(normExpanderType)) {
      int defaultFbDocs = XMLTools.getAttributeValue(model, "fbDocs", 10);
      int defaultFbTerms = XMLTools.getAttributeValue(model, "fbTerms", 10);

      List<Integer> gramList = new ArrayList<Integer>();
      List<MRFBuilder> builderList = new ArrayList<MRFBuilder>();
      List<Integer> fbDocsList = new ArrayList<Integer>();
      List<Integer> fbTermsList = new ArrayList<Integer>();

      // Get the expandermodel, which describes how to actually build the expanded MRF.
      NodeList children = model.getChildNodes();
      for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        if ("expansionmodel".equals(child.getNodeName())) {
          int gramSize = XMLTools.getAttributeValue(child, "gramSize", 1);
          int fbDocs = XMLTools.getAttributeValue(child, "fbDocs", defaultFbDocs);
          int fbTerms = XMLTools.getAttributeValue(child, "fbTerms", defaultFbTerms);

          // Set MRF builder parameters.
          gramList.add(gramSize);
          builderList.add(MRFBuilder.get(env, child));
          fbDocsList.add(fbDocs);
          fbTermsList.add(fbTerms);
        }
      }

      // Make sure there's at least one expansion model specified.
      if (builderList.size() == 0) {
        throw new ConfigurationException("No expansionmodel specified!");
      }

      // Create the expander.
      expander = new NGramLatentConceptExpander(env, gramList, builderList, fbDocsList,
          fbTermsList);

      // Maximum number of candidate expansion terms to consider per query.
      int maxCandidates = XMLTools.getAttributeValue(model, "maxCandidates", 0);
      if (maxCandidates > 0) {
        expander.setMaxCandidates(maxCandidates);
      }
    } else {
      throw new ConfigurationException("Unrecognized expander type -- " + expanderType);
    }

    return expander;
  }
View Full Code Here

TOP

Related Classes of ivory.core.exception.ConfigurationException

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.