Ejemplo n.º 1
0
        public IEnumerable <WordWeight> ExtractTagsWithWeight(ForensicResult resource)
        {
            init();
            var source = new List <object>();

            foreach (var it in resource.GetItemWithMark(UserTextMark))
            {
                source.AddRange(it.GetColumnDataByMark(UserTextMark));
            }
            var t = string.Join(" ", source);

            return(Extractor.ExtractTagsWithWeight(t, KeywordCount).Select(c => new WordWeight()
            {
                Weight = c.Weight,
                Word = c.Word,
            }));
        }
Ejemplo n.º 2
0
        public void Classify(ForensicResult resource, int Kcount = 3)
        {
            init();
            var source = new List <object>();
            Dictionary <string, int> WordIndexMap = new Dictionary <string, int>();
            List <string>            WordList     = new List <string>();
            var WordWeight = new Dictionary <ForensicResultItem, IEnumerable <WordWeight> >();

            foreach (var it in resource.GetItemWithMark(UserTextMark))
            {
                var tTags = ExtractTagsWithWeight(it);
                if (tTags.Count() > 0)
                {
                    WordWeight.Add(it, tTags);
                    WordList.AddRange(tTags.Select(c => c.Word));
                }
            }
            WordList = WordList.Distinct().ToList();
            for (int i = 0; i < WordList.Count; ++i)
            {
                WordIndexMap.Add(WordList[i], i);
            }
            ;

            var tEngine = new EngineModel()
            {
                ClassCount = Kcount,
                Samples    = WordWeight.Values.Select(c =>
                {
                    var tX = new double[WordList.Count];
                    foreach (var it in c)
                    {
                        tX[WordIndexMap[it.Word]] = it.Weight;
                    }
                    var t = new PointModel()
                    {
                        X = tX,
                    };
                    return(t);
                }).ToList()
            };

            tEngine.Run();
            var res = tEngine.Classes;
        }