示例#1
0
        public static void ExportMoviesToWeka(Dictionary <string, Movie> movies, string destination)
        {
            List <string> fileLines = new List <string>();

            fileLines.Add("@RELATION movie");
            fileLines.Add("@ATTRIBUTE duration {Short,Regular,Long,Very_Long}");
            fileLines.Add("@ATTRIBUTE awardedDirector {0,1}");
            fileLines.Add("@ATTRIBUTE oscarDirector {0,1}");
            fileLines.Add("@ATTRIBUTE awardedActor {0,1}");
            fileLines.Add("@ATTRIBUTE oscarActor {0,1}");
            fileLines.Add("@ATTRIBUTE genre {Drama,Horror,Action,Comedy,Others}");
            fileLines.Add("@ATTRIBUTE certificate {G, R, PG_13, PG, NOT_RATED}");
            fileLines.Add("@ATTRIBUTE isViolent {0,1}");
            fileLines.Add("@ATTRIBUTE hasFireguns {0,1}");
            fileLines.Add("@ATTRIBUTE isGoreViolent {0,1}");
            fileLines.Add("@ATTRIBUTE hasSex {0,1}");
            fileLines.Add("@ATTRIBUTE hasNudeScenes {0,1}");
            fileLines.Add("@ATTRIBUTE aboutRelationships {0,1}");
            fileLines.Add("@ATTRIBUTE aboutFamily {0,1}");
            fileLines.Add("@ATTRIBUTE hasFlashbacks {0,1}");
            fileLines.Add("@ATTRIBUTE hasSurpriseEnding {0,1}");
            fileLines.Add("@ATTRIBUTE aboutHumanDrama {0,1}");
            fileLines.Add("@ATTRIBUTE aboutNatureOrCity {0,1}");
            fileLines.Add("@ATTRIBUTE hasNowadaysTechnology {0,1}");
            fileLines.Add("@ATTRIBUTE isSequel {0,1}");
            fileLines.Add("@ATTRIBUTE isBasedOnNovel {0,1}");
            fileLines.Add("@ATTRIBUTE isWrittenByDirector {0,1}");
            fileLines.Add("@ATTRIBUTE isIndependent {0,1}");
            fileLines.Add("@ATTRIBUTE hasCameraWorks {0,1}");
            fileLines.Add("@ATTRIBUTE rating {Bad,Regular,Good}");
            fileLines.Add("@DATA");

            string line = "";

            foreach (string key in movies.Keys)
            {
                Movie movie = movies[key];

                string runtime = "";
                if (movie.Runtime < 88.0f)
                {
                    runtime = "Short";
                }
                else if (movie.Runtime < 122.0f)
                {
                    runtime = "Regular";
                }
                else if (movie.Runtime < 160.0f)
                {
                    runtime = "Long";
                }
                else
                {
                    runtime = "Very_Long";
                }
                line += runtime + ",";

                line += ((movie.AwardedDirector) ? "1" : "0") + ",";
                line += ((movie.OscarDirector) ? "1" : "0") + ",";
                line += ((movie.AwardedActors) ? "1" : "0") + ",";
                line += ((movie.OscarActors) ? "1" : "0") + ",";

                string genre       = "";
                string actualGenre = movie.Genre.Split('@')[0];
                #region defining genre
                if (actualGenre.Equals("Drama") || actualGenre.Equals("Family") || actualGenre.Equals("Romance") || actualGenre.Equals("History") || actualGenre.Equals("Reality-TV") || actualGenre.Equals("Adult") || actualGenre.Equals("Biography"))
                {
                    genre = "Drama";
                }
                else if (actualGenre.Equals("Horror") || actualGenre.Equals("Thriller") || actualGenre.Equals("Mistery"))
                {
                    genre = "Horror";
                }
                else if (actualGenre.Equals("Action") || actualGenre.Equals("Adventure") || actualGenre.Equals("Crime") || actualGenre.Equals("Sci-Fi") || actualGenre.Equals("Fantasy") || actualGenre.Equals("War") || actualGenre.Equals("Western") || actualGenre.Equals("Sport"))
                {
                    genre = "Action";
                }
                else if (actualGenre.Equals("Comedy"))
                {
                    genre = "Comedy";
                }
                else
                {
                    genre = "Others";
                }
                #endregion

                line += genre + ",";

                string certificate = "";
                if (movie.Certificate.Equals("R"))
                {
                    certificate = "R";
                }
                else if (movie.Certificate.Equals("G"))
                {
                    certificate = "G";
                }
                else if (movie.Certificate.Equals("PG_13"))
                {
                    certificate = "PG_13";
                }
                else if (movie.Certificate.Equals("PG"))
                {
                    certificate = "PG";
                }
                else
                {
                    certificate = "NOT_RATED";
                }

                line += certificate + ",";

                movie.GetClassification();
                string rating = movie.Classification;

                //isViolent + ";" + hasFireguns + ";" + isGoreViolent + ";" + hasSex + ";" + hasNudeScenes + ";" +
                //aboutRelationships + ";" + aboutFamily + ";" + hasFlashbacks + ";" + hasSurpriseEnding + ";" +
                //aboutHumanDrama + ";" + aboutNatureOrCity + ";" + hasNowadaysTechnology + ";" + isSequel + ";" +
                //isBasedOnNovel + ";" + isWrittenByDirector + ";" + isIndependent + ";" + hasCameraWorks;

                line += ((movie.IsViolent) ? "1" : "0") + ",";
                line += ((movie.HasFireguns) ? "1" : "0") + ",";
                line += ((movie.IsGoreViolent) ? "1" : "0") + ",";
                line += ((movie.HasSex) ? "1" : "0") + ",";
                line += ((movie.HasNudeScenes) ? "1" : "0") + ",";
                line += ((movie.AboutRelationships) ? "1" : "0") + ",";
                line += ((movie.AboutFamily) ? "1" : "0") + ",";
                line += ((movie.HasFlashbacks) ? "1" : "0") + ",";
                line += ((movie.HasSurpriseEnding) ? "1" : "0") + ",";
                line += ((movie.AboutHumanDrama) ? "1" : "0") + ",";
                line += ((movie.AboutNatureOrCity) ? "1" : "0") + ",";
                line += ((movie.HasNowadaysTechnology) ? "1" : "0") + ",";
                line += ((movie.IsSequel) ? "1" : "0") + ",";
                line += ((movie.IsBasedOnNovel) ? "1" : "0") + ",";
                line += ((movie.IsWrittenByDirector) ? "1" : "0") + ",";
                line += ((movie.IsIndependent) ? "1" : "0") + ",";
                line += ((movie.HasCameraWorks) ? "1" : "0") + ",";

                line += rating;
                fileLines.Add(line);
                line = "";
            }

            FileAO.ExportToArff(fileLines, destination);
        }
