コード例 #1
1
ファイル: Class1.cs プロジェクト: ejohn916/WordNet.Net-3.1
		public void OverviewFor(string t, string p, ref bool b, ref SearchSet obj, ArrayList list)
		{
			PartOfSpeech pos = PartOfSpeech.of(p);
			SearchSet ss = WNDB.is_defined(t, pos);
			MorphStr ms = new MorphStr(t, pos);
			bool checkmorphs = false;

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

		    if (checkmorphs)
				HasMatch = true;

			if (!HasMatch)
			{
			    // loop through morphs (if there are any)
			    string m;
			    while ((m = ms.next()) != null)
					if (m != t)
					{
						ss = ss + WNDB.is_defined(m, pos);
						AddSearchFor(m, pos, list);
					}
			}
		    b = ss.NonEmpty;
			obj = ss;
		}
コード例 #2
0
		public MyWordInfo[] FindSynonyms(ref MyWordInfo pos, bool includeMorphs)
		{
			pos.Word = pos.Word.ToLower();
			Wnlib.Index index = Wnlib.Index.lookup( pos.Word, PartOfSpeech.of( pos.Pos  ) );
		
			if( index == null )
			{
				if( !includeMorphs )
					return null;

				Wnlib.MorphStr morphs = new Wnlib.MorphStr( pos.Word, Wnlib.PartOfSpeech.of( pos.Pos  ) );
				string morph = "";
				while( ( morph = morphs.next() ) != null )
				{
					index = Wnlib.Index.lookup( morph, Wnlib.PartOfSpeech.of( pos.Pos  ) );
					pos.Word=morph;
					if( index != null )
						break;
				}
			}

			
			if( index == null )
				return null;
			
			return LookupCandidates( index, pos );
		}
コード例 #3
0
ファイル: wordnet.cs プロジェクト: yehudapashay/Search-Engine
        /// <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;
            }
        }
コード例 #4
0
        public void OverviewFor(string t, string p, ref bool b, ref SearchSet obj, ArrayList list)
        {
            PartOfSpeech pos         = Wnlib.PartOfSpeech.of(p);
            SearchSet    ss          = Wnlib.WNDB.is_defined(t, pos);
            MorphStr     ms          = new Wnlib.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;
        }
コード例 #5
0
ファイル: SimilarGenerator.cs プロジェクト: hajarSA/d
        public MyWordInfo[] FindSynonyms(ref MyWordInfo pos, bool includeMorphs)
        {
            pos.Word = pos.Word.ToLower();
            Wnlib.Index index = Wnlib.Index.lookup(pos.Word, PartOfSpeech.of(pos.Pos));

            if (index == null)
            {
                if (!includeMorphs)
                {
                    return(null);
                }

                Wnlib.MorphStr morphs = new Wnlib.MorphStr(pos.Word, Wnlib.PartOfSpeech.of(pos.Pos));
                string         morph  = "";
                while ((morph = morphs.next()) != null)
                {
                    index    = Wnlib.Index.lookup(morph, Wnlib.PartOfSpeech.of(pos.Pos));
                    pos.Word = morph;
                    if (index != null)
                    {
                        break;
                    }
                }
            }


            if (index == null)
            {
                return(null);
            }

            return(LookupCandidates(index, pos));
        }
コード例 #6
0
ファイル: SimilarGenerator.cs プロジェクト: hajarSA/d
        public static int GetSynsetIndex(string word, PartsOfSpeech pos)
        {
            word = word.ToLower();
            //word=RemoveBadChars (word);
            Wnlib.Index index = Wnlib.Index.lookup(word, PartOfSpeech.of(pos));

            if (index == null)
            {
                Wnlib.MorphStr morphs = new Wnlib.MorphStr(word, Wnlib.PartOfSpeech.of(pos));
                string         morph  = "";
                while ((morph = morphs.next()) != null)
                {
                    index = Wnlib.Index.lookup(morph, Wnlib.PartOfSpeech.of(pos));
                    if (index != null)
                    {
                        break;
                    }
                }
            }

            if (index == null)
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }
コード例 #7
0
        public void OverviewFor(string t, string p, ref bool b, ref SearchSet obj, ArrayList list)
        {
            PartOfSpeech pos         = Wnlib.PartOfSpeech.of(p);
            SearchSet    ss          = Wnlib.WNDB.is_defined(t, pos);
            MorphStr     ms          = new Wnlib.MorphStr(t, pos);
            bool         checkmorphs = false;

            hasmatch = false;                         //TODO: if this isn't reset then morphs aren't checked on subsequent searches - check for side effects of resetting this manually

            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;
        }
コード例 #8
0
		public static int GetSynsetIndex(string word, PartsOfSpeech pos)
		{
			word=word.ToLower() ;
			//word=RemoveBadChars (word);
			Wnlib.Index index=Wnlib.Index.lookup( word, PartOfSpeech.of(pos) );
			
			if( index == null )
			{
				Wnlib.MorphStr morphs=new Wnlib.MorphStr(word, Wnlib.PartOfSpeech.of( pos  ) );
				string morph = "";
				while( ( morph = morphs.next() ) != null )
				{
					index = Wnlib.Index.lookup(morph, Wnlib.PartOfSpeech.of(pos) );
					if( index != null )
						break;
				}
			}			

			if (index == null) return -1;
			else 
				return 0;
		}
コード例 #9
0
ファイル: wordnet.cs プロジェクト: Shoop123/Reworder-C-Sharp
		/// <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;
			}
		}