コード例 #1
0
ファイル: TALA.cs プロジェクト: FerryWr25/Site_Final_Mining
        public bool getKataSambung(string kata)
        {
            con.openConnection();
            string    query  = "SELECT kata FROM public.kata_sambung where kata =  '" + kata + "'";
            DataTable result = this.con.getResult(query);

            if (result.Rows.Count == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        public string[] getDate_PURE(string[] idDoc, string sumber)
        {
            List <string>   List_dateDoc = new List <string>();
            connectionClass con          = new connectionClass();
            string          queryTerm;

            if (!sumber.Equals("null"))
            {
                queryTerm = "SELECT  \"dateDoc\"  FROM public.\"Dokumen\" where \"idDokumen\" in (" + string.Join(", ", idDoc) + ") " +
                            " and site_name='" + sumber + "' order by \"dateDoc\" desc;";
            }
            else
            {
                queryTerm = "SELECT  \"dateDoc\"  FROM public.\"Dokumen\" where \"idDokumen\" in (" + string.Join(", ", idDoc) + ") order by \"dateDoc\" desc;";
            }
            con.openConnection();
            DataTable result = con.getResult(queryTerm);

            string[] arrayDate = new string[result.Rows.Count];
            for (int i = 0; i < result.Rows.Count; i++)
            {
                string temp = result.Rows[i]["dateDoc"].ToString();
                if (temp.Length > 10)
                {
                    temp = temp.Substring(0, temp.Length - 1);
                }
                if (!List_dateDoc.Contains(temp))
                {
                    List_dateDoc.Add(temp);
                }
            }
            arrayHasilDatePure = List_dateDoc.ToArray();
            return(arrayHasilDatePure);
        }
コード例 #3
0
 public void getDoc_MengandungQuery(string[] query)
 {
     double[] hasilPembilang_Perkata;
     double[] hasilPenyebut_Perkata;
     for (int i = 0; i < query.Length; i++)
     {
         string queryPakek = cariID_Term(query[i]);
         if (queryPakek.Equals("0"))
         {
             Console.WriteLine("Tidak ada dokument yang memakai kata '" + query + "'");
             Console.WriteLine("======================================================================");
         }
         else
         {
             connectionClass con = new connectionClass();
             con.openConnection();
             string queryDF = "SELECT \"idDokumen\", \"id_Term\", \"TF-IDF\" FROM public.\"bobotTerm\" where" +
                              " \"id_Term\"='" + queryPakek + "'";
             DataTable result      = con.getResult(queryDF);
             string[]  dataID_Term = new string[result.Rows.Count];
             hasilTF_IDF_Perkata_Pembagi   = new double[dataID_Term.Length];
             hasilTF_IDF_Perkata_Pembilang = new double[dataID_Term.Length];
             string[] dataTF_IDF_Term = new string[result.Rows.Count];
         }
     }
 }
コード例 #4
0
        public string[] getID_Doc_Sumber(int status, string[] idTerm)
        {
            connectionClass con = new connectionClass();

            con.openConnection();
            DataTable result;

            string[]      arrayDoc;
            List <string> List_idDoc = new List <string>();

            if (status == 1)
            {
                string queryTerm = "SELECT dk.\"idDokumen\",count(*) FROM" +
                                   " public.\"bobotTerm\" bt join \"Dokumen\" dk on (bt.\"idDokumen\"=dk.\"idDokumen\")" +
                                   " where dk.site_name='Tribunnews.com' and bt.\"id_Term\" in (" + string.Join(", ", idTerm) + ") group by dk.\"idDokumen\";";
                result = con.getResult(queryTerm);
                for (int i = 0; i < result.Rows.Count; i++)
                {
                    if (!List_idDoc.Contains(result.Rows[i]["idDokumen"]))
                    {
                        List_idDoc.Add("'" + result.Rows[i]["idDokumen"] + "'".ToString());
                    }
                }
                arrayDoc = List_idDoc.ToArray();
            }
            else if (status == 2)
            {
                string queryTerm = "SELECT dk.\"idDokumen\",count(*) FROM" +
                                   " public.\"bobotTerm\" bt join \"Dokumen\" dk on (bt.\"idDokumen\"=dk.\"idDokumen\")" +
                                   " where dk.site_name='Detik.com' and bt.\"id_Term\" in (" + string.Join(", ", idTerm) + ") group by dk.\"idDokumen\";";
                result = con.getResult(queryTerm);
                for (int i = 0; i < result.Rows.Count; i++)
                {
                    if (!List_idDoc.Contains(result.Rows[i]["idDokumen"]))
                    {
                        List_idDoc.Add("'" + result.Rows[i]["idDokumen"] + "'".ToString());
                    }
                }
                arrayDoc = List_idDoc.ToArray();
            }
            else
            {
                string queryTerm = "SELECT dk.\"idDokumen\",count(*) FROM" +
                                   " public.\"bobotTerm\" bt join \"Dokumen\" dk on (bt.\"idDokumen\"=dk.\"idDokumen\")" +
                                   " where dk.site_name='Liputan6.com' and bt.\"id_Term\" in (" + string.Join(", ", idTerm) + ") group by dk.\"idDokumen\";";
                result = con.getResult(queryTerm);
                for (int i = 0; i < result.Rows.Count; i++)
                {
                    if (!List_idDoc.Contains(result.Rows[i]["idDokumen"]))
                    {
                        List_idDoc.Add("'" + result.Rows[i]["idDokumen"] + "'".ToString());
                    }
                }
                arrayDoc = List_idDoc.ToArray();
            }
            return(arrayDoc);
        }
コード例 #5
0
        public string getIDF_Term(string term)
        {
            connectionClass con = new connectionClass();

            con.openConnection();
            double    getIDF_Term = 0;
            string    QgetDF_Term = "SELECT \"IDF\"  FROM public.\"Term\" where \"Term\"='" + term + "';";
            DataTable result      = con.getResult(QgetDF_Term);

            getIDF_Term = Convert.ToDouble(result.Rows[0]["IDF"]);
            return(getIDF_Term.ToString());
        }
コード例 #6
0
        public double cekKetersediaan_Term(string kata)
        {
            connectionClass con = new connectionClass();

            con.openConnection();
            string    query  = "SELECT \"Term\"  FROM public.\"Term\" where \"Term\"='" + kata + "';";
            DataTable result = con.getResult(query);

            if (result.Rows.Count >= 1)
            {
                con.openConnection();
                double    getIDF_Term = 0;
                string    QgetDF_Term = "SELECT \"IDF\"  FROM public.\"Term\" where \"Term\"='" + kata + "';";
                DataTable result2     = con.getResult(QgetDF_Term);
                getIDF_Term = Convert.ToDouble(result2.Rows[0]["IDF"]);
                return(getIDF_Term);
            }
            else
            {
                return(0);
            }
        }
コード例 #7
0
        public string[] getId_Doc(string idTerm)
        {
            connectionClass con = new connectionClass();

            con.openConnection();
            string    query  = "SELECT \"idDokumen\" FROM public.\"bobotTerm\" where \"id_Term\" = '" + idTerm + "'";
            DataTable result = con.getResult(query);

            string[] arrayDoc = new string[result.Rows.Count];
            for (int i = 0; i < result.Rows.Count; i++)
            {
                arrayDoc[i] = result.Rows[i]["idDokumen"].ToString();
            }
            return(arrayDoc);
        }
コード例 #8
0
        public string cariID_Term(string data)
        {
            connectionClass con = new connectionClass();

            con.openConnection();
            string    termCari  = null;
            string    termMasuk = "SELECT * FROM public.\"Term\" where \"Term\"='" + data + "';";
            DataTable result2   = con.getResult(termMasuk);

            idDoc = new string[result2.Rows.Count];
            if (result2.Rows.Count >= 1)
            {
                termCari = result2.Rows[0]["id_Term"].ToString();
                return(termCari);
            }
            else
            {
                return("null");
            }
        }
コード例 #9
0
        public double cariTF_IDF(string id_doc, string idTerm)
        {
            connectionClass con = new connectionClass();

            con.openConnection();
            double termCari;
            string termMasuk = "SELECT \"TF-IDF\" FROM public.\"bobotTerm\" where" +
                               " \"idDokumen\"=" + id_doc + " and \"id_Term\"=" + idTerm + ";";
            DataTable result2 = con.getResult(termMasuk);

            if (result2.Rows.Count >= 1)
            {
                termCari = Convert.ToDouble(result2.Rows[0]["TF-IDF"]);
                return(termCari);
            }
            else
            {
                return(0);
            }
        }
コード例 #10
0
        public string[] getID_Doc(string[] idTerm)
        {
            connectionClass con = new connectionClass();

            con.openConnection();
            string queryTerm = "SELECT \"idDokumen\" ,count(*) FROM public.\"bobotTerm\" where \"id_Term\" in " +
                               "(" + string.Join(", ", idTerm) + ") group by \"idDokumen\";";
            DataTable result = con.getResult(queryTerm);

            string[]      arrayDoc   = new string[result.Rows.Count];
            List <string> List_idDoc = new List <string>();

            for (int i = 0; i < result.Rows.Count; i++)
            {
                if (!List_idDoc.Contains(result.Rows[i]["idDokumen"]))
                {
                    List_idDoc.Add("'" + result.Rows[i]["idDokumen"] + "'".ToString());
                }
            }
            arrayDoc = List_idDoc.ToArray();
            return(arrayDoc);
        }
コード例 #11
0
        public string[] getID_Term(string[] query)
        {
            connectionClass con = new connectionClass();

            con.openConnection();
            string    queryTerm = "SELECT \"id_Term\" FROM public.\"Term\" where \"Term\" in ( " + string.Join(", ", query) + ");";
            DataTable result    = con.getResult(queryTerm);

            string[] arrayTerm = new string[result.Rows.Count];

            for (int i = 0; i < result.Rows.Count; i++)
            {
                if (result.Rows.Count > 0)
                {
                    arrayTerm[i] = "'" + result.Rows[i]["id_Term"] + "'".ToString();
                }
                else
                {
                    arrayTerm[i] = "null".ToString();
                }
            }
            return(arrayTerm);
        }
コード例 #12
0
        public string[] getDate_Doc(int status, string[] idDoc)
        {
            connectionClass con = new connectionClass();

            con.openConnection();
            string[] arrayDateAkhir;
            if (status == 1) // semua ambil
            {
                string    queryTerm = "SELECT  \"dateDoc\"  FROM public.\"Dokumen\" where \"idDokumen\" in (" + string.Join(", ", idDoc) + ") order by  \"dateDoc\" desc;";
                DataTable result    = con.getResult(queryTerm);
                string[]  arrayDate = new string[result.Rows.Count];
                arrayDateAkhir = new string[result.Rows.Count];
                List <string> List_dateDoc      = new List <string>();
                List <string> List_dateDocAkhir = new List <string>();

                for (int i = 0; i < result.Rows.Count; i++)
                {
                    string temp = result.Rows[i]["dateDoc"].ToString();
                    if (temp.Length > 10)
                    {
                        temp = temp.Substring(0, temp.Length - 1);
                    }
                    List_dateDoc.Add(temp);
                }
                arrayDate = List_dateDoc.OrderBy(x => DateTime.Parse(x)).ToArray();
                for (int i = 0; i < arrayDate.Length; i++)
                {
                    List_dateDocAkhir.Add("'" + arrayDate[i] + "'");
                }
                arrayDateAkhir = List_dateDocAkhir.ToArray();
                Console.WriteLine("=============ini urutannya");
                for (int i = 0; i < arrayDateAkhir.Length; i++)
                {
                    Console.WriteLine(arrayDateAkhir[i]);
                }
            }
            else if (status == 2) // ambil data tribun saja
            {
                string queryTerm = "SELECT  \"dateDoc\"  FROM public.\"Dokumen\" where \"idDokumen\" in (" + string.Join(", ", idDoc) + ") and site_name='Tribunnews.com' " +
                                   "order by  \"dateDoc\" desc;";
                DataTable result    = con.getResult(queryTerm);
                string[]  arrayDate = new string[result.Rows.Count];
                arrayDateAkhir = new string[result.Rows.Count];
                List <string> List_dateDoc      = new List <string>();
                List <string> List_dateDocAkhir = new List <string>();

                for (int i = 0; i < result.Rows.Count; i++)
                {
                    string temp = result.Rows[i]["dateDoc"].ToString();
                    if (temp.Length > 10)
                    {
                        temp = temp.Substring(0, temp.Length - 1);
                    }
                    List_dateDoc.Add(temp);
                }
                arrayDate = List_dateDoc.OrderBy(x => DateTime.Parse(x)).ToArray();
                for (int i = 0; i < arrayDate.Length; i++)
                {
                    List_dateDocAkhir.Add("'" + arrayDate[i] + "'");
                }
                arrayDateAkhir = List_dateDocAkhir.ToArray();
                Console.WriteLine("=============ini urutannya");
                for (int i = 0; i < arrayDateAkhir.Length; i++)
                {
                    Console.WriteLine(arrayDateAkhir[i]);
                }
            }
            else if (status == 3) // ambil detik saja
            {
                string queryTerm = "SELECT  \"dateDoc\"  FROM public.\"Dokumen\" where \"idDokumen\" in (" + string.Join(", ", idDoc) + ") and site_name='Detik.com'" +
                                   " order by  \"dateDoc\" desc;";
                DataTable result    = con.getResult(queryTerm);
                string[]  arrayDate = new string[result.Rows.Count];
                arrayDateAkhir = new string[result.Rows.Count];
                List <string> List_dateDoc      = new List <string>();
                List <string> List_dateDocAkhir = new List <string>();

                for (int i = 0; i < result.Rows.Count; i++)
                {
                    string temp = result.Rows[i]["dateDoc"].ToString();
                    if (temp.Length > 10)
                    {
                        temp = temp.Substring(0, temp.Length - 1);
                    }
                    List_dateDoc.Add(temp);
                }
                arrayDate = List_dateDoc.OrderBy(x => DateTime.Parse(x)).ToArray();
                for (int i = 0; i < arrayDate.Length; i++)
                {
                    List_dateDocAkhir.Add("'" + arrayDate[i] + "'");
                }
                arrayDateAkhir = List_dateDocAkhir.ToArray();
                Console.WriteLine("=============ini urutannya");
                for (int i = 0; i < arrayDateAkhir.Length; i++)
                {
                    Console.WriteLine(arrayDateAkhir[i]);
                }
            }
            else // ambil liputan6 saja
            {
                string queryTerm = "SELECT  \"dateDoc\"  FROM public.\"Dokumen\" where \"idDokumen\" in (" + string.Join(", ", idDoc) + ") and site_name='Liputan6.com'" +
                                   "order by  \"dateDoc\" desc;";
                DataTable result    = con.getResult(queryTerm);
                string[]  arrayDate = new string[result.Rows.Count];
                arrayDateAkhir = new string[result.Rows.Count];
                List <string> List_dateDoc      = new List <string>();
                List <string> List_dateDocAkhir = new List <string>();

                for (int i = 0; i < result.Rows.Count; i++)
                {
                    string temp = result.Rows[i]["dateDoc"].ToString();
                    if (temp.Length > 10)
                    {
                        temp = temp.Substring(0, temp.Length - 1);
                    }
                    List_dateDoc.Add(temp);
                }
                arrayDate = List_dateDoc.OrderBy(x => DateTime.Parse(x)).ToArray();
                for (int i = 0; i < arrayDate.Length; i++)
                {
                    List_dateDocAkhir.Add("'" + arrayDate[i] + "'");
                }
                arrayDateAkhir = List_dateDocAkhir.ToArray();
                Console.WriteLine("=============ini urutannya");
                for (int i = 0; i < arrayDateAkhir.Length; i++)
                {
                    Console.WriteLine(arrayDateAkhir[i]);
                }
            }
            return(arrayDateAkhir);
        }