예제 #1
0
 // One subject summaries
 public Measures(LinguisticVariable quantifier, List <LinguisticVariable> qualifiers,
                 List <LinguisticVariable> summarizers, List <FifaPlayer> fifaPlayers, List <double> weights)
 {
     SetFields(quantifier, qualifiers, summarizers, weights);
     _fifaPlayers = fifaPlayers;
     _weights     = weights;
 }
예제 #2
0
        // T1
        public static double DegreeOfTruth(List <FifaPlayer> fifaPlayers, LinguisticVariable quantifier,
                                           List <LinguisticVariable> summarizers, List <LinguisticVariable> qualifiers)
        {
            if (qualifiers != null) // zdanie z kwalifikatorem
            {
                // nowa baza D' - strona  150 a.n.
                var fifaPlayersPrime = fifaPlayers
                                       .Where(player => CountMembershipValue(qualifiers, player) > 0)
                                       .ToList();

                // wzór na r
                double d = 0;
                double u = 0;
                foreach (var x in fifaPlayersPrime)
                {
                    u += Math.Min(CountMembershipValue(qualifiers, x), CountMembershipValue(summarizers, x));
                    d += CountMembershipValue(qualifiers, x);
                }

                return(quantifier.QuantifierAbsolute
                    ? quantifier.MembershipFunction.CountValue(u)
                    : quantifier.MembershipFunction.CountValue(u / d));
            }

            // zdanie bez kwalifikatora
            var r = fifaPlayers.Sum(x => CountMembershipValue(summarizers, x));

            return(quantifier.QuantifierAbsolute
                ? quantifier.MembershipFunction.CountValue(r)
                : quantifier.MembershipFunction.CountValue(r / fifaPlayers.Count));
        }
