Ejemplo n.º 1
0
        public static Person GenerateRandomPerson(Person.Gender gender = (Person.Gender)(-1),
                                                  string firstName     = null, string lastName = null)
        {
            int age = RandomInt(1, 100);

            if (gender == (Person.Gender)(-1))
            {
                gender = RandomGender();
            }

            if (firstName == null)
            {
                if (gender == Person.Gender.Male)
                {
                    firstName = RandomArrayString(Person.firstNameMales);
                }
                else
                {
                    firstName = RandomArrayString(Person.firstNameFemales);
                }
            }

            if (lastName == null)
            {
                lastName = RandomArrayString(Person.lastNames);
            }

            return(new Person(firstName, lastName, age, gender));
        }
Ejemplo n.º 2
0
 public Person(string name, string gender, IList <string> aliases)
 {
     this.name = name;
     if (gender.ToLower().StartsWith("m"))
     {
         this.gender = Person.Gender.Male;
     }
     else
     {
         if (gender.ToLower().StartsWith("f"))
         {
             this.gender = Person.Gender.Female;
         }
         else
         {
             this.gender = Person.Gender.Unk;
         }
     }
     if (aliases != null)
     {
         this.aliases = new HashSet <string>(aliases);
     }
     else
     {
         this.aliases = new HashSet <string>();
     }
     this.aliases.Add(name);
 }
Ejemplo n.º 3
0
        public static Person BuildPerson(String firstName, String lastName, int age, Person.Gender gender)
        {
            Person person = new Person();

            person.FirstName    = firstName;
            person.LastName     = lastName;
            person.Age          = age;
            person.PersonGender = gender;
            return(person);
        }
Ejemplo n.º 4
0
        public virtual void TopSpeakerInRange(Annotation doc)
        {
            IList <CoreLabel> toks   = doc.Get(typeof(CoreAnnotations.TokensAnnotation));
            IList <ICoreMap>  quotes = doc.Get(typeof(CoreAnnotations.QuotationsAnnotation));

            for (int quote_idx = 0; quote_idx < quotes.Count; quote_idx++)
            {
                ICoreMap quote = quotes[quote_idx];
                if (quote.Get(typeof(QuoteAttributionAnnotator.SpeakerAnnotation)) == null)
                {
                    Pair <int, int>           quoteRun = new Pair <int, int>(quote.Get(typeof(CoreAnnotations.TokenBeginAnnotation)), quote.Get(typeof(CoreAnnotations.TokenEndAnnotation)));
                    IList <Sieve.MentionData> closestMentionsBackward = FindClosestMentionsInSpanBackward(new Pair <int, int>(Math.Max(0, quoteRun.first - BackwardWindow), quoteRun.first - 1));
                    IList <Sieve.MentionData> closestMentions         = FindClosestMentionsInSpanForward(new Pair <int, int>(quoteRun.second + 1, Math.Min(quoteRun.second + ForwardWindow, toks.Count - 1)));
                    Sharpen.Collections.AddAll(closestMentions, closestMentionsBackward);
                    Person.Gender  gender      = GetGender(MakeMentionData(quote));
                    IList <string> topSpeakers = Counters.ToSortedList(GetTopSpeakers(closestMentions, closestMentionsBackward, gender, quote, false));
                    //if none found, try again with bigger window
                    if (topSpeakers.IsEmpty())
                    {
                        closestMentionsBackward = FindClosestMentionsInSpanBackward(new Pair <int, int>(Math.Max(0, quoteRun.first - BackwardWindowBig), quoteRun.first - 1));
                        closestMentions         = FindClosestMentionsInSpanForward(new Pair <int, int>(quoteRun.second + 1, Math.Min(quoteRun.second + ForwardWindowBig, toks.Count - 1)));
                        topSpeakers             = Counters.ToSortedList(GetTopSpeakers(closestMentions, closestMentionsBackward, gender, quote, true));
                    }
                    if (topSpeakers.IsEmpty())
                    {
                        log.Warn("Watch out, there's an empty top speakers list!");
                        continue;
                    }
                    topSpeakers = RemoveQuoteNames(topSpeakers, quote);
                    string topSpeaker = topSpeakers[0];
                    Pair <string, string> nextPrediction = GetConversationalNextPrediction(quotes, quote_idx, gender);
                    bool set = UpdatePredictions(quote, nextPrediction);
                    if (set)
                    {
                        continue;
                    }
                    Pair <string, string> prevPrediction = GetConversationalPreviousPrediction(quotes, quote_idx, gender);
                    set = UpdatePredictions(quote, prevPrediction);
                    if (set)
                    {
                        continue;
                    }
                    Pair <string, string> famPrediction = GetFamilyAnimateVocative(quotes, quote_idx, gender, topSpeakers);
                    set = UpdatePredictions(quote, famPrediction);
                    if (set)
                    {
                        continue;
                    }
                    UpdatePredictions(quote, new Pair <string, string>(topSpeaker, string.Empty));
                }
            }
        }
