/** * Annotate for gender of tokens */ public Annotator gender(Properties properties, String name) { return new GenderAnnotator(name, properties); }
public void annotate(Annotation annotation) { // iterate through each sentence, iterate through each entity mention in the sentence for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) { for (CoreMap entityMention : sentence.get(CoreAnnotations.MentionsAnnotation.class)) { // if the entityMention is of type PERSON, see if name is in one of the lists for male and female names // annotate the entity mention's CoreMap if (entityMention.get(CoreAnnotations.EntityTypeAnnotation.class).equals("PERSON")) { CoreLabel firstName = entityMention.get(CoreAnnotations.TokensAnnotation.class).get(0); if (maleNames.contains(firstName.word().toLowerCase())) annotateEntityMention(entityMention, "MALE"); else if (femaleNames.contains(firstName.word().toLowerCase())) annotateEntityMention(entityMention, "FEMALE"); } } } }
public GenderAnnotator(String annotatorName, Properties props) { // load the male and female names MALE_FIRST_NAMES_PATH = props.getProperty("gender.maleNamesFile", MALE_FIRST_NAMES_PATH); FEMALE_FIRST_NAMES_PATH = props.getProperty("gender.femaleNamesFile", FEMALE_FIRST_NAMES_PATH); loadGenderNames(maleNames, MALE_FIRST_NAMES_PATH); loadGenderNames(femaleNames, FEMALE_FIRST_NAMES_PATH); }
/** * Annotate for gender of tokens */ public Annotator gender(Properties properties, String name) { return new GenderAnnotator(name, properties); }
public GenderAnnotator(String annotatorName, Properties props) { // load the male and female names MALE_FIRST_NAMES_PATH = props.getProperty("gender.maleNamesFile", MALE_FIRST_NAMES_PATH); FEMALE_FIRST_NAMES_PATH = props.getProperty("gender.femaleNamesFile", FEMALE_FIRST_NAMES_PATH); loadGenderNames(maleNames, MALE_FIRST_NAMES_PATH); loadGenderNames(femaleNames, FEMALE_FIRST_NAMES_PATH); }
public void annotate(Annotation annotation) { // iterate through each sentence, iterate through each entity mention in the sentence for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) { for (CoreMap entityMention : sentence.get(CoreAnnotations.MentionsAnnotation.class)) { // if the entityMention is of type PERSON, see if name is in one of the lists for male and female names // annotate the entity mention's CoreMap if (entityMention.get(CoreAnnotations.EntityTypeAnnotation.class).equals("PERSON")) { CoreLabel firstName = entityMention.get(CoreAnnotations.TokensAnnotation.class).get(0); if (maleNames.contains(firstName.word().toLowerCase())) annotateEntityMention(entityMention, "MALE"); else if (femaleNames.contains(firstName.word().toLowerCase())) annotateEntityMention(entityMention, "FEMALE"); } } } }
@Override public Annotator create() { return new GenderAnnotator(false, properties.getProperty("gender.firstnames", DefaultPaths.DEFAULT_GENDER_FIRST_NAMES)); }
public Annotator create() { return new GenderAnnotator(false, props.getProperty("gender.firstnames", DefaultPaths.DEFAULT_GENDER_FIRST_NAMES)); } });