Пример #1
0
  /**
   * Creates the vocabulary related to the given category. This vocabulary is composed by the terms
   * that appears in the category articles and its frequency.
   *
   * @param category The category.
   * @return The vocabulary related to the category.
   * @throws WikiApiException
   */
  public DomainVocabulary createCategoryVocabulary(Category category) throws WikiApiException {
    CHK.CHECK_NOT_NULL(category);
    Locale language = new Locale(wiki.getLanguage().name());
    DomainVocabulary vocabulary = new DomainVocabulary(language);
    HashSet<Page> pages = null;
    pages = (HashSet<Page>) category.getArticles();
    for (Page page : pages) {
      String text = wiki.getParsedArticle(page.getPageId()).getText();
      vocabulary.addTerms(text);
    }

    return vocabulary;
  }
Пример #2
0
 /**
  * Loads a category from Wikipedia by its title.
  *
  * @param title Title of the category to load.
  * @return The category if it exists. {@code null} if any category exists with that name.
  */
 public Category loadCategory(String title) {
   Category cat;
   try {
     cat = wiki.getCategory(title);
   } catch (WikiApiException e) {
     cat = null;
   }
   return cat;
 }
Пример #3
0
 /**
  * Loads a category from Wikipedia by its page ID.
  *
  * @param ID Identifier of the category to load.
  * @return The category if it exists. {@code null} if any category exists with that ID.
  */
 public Category loadCategory(int ID) {
   return wiki.getCategory(ID);
 }
Пример #4
0
 public Locale getLocale() {
   return new Locale(wiki.getLanguage().name());
 }