Ejemplo n.º 5
0
 public GameInfo_v2()
 {
     this.teamName          = string.Empty;
     this.teamLogoID        = 0;
     this.teamColor         = new TeamColor();
     this.championship      = string.Empty;
     this.playerName        = string.Empty;
     this.playerAge         = 24;
     this.playerGender      = Person.Gender.Male;
     this.playerPortrait    = new Portrait();
     this.playerNationality = new Nationality();
     this.playerTeamCarData = new FrontendCarData[CarManager.carCount];
 }
Ejemplo n.º 6
0
        void PokazDane()
        {
            DataTable dataTable = new DataTable();

            dataTable = zb.WykonajZapytanieTSQL(@"select[id]
            ,[imie]
            ,[nazwisko]
            ,[wiek]
            ,[wzwiazku]
            ,[email]
            ,[plec]
              FROM[Test].[dbo].[Osoby]
              where imie +' '+ nazwisko like '%" + Wyszukaj.Text + "%' or nazwisko+' '+imie like '%" + Wyszukaj.Text + "%'  ");

            //dataTable = zb.WykonajZapytanieTSQL(@"with CTE as (select [id],[imie],[nazwisko],[wiek],[wzwiazku],[email],[plec],(FLOOR(ROW_NUMBER() over(order by nazwisko)-1)/10) as stronaFROM [Test].[dbo].[Osoby])
            //select [id],[imie] ,[nazwisko],[wiek],[wzwiazku] ,[email],[plec] from cte where strona = " + (strona - 1)); //SPOSOB SQL - !!!

            StronaTextBlock.Content = strona.ToString();

            Kolekcja.Clear();
            //foreach (DataRow r in dataTable.Rows)
            //{
            //    int id = Int32.Parse(r[0].ToString());
            //    string imie = r[1].ToString();
            //    string nazwisko = r[2].ToString();
            //    int wiek = Int32.Parse(r[3].ToString());
            //    bool wZwiazku = bool.Parse(r[4].ToString());
            //    string email = r[5].ToString();
            //    Person.Gender plec = JakiejPlci(r[6].ToString());
            //    Kolekcja.Add(new Person(id, imie, nazwisko, wiek, wZwiazku, email, plec));
            //}

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                int           id       = Int32.Parse(dataTable.Rows[i][0].ToString());
                string        imie     = dataTable.Rows[i][1].ToString();
                string        nazwisko = dataTable.Rows[i][2].ToString();
                int           wiek     = Convert.ToInt32(dataTable.Rows[i][3]);
                bool          wZwiazku = bool.Parse(dataTable.Rows[i][4].ToString());
                string        email    = dataTable.Rows[i][5].ToString();
                Person.Gender plec     = JakiejPlci(dataTable.Rows[i][6].ToString());
                Kolekcja.Add(new Person(id, imie, nazwisko, wiek, wZwiazku, email, plec));
            }

            Tabela.ItemsSource = kolekcjaStrona(Kolekcja);

            //Tabela.ItemsSource = Kolekcja; // PRZY ROZWIAZANIU SQL STYKAAA
            KolumnaPlec.ItemsSource      = Enum.GetValues(typeof(Person.Gender));
            maxStronaLabel.Content       = (Kolekcja.Count / 10) + 1;
            Tabela.Columns[0].Visibility = Visibility.Hidden;
        }
        public static IDictionary <string, Person.Gender> ReadGenderedNounList(string filename)
        {
            IDictionary <string, Person.Gender> genderMap = Generics.NewHashMap();
            IList <string> lines = IOUtils.LinesFromFile(filename);

            foreach (string line in lines)
            {
                string[]      nounAndStats = line.Split("\\t");
                string[]      stats        = nounAndStats[1].Split(" ");
                Person.Gender gender       = (System.Convert.ToInt32(stats[0]) >= System.Convert.ToInt32(stats[1])) ? Person.Gender.Male : Person.Gender.Female;
                genderMap[nounAndStats[0]] = gender;
            }
            return(genderMap);
        }