示例#2
0
        public static void ExportMoviesToWeka(List <Movie> movies, string destination)
        {
            List <string> fileLines = new List <string>();

            fileLines.Add("@RELATION movie");
            //fileLines.Add("@ATTRIBUTE duration NUMERIC");
            fileLines.Add("@ATTRIBUTE duration {Short,Regular,Long,Very_Long}");
            fileLines.Add("@ATTRIBUTE awardedDirector {0,1}");
            fileLines.Add("@ATTRIBUTE oscarDirector {0,1}");
            fileLines.Add("@ATTRIBUTE awardedActor {0,1}");
            fileLines.Add("@ATTRIBUTE oscarActor {0,1}");
            fileLines.Add("@ATTRIBUTE genre {Drama,Horror,Action,Comedy,Others}");
            fileLines.Add("@ATTRIBUTE certificate {G, R, PG_13, PG, NOT_RATED}");
            fileLines.Add("@ATTRIBUTE rating {Bad,Regular,Good}");
            fileLines.Add("@DATA");

            string line = "";

            int a = 0, b = 0, c = 0;

            int drama = 0, horror = 0, action = 0, comedy = 0, others = 0;
            int shorte = 0, regular = 0, longe = 0, verylong = 0;

            foreach (Movie movie in movies)
            {
                //line += movie.Runtime + ",";

                string runtime = "";
                if (movie.Runtime < 88.0f)
                {
                    runtime = "Short";
                    shorte++;
                }
                else if (movie.Runtime < 122.0f)
                {
                    runtime = "Regular";
                    regular++;
                }
                else if (movie.Runtime < 160.0f)
                {
                    runtime = "Long";
                    longe++;
                }
                else
                {
                    runtime = "Very_Long";
                    verylong++;
                }
                line += runtime + ",";

                line += ((movie.AwardedDirector)? "1" : "0") + ",";
                line += ((movie.OscarDirector)? "1" : "0") + ",";
                line += ((movie.AwardedActors)? "1" : "0") + ",";
                line += ((movie.OscarActors)? "1" : "0") + ",";

                string genre       = "";
                string actualGenre = movie.Genre.Split('@')[0];
                #region defining genre
                if (actualGenre.Equals("Drama") || actualGenre.Equals("Family") || actualGenre.Equals("Romance") || actualGenre.Equals("History") || actualGenre.Equals("Reality-TV") || actualGenre.Equals("Adult") || actualGenre.Equals("Biography"))
                {
                    genre = "Drama";
                    drama++;
                }
                else if (actualGenre.Equals("Horror") || actualGenre.Equals("Thriller") || actualGenre.Equals("Mistery"))
                {
                    genre = "Horror";
                    horror++;
                }
                else if (actualGenre.Equals("Action") || actualGenre.Equals("Adventure") || actualGenre.Equals("Crime") || actualGenre.Equals("Sci-Fi") || actualGenre.Equals("Fantasy") || actualGenre.Equals("War") || actualGenre.Equals("Western") || actualGenre.Equals("Sport"))
                {
                    genre = "Action";
                    action++;
                }
                else if (actualGenre.Equals("Comedy"))
                {
                    genre = "Comedy";
                    comedy++;
                }
                else
                {
                    genre = "Others";
                    others++;
                }
                #endregion

                line += genre + ",";

                string certificate = "";
                if (movie.Certificate.Equals("R"))
                {
                    certificate = "R";
                }
                else if (movie.Certificate.Equals("G"))
                {
                    certificate = "G";
                }
                else if (movie.Certificate.Equals("PG_13"))
                {
                    certificate = "PG_13";
                }
                else if (movie.Certificate.Equals("PG"))
                {
                    certificate = "PG";
                }
                else
                {
                    certificate = "NOT_RATED";
                }

                line += certificate + ",";

                movie.GetClassification();
                string rating = movie.Classification;

                line += rating;
                fileLines.Add(line);
                line = "";
            }

            Console.WriteLine("drama = " + drama);
            Console.WriteLine("horror = " + horror);
            Console.WriteLine("action = " + action);
            Console.WriteLine("comedy = " + comedy);
            Console.WriteLine("others = " + others);

            Console.WriteLine();

            Console.WriteLine("Bad = " + c);
            Console.WriteLine("Regular = " + b);
            Console.WriteLine("Good = " + a);

            Console.WriteLine();

            Console.WriteLine("shorte = " + shorte);
            Console.WriteLine("regular = " + regular);
            Console.WriteLine("longe = " + longe);
            Console.WriteLine("verylong = " + verylong);

            FileAO.ExportToArff(fileLines, destination);
        }