예제 #3
0
        public List <List <string> > GenerateAllFormsSentence(List <FifaPlayer> p1, List <FifaPlayer> p2,
                                                              LinguisticVariable quantifier, List <LinguisticVariable> summarizers, List <LinguisticVariable> qualifiers)
        {
            var      returnList = new List <List <string> >();
            Measures measures;

            for (int t = 1; t <= 4; t++)
            {
                var sentence = new List <string>();
                measures = new Measures(quantifier, qualifiers, summarizers, p1, p2, null, t);
                switch (t)
                {
                case 1:
                    sentence.Add(GenerateSentenceFirstForm(p1, p2, quantifier, summarizers));
                    break;

                case 2:
                    sentence.Add(GenerateSentenceSecondForm(p1, p2, quantifier, summarizers, qualifiers));
                    break;

                case 3:
                    sentence.Add(GenerateSentenceThirdForm(p1, p2, quantifier, summarizers, qualifiers));
                    break;

                case 4:
                    sentence.Add(GenerateSentenceFourthForm(p1, p2, summarizers));
                    break;
                }

                if (sentence[^ 1] != "err")
예제 #4
0
 private void SetFields(
     LinguisticVariable quantifier, List <LinguisticVariable> qualifiers,
     List <LinguisticVariable> summarizers, List <double> wages)
 {
     _quantifier  = quantifier;
     _qualifiers  = qualifiers;
     _summarizers = summarizers;
     _weights     = wages;
 }
예제 #5
0
        // T7
        public static double DegreeOfQuantifierCardinality(LinguisticVariable quantifier, List <FifaPlayer> fifaPlayers)
        {
            var x = quantifier.MembershipFunction.CountArea();

            if (quantifier.QuantifierAbsolute)
            {
                return(1 - x / fifaPlayers.Count);
            }
            return(1 - x);
        }
예제 #6
0
 // Multi subject summaries
 public Measures(LinguisticVariable quantifier, List <LinguisticVariable> qualifiers,
                 List <LinguisticVariable> summarizers, List <FifaPlayer> p1, List <FifaPlayer> p2, List <double> wages,
                 int type)
 {
     SetFields(quantifier, qualifiers, summarizers, wages);
     _fifaPlayers = new List <FifaPlayer>();
     _fifaPlayers.AddRange(p1);
     _fifaPlayers.AddRange(p2);
     _p1   = p1;
     _p2   = p2;
     _type = type;
 }
예제 #7
0
        // T6
        public static double DegreeOfQuantifierImprecision(LinguisticVariable quantifier, List <FifaPlayer> fifaPlayers)
        {
            FuzzySet fs;

            if (quantifier.QuantifierAbsolute)
            {
                fs = new FuzzySet("Quantifier Absolute", quantifier.MembershipFunction);
            }
            else
            {
                fs = new FuzzySet("Quantifier", quantifier.MembershipFunction);
            }
            return(1 - fs.DegreeOfFuzziness(fifaPlayers));
        }
예제 #8
0
        // Q P1 w porównaniu do P2 ma S
        public string GenerateSentenceFirstForm(List <FifaPlayer> p1, List <FifaPlayer> p2,
                                                LinguisticVariable quantifier, List <LinguisticVariable> summarizers)
        {
            if (quantifier.QuantifierAbsolute)
            {
                return("err");
            }
            var p1Plural = ConvertToPluralForm(p1[0].GetPosition());
            var p2Plural = ConvertToPluralForm(p2[0].GetPosition());
            var text     = quantifier.Text + " of " + p1Plural + " in comparision to " + p2Plural + " ";

            text += ListToStringConverter.ConvertSummarizersToString(summarizers) + ".";
            generatedSentence = text;
            return(text);
        }
예제 #9
0
        private static double CountRforT4(LinguisticVariable summarizer,
                                          List <FifaPlayer> fifaPlayers)
        {
            double sumG = 0;

            foreach (var fp in fifaPlayers)
            {
                var miS = summarizer.CountMembership(fp);
                if (miS > 0)
                {
                    sumG++;
                }
            }

            return(sumG / fifaPlayers.Count);
        }
예제 #10
0
        public static double DegreeOfTruthMultiSubject(List <FifaPlayer> p1, List <FifaPlayer> p2,
                                                       LinguisticVariable quantifier, List <LinguisticVariable> summarizers,
                                                       List <LinguisticVariable> qualifiers, int type)
        {
            var mp1   = p1.Count;
            var mp2   = p2.Count;
            var sumP1 = p1.Sum(x => CountMembershipValue(summarizers, x));
            var sumP2 = p2.Sum(x => CountMembershipValue(summarizers, x));

            switch (type)
            {
            case 1:
                var upperCase1 = sumP1 / mp1;
                var lowerCase1 = sumP1 / mp1 + sumP2 / mp2;
                return(quantifier.MembershipFunction.CountValue(upperCase1 / lowerCase1));

            case 2:
                var sumP2W = p2.Sum(x =>
                                    Math.Min(CountMembershipValue(summarizers, x), CountMembershipValue(qualifiers, x)));
                var upperCase2 = sumP1 / mp1;
                var lowerCase2 = sumP1 / mp1 + sumP2W / mp2;
                return(quantifier.MembershipFunction.CountValue(upperCase2 / lowerCase2));

            case 3:
                var sumP1W = p1.Sum(x =>
                                    Math.Min(CountMembershipValue(summarizers, x), CountMembershipValue(qualifiers, x)));
                var upperCase3 = sumP1W / mp1;
                var lowerCase3 = sumP1W / mp1 + sumP2 / mp2;
                return(quantifier.MembershipFunction.CountValue(upperCase3 / lowerCase3));

            case 4:
                return(sumP1 / (sumP1 + sumP2));

            default:
                return(-121321);
            }
        }
예제 #11
0
        // 0 - Sentence, 1-11 - t1-t11 , 12 - sumT
        // tworzy zdanie i wylicza T1-T11
        public List <string> GenerateOneSubjectSentence(LinguisticVariable quantifier,
                                                        List <LinguisticVariable> qualifiers,
                                                        List <LinguisticVariable> summarizers, List <double> weights)
        {
            var startText = quantifier.Text + " of football players ";

            if (qualifiers != null)
            {
                startText += ", which " + ListToStringConverter.ConvertSummarizersToString(qualifiers) + ", ";
            }

            startText += ListToStringConverter.ConvertSummarizersToString(summarizers) + ".";
            var returnList = new List <string> {
                startText
            };
            var measures = new Measures(quantifier, qualifiers, summarizers, _fifaPlayers, weights);

            foreach (var m in measures.CountMeasuresOneSubject())
            {
                returnList.Add(m.ToString(CultureInfo.InvariantCulture));
            }

            return(returnList);
        }