Ejemplo n.º 8
0
 public GameInfo_v1(SaveFileInfo.GameInfo v0)
 {
     this.isChallenge       = v0.isChallenge;
     this.gameTime          = v0.gameTime;
     this.teamName          = v0.teamName;
     this.teamLogoID        = v0.teamLogoID;
     this.teamColor         = v0.teamColor;
     this.championship      = v0.championship;
     this.playerName        = v0.playerName;
     this.playerAge         = 24;
     this.playerGender      = v0.playerGender;
     this.playerPortrait    = v0.playerPortrait;
     this.playerNationality = v0.playerNationality;
     this.playerTeamCarData = v0.playerTeamCarData;
     this.seasonNumber      = v0.seasonNumber;
     this.raceNumber        = v0.raceNumber;
     this.racesInSeason     = v0.racesInSeason;
 }
Ejemplo n.º 9
0
 public GameInfo_v2(SaveFileInfo.GameInfo_v1 v1)
 {
     this.isChallenge        = v1.isChallenge;
     this.gameTime           = v1.gameTime;
     this.teamName           = v1.teamName;
     this.teamLogoID         = v1.teamLogoID;
     this.teamColor          = v1.teamColor;
     this.championship       = v1.championship;
     this.championshipID     = -1;
     this.championshipSeries = Championship.Series.SingleSeaterSeries;
     this.playerName         = v1.playerName;
     this.playerAge          = v1.playerAge;
     this.playerGender       = v1.playerGender;
     this.playerPortrait     = v1.playerPortrait;
     this.playerNationality  = v1.playerNationality;
     this.playerTeamCarData  = v1.playerTeamCarData;
     this.seasonNumber       = v1.seasonNumber;
     this.raceNumber         = v1.raceNumber;
     this.racesInSeason      = v1.racesInSeason;
 }
Ejemplo n.º 10
0
 public virtual Person.Gender GetGender(Sieve.MentionData mention)
 {
     Person.Gender gender = Person.Gender.Unk;
     if (mention.type != null && mention.type.Equals("pronoun"))
     {
         if (Sharpen.Runtime.EqualsIgnoreCase(mention.text, "he"))
         {
             gender = Person.Gender.Male;
         }
         else
         {
             if (Sharpen.Runtime.EqualsIgnoreCase(mention.text, "she"))
             {
                 gender = Person.Gender.Female;
             }
         }
     }
     else
     {
         if (mention.type != null && mention.type.Equals("animate noun"))
         {
             string mentionText = mention.text.ToLower();
             if (genderList[mentionText] != null)
             {
                 gender = genderList[mentionText];
             }
         }
         else
         {
             if (mention.type != null && mention.type.Equals("name"))
             {
                 gender = characterMap[mention.text][0].gender;
             }
         }
     }
     return(gender);
 }