示例#3
0
        public static void ExportMoviesToWeka(List <Movie> movies, string destination)
        {
            List <string> fileLines = new List <string>();

            fileLines.Add("@RELATION movie");
            fileLines.Add("@ATTRIBUTE duration {Short,Regular,Long,Very_Long}");
            fileLines.Add("@ATTRIBUTE awardedDirector {0,1}");
            fileLines.Add("@ATTRIBUTE oscarDirector {0,1}");
            fileLines.Add("@ATTRIBUTE awardedActor {0,1}");
            fileLines.Add("@ATTRIBUTE oscarActor {0,1}");
            fileLines.Add("@ATTRIBUTE genre {Drama,Horror,Action,Comedy,Others}");
            fileLines.Add("@ATTRIBUTE certificate {G, R, PG_13, PG, NOT_RATED}");
            fileLines.Add("@ATTRIBUTE rating {Very Bad, Bad,Regular,Good, Excellent}");

            //
            fileLines.Add("@DATA");

            string line = "";

            foreach (Movie movie in movies)
            {
                string runtime = "";
                if (movie.Runtime < 88.0f)
                {
                    runtime = "Short";
                }
                else if (movie.Runtime < 122.0f)
                {
                    runtime = "Regular";
                }
                else if (movie.Runtime < 160.0f)
                {
                    runtime = "Long";
                }
                else
                {
                    runtime = "Very_Long";
                }
                line += runtime + ",";

                line += ((movie.AwardedDirector)? "1" : "0") + ",";
                line += ((movie.OscarDirector)? "1" : "0") + ",";
                line += ((movie.AwardedActors)? "1" : "0") + ",";
                line += ((movie.OscarActors)? "1" : "0") + ",";

                string genre       = "";
                string actualGenre = movie.Genre.Split('@')[0];
                movie.Genre = actualGenre;
                movie.GetMovieGenre();

                line += genre + ",";

                string certificate = "";
                if (movie.Certificate.Equals("R"))
                {
                    certificate = "R";
                }
                else if (movie.Certificate.Equals("G"))
                {
                    certificate = "G";
                }
                else if (movie.Certificate.Equals("PG_13"))
                {
                    certificate = "PG_13";
                }
                else if (movie.Certificate.Equals("PG"))
                {
                    certificate = "PG";
                }
                else
                {
                    certificate = "NOT_RATED";
                }

                line += certificate + ",";

                movie.GetClassification();
                string rating = movie.Classification;

                line += rating;
                fileLines.Add(line);
                line = "";
            }

            FileAO.ExportToArff(fileLines, destination);
        }
