info.ephyra.questionanalysis
Class TermExpander

java.lang.Object
  extended by info.ephyra.questionanalysis.TermExpander

public class TermExpander
extends java.lang.Object

Expands single- and multi-token terms by looking them up in one or more open- or specific-domain ontologies.

Version:
2007-02-30
Author:
Nico Schlaefer

Field Summary
static int MAX_EXPANSIONS
          Maximum number of expansions.
static int MAX_EXPANSIONS_QUERY
          Maximum number of expansions used in a query.
static double MIN_EXPANSION_WEIGHT
          Minimum weight of an expansion.
static double MIN_EXPANSION_WEIGHT_QUERY
          Minimum weight of an expansion used in a query.
 
Constructor Summary
TermExpander()
           
 
Method Summary
static double cutOffExpansions(java.util.Map<java.lang.String,java.lang.Double> expansions, boolean strict)
          Drops expansions that do not contain any keywords and applies the default thresholds for the maximum number of expansions and the minimum weight of an expansion.
static double cutOffExpansions(java.util.Map<java.lang.String,java.lang.Double> expansions, int maxExpansions, double minExpansionWeight, boolean strict)
          Drops expansions that do not contain any keywords and applies the given thresholds for the maximum number of expansions and the minimum weight of an expansion.
static java.util.Map<java.lang.String,java.lang.Double> expandPhrase(java.lang.String phrase, Term[] terms)
          Expands a phrase by replacing the terms that occur within the phrase by their expansions.
static void expandTerm(Term term, Predicate[] ps, Ontology[] ontologies)
          Expands a term by looking up related terms in ontologies.
static void expandTerms(Term[] terms, Predicate[] ps, Ontology[] ontologies)
          Expands all terms by looking up related terms in ontologies.
private static boolean isTarget(Term term, Predicate[] ps)
          Checks if the term is the target of one of the predicates.
static java.util.Map<java.lang.String,java.lang.Double> reduceExpansionsQuery(java.util.Map<java.lang.String,java.lang.Double> expansions, boolean strict)
          Creates a new expansion map and applies the thresholds for the maximum number of expansions and the minimum weight of an expansion for queries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_EXPANSIONS

public static final int MAX_EXPANSIONS
Maximum number of expansions.

See Also:
Constant Field Values

MIN_EXPANSION_WEIGHT

public static final double MIN_EXPANSION_WEIGHT
Minimum weight of an expansion.

See Also:
Constant Field Values

MAX_EXPANSIONS_QUERY

public static final int MAX_EXPANSIONS_QUERY
Maximum number of expansions used in a query.

See Also:
Constant Field Values

MIN_EXPANSION_WEIGHT_QUERY

public static final double MIN_EXPANSION_WEIGHT_QUERY
Minimum weight of an expansion used in a query.

See Also:
Constant Field Values
Constructor Detail

TermExpander

public TermExpander()
Method Detail

isTarget

private static boolean isTarget(Term term,
                                Predicate[] ps)
Checks if the term is the target of one of the predicates.

Parameters:
term - a term
ps - predicates in the same sentence
Returns:
true iff the term is a predicate target

cutOffExpansions

public static double cutOffExpansions(java.util.Map<java.lang.String,java.lang.Double> expansions,
                                      int maxExpansions,
                                      double minExpansionWeight,
                                      boolean strict)
Drops expansions that do not contain any keywords and applies the given thresholds for the maximum number of expansions and the minimum weight of an expansion.

Parameters:
expansions - expansions along with their weights
maxExpansions - maximum number of expansions
minExpansionWeight - minimum weight of an expansion
strict - iff true, the threshold for the maximum number of expansions is applied strictly even if that means that some of a number of expansion with equal weights have to be dropped randomly
Returns:
minimum weight of an expansion in the reduced map

cutOffExpansions

public static double cutOffExpansions(java.util.Map<java.lang.String,java.lang.Double> expansions,
                                      boolean strict)
Drops expansions that do not contain any keywords and applies the default thresholds for the maximum number of expansions and the minimum weight of an expansion.

Parameters:
expansions - expansions along with their weights
strict - iff true, the threshold for the maximum number of expansions is applied strictly even if that means that some of a number of expansion with equal weights have to be dropped randomly
Returns:
minimum weight of an expansion in the reduced map

reduceExpansionsQuery

public static java.util.Map<java.lang.String,java.lang.Double> reduceExpansionsQuery(java.util.Map<java.lang.String,java.lang.Double> expansions,
                                                                                     boolean strict)
Creates a new expansion map and applies the thresholds for the maximum number of expansions and the minimum weight of an expansion for queries.

Parameters:
expansions - expansions along with their weights
strict - iff true, the threshold for the maximum number of expansions is applied strictly even if that means that some of a number of expansion with equal weights have to be dropped randomly
Returns:
new reduced expansion map for queries

expandTerm

public static void expandTerm(Term term,
                              Predicate[] ps,
                              Ontology[] ontologies)
Expands a term by looking up related terms in ontologies.

Parameters:
term - a term
ps - predicates in the same sentence
ontologies - ontologies used to expand the term

expandTerms

public static void expandTerms(Term[] terms,
                               Predicate[] ps,
                               Ontology[] ontologies)
Expands all terms by looking up related terms in ontologies.

Parameters:
terms - the terms
ps - predicates in the same sentence
ontologies - ontologies used to expand the term

expandPhrase

public static java.util.Map<java.lang.String,java.lang.Double> expandPhrase(java.lang.String phrase,
                                                                            Term[] terms)
Expands a phrase by replacing the terms that occur within the phrase by their expansions. All possible combinations of expansions of the individual terms are formed and each is assigned the product of the weights of the expansions as a combined weight. The (at most) MAX_EXPANSIONS resulting phrases with the highest weights are returned.

Parameters:
phrase - phrase to expand
terms - expanded terms that potentially occur within the phrase
Returns:
expansions and their weights