Ejemplo n.º 11
0
        public virtual Pair <string, string> GetConversationalNextPrediction(IList <ICoreMap> quotes, int quoteIndex, Person.Gender gender)
        {
            string topSpeaker = null;
            string modifier   = null;
            // if the n - 2 paragraph quotes are labelled with a speaker and
            // that speakers gender does not disagree, label with that speaker
            IList <int> quotesInNextNext = new List <int>();
            ICoreMap    quote            = quotes[quoteIndex];
            int         quoteParagraph   = GetQuoteParagraph(quote);

            for (int j = quoteIndex + 1; j < quotes.Count; j++)
            {
                if (GetQuoteParagraph(quotes[j]) == quoteParagraph + 2)
                {
                    quotesInNextNext.Add(j);
                }
            }
            foreach (int nextNext in quotesInNextNext)
            {
                ICoreMap          nextNextQuote = quotes[nextNext];
                string            speakerName   = nextNextQuote.Get(typeof(QuoteAttributionAnnotator.SpeakerAnnotation));
                Sieve.MentionData md            = MakeMentionData(quotes[nextNext]);
                if (speakerName != null && (gender == Person.Gender.Unk) || GetGender(md) == gender)
                {
                    topSpeaker = speakerName;
                    modifier   = " conversation - next";
                }
            }
            return(new Pair <string, string>(topSpeaker, modifier));
        }
Ejemplo n.º 12
0
        public virtual Pair <string, string> GetConversationalPreviousPrediction(IList <ICoreMap> quotes, int quoteIndex, Person.Gender gender)
        {
            string topSpeaker = null;
            string modifier   = null;
            // if the n - 2 paragraph quotes are labelled with a speaker and
            // that speakers gender does not disagree, label with that speaker
            IList <int> quotesInPrevPrev = new List <int>();
            ICoreMap    quote            = quotes[quoteIndex];
            int         quoteParagraph   = GetQuoteParagraph(quote);

            for (int j = quoteIndex - 1; j >= 0; j--)
            {
                if (GetQuoteParagraph(quotes[j]) == quoteParagraph - 2)
                {
                    quotesInPrevPrev.Add(j);
                }
            }
            foreach (int prevPrev in quotesInPrevPrev)
            {
                ICoreMap prevprevQuote = quotes[prevPrev];
                string   speakerName   = prevprevQuote.Get(typeof(QuoteAttributionAnnotator.SpeakerAnnotation));
                if (speakerName != null && (gender == Person.Gender.Unk) || GetGender(MakeMentionData(prevprevQuote)) == gender)
                {
                    topSpeaker = speakerName;
                    modifier   = " conversation - prev";
                }
            }
            return(new Pair <string, string>(topSpeaker, modifier));
        }
Ejemplo n.º 13
0
 public virtual Pair <string, string> GetFamilyAnimateVocative(IList <ICoreMap> quotes, int quote_index, Person.Gender gender, IList <string> topSpeakers)
 {
     Sieve.MentionData mention = MakeMentionData(quotes[quote_index]);
     if (mention.text != null)
     {
         if (mention.type.Equals("animate noun") && familyRelations.Contains(mention.text.ToLower()) && gender != Person.Gender.Unk)
         {
             int quoteContainingMention = GetQuoteContainingRange(quotes, new Pair <int, int>(mention.begin, mention.end));
             if (quoteContainingMention >= 0)
             {
                 string relatedName = quotes[quoteContainingMention].Get(typeof(QuoteAttributionAnnotator.SpeakerAnnotation));
                 if (relatedName != null)
                 {
                     foreach (string speaker in topSpeakers)
                     {
                         string[] speakerNames = speaker.Split("_");
                         if (relatedName.EndsWith(speakerNames[speakerNames.Length - 1]))
                         {
                             return(new Pair <string, string>(speaker, "family animate"));
                         }
                     }
                 }
             }
         }
     }
     return(new Pair <string, string>(null, null));
 }
