コード例 #1
0
 public void DoClassification()
 {
     if (SingleThreaded)
     {
         var cnt = 0;
         foreach (var post in Records)
         {
             Process(++cnt, post);
         }
     }
     else
     {
         Parallel.ForEach(
             GetNextPost(),
             () => new Classify(this),
             (line, state, cnt, partial) => partial.Process(cnt, line),
             partial =>
         {
             lock (_obj)
             {
                 Scores.AddRange(partial.Scores);
                 Sad.Merge(partial.Sad);
             }
         });
     }
 }
コード例 #2
0
ファイル: Startup.cs プロジェクト: MihailDobrev/SoftUni
        private static string SetMood(int totalHappiness)
        {
            string mood = string.Empty;

            if (totalHappiness < -5)
            {
                Angry angry = new Angry();
                mood = angry.SetMood(totalHappiness);
            }
            else if (totalHappiness >= -5 && totalHappiness <= 0)
            {
                Sad sad = new Sad();
                mood = sad.SetMood(totalHappiness);
            }
            else if (totalHappiness >= 1 && totalHappiness <= 15)
            {
                Happy happy = new Happy();
                mood = happy.SetMood(totalHappiness);
            }
            else if (totalHappiness > 15)
            {
                JavaScript js = new JavaScript();
                mood = js.SetMood(totalHappiness);
            }

            return(mood);
        }
コード例 #3
0
 private void OnSad()
 {
     if (Sad != null)
     {
         Sad.Invoke();
     }
 }
コード例 #4
0
        public ClassifyArea Process(long cnt, AreaSentiExtract post)
        {
            // find areas
            var pt      = new LatLong(post.Xloc, post.Yloc);
            var regions = Sad.WhatRegions(pt);

            var score = new LocatedAreaScore(post, regions);

            Scores.Add(score);

            return(this);
        }
コード例 #5
0
        public Classify Process(long cnt, GeoSentimentParameters post)
        {
            // find areas
            var pt      = new LatLong(post.Xloc, post.Yloc);
            var regions = Sad.WhatRegions(pt);

            var score = new LocatedScore(post, regions);

            Scores.Add(score);

            return(this);
        }
コード例 #6
0
        public override string ToString()
        {
            string result = Timestamp.ToString();

            result += ";" + Neutral.ToString();
            result += ";" + Happy.ToString();
            result += ";" + Sad.ToString();
            result += ";" + Angry.ToString();
            result += ";" + Surprised.ToString();
            result += ";" + Scared.ToString();
            result += ";" + Disgusted.ToString();
            result += ";" + Contempt.ToString();
            result += ";" + Valence.ToString();
            result += ";" + Arousal.ToString();

            return(result);
        }
コード例 #7
0
    private void Awake()
    {
        //For scared condition
        orangeDino = GameObject.FindObjectOfType <OrangeDinoBoo>();

        //For angry condition
        greenDino = GameObject.FindObjectOfType <CubeDinoCollect>();

        //For sad condition
        calCounter = GameObject.FindObjectOfType <CubeCaloryCounter>();

        //friend bot not written yet


        _stateMachine = new StateMachine();


        //here the Emotion States are declared and instantiated:
        var scared = new Scared(this /*,  animator*/);
        var happy  = new Happy(this);
        var sad    = new Sad(this);
        var angry  = new Angry(this);

        //var depressed = new Depressed(this);

        //here ALL the transitions are added(declared) to _transition
        At(happy, sad, calCounter.calories > hungerCal);
        At(sad, happy, calCounter.calories < hungerCal);



        At(angry, happy, orangeDino.booNear1);
        At(happy, angry, angry.timeStuck > 1f);

        _stateMachine.AddAnyTransition(scared, orangeDino.booNear1);
        At(happy, scared, scared.timeStuck > 3f);



        //Set the starting ( happy) state
        _stateMachine.SetState(happy);


        void At(IState to, IState from, bool condition) => _stateMachine.AddTransition(to, from, condition);
    }
