SNCT.Phrase.add_recipient C# (CSharp) Method

add_recipient() public method

public add_recipient ( Phrase recipient, double weight ) : void
recipient Phrase
weight double
return void
        public void add_recipient(Phrase recipient, double weight) { outs[recipient] = weight; }
        public double get_importance() { return importance; }

Usage Example

コード例 #1
0
        public PhraseGraph(JudgeOfRelevancy JoR_, String text, String q, HashSet <String> q_content_words)
        {
            JoR                 = JoR_;
            phrases             = new SortedDictionary <String, Phrase>();
            query               = q;
            query_content_words = q_content_words;

            String[] sentences     = get_sentences(text.ToLower());
            Phrase   last_sentence = null;

            foreach (var sentence in sentences)
            {
                Phrase sentence_phrase = ensure_phrase(sentence);
                // link neighboring sentences
                if (last_sentence != null)
                {
                    // 0.5 < 0.6 so weight will drift back
                    // earlier sentences are better
                    last_sentence.add_recipient(sentence_phrase, 0.5);
                    sentence_phrase.add_recipient(last_sentence, 0.6);
                }
                String[] words = get_words(sentence);
                // link sentences with their words
                foreach (var word in words)
                {
                    if (word == "")
                    {
                        continue;
                    }
                    Phrase word_phrase = ensure_phrase(word);
                    // weight flows from long sentences to words, to short sentences
                    word_phrase.add_recipient(sentence_phrase, 1.0);
                    sentence_phrase.add_recipient(word_phrase, 1.0);
                }
                last_sentence = sentence_phrase;
            }

            // link synonyms
            //foreach (var word in phrases.Keys)
            //{
            //    // don't include sentences
            //    if (word.Split().Count() >= 2) { continue; }
            //    HashSet<String> syns = JoR.get_synonyms(word);
            //    foreach (String synonym in syns)
            //    {
            //        // TODO: fix this :D can't modify the phrases collection while we're enumerating phrases.Keys!
            //        Phrase word_phrase = ensure_phrase(word);
            //        Phrase syn_phrase = ensure_phrase(synonym);
            //        syn_phrase.add_recipient(word_phrase, 1.0 * syns.Count());
            //        word_phrase.add_recipient(syn_phrase, 1.0 * syns.Count());
            //    }
            //}
        }
All Usage Examples Of SNCT.Phrase::add_recipient