Package ivory.core

Examples of ivory.core.ConfigurationException


    Document d = null;

    try {
      d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(fs.open(new Path(qfile)));
    } catch (SAXException e) {
      throw new ConfigurationException(e.getMessage());
    } catch (IOException e) {
      throw new ConfigurationException(e.getMessage());
    } catch (ParserConfigurationException e) {
      throw new ConfigurationException(e.getMessage());
    }

    Map<String, String> queries = Maps.newLinkedHashMap();
    NodeList queryNodes = d.getElementsByTagName("query");

    LOG.info("Parsing "+queryNodes.getLength()+" nodes...");
    for (int i = 0; i < queryNodes.getLength(); i++) {
      // Get query XML node.
      Node node = queryNodes.item(i);

      // Get query id.
      String qid = XMLTools.getAttributeValueOrThrowException(node, "id",
      "Must specify a query id attribute for every query!");

      // Get query text.
      String queryText = node.getTextContent();

      // Add query to internal map.
      if (queries.get(qid) != null) {
        throw new ConfigurationException(
            "Duplicate query ids not allowed! Already parsed query with id=" + qid);
      }
      queries.put(qid, queryText);
    }
View Full Code Here


    Document d = null;

    try {
      d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(fs.open(new Path(qfile)));
    } catch (SAXException e) {
      throw new ConfigurationException(e.getMessage());
    } catch (IOException e) {
      throw new ConfigurationException(e.getMessage());
    } catch (ParserConfigurationException e) {
      throw new ConfigurationException(e.getMessage());
    }

    Map<String, String> grammarPaths = Maps.newLinkedHashMap();
    NodeList queryNodes = d.getElementsByTagName("query");

    LOG.info("Parsing "+queryNodes.getLength()+" nodes...");
    for (int i = 0; i < queryNodes.getLength(); i++) {
      // Get query XML node.
      Node node = queryNodes.item(i);

      // Get query id.
      String qid = XMLTools.getAttributeValueOrThrowException(node, "id",
      "Must specify a query id attribute for every query!");

      String grammar = XMLTools.getAttributeValue(node, "grammar");

      // Add query to internal map.
      if (grammarPaths.get(qid) != null) {
        throw new ConfigurationException(
            "Duplicate query ids not allowed! Already parsed query with id=" + qid);
      }
      grammarPaths.put(qid, grammar);
    }
View Full Code Here

      f.configure(functionNode);

      return f;
    } catch (Exception e) {
      e.printStackTrace();
      throw new ConfigurationException(
          "Unable to instantiate scoring function \"" + functionType + "\"!", e);
    }
  }
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

    // 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

    Document d = null;

    try {
      d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(fs.open(new Path(qfile)));
    } catch (SAXException e) {
      throw new ConfigurationException(e.getMessage());
    } catch (IOException e) {
      throw new ConfigurationException(e.getMessage());
    } catch (ParserConfigurationException e) {
      throw new ConfigurationException(e.getMessage());
    }

    Map<String, String> queries = Maps.newLinkedHashMap();
    NodeList queryNodes = d.getElementsByTagName("query");

    LOG.info("Parsing "+queryNodes.getLength()+" nodes...");
    for (int i = 0; i < queryNodes.getLength(); i++) {
      // Get query XML node.
      Node node = queryNodes.item(i);

      // Get query id.
      String qid = XMLTools.getAttributeValueOrThrowException(node, "id",
      "Must specify a query id attribute for every query!");

      // Get query text.
      String queryText = node.getTextContent();

      // Add query to internal map.
      if (queries.get(qid) != null) {
        throw new ConfigurationException(
            "Duplicate query ids not allowed! Already parsed query with id=" + qid);
      }
      queries.put(qid, queryText);
    }
  
View Full Code Here

TOP

Related Classes of ivory.core.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.