コード例 #8
0
        public Classify Process(long cnt, TagPosterDetails post)
        {
            // find areas
            if (!post.Xloc.HasValue || !post.Yloc.HasValue)
            {
                return(this);
            }

            var pt = new LatLong(post.Xloc.Value, post.Yloc.Value);

            var regions = Sad.WhatRegions(pt);
            var res     = _analyzer.PolarityScores(post.Text);
            var stamp   = post.LocalTime;

            var score = new LocatedScore(res.Compound, stamp, regions);

            Scores.Add(score);

            return(this);
        }
    public static Mood GetMood(int happinessPoints)
    {
        Mood mood = null;

        if (happinessPoints < -5)
        {
            mood = new Angry();
        }
        else if (happinessPoints <= 0)
        {
            mood = new Sad();
        }
        else if (happinessPoints <= 15)
        {
            mood = new Happy();
        }
        else
        {
            mood = new JavaScript();
        }

        return(mood);
    }
コード例 #10
0
    public static Mood CreateMood(int happiness)
    {
        Mood newMood = null;

        if (happiness < -5)
        {
            newMood = new Angry();
        }
        else if (happiness <= 0)
        {
            newMood = new Sad();
        }
        else if (happiness < 15)
        {
            newMood = new Happy();
        }
        else
        {
            newMood = new JavaScript();
        }

        return(newMood);
    }
コード例 #11
0
ファイル: Program.cs プロジェクト: Serhiy0406/repository
        static void Main(string[] args)
        {
            try
            {
                int      totalpoints = 0;
                string   a           = Console.ReadLine();
                string[] s           = a.Split(' ');
                if (a.Length > 1000)
                {
                    throw new Exception("The characters in the input string will be no more than: 1000");
                }
                if (s.Length < 1 || s.Length > 100)
                {
                    throw new Exception("The food count would be in the range [1…100].");
                }
                string caseSwitch;
                foreach (var p in s)
                {
                    caseSwitch = p;
                    switch (caseSwitch)
                    {
                    case "Apple":
                        Apple apple = new Apple(p);
                        totalpoints += apple.Point;
                        break;

                    case "Cram":
                        Cram cram = new Cram(p);
                        totalpoints += cram.Point;
                        break;

                    case "HoneyCake":
                        HoneyCake honeyCake = new HoneyCake(p);
                        totalpoints += honeyCake.Point;
                        break;

                    case "Lembas":
                        Lembas lembas = new Lembas(p);
                        totalpoints += lembas.Point;
                        break;

                    case "Melon":
                        Melon melon = new Melon(p);
                        totalpoints += melon.Point;
                        break;

                    case "Mushrooms":
                        Mushrooms mushrooms = new Mushrooms(p);
                        totalpoints += mushrooms.Point;
                        break;

                    default:
                        EverithingElse everithingElse = new EverithingElse(p);
                        totalpoints += everithingElse.Point;
                        break;
                    }
                }
                if (totalpoints < -5)
                {
                    Angry angry = new Angry();
                    Console.WriteLine(totalpoints);
                    angry.Output();
                }
                else if (totalpoints >= 1 && totalpoints <= 15)
                {
                    Happy happy = new Happy();
                    Console.WriteLine(totalpoints);
                    happy.Output();
                }
                else if (totalpoints >= -5 && totalpoints <= 0)
                {
                    Sad sad = new Sad();
                    Console.WriteLine(totalpoints);
                    sad.Output();
                }
                else if (totalpoints > 15)
                {
                    JavaScript javaScript = new JavaScript();
                    Console.WriteLine(totalpoints);
                    javaScript.Output();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{ex.Message}");
            }


            Console.ReadKey();
        }
コード例 #12
0
        public void TestSadPositive()
        {
            var actual = new Sad().FaceMask();

            Assert.AreEqual(expected: ":-(", actual: actual);
        }
コード例 #13
0
        public void TestSadNegative()
        {
            var actual = new Sad().FaceMask();

            Assert.AreNotEqual(expected: ":-)", actual: actual);
        }