info.ephyra.search.searchers
Class WorldFactbookKA

java.lang.Object
  extended by java.lang.Thread
      extended by info.ephyra.search.searchers.Searcher
          extended by info.ephyra.search.searchers.KnowledgeAnnotator
              extended by info.ephyra.search.searchers.WorldFactbookKA
All Implemented Interfaces:
java.lang.Runnable

public class WorldFactbookKA
extends KnowledgeAnnotator

A KnowledgeAnnotator for the CIA World Factbook. It answers a question about a country by extracting the information from the web page for that country.

It runs as a separate thread, so several queries can be performed in parallel.

This class extends the class KnowledgeAnnotator.

Version:
2005-09-29
Author:
Nico Schlaefer

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  java.util.Hashtable<java.lang.String,java.lang.String> countries
          Country names and corresponding web pages.
private static java.lang.String URL
          The URL of the CIA World Factbook.
 
Fields inherited from class info.ephyra.search.searchers.KnowledgeAnnotator
index, matcher, name, qContents, qPatterns
 
Fields inherited from class info.ephyra.search.searchers.Searcher
query, results
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
  WorldFactbookKA(java.lang.String filename)
          Creates a WorldFactbookKA and calls the constructor of the superclass that reads the question patterns from a file.
protected WorldFactbookKA(java.lang.String name, java.util.ArrayList<java.util.regex.Pattern> qPatterns, java.util.ArrayList<java.lang.String> qContents)
          Protected constructor used by the getCopy() method.
 
Method Summary
protected  Result[] doSearch()
          Searches the World Factbook for country details and returns an array containing a single Result object or an empty array, if the search failed.
 KnowledgeAnnotator getCopy()
          Returns a new instance of WorldFactbookKA.
 
Methods inherited from class info.ephyra.search.searchers.KnowledgeAnnotator
getContent, getKAName, getResult, matches, start
 
Methods inherited from class info.ephyra.search.searchers.Searcher
run
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

URL

private static final java.lang.String URL
The URL of the CIA World Factbook.

See Also:
Constant Field Values

countries

private java.util.Hashtable<java.lang.String,java.lang.String> countries
Country names and corresponding web pages.

Constructor Detail

WorldFactbookKA

protected WorldFactbookKA(java.lang.String name,
                          java.util.ArrayList<java.util.regex.Pattern> qPatterns,
                          java.util.ArrayList<java.lang.String> qContents)
Protected constructor used by the getCopy() method.

Parameters:
name - name of the KnowledgeAnnotator
qPatterns - question patterns
qContents - descriptors of the relevant content of a question

WorldFactbookKA

public WorldFactbookKA(java.lang.String filename)
                throws java.io.IOException

Creates a WorldFactbookKA and calls the constructor of the superclass that reads the question patterns from a file.

Furthermore, a list of the available countries and the URLs of the corresponding web pages are retrieved from the Factbook.

Parameters:
filename - file containing the question patterns
Throws:
java.io.IOException
Method Detail

doSearch

protected Result[] doSearch()
Searches the World Factbook for country details and returns an array containing a single Result object or an empty array, if the search failed.

Specified by:
doSearch in class Searcher
Returns:
array containing a single Result or an empty array

getCopy

public KnowledgeAnnotator getCopy()
Returns a new instance of WorldFactbookKA. A new instance is created for each query.

Specified by:
getCopy in class KnowledgeAnnotator
Returns:
new instance of WorldFactbookKA