예제 #1
0
        public CareerLocationSuggestions(Person p, IList <Event> events)
            : base(p)
        {
            foreach (Event e in events)
            {
                IEnumerable <Career> careers = p.Careers
                                               .Where(x => x.Location != null && x.Location.IsNotUnknown())
                                               .Where(x => x.Location == e.Location || x.Location.Territory == e.Location.Territory)
                                               .Where(x => x.HasIntersectingDateWith(e));

                if (careers != null && careers.Any())
                {
                    Career           career = careers.First();
                    SuggestedFeature sf     = new SuggestedFeature()
                    {
                        FeatureID = this.Features[AdminSuggestionFeaturePersonResponsibility.CAREER_IN_LOCATION].Id
                    };
                    if (career.HasIncompleteDate())
                    {
                        sf.IncompleteDatePenalty = this.INCOMPLETE_DATE_PENALTY;
                    }
                    this.AddSuggestionFeatureWithReason(sf, e, career);
                }
            }
        }
예제 #2
0
 public CareerInResponsibleUnitSuggestions(Person p, IList <OrganizationResponsibility> responsibilities)
     : base(p)
 {
     foreach (OrganizationResponsibility or in responsibilities)
     {
         // multiple OrganizationResponsibilities may exist in the database, we only need one
         if (!this.Suggestions.Where(x => x.EventID == or.Event.Id).Any())
         {
             IEnumerable <Career> careers = p.Careers
                                            .Where(x => !x.Archive && x.Unit == or.Unit)
                                            .OrderByDescending(x => x.YearOfStart + x.YearOfEnd); // attempt at ordering by most-complete-date-first
             if (careers != null && careers.Any())
             {
                 // perform suggestion based only on 1 career linked to unit
                 Career           career = careers.First();
                 SuggestedFeature sf     = new SuggestedFeature()
                 {
                     FeatureID = this.Features[AdminSuggestionFeaturePersonResponsibility.CAREER_IN_UNIT_RESPONSIBLE].Id
                 };
                 if (career.HasIncompleteDate())
                 {
                     sf.IncompleteDatePenalty = this.INCOMPLETE_DATE_PENALTY;
                 }
                 this.CurrentUnit = or.Unit;
                 this.AddSuggestionFeatureWithReason(sf, or.Event, career);
             }
         }
     }
 }
예제 #3
0
        public EventRelationshipSuggestions(Person p, IEnumerable <EventRelationship> relationships)
            : base(p)
        {
            foreach (EventRelationship er in relationships)
            {
                Event other            = null;
                Event responsibleEvent = null;
                if (!er.SubjectEvent.IsPersonResponsible(p))
                {
                    other            = er.SubjectEvent;
                    responsibleEvent = er.ObjectEvent;
                }
                else if (!er.ObjectEvent.IsPersonResponsible(p))
                {
                    other            = er.ObjectEvent;
                    responsibleEvent = er.SubjectEvent;
                }

                if (other != null && !other.Archive)
                {
                    SuggestedFeature sf = new SuggestedFeature()
                    {
                        FeatureID = this.Features[AdminSuggestionFeaturePersonResponsibility.RESPONSIBLE_FOR_RELATED_EVENT].Id
                    };
                    this.AddSuggestionFeatureWithReason(sf, other, responsibleEvent);
                }
            }
        }
 public EventInSameLocationSuggestions(Person p, IList <Event> events)
     : base(p)
 {
     foreach (Event e in events)
     {
         SuggestedFeature sf = new SuggestedFeature()
         {
             FeatureID = this.Features[AdminSuggestionFeaturePersonResponsibility.RESPONSIBILITY_IN_LOCATION].Id
         };
         this.AddSuggestionFeatureWithReason(sf, e, e);
     }
 }
예제 #5
0
 public AliasSuggestions(Person p, IList <Event> events)
     : base(p)
 {
     foreach (Event e in events)
     {
         SuggestedFeature sf = new SuggestedFeature()
         {
             FeatureID = this.Features[AdminSuggestionFeaturePersonResponsibility.ALIAS_APPEARS].Id
         };
         this.AddSuggestionFeatureWithReason(sf, e, null);
     }
 }
예제 #6
0
        protected void AddSuggestionFeatureWithReason(SuggestedFeature feature, Event suggestedEvent, Entity entity)
        {
            SuggestedFeatureWithReason s = new SuggestedFeatureWithReason()
            {
                SuggestedFeature = feature,
                EventID          = suggestedEvent.Id,
                EventHeadline    = suggestedEvent.Headline,
                Reason           = this.ConstructSuggestionReason(entity)
            };

            this.Suggestions.Add(s);
        }
예제 #7
0
 public SourceSuggestions(Person p, IList <EventSource> eventSources)
     : base(p)
 {
     foreach (EventSource es in eventSources)
     {
         if (es.Source != null && es.Event != null && !es.Source.Archive)
         {
             SuggestedFeature sf = new SuggestedFeature()
             {
                 FeatureID = this.Features[AdminSuggestionFeaturePersonResponsibility.COMMON_SOURCE].Id
             };
             this.AddSuggestionFeatureWithReason(sf, es.Event, es.Source);
         }
     }
 }
예제 #8
0
        // calculates Feature.Weight based on feature counts stored in this.FeatureProbabilityCalcs
        protected IList <SuggestedFeatureWithReason> CalculateFeatureWeights(IList <SuggestedFeatureWithReason> features)
        {
            IList <SuggestedFeatureWithReason> populated = new List <SuggestedFeatureWithReason>();

            foreach (SuggestedFeatureWithReason sfwr in features)
            {
                SuggestedFeature f = sfwr.SuggestedFeature;
                if (f.Weight == 0 && f.FeatureID > 0)
                {
                    f.Weight = 10.0 * this.GetFeatureCoefficient(f.FeatureID);
                    sfwr.SuggestedFeature = f;
                }
                populated.Add(sfwr);
            }
            return(populated);
        }
예제 #9
0
        public PersonRelationshipSuggestions(Person p, IEnumerable <PersonRelationship> relationships)
            : base(p)
        {
            // one-to-one mapping between relationship and feature
            foreach (PersonRelationship relationship in relationships)
            {
                Person other = null;
                if (relationship.SubjectPerson != p)
                {
                    other = relationship.SubjectPerson;
                }
                else if (relationship.ObjectPerson != p)
                {
                    other = relationship.ObjectPerson;
                }

                if (other != null)
                {
                    // TODO source of n+1 problem
                    IEnumerable <Event> events = other.PersonResponsibilities
                                                 .Select(x => x.Event)
                                                 .Where(x => !x.Archive && relationship.HasIntersectingDateWith(x));
                    if (events.Any())
                    {
                        SuggestedFeature feature = new SuggestedFeature()
                        {
                            FeatureID = this.GetSuggestionFeatureId(relationship.PersonRelationshipType.Code)
                        };
                        if (relationship.HasIncompleteDate())
                        {
                            feature.IncompleteDatePenalty = this.INCOMPLETE_DATE_PENALTY;
                        }

                        foreach (Event e in events)
                        {
                            this.AddSuggestionFeatureWithReason(feature, e, relationship);
                        }
                    }
                }
            }
        }