Example #1
0
        public GenderAttribute GuessGender(InformedPhrase word, IWordLookup informer)
        {
            List <string> parts = word.Generate();
            string        part  = parts[0];

            ProbableStrength given = IsGivenName(informer, part);

            if (given.strength < .25 && given.weight > 0.75)
            {
                GenderAttribute attr = new GenderAttribute(GenderAttribute.GenderOptions.Neuter);
                attr.Strength = given.InverseProbability();
                return(attr);
            }

            ProbableStrength female = IsFemaleName(part);

            if (female.strength > 0.5)
            {
                GenderAttribute attr = new GenderAttribute(GenderAttribute.GenderOptions.Female);
                attr.Strength = (new ProbableStrength(2.0 * (female.strength - 0.5), female.weight)).Relative(given);
                return(attr);
            }
            else if (female.strength < 0.5 && female.weight > 0.25)
            {
                GenderAttribute attr = new GenderAttribute(GenderAttribute.GenderOptions.Male);
                attr.Strength = (new ProbableStrength(2.0 * (0.5 - female.strength), female.weight)).Relative(given);
                return(attr);
            }
            else
            {
                GenderAttribute attr = new GenderAttribute(GenderAttribute.GenderOptions.Human);
                attr.Strength = given;
                return(attr);
            }
        }
Example #2
0
        public static ProbableStrength SeemsReferee(InformedPhrase phrase, IWordLookup informer, ProbableStrength anaphora)
        {
            List <string> words = phrase.Generate();

            double weight = 0;

            foreach (string word in words)
            {
                weight += informer.GetWeight(word, false);
            }

            /* words weight result
             * 1     0      0
             * 1     1      1
             * 2     0      0
             * 2     .5     .4
             * 2     1      2/3
             * 2     1.5    .86
             * 2     2      1
             * 3     .5     .3
             * 3     1      .5
             * 3     2      .8
             */
            double myweight = 2.0 * weight / (words.Count + weight);

            if (words.Count == 1)
            {
                myweight /= 2.0;    // down-score 1-word answers
            }
            if (words.Count > 2)
            {
                myweight /= Math.Log(words.Count);
            }

            ProbableStrength notanaphora = anaphora.InverseProbability();

            return(new ProbableStrength(Math.Sqrt(myweight * notanaphora.strength), notanaphora.weight + .5 - notanaphora.weight * .5));
        }
        public static ProbableStrength SeemsReferee(InformedPhrase phrase, IWordLookup informer, ProbableStrength anaphora)
        {
            List<string> words = phrase.Generate();

            double weight = 0;
            foreach (string word in words)
                weight += informer.GetWeight(word, false);
            /* words weight result
             * 1     0      0
             * 1     1      1
             * 2     0      0
             * 2     .5     .4
             * 2     1      2/3
             * 2     1.5    .86
             * 2     2      1
             * 3     .5     .3
             * 3     1      .5
             * 3     2      .8
             */
            double myweight = 2.0 * weight / (words.Count + weight);
            if (words.Count == 1)
                myweight /= 2.0;    // down-score 1-word answers
            if (words.Count > 2)
                myweight /= Math.Log(words.Count);

            ProbableStrength notanaphora = anaphora.InverseProbability();

            return new ProbableStrength(Math.Sqrt(myweight * notanaphora.strength), notanaphora.weight + .5 - notanaphora.weight * .5);
        }