Package ivory.core

Examples of ivory.core.ConfigurationException


      PotentialFunction f = clz.newInstance();
      f.configure(env, functionNode);

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


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

    conf.set(Constants.QueriesPath, cmdline.getOptionValue(Constants.QueriesPath));

    NodeList list = d.getElementsByTagName(Constants.QueryType);
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

    // read instances
    int rowNum = 0;
    while((line = in.readLine()) != null) {
      String [] fvals = line.split("\t");
      if(fvals.length != numCols) {
        throw new ConfigurationException("Line -- " + line + " has the incorrect number of columns! "+fvals.length+" "+numCols);
      }
   
      queryIds[rowNum] = new String(fvals[qidCol]);
      docIds[rowNum] = new String(fvals[docidCol]);
      grades[rowNum] = Float.parseFloat(fvals[gradeCol]);
View Full Code Here

    parseParameters(args);
    loadRetrievalEnv();
    try {
      docnoMapping = RetrievalEnvironment.loadDocnoMapping(indexPath, fs);
    } catch (IOException e) {
      throw new ConfigurationException("Failed to load Docnomapping: " + e.getMessage());
    }

    // Load static concept importance models
    for (Map.Entry<String, Node> n : importanceModels.entrySet()) {
      ConceptImportanceModel m = ConceptImportanceModel.get(n.getValue());
      env.addImportanceModel(n.getKey(), m);
    }

    // Load static docscores (e.g., spam score, PageRank, etc.).
    for (Map.Entry<String, Node> n : docscores.entrySet()) {
      String type = XMLTools.getAttributeValue(n.getValue(), "type", "");
      String provider = XMLTools.getAttributeValue(n.getValue(), "provider", "");
      String path = n.getValue().getTextContent();

      if (type.equals("") || provider.equals("") || path.equals("")) {
        throw new ConfigurationException("Invalid docscore!");
      }

      LOG.info("Loading docscore: type=" + type + ", provider=" + provider + ", path=" + path);
      env.loadDocScore(type, provider, path);
    }
View Full Code Here

  protected void loadRetrievalEnv() throws ConfigurationException {
    try {
      env = new RetrievalEnvironment(indexPath, fs);
      env.initialize(true);
    } catch (IOException e) {
      throw new ConfigurationException("Failed to instantiate RetrievalEnvironment: "
          + e.getMessage());
    }
  }
View Full Code Here

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

      parseQueries(d);
      parseImportanceModels(d);
      parseModels(d);
      parseStopwords(d);
      parseIndexLocation(d);
      parseDocscores(d);
      parseJudgments(d);
    }

    // Make sure we have some queries to run.
    if (queries.isEmpty()) {
      throw new ConfigurationException("Must specify at least one query!");
    }

    // Make sure there are models that need evaluated.
    if (models.isEmpty()) {
      throw new ConfigurationException("Must specify at least one model!");
    }

    // Make sure we have an index to run against.
    if (indexPath == null) {
      throw new ConfigurationException("Must specify an index!");
    }
  }
View Full Code Here

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

      String id = XMLTools.getAttributeValueOrThrowException(node, "id",
          "Must specify an id for every importancemodel!");

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

      NodeList children = node.getChildNodes();
      for (int j = 0; j < children.getLength(); j++) {
        Node child = children.item(j);
        if ("expander".equals(child.getNodeName())) {
          if (expanders.containsKey(id)) {
            throw new ConfigurationException("Only one expander allowed per model!");
          }
          expanders.put(id, child);
        }
      }

      // Add model to internal map.
      if (models.get(id) != null) {
        throw new ConfigurationException(
            "Duplicate model ids not allowed! Already parsed model with id=" + id);
      }
      models.put(id, node);
    }
  }
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.