gpt4 book ai didi

de.tudarmstadt.ukp.wikipedia.api.exception.WikiApiException.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 17:39:05 28 4
gpt4 key购买 nike

本文整理了Java中de.tudarmstadt.ukp.wikipedia.api.exception.WikiApiException.<init>()方法的一些代码示例,展示了WikiApiException.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WikiApiException.<init>()方法的具体详情如下:
包路径:de.tudarmstadt.ukp.wikipedia.api.exception.WikiApiException
类名称:WikiApiException
方法名:<init>

WikiApiException.<init>介绍

暂无

代码示例

代码示例来源:origin: dkpro/dkpro-jwpl

/**
 * Serializes the graph to the given destination.
 * @param destination The destination to which should be saved.
 * @throws WikiApiException Thrown if errors occurred.
 */
public void saveGraph(String destination) throws WikiApiException {
  try {
    GraphSerialization.saveGraph(graph, destination);
  } catch (IOException e) {
    throw new WikiApiException(e);
  }
}

代码示例来源:origin: dkpro/dkpro-jwpl

/**
 * Get infos only for a subset of articles.
 * @param pPages A set of pages. Only this subset of wiki pages is used in the info object.
 */
public WikipediaInfo(Iterable<Page> pPages) throws WikiApiException {
  if (pPages == null) {
    throw new WikiApiException("The page set has to be initialized.");
  }
  pages = pPages;
  averageFanOut = -1.0;   // lazy initialization => it is computed and stored when it is accessed
  degreeDistribution = new HashMap<Integer,Integer>();
  categorizedArticleSet = new HashSet<Integer>();
  // get number of pages
  numberOfPages = 0;
  while (pages.iterator().hasNext()) {
    numberOfPages++;
    pages.iterator().next();
  }
}

代码示例来源:origin: dkpro/dkpro-jwpl

public int getTaxonomicallyBoundPathLengthInNodes(Category cat1, Category cat2) throws WikiApiException {
  int retValue = getTaxonomicallyBoundPathLengthInEdges(cat1, cat2);
  if (retValue == 0) {
    return 0;
  }
  else if (retValue > 0) {
    return (--retValue);
  }
  else if (retValue == -1) {
    return -1;
  }
  else {
    throw new WikiApiException("Unknown return value.");
  }
}

代码示例来源:origin: dkpro/dkpro-jwpl

/**
 * Creates an {@link CategoryGraph} using a serialized DirectedGraph object.
 * @param pWiki A {@link Wikipedia} object.
 * @param location The location of the serialized graph
 * @throws WikiApiException Thrown if errors occurred.
 */
public CategoryGraph(Wikipedia pWiki, File location) throws WikiApiException{
  try {
    constructCategoryGraph(pWiki, GraphSerialization.loadGraph(location));
  } catch (IOException e) {
    throw new WikiApiException(e);
  } catch (ClassNotFoundException e) {
    throw new WikiApiException(e);
  }
}

代码示例来源:origin: dkpro/dkpro-jwpl

/**
 * Gets the path length between two category nodes - measured in "nodes".
 * @param node1 The first node.
 * @param node2 The second node.
 * @return The number of nodes of the path between node1 and node2. 0, if the nodes are identical or neighbors. -1, if no path exists.
 */
public int getPathLengthInNodes(Category node1, Category node2) throws WikiApiException {
  int retValue = getPathLengthInEdges(node1, node2);
  if (retValue == 0) {
    return 0;
  }
  else if (retValue > 0) {
    return (--retValue);
  }
  else if (retValue == -1) {
    return -1;
  }
  else {
    throw new WikiApiException("Unknown return value.");
  }
}

代码示例来源:origin: dkpro/dkpro-jwpl

