Beispiel #1
0
        //検索文章の形態素解析
        public List <List <string> > maketextana()
        {
            List <List <string> > textAna = new List <List <string> >();
            MeCabanalyse          mecab   = new MeCabanalyse();
            List <string>         atext   = new List <string>();

            foreach (Document e in this.docs)
            {
                atext = mecab.Analyse(e.Body);
                textAna.Add(atext);
            }

            return(textAna);
        }
Beispiel #2
0
        public List <Document> Search(string query)
        {
            //string query を vector に直す
            List <string>            kensaku = new List <string>();
            Dictionary <int, double> searchValues;
            MeCabanalyse             mecab        = new MeCabanalyse();
            List <Document>          searchResult = new List <Document>();

            kensaku = mecab.Analyse(query);
            //検索queryと this.bodyのCosine計算
            searchValues = Cosine(kensaku);
            //計算値のcosが大きいものから順に並べる
            var vs1 = searchValues.OrderBy((x) => x.Value);

            foreach (var v in vs1)
            {
                searchResult.Add(this.docs[v.Key]);
            }
            //並べたDocumentを返す
            return(searchResult);
        }