Ejemplo n.º 1
0
        /// <summary>
        /// Performs a search based on the parameters setup
        /// in the Search constructor.
        /// </summary>
        /// <param name="doMorphs">Specifies whether to perform a search on morphs.
        /// This parameter is retrieved in the first
        /// call from do_search(bool m, string p).  If morph searching is specified
        /// and a morph is found, then on a recursive call to this method
        /// morphing will be turned off to prevent unnecessary morph searching.</param>
        internal void do_search(bool doMorphs)
        {
            findtheinfo();
            if (buf.Length > 0)
            {
                buf = "\n" + sch.label + " of " + pos.name + " " + word + "\n" + buf;
            }
            if (!doMorphs)
            {
                return;
            }
            morphs = new Hashtable();
            MorphStr st = new MorphStr(word, pos);
            string   morphword;

            // if there are morphs then perform iterative searches
            // on each morph, filling the morph tree in the search
            // object.
            while ((morphword = st.next()) != null)
            {
                Search s = new Search(morphword, pos, sch, whichsense);
                s.do_search(false);
                // Fill the morphlist - eg. if verb relations of 'drunk' are requested, none are directly
                // found, but the morph 'drink' will have results.  The morph hashtable will be populated
                // into the search results and should be iterated instead of the returned synset if the
                // morphs are non-empty
                morphs[morphword] = s;
                buf += s.buf;
            }
        }
Ejemplo n.º 2
0
        public void OverviewFor(string t, string p, ref bool b, ref SearchSet obj, ArrayList list)
        {
            PartOfSpeech pos         = MyWnlib.PartOfSpeech.of(p);
            SearchSet    ss          = MyWnlib.WNDB.is_defined(t, pos);
            MorphStr     ms          = new MyWnlib.MorphStr(t, pos);
            bool         checkmorphs = false;

            checkmorphs = AddSearchFor(t, pos, list);            // do a search
            string m;

            if (checkmorphs)
            {
                WN.hasmatch = true;
            }

            if (!hasmatch)
            {
                // loop through morphs (if there are any)
                while ((m = ms.next()) != null)
                {
                    if (m != t)
                    {
                        ss = ss + WNDB.is_defined(m, pos);
                        AddSearchFor(m, pos, list);
                    }
                }
            }
            b   = ss.NonEmpty;
            obj = ss;
        }