Ejemplo n.º 1
0
        public void ClassifySongsTogether()
        {
            string positivitySvmPath = System.IO.Path.Combine(Classifier.ExecutableInformation.getModelsDir(), positiveClassificationMethod);
            string energySvmPath     = System.IO.Path.Combine(Classifier.ExecutableInformation.getModelsDir(), energyClassificationMethod);

            Classifier.SupportVectorMachine svm = new Classifier.SupportVectorMachine(positivitySvmPath, energySvmPath);
            List <string> unclassifiedSongs     = new List <string>();

            foreach (string song in songs)
            {
                if (!ServerDatabase.Instance.DoesSongExist(song))
                {
                    unclassifiedSongs.Add(song);
                }
            }
            //Don't try to reclassify the same song. Waste of time.
            string output = svm.Classify(unclassifiedSongs);

            foreach (ClassifierResult result in JsonDTOMapper.getJsonDTO(output).ClassifierResults)
            {
                Song            classifiedSong = result.song;
                EmotionSpaceDTO point          = new EmotionSpaceDTO(classifiedSong.energy, classifiedSong.positivity);
                ServerDatabase.Instance.addSongToDatabase(classifiedSong.title, point);
            }
        }
Ejemplo n.º 2
0
        public void Classify()
        {
            Classifier clas = new Classifier();

            foreach (string song in songs)
            {
                if (!ServerDatabase.Instance.DoesSongExist(song))
                {
                    //Don't try to reclassify the same song. Waste of time.
                    string          output         = clas.classify(song);
                    Song            classifiedSong = JsonDTOMapper.getJsonDTO(output).ClassifierResults[0].song;
                    EmotionSpaceDTO point          = new EmotionSpaceDTO(classifiedSong.energy, classifiedSong.positivity);
                    ServerDatabase.Instance.addSongToDatabase(song, point);
                }
            }
        }