edu.illinois.cs.cogcomp.lbj.coref.features
Class GenderFeatures

java.lang.Object
  extended by edu.illinois.cs.cogcomp.lbj.coref.features.GenderFeatures

public class GenderFeatures
extends java.lang.Object

A collection of feature generating functions and utilities for determining the gender of an entity.


Field Summary
protected static java.util.Map<java.lang.String,java.lang.Character> m_genderCache
          A Cache of genders.
 
Constructor Summary
protected GenderFeatures()
          Should not need to construct this static library of features.
 
Method Summary
static java.lang.String doGendersMatch(CExample ex, boolean useWN)
          Determines whether the gender of two mentions match, according to getGender(edu.illinois.cs.cogcomp.lbj.coref.ir.Mention, boolean).
static java.lang.String doGendersMatch(CExample ex, boolean useWN, boolean useCache)
          Determines whether the gender of two mentions match, according to getGender(edu.illinois.cs.cogcomp.lbj.coref.ir.Mention, boolean).
static java.lang.String doGendersMatchForBasic(CExample ex)
          This is a legacy function for use as a feature for the learned classifier that predicts simple coreference, used to determine whether names match.
static java.lang.String doGendersMatchForCompatible(CExample ex, boolean useWN)
          Determines the gender of a mention.
static boolean genderMatchBoolean(CExample ex)
          Determines whether the gender of two mentions match as determined by getGender(edu.illinois.cs.cogcomp.lbj.coref.ir.Mention, boolean).
static char getGender(Mention m, boolean useWN)
          Determines the gender of a mention.
static char getGender(Mention m, boolean useWN, boolean useCache)
          Determines the gender of a mention.
static char getGenderForCompatible(Mention m)
          Gets the gender of a mention.
static char getNameGender(Mention m)
          Determines the gender of a mention, assuming it is a proper name.
static char getNameGenderCitiesFirst(Mention m)
          Gets the gender of the mention, prioritizing cities over names (resolving cases where a name could either be a city or a person).
static char getNominalGender(Mention m, boolean useWN)
          Determines the gender of a mention, assuming it is a nominal.
static char getPronounGender(java.lang.String word)
          Determines the gender of a mention, assuming it is a pronoun.
static char getStrongerGender(char g1, char g2)
          Gets the stronger of the two genders.
static java.lang.String removePunctuationFromEnds(java.lang.String s)
          Trims punctuation from string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_genderCache

protected static java.util.Map<java.lang.String,java.lang.Character> m_genderCache
A Cache of genders.

Constructor Detail

GenderFeatures

protected GenderFeatures()
Should not need to construct this static library of features.

Method Detail

genderMatchBoolean

public static boolean genderMatchBoolean(CExample ex)
Determines whether the gender of two mentions match as determined by getGender(edu.illinois.cs.cogcomp.lbj.coref.ir.Mention, boolean). Returns a boolean value and assumes true if unknown.

Parameters:
ex - The example containing the mentions.
Returns:
true if same or either is unknown, false otherwise.

doGendersMatch

public static java.lang.String doGendersMatch(CExample ex,
                                              boolean useWN)
Determines whether the gender of two mentions match, according to getGender(edu.illinois.cs.cogcomp.lbj.coref.ir.Mention, boolean). Caching is not done.

Parameters:
useWN - Whether WordNet should be used to help predict genders?
Returns:
"t" (true), "f" (false), or "u" (unknown).

doGendersMatch

public static java.lang.String doGendersMatch(CExample ex,
                                              boolean useWN,
                                              boolean useCache)
Determines whether the gender of two mentions match, according to getGender(edu.illinois.cs.cogcomp.lbj.coref.ir.Mention, boolean).

Parameters:
useWN - Whether WordNet should be used to help predict genders?
useCache - Whether to cache genders.
Returns:
"t" (true), "f" (false), or "u" (unknown).

getGender

public static char getGender(Mention m,
                             boolean useWN)
Determines the gender of a mention. First, determines whether the mention is a proper name, common noun, or pronoun, and then delegate to the corresponding method. Caching will not be done.

Parameters:
m - The mention whose gender to determine.
useWN - Whether WordNet should be used to help predict genders?
Returns:
'm' (male), 'f' (female), 'n' (neuter), or 'u' (unknown).

getGender

public static char getGender(Mention m,
                             boolean useWN,
                             boolean useCache)
Determines the gender of a mention. First, determines whether the mention is a proper name,common noun, or pronoun, and then delegate to the corresponding method.

Parameters:
m - The mention whose gender to determine.
useWN - Whether WordNet should be used to help predict genders?
useCache - Whether to cache genders based on the head text.
Returns:
'm' (male), 'f' (female), 'n' (neuter), or 'u' (unknown).

doGendersMatchForCompatible

public static java.lang.String doGendersMatchForCompatible(CExample ex,
                                                           boolean useWN)
Determines the gender of a mention. For use in reproducing published data.

Parameters:
ex - An example.
useWN - Whether WordNet should be used to help predict genders?
Returns:
Whether genders match, "true", "false", or "unknown".

doGendersMatchForBasic

public static java.lang.String doGendersMatchForBasic(CExample ex)
This is a legacy function for use as a feature for the learned classifier that predicts simple coreference, used to determine whether names match.

Parameters:
ex - An example.
Returns:
Whether genders match, "true", "false", or "unknown".

getGenderForCompatible

public static char getGenderForCompatible(Mention m)
Gets the gender of a mention. This is the legacy function for use in reproducing published data.

Parameters:
m - A mention.
Returns:
The gender of the mention.

getNameGenderCitiesFirst

public static char getNameGenderCitiesFirst(Mention m)
Gets the gender of the mention, prioritizing cities over names (resolving cases where a name could either be a city or a person). Used to reproduce published data.

Parameters:
m - The mention, assumed to be a proper name.
Returns:
The gender of this name.

getNameGender

public static char getNameGender(Mention m)
Determines the gender of a mention, assuming it is a proper name.

Returns:
'm'ale, 'f'emale, 'p'erson, 'n'euter, or 'u'nknown.

getNominalGender

public static char getNominalGender(Mention m,
                                    boolean useWN)
Determines the gender of a mention, assuming it is a nominal.

Returns:
'm'ale, 'f'emale, 'p'erson, 'n'euter, or 'u'nknown.

getPronounGender

public static char getPronounGender(java.lang.String word)
Determines the gender of a mention, assuming it is a pronoun.

Returns:
'm'ale, 'f'emale, 'p'erson, 'n'euter, or 'u'nknown.

getStrongerGender

public static char getStrongerGender(char g1,
                                     char g2)
Gets the stronger of the two genders. A gender is stronger than another if one is more specific than the other.

Parameters:
g1 - One gender ('m', 'f', 'p', or 'u').
g2 - Another gender ('m', 'f', 'p', or 'u').
Returns:
The stronger of the two genders, favoring g2 in case g1 and g2 are equal strength.

removePunctuationFromEnds

public static java.lang.String removePunctuationFromEnds(java.lang.String s)
Trims punctuation from string.

Parameters:
s - A String.
Returns:
The string with the leading and trailing punctuation removed.