示例#4
0
        public static void ExportMoviesToWeka(Dictionary <string, Movie> movies, string destination)
        {
            List <string> fileLines = new List <string>();

            fileLines.Add("@RELATION movie");
            fileLines.Add("@ATTRIBUTE duration {Short,Regular,Long,Very_Long}");
            fileLines.Add("@ATTRIBUTE awardedDirector {0,1}");
            fileLines.Add("@ATTRIBUTE oscarDirector {0,1}");
            fileLines.Add("@ATTRIBUTE awardedActor {0,1}");
            fileLines.Add("@ATTRIBUTE oscarActor {0,1}");
            fileLines.Add("@ATTRIBUTE genre {Drama,Horror,Action,Comedy,Others}");
            fileLines.Add("@ATTRIBUTE certificate {G, R, PG_13, PG, NOT_RATED}");
            fileLines.Add("@ATTRIBUTE rating {Bad,Regular,Good}");
            fileLines.Add("@DATA");

            string line = "";

            foreach (string key in movies.Keys)
            {
                Movie movie = movies[key];

                string runtime = "";
                if (movie.Runtime < 88.0f)
                {
                    runtime = "Short";
                }
                else if (movie.Runtime < 122.0f)
                {
                    runtime = "Regular";
                }
                else if (movie.Runtime < 160.0f)
                {
                    runtime = "Long";
                }
                else
                {
                    runtime = "Very_Long";
                }
                line += runtime + ",";

                line += ((movie.AwardedDirector) ? "1" : "0") + ",";
                line += ((movie.OscarDirector) ? "1" : "0") + ",";
                line += ((movie.AwardedActors) ? "1" : "0") + ",";
                line += ((movie.OscarActors) ? "1" : "0") + ",";

                string genre       = "";
                string actualGenre = movie.Genre.Split('@')[0];
                #region defining genre
                if (actualGenre.Equals("Drama") || actualGenre.Equals("Family") || actualGenre.Equals("Romance") || actualGenre.Equals("History") || actualGenre.Equals("Reality-TV") || actualGenre.Equals("Adult") || actualGenre.Equals("Biography"))
                {
                    genre = "Drama";
                }
                else if (actualGenre.Equals("Horror") || actualGenre.Equals("Thriller") || actualGenre.Equals("Mistery"))
                {
                    genre = "Horror";
                }
                else if (actualGenre.Equals("Action") || actualGenre.Equals("Adventure") || actualGenre.Equals("Crime") || actualGenre.Equals("Sci-Fi") || actualGenre.Equals("Fantasy") || actualGenre.Equals("War") || actualGenre.Equals("Western") || actualGenre.Equals("Sport"))
                {
                    genre = "Action";
                }
                else if (actualGenre.Equals("Comedy"))
                {
                    genre = "Comedy";
                }
                else
                {
                    genre = "Others";
                }
                #endregion

                line += genre + ",";

                string certificate = "";
                if (movie.Certificate.Equals("R"))
                {
                    certificate = "R";
                }
                else if (movie.Certificate.Equals("G"))
                {
                    certificate = "G";
                }
                else if (movie.Certificate.Equals("PG_13"))
                {
                    certificate = "PG_13";
                }
                else if (movie.Certificate.Equals("PG"))
                {
                    certificate = "PG";
                }
                else
                {
                    certificate = "NOT_RATED";
                }

                line += certificate + ",";

                movie.GetClassification();
                string rating = movie.Classification;

                line += rating;
                fileLines.Add(line);
                line = "";
            }

            FileAO.ExportToArff(fileLines, destination);
        }