/// <summary> /// Creates a new entity based on the specified mention and its specified gender and number properties. /// </summary> /// <param name="mention"> /// The first mention of this entity. /// </param> /// <param name="gender"> /// The gender of this entity. /// </param> /// <param name="genderProbability"> /// The probability that the specified gender is correct. /// </param> /// <param name="number"> /// The number for this entity. /// </param> /// <param name="numberProbability"> /// The probability that the specified number is correct. /// </param> public DiscourseEntity(Mention.MentionContext mention, Similarity.GenderEnum gender, double genderProbability, Similarity.NumberEnum number, double numberProbability) : base(mention) { mGender = gender; mGenderProbability = genderProbability; mNumber = number; mNumberProbability = numberProbability; }
private GenderEnum GetGender(List <Context> entity) { foreach (Context entityContext in entity) { GenderEnum gender = GetGender(entityContext); if (gender != GenderEnum.Unknown) { return(gender); } } return(GenderEnum.Unknown); }
virtual public void SetExtents(Context[] extents) { var entities = new Util.HashList <int, Context>(); var singletons = new List <Context>(); for (int currentExtent = 0; currentExtent < extents.Length; currentExtent++) { Context extent = extents[currentExtent]; if (extent.Id != -1) { entities.Put(extent.Id, extent); } else { singletons.Add(extent); } } var males = new List <Context>(); var females = new List <Context>(); var eunuches = new List <Context>(); //coref entities foreach (int key in entities.Keys) { List <Context> entityContexts = entities[key]; GenderEnum gender = GetGender(entityContexts); if (gender != null) { if (gender == GenderEnum.Male) { males.AddRange(entityContexts); } else if (gender == GenderEnum.Female) { females.AddRange(entityContexts); } else if (gender == GenderEnum.Neuter) { eunuches.AddRange(entityContexts); } } } //non-coref entities foreach (Context entityContext in singletons) { GenderEnum gender = GetGender(entityContext); if (gender == GenderEnum.Male) { males.Add(entityContext); } else if (gender == GenderEnum.Female) { females.Add(entityContext); } else if (gender == GenderEnum.Neuter) { eunuches.Add(entityContext); } } foreach (Context entityContext in males) { AddEvent(GenderEnum.Male.ToString(), entityContext); } foreach (Context entityContext in females) { AddEvent(GenderEnum.Female.ToString(), entityContext); } foreach (Context entityContext in eunuches) { AddEvent(GenderEnum.Neuter.ToString(), entityContext); } }
virtual public void SetExtents(Context[] extents) { Util.HashList <int, Context> entities = new Util.HashList <int, Context>(); List <Context> singletons = new List <Context>(); for (int currentExtent = 0; currentExtent < extents.Length; currentExtent++) { Context extent = extents[currentExtent]; //System.err.println("GenderModel.setExtents: ec("+ec.getId()+") "+ec.toText()); if (extent.Id != -1) { entities.Put(extent.Id, extent); } else { singletons.Add(extent); } } List <Context> males = new List <Context>(); List <Context> females = new List <Context>(); List <Context> eunuches = new List <Context>(); //coref entities foreach (int key in entities.Keys) { List <Context> entityContexts = entities[key]; GenderEnum gender = GetGender(entityContexts); if (gender != null) { if (gender == GenderEnum.Male) { males.AddRange(entityContexts); } else if (gender == GenderEnum.Female) { females.AddRange(entityContexts); } else if (gender == GenderEnum.Neuter) { eunuches.AddRange(entityContexts); } } } //non-coref entities foreach (Context entityContext in singletons) { GenderEnum gender = GetGender(entityContext); if (gender == GenderEnum.Male) { males.Add(entityContext); } else if (gender == GenderEnum.Female) { females.Add(entityContext); } else if (gender == GenderEnum.Neuter) { eunuches.Add(entityContext); } } foreach (Context entityContext in males) { AddEvent(GenderEnum.Male.ToString(), entityContext); } foreach (Context entityContext in females) { AddEvent(GenderEnum.Female.ToString(), entityContext); } foreach (Context entityContext in eunuches) { AddEvent(GenderEnum.Neuter.ToString(), entityContext); } }
public Gender(GenderEnum type, double confidence) { mType = type; mConfidence = confidence; }
/// <summary> /// Creates a new entity based on the specified mention. /// </summary> /// <param name="mention"> /// The first mention of this entity. /// </param> public DiscourseEntity(Mention.MentionContext mention) : base(mention) { mGender = Similarity.GenderEnum.Unknown; mNumber = Similarity.NumberEnum.Unknown; }