private static CategoryGraph tryToLoadCategoryGraph(Wikipedia wiki, String wikiId, String size) throws WikiApiException {
  String defaultSerializedGraphLocation = getCategoryGraphSerializationFileName(wikiId, size);
  File defaulSerializedGraphFile = new File(defaultSerializedGraphLocation);
  if (defaulSerializedGraphFile.exists()) {
    try {
      logger.info("Loading category graph from " + defaultSerializedGraphLocation);
      return new CategoryGraph(wiki, GraphSerialization.loadGraph(defaultSerializedGraphLocation));
    } catch (IOException e) {
      throw new WikiApiException(e);
    } catch (ClassNotFoundException e) {
      throw new WikiApiException(e);
    }
  }
  else {
    return null;
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.wikipedia/de.tudarmstadt.ukp.wikipedia.revisionmachine

private Connection getConnection(RevisionAPIConfiguration config)
  throws WikiApiException
{
  Connection c;
  try {
    String driverDB = "com.mysql.jdbc.Driver";
    Class.forName(driverDB);
    c = DriverManager.getConnection(
        "jdbc:mysql://" + config.getHost() + "/" + config.getDatabase(),
        config.getUser(), config.getPassword());
    if (!c.isValid(5)) {
      throw new WikiApiException("Connection could not be established.");
    }
  }
  catch (SQLException e) {
    throw new WikiApiException(e);
  }
  catch (ClassNotFoundException e) {
    throw new WikiApiException(e);
  }
  return c;
}

代码示例来源:origin: dkpro/dkpro-jwpl

private Connection getConnection(Wikipedia wiki)
  throws WikiApiException
{
  DatabaseConfiguration config = wiki.getDatabaseConfiguration();
  Connection c;
  try {
    String driverDB = "com.mysql.jdbc.Driver";
    Class.forName(driverDB);
    c = DriverManager.getConnection("jdbc:mysql://" + config.getHost()
        + "/" + config.getDatabase()+"?autoReconnect=true", config.getUser(),
        config.getPassword());
    if (!c.isValid(5)) {
      throw new WikiApiException(
          "Connection could not be established.");
    }
  }
  catch (SQLException e) {
    throw new WikiApiException(e);
  }
  catch (ClassNotFoundException e) {
    throw new WikiApiException(e);
  }
  return c;
}

代码示例来源:origin: dkpro/dkpro-jwpl

/**
 * Helper method to obtain a connection via the given {@link RevisionAPIConfiguration} parameter.
 * @param config Must not be {@code null}.
 * @return A valid {@link Connection} to the database endpoint.
 * @throws WikiApiException Thrown if errors occurred while opening a connection.
 */
protected Connection getConnection(RevisionAPIConfiguration config) throws WikiApiException
{
  Connection c;
  try {
    String driverDB = config.getDatabaseDriver();
    Class.forName(driverDB);
    c = DriverManager.getConnection(config.getJdbcURL(), config.getUser(), config.getPassword());
    if (!c.isValid(5)) {
      throw new WikiApiException("Connection could not be established.");
    }
  }
  catch (SQLException | ClassNotFoundException e) {
    throw new WikiApiException(e);
  }
  return c;
}

代码示例来源:origin: dkpro/dkpro-jwpl

private static void saveCategoryGraph(CategoryGraph catGraph, String wikiId, String size) throws WikiApiException {
  String defaultSerializedGraphLocation = getCategoryGraphSerializationFileName(wikiId, size);
  try {
    logger.info("Saving category graph to " + defaultSerializedGraphLocation);
    GraphSerialization.saveGraph(catGraph.getGraph(), defaultSerializedGraphLocation);
  } catch (IOException e) {
    throw new WikiApiException(e);
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.similarity.algorithms/de.tudarmstadt.ukp.similarity.algorithms.wikipedia-asl

private int[] getCachedInlinkIds(Page article) throws WikiApiException {
  if (cache.isCacheEmpty()) {
    try {
      cache.fillInLinkCache();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      throw new WikiApiException(e);
    } catch (IOException e) {
      e.printStackTrace();
      throw new WikiApiException(e);
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      throw new WikiApiException(e);
    }
  }
  if (cache.cachedInLinks.containsKey(article.getPageId())) {
    return cache.cachedInLinks.get(article.getPageId()) ;
  }
  else {
    return new int[0] ;
  }
}

代码示例来源:origin: dkpro/dkpro-similarity

private int[] getCachedInlinkIds(Page article) throws WikiApiException {
  if (cache.isCacheEmpty()) {
    try {
      cache.fillInLinkCache();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      throw new WikiApiException(e);
    } catch (IOException e) {
      e.printStackTrace();
      throw new WikiApiException(e);
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      throw new WikiApiException(e);
    }
  }
  if (cache.cachedInLinks.containsKey(article.getPageId())) {
    return cache.cachedInLinks.get(article.getPageId()) ;
  }
  else {
    return new int[0] ;
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.wikipedia/de.tudarmstadt.ukp.wikipedia.revisionmachine

/**
 * (Constructor) Creates a new RevisionIterator object.
 *
 * @param config
 *            Reference to the configuration object
 *
 * @throws WikiApiException
 *             if an error occurs
 */
public RevisionIterator(final RevisionAPIConfiguration config)
  throws WikiApiException
{
  this.config = config;
  try {
    this.primaryKey = -1;
    this.endPK = Integer.MAX_VALUE;
    this.statement = null;
    this.result = null;
    this.previousRevision = null;
    MAX_NUMBER_RESULTS = config.getBufferSize();
    connect();
  }
  catch (SQLException e) {
    throw new WikiApiException(e);
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.wikipedia/de.tudarmstadt.ukp.wikipedia.revisionmachine

/**
 * (Constructor) Creates the IndexIterator object.
 * 
 * @param config
 *            Reference to the configuration
 * 
 * @throws WikiApiException
 *             if an error occurs
 */
public IndexIterator(final RevisionAPIConfiguration config)
  throws WikiApiException
{
  try {
    this.primaryKey = -1;
    this.statement = null;
    this.result = null;
    String driverDB = "com.mysql.jdbc.Driver";
    Class.forName(driverDB);
    MAX_NUMBER_RESULTS = config.getBufferSize();
    this.connection = DriverManager.getConnection("jdbc:mysql://"
        + config.getHost() + "/" + config.getDatabase(),
        config.getUser(), config.getPassword());
  }
  catch (SQLException e) {
    throw new WikiApiException(e);
  }
  catch (ClassNotFoundException e) {
    throw new WikiApiException(e);
  }
}

代码示例来源:origin: dkpro/dkpro-jwpl

/**
 * Intrinsic information content (Seco Etal. 2004) allows to compute information content from the structure of the taxonomy (no corpus needed).
 * IC(n) = 1 - log( hypo(n) + 1) / log(#cat)
 * hypo(n) is the (recursive) number of hyponyms of a node n. Recursive means that the hyponyms of hyponyms are also taken into account
 * #cat is the number of categories in the graph
 * @param category The category node for which the intrinsic information content should be returned.
 * @return The intrinsic information content for this category node.
 * @throws WikiApiException Thrown if errors occurred.
 */
public double getIntrinsicInformationContent(Category category) throws WikiApiException {
  int node = category.getPageId();
  int hyponymCount  = getHyponymCountMap().get(node);
  int numberOfNodes = this.getNumberOfNodes();
  if (hyponymCount > numberOfNodes) {
    throw new WikiApiException("Something is wrong with the hyponymCountMap. " + hyponymCount + " hyponyms, but only " + numberOfNodes + " nodes.");
  }
  logger.debug(category.getTitle().getPlainTitle() + " has # hyponyms: " + hyponymCount);
  double intrinsicIC = -1;
  if (hyponymCount >= 0) {
    intrinsicIC = (1 - ( Math.log(hyponymCount + 1) / Math.log(numberOfNodes) ) );
  }
  return intrinsicIC;
}

代码示例来源:origin: dkpro/dkpro-jwpl

/**
 * (Constructor) Creates the IndexIterator object.
 *
 * @param config
 *            Reference to the configuration
 *
 * @throws WikiApiException
 *             if an error occurs
 */
public IndexIterator(final RevisionAPIConfiguration config)
  throws WikiApiException
{
  try {
    this.primaryKey = -1;
    this.statement = null;
    this.result = null;
    String driverDB = "com.mysql.jdbc.Driver";
    Class.forName(driverDB);
    MAX_NUMBER_RESULTS = config.getBufferSize();
    this.connection = DriverManager.getConnection("jdbc:mysql://"
        + config.getHost() + "/" + config.getDatabase(),
        config.getUser(), config.getPassword());
  }
  catch (SQLException e) {
    throw new WikiApiException(e);
  }
  catch (ClassNotFoundException e) {
    throw new WikiApiException(e);
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.wikipedia/de.tudarmstadt.ukp.wikipedia.revisionmachine

throw new WikiApiException(e);
throw new WikiApiException(e);

代码示例来源:origin: de.tudarmstadt.ukp.wikipedia/de.tudarmstadt.ukp.wikipedia.revisionmachine

throw new WikiApiException(sql);
throw new WikiApiException(sql);

代码示例来源:origin: dkpro/dkpro-core

/**
   * a Returns CompiledPage produced by the SWEBLE parser using the SimpleWikiConfiguration.
   * 
   * @return the parsed page
   */
  private CompiledPage getCompiledPage(Page page)
    throws WikiApiException
  {
    CompiledPage cp;
    try {

      PageTitle pageTitle = PageTitle.make(config, page.getTitle());
      PageId pageId = new PageId(pageTitle, -1);

      // Compile the retrieved page
      cp = compiler.postprocess(pageId, page.getCurrentContent(), null);
    }
    catch (Exception e) {
      throw new WikiApiException(e);
    }
    return cp;
  }
}

代码示例来源:origin: dkpro/dkpro-jwpl

/**
 * Returns CompiledPage produced by the SWEBLE parser using the SimpleWikiConfiguration.
 *
 * @return the parsed page
 * @throws WikiApiException Thrown if errors occurred.
 */
private EngProcessedPage getCompiledPage() throws WikiApiException
{
  EngProcessedPage cp;
  try{
    WtEngineImpl engine = new WtEngineImpl(this.wiki.getWikConfig());
    PageTitle pageTitle = PageTitle.make(this.wiki.getWikConfig(), this.getTitle().toString());
    PageId pageId = new PageId(pageTitle, -1);
    // Compile the retrieved page
    cp = engine.postprocess(pageId, this.getText(), null);
  } catch(Exception e){
    throw new WikiApiException(e);
  }
  return cp;
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com