SNCT.JudgeOfRelevancy.build_JoR C# (CSharp) Method

build_JoR() public static method

public static build_JoR ( ) : Task
return Task
        async public static Task<JudgeOfRelevancy> build_JoR()
        {
            // initialize thesaurus
            // TODO: debug "file not found" in following line
            //String thes_text = await get_text("thesaurus.txt");
            String thes_text = "";
            SortedDictionary<String, HashSet<String>> thesaurus_ = new SortedDictionary<String, HashSet<String>>();

            bool new_word = false;
            String word = "";
            foreach(String line in thes_text.Split('\n'))
            {
                if(new_word) {
                    word = line;
                    thesaurus_.Add(word, new HashSet<String>());
                    thesaurus_[word].Add(word);
                    new_word = false;
                } else if(line=="-----------word----------") {
                    new_word = true;
                } else if(line.Count()>0 && line[0] != '-') {
                    thesaurus_[word].Add(line);
                }
            }

            return new JudgeOfRelevancy(thesaurus_);
        }
        

Usage Example

Example #1
0
        async public static Task <PhraseGraph> build_PG(String text, String q, HashSet <String> q_content_words)
        {
            JudgeOfRelevancy JoR_ = await JudgeOfRelevancy.build_JoR();

            return(new PhraseGraph(JoR_, text, q, q_content_words));
        }