Exemple #1
0
            public List <InputtedKeyword> GenerateKeywordByInput(UploadedTemplates template, String inputKeyword)
            {
                ComputeKeywordTermFrequency keywordTF = new ComputeKeywordTermFrequency(GetOCRContent(template.FileID), GetAllOCRContentsExcludeFileID(template.FileID));
                List <InputtedKeyword>      keywords  = new List <InputtedKeyword>();
                double rate = keywordTF.GetKeywordFrequency(inputKeyword);

                if (rate == 0.0f)
                {
                    rate = 1.0f;
                }
                keywords.Add(new InputtedKeyword {
                    Keyword         = inputKeyword,
                    GeneratedTFRate = GetRateRound(rate),
                    AddedFlag       = CheckKeywordExists(template.FileID, inputKeyword)
                });
                return(keywords);
            }
Exemple #2
0
            public List <InputtedKeyword> GenerateKeywordsBySystem(UploadedTemplates template)
            {
                ListUniqueKeywords   listUniqueKeyword = new ListUniqueKeywords();
                DictionarySpellCheck spellCheck        = new DictionarySpellCheck();
                String        textOCR                 = GetOCRContent(template.FileID);
                List <String> ListWords               = listUniqueKeyword.GetSingleKeywordsFromString(textOCR);
                List <String> listSentences           = listUniqueKeyword.GetShortSentencesFromString(textOCR);
                ComputeKeywordTermFrequency keywordTF = new ComputeKeywordTermFrequency(textOCR, GetAllOCRContentsExcludeFileID(template.FileID));
                List <InputtedKeyword>      keywords  = new List <InputtedKeyword>();

                foreach (String word in ListWords)
                {
                    double rate = keywordTF.GetKeywordFrequency(word);
                    if (rate >= 0.0f && (spellCheck.IsEnglishWord(word) || spellCheck.IsNumber(word)))
                    {
                        if (word.Trim().Length < 4)
                        {
                            continue;
                        }
                        keywords.Add(new InputtedKeyword {
                            Keyword         = word,
                            GeneratedTFRate = GetRateRound(rate),
                            AddedFlag       = CheckKeywordExists(template.FileID, word)
                        });
                    }
                }
                foreach (String line in listSentences)
                {
                    double rate = keywordTF.GetKeywordFrequency(line);
                    if (rate >= 0.0f && spellCheck.IsEnglishSentenceOrNumbers(line))
                    {
                        keywords.Add(new InputtedKeyword {
                            Keyword         = line,
                            GeneratedTFRate = GetRateRound(rate),
                            AddedFlag       = CheckKeywordExists(template.FileID, line)
                        });
                    }
                }
                return(keywords);
            }