virtual public void SetExtents(Context[] extents) { Util.HashList <int, Context> entities = new Util.HashList <int, Context>(); List <Context> singletons = new List <Context>(); for (int extentIndex = 0; extentIndex < extents.Length; extentIndex++) { Context currentExtent = extents[extentIndex]; //System.err.println("NumberModel.setExtents: ec("+ec.getId()+") "+ec.toText()); if (currentExtent.Id != -1) { entities.Put(currentExtent.Id, currentExtent); } else { singletons.Add(currentExtent); } } List <Context> singles = new List <Context>(); List <Context> plurals = new List <Context>(); // coref entities foreach (int key in entities.Keys) { List <Context> entityContexts = entities[key]; NumberEnum number = GetNumber(entityContexts); if (number == NumberEnum.Singular) { singles.AddRange(entityContexts); } else if (number == NumberEnum.Plural) { plurals.AddRange(entityContexts); } } // non-coref entities. foreach (Context currentContext in singletons) { NumberEnum number = GetNumber(currentContext); if (number == NumberEnum.Singular) { singles.Add(currentContext); } else if (number == NumberEnum.Plural) { plurals.Add(currentContext); } } foreach (Context currentContext in singles) { AddEvent(NumberEnum.Singular.ToString(), currentContext); } foreach (Context currentContext in plurals) { AddEvent(NumberEnum.Plural.ToString(), currentContext); } }
virtual public void SetExtents(Context[] extents) { var entities = new Util.HashList <int, Context>(); var singletons = new List <Context>(); for (var extentIndex = 0; extentIndex < extents.Length; extentIndex++) { var currentExtent = extents[extentIndex]; if (currentExtent.Id != -1) { entities.Put(currentExtent.Id, currentExtent); } else { singletons.Add(currentExtent); } } var singles = new List <Context>(); var plurals = new List <Context>(); // coref entities foreach (var key in entities.Keys) { var entityContexts = entities[key]; var number = GetNumber(entityContexts); if (number == NumberEnum.Singular) { singles.AddRange(entityContexts); } else if (number == NumberEnum.Plural) { plurals.AddRange(entityContexts); } } // non-coref entities. foreach (var currentContext in singletons) { var number = GetNumber(currentContext); if (number == NumberEnum.Singular) { singles.Add(currentContext); } else if (number == NumberEnum.Plural) { plurals.Add(currentContext); } } foreach (var currentContext in singles) { AddEvent(NumberEnum.Singular.ToString(), currentContext); } foreach (var currentContext in plurals) { AddEvent(NumberEnum.Plural.ToString(), currentContext); } }
virtual public void SetExtents(Context[] extents) { var entities = new Util.HashList<int, Context>(); var singletons = new List<Context>(); for (int extentIndex = 0; extentIndex < extents.Length; extentIndex++) { Context currentExtent = extents[extentIndex]; if (currentExtent.Id != -1) { entities.Put(currentExtent.Id, currentExtent); } else { singletons.Add(currentExtent); } } var singles = new List<Context>(); var plurals = new List<Context>(); // coref entities foreach (int key in entities.Keys) { List<Context> entityContexts = entities[key]; NumberEnum number = GetNumber(entityContexts); if (number == NumberEnum.Singular) { singles.AddRange(entityContexts); } else if (number == NumberEnum.Plural) { plurals.AddRange(entityContexts); } } // non-coref entities. foreach (Context currentContext in singletons) { NumberEnum number = GetNumber(currentContext); if (number == NumberEnum.Singular) { singles.Add(currentContext); } else if (number == NumberEnum.Plural) { plurals.Add(currentContext); } } foreach (Context currentContext in singles) { AddEvent(NumberEnum.Singular.ToString(), currentContext); } foreach (Context currentContext in plurals) { AddEvent(NumberEnum.Plural.ToString(), currentContext); } }
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); } }
public virtual void SetExtents(Context[] extents) { var entities = new Util.HashList <int, Context>(); // Extents which are not in a coreference chain. var singletons = new List <Context>(); var allExtents = new List <Context>(); //populate data structures foreach (Context currentExtent in extents) { if (currentExtent.Id == -1) { singletons.Add(currentExtent); } else { entities.Put(currentExtent.Id, currentExtent); } allExtents.Add(currentExtent); } int allExtentsIndex = 0; Dictionary <int, Util.Set <string> > headSets = ConstructHeadSets(entities); Dictionary <int, Util.Set <string> > nameSets = ConstructNameSets(entities); foreach (int key in entities.Keys) { Util.Set <string> entityNameSet = nameSets[key]; if (entityNameSet.Count == 0) { continue; } List <Context> entityContexts = entities[key]; Util.Set <Context> exclusionSet = ConstructExclusionSet(key, entities, headSets, nameSets, singletons); //if (entityContexts.Count == 1) //{ //} for (int firstEntityContextIndex = 0; firstEntityContextIndex < entityContexts.Count; firstEntityContextIndex++) { Context firstEntityContext = entityContexts[firstEntityContextIndex]; //if (isPronoun(ec1)) { // continue; //} for (int secondEntityContextIndex = firstEntityContextIndex + 1; secondEntityContextIndex < entityContexts.Count; secondEntityContextIndex++) { Context secondEntityContext = entityContexts[secondEntityContextIndex]; //if (isPronoun(ec2)) { // continue; //} AddEvent(true, firstEntityContext, secondEntityContext); int startIndex = allExtentsIndex; do { Context compareEntityContext = allExtents[allExtentsIndex]; allExtentsIndex = (allExtentsIndex + 1) % allExtents.Count; if (!exclusionSet.Contains(compareEntityContext)) { if (DebugOn) { System.Console.Error.WriteLine(firstEntityContext.ToString() + " " + string.Join(",", entityNameSet.ToArray()) + " " + compareEntityContext.ToString() + " " + nameSets[compareEntityContext.Id]); } AddEvent(false, firstEntityContext, compareEntityContext); break; } }while (allExtentsIndex != startIndex); } } } }
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 virtual void SetExtents(Context[] extents) { Util.HashList<int, Context> entities = new Util.HashList<int, Context>(); /** Extents which are not in a coreference chain. */ List<Context> singletons = new List<Context>(); List<Context> allExtents = new List<Context>(); //populate data structures for (int extentIndex = 0; extentIndex < extents.Length; extentIndex++) { Context currentExtent = extents[extentIndex]; //System.err.println("SimilarityModel: setExtents: ec("+ec.getId()+") "+ec.getNameType()+" "+ec); if (currentExtent.Id == -1) { singletons.Add(currentExtent); } else { entities.Put(currentExtent.Id, currentExtent); } allExtents.Add(currentExtent); } int allExtentsIndex = 0; Dictionary<int, Util.Set<string>> headSets = ConstructHeadSets(entities); Dictionary<int, Util.Set<string>> nameSets = ConstructNameSets(entities); foreach (int key in entities.Keys) { Util.Set<string> entityNameSet = nameSets[key]; if (entityNameSet.Count == 0) { continue; } List<Context> entityContexts = entities[key]; Util.Set<Context> exclusionSet = ConstructExclusionSet(key, entities, headSets, nameSets, singletons); //if (entityContexts.Count == 1) //{ //} for (int firstEntityContextIndex = 0; firstEntityContextIndex < entityContexts.Count; firstEntityContextIndex++) { Context firstEntityContext = entityContexts[firstEntityContextIndex]; //if (isPronoun(ec1)) { // continue; //} for (int secondEntityContextIndex = firstEntityContextIndex + 1; secondEntityContextIndex < entityContexts.Count; secondEntityContextIndex++) { Context secondEntityContext = entityContexts[secondEntityContextIndex]; //if (isPronoun(ec2)) { // continue; //} AddEvent(true, firstEntityContext, secondEntityContext); int startIndex = allExtentsIndex; do { Context compareEntityContext = allExtents[allExtentsIndex]; allExtentsIndex = (allExtentsIndex + 1) % allExtents.Count; if (!exclusionSet.Contains(compareEntityContext)) { if (mDebugOn) { System.Console.Error.WriteLine(firstEntityContext.ToString() + " " + string.Join(",", entityNameSet.ToArray()) + " " + compareEntityContext.ToString() + " " + nameSets[compareEntityContext.Id]); } AddEvent(false, firstEntityContext, compareEntityContext); break; } } while (allExtentsIndex != startIndex); } } } }
public virtual 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 virtual void SetExtents(Context[] extents) { Util.HashList<int, Context> entities = new Util.HashList<int, Context>(); List<Context> singletons = new List<Context>(); for (int extentIndex = 0; extentIndex < extents.Length; extentIndex++) { Context currentExtent = extents[extentIndex]; //System.err.println("NumberModel.setExtents: ec("+ec.getId()+") "+ec.toText()); if (currentExtent.Id != -1) { entities.Put(currentExtent.Id, currentExtent); } else { singletons.Add(currentExtent); } } List<Context> singles = new List<Context>(); List<Context> plurals = new List<Context>(); // coref entities foreach (int key in entities.Keys) { List<Context> entityContexts = entities[key]; NumberEnum number = GetNumber(entityContexts); if (number == NumberEnum.Singular) { singles.AddRange(entityContexts); } else if (number == NumberEnum.Plural) { plurals.AddRange(entityContexts); } } // non-coref entities. foreach (Context currentContext in singletons) { NumberEnum number = GetNumber(currentContext); if (number == NumberEnum.Singular) { singles.Add(currentContext); } else if (number == NumberEnum.Plural) { plurals.Add(currentContext); } } foreach (Context currentContext in singles) { AddEvent(NumberEnum.Singular.ToString(), currentContext); } foreach (Context currentContext in plurals) { AddEvent(NumberEnum.Plural.ToString(), currentContext); } }