Ejemplo n.º 14
0
        public virtual ICounter <string> GetTopSpeakers(IList <Sieve.MentionData> closestMentions, IList <Sieve.MentionData> closestMentionsBackward, Person.Gender gender, ICoreMap quote, bool overrideGender)
        {
            ICounter <string> topSpeakerInRange               = new ClassicCounter <string>();
            ICounter <string> topSpeakerInRangeIgnoreGender   = new ClassicCounter <string>();
            ICollection <Sieve.MentionData> backwardsMentions = new HashSet <Sieve.MentionData>(closestMentionsBackward);

            foreach (Sieve.MentionData mention in closestMentions)
            {
                double weight = backwardsMentions.Contains(mention) ? BackwardWeight : ForwardWeight;
                if (mention.type.Equals(Name))
                {
                    if (!characterMap.Keys.Contains(mention.text))
                    {
                        continue;
                    }
                    Person p = characterMap[mention.text][0];
                    if ((gender == Person.Gender.Male && p.gender == Person.Gender.Male) || (gender == Person.Gender.Female && p.gender == Person.Gender.Female) || (gender == Person.Gender.Unk))
                    {
                        topSpeakerInRange.IncrementCount(p.name, weight);
                    }
                    topSpeakerInRangeIgnoreGender.IncrementCount(p.name, weight);
                    if (closestMentions.Count == 128 && closestMentionsBackward.Count == 94)
                    {
                        System.Console.Out.WriteLine(p.name + " " + weight + " name");
                    }
                }
                else
                {
                    if (mention.type.Equals(Pronoun))
                    {
                        int    charBeginKey = doc.Get(typeof(CoreAnnotations.TokensAnnotation))[mention.begin].BeginPosition();
                        Person p            = DoCoreference(charBeginKey, quote);
                        if (p != null)
                        {
                            if ((gender == Person.Gender.Male && p.gender == Person.Gender.Male) || (gender == Person.Gender.Female && p.gender == Person.Gender.Female) || (gender == Person.Gender.Unk))
                            {
                                topSpeakerInRange.IncrementCount(p.name, weight);
                            }
                            topSpeakerInRangeIgnoreGender.IncrementCount(p.name, weight);
                            if (closestMentions.Count == 128 && closestMentionsBackward.Count == 94)
                            {
                                System.Console.Out.WriteLine(p.name + " " + weight + " pronoun");
                            }
                        }
                    }
                }
            }
            if (topSpeakerInRange.Size() > 0)
            {
                return(topSpeakerInRange);
            }
            else
            {
                if (gender != Person.Gender.Unk && !overrideGender)
                {
                    return(topSpeakerInRange);
                }
            }
            return(topSpeakerInRangeIgnoreGender);
        }
Ejemplo n.º 15
0
        public override void AddPersone(int number, string firstName, string lastName, string patronymic, string dateOfBirthday, Person.Gender gender, params object[] list)
        {
            Teacher teacher = new Teacher(number, firstName, lastName, patronymic, dateOfBirthday, gender, list);

            teachers.Add(teacher);
        }
Ejemplo n.º 16
0
        public override void AddPersone(int number, string firstName, string lastName, string patronymic, string dateOfBirthday, Person.Gender gender, params object[] list)
        {
            Student student = new Student(number, firstName, lastName, patronymic, dateOfBirthday, gender, list);

            students.Add(student);
        }
Ejemplo n.º 17
0
 static public void InputPerson(string first,
                                string last, Person.Gender gender, int age = 20)
 {
     Console.WriteLine($"{first} {last}, {age}, {gender}");
 }
Ejemplo n.º 18
0
 public abstract void AddPersone(int number, string firstName, string lastName, string patronymic, string dateOfBirthday, Person.Gender gender, params object[] list);