Ejemplo n.º 1
0
        public bool HasHoloMero(PointerType p, Search search)
        {
            PointerType pbase;

            if (p.Mnemonic == "HMERONYM")
            {
                pbase = PointerType.Of("HASMEMBERPTR");
            }
            else
            {
                pbase = PointerType.Of("ISMEMBERPTR");
            }

            if (offs != null)
            {
                for (int i = 0; i < offs.Length; i++)
                {
                    SynonymSet s = new SynonymSet(offs[i], PartOfSpeech.Of("noun"), "", search, 0, netData);

                    if (s.Has(pbase) || s.Has(pbase + 1) || s.Has(pbase + 2))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Trace meronyms.
        /// </summary>
        /// <param name="pbase"></param>
        /// <param name="fpos"></param>
        /// <param name="depth"></param>
        private void TraceInherit(PointerType pbase, PartOfSpeech fpos, int depth)
        {
            for (int i = 0; i < ptrs.Length; i++)
            {
                Pointer pt = ptrs[i];
                if (pt.ptp.Ident == HYPERPTR && (pt.sce == 0 || pt.sce == whichword))
                {
                    Spaces("TRACEI", depth);
                    SynonymSet cursyn = new SynonymSet(pt.off, pt.pos, this, netData);
                    search.WordsFrom(cursyn);
                    cursyn.Str("=> ", "\n", 1, 0, 0, 1);
                    // TDMS 6 Oct 2005 - build hierarchical results
                    // TODO: verify this
                    if (senses == null)
                    {
                        senses = new List <SynonymSet>();
                    }

                    cursyn.thisptr = pt;  // TDMS 17 Nov 2005 - add this pointer type
                    // TODO: This is adding senses incorrectly
                    senses.Add(cursyn);

                    cursyn.TracePtrs(pbase, PartOfSpeech.Of("noun"), depth);
                    cursyn.TracePtrs(pbase + 1, PartOfSpeech.Of("noun"), depth);
                    cursyn.TracePtrs(pbase + 2, PartOfSpeech.Of("noun"), depth);

                    if (depth > 0)
                    {
                        depth = Depthcheck(depth);
                        cursyn.TraceInherit(pbase, cursyn.pos, depth + 1);
                    }
                }
            }
            search.Trunc();
        }
Ejemplo n.º 3
0
        private WordInfo LookupWord(string word)
        {
            // OVERVIEW: For each part of speech, look for the word.
            //           Compare relative strengths of the synsets in each category
            //			 to determine the most probable part of speech.
            //
            // PROBLEM:  Word definitions are often context-based. It would be better
            //           to find a way to search in-context in stead of just singling
            //           out an individual word.
            //
            // SOLUTION: Modify FindPartOfSpeech to include a second argument, string
            //           context. The pass the entire sentence as the context for part
            //           of speech determination.
            //
            // PROBLEM:  That's difficult to do so I'm going to keep this simple for now.

            int      maxCount = 0;
            WordInfo wordinfo = new WordInfo
            {
                partOfSpeech = PartsOfSpeech.None
            };

            // for each part of speech...
            PartsOfSpeech[] enums = (PartsOfSpeech[])Enum.GetValues(typeof(PartsOfSpeech));
            wordinfo.senseCounts = new int[enums.Length];
            for (int i = 0; i < enums.Length; i++)
            {
                // get a valid part of speech
                PartsOfSpeech pos = enums[i];
                if (pos == PartsOfSpeech.None)
                {
                    continue;
                }

                // get an index to a synset collection
                Index index = new Index(word, PartOfSpeech.Of(pos), netData);

                // none found?
                if (index == null)
                {
                    continue;
                }

                // does this part of speech have a higher sense count?
                wordinfo.senseCounts[i] = index.sense_cnt;
                if (wordinfo.senseCounts[i] > maxCount)
                {
                    maxCount = wordinfo.senseCounts[i];
                    wordinfo.partOfSpeech = pos;
                }
            }

            return(wordinfo);
        }
Ejemplo n.º 4
0
        private void StrAnt(string tail, AdjSynSetType attype, int definition)
        {
            int  i, wdcnt;
            bool first = true;

            if (WordNetOption.Opt("-o").flag)
            {
                search.buf += "(" + hereiam + ") ";
            }

            search.prlexid = WordNetOption.Opt("-a").flag;
            if (search.prlexid)
            {
                search.buf    += "<" + netData.lexfiles[fnum] + "> ";
                search.prlexid = true;
            }

            /* print antonyms from cluster head (of indirect ant) */
            search.buf += "INDIRECT (VIA ";
            for (i = 0, wdcnt = words.Length; i < wdcnt; i++)
            {
                if (first)
                {
                    StrAnt(PartOfSpeech.Of("adj"), i + 1, "", ", ");
                    first = false;
                }
                else
                {
                    StrAnt(PartOfSpeech.Of("adj"), i + 1, ", ", ", ");
                }
            }
            search.buf += ") -> ";

            /* now print synonyms from cluster head (of indirect ant) */
            for (i = 0, wdcnt = words.Length; i < wdcnt; i++)
            {
                Catword(i, 0, 0);
                if (i < wdcnt - 1)
                {
                    search.buf += ", ";
                }
            }

            if (WordNetOption.Opt("-g").flag&& defn != null && definition != 0)
            {
                search.buf += " -- " + defn;

                isDirty = true;                 // TDMS 19 July 2006 - attempt to tie the logic which
                // populates buf to the logic that defines whether the
                // synset is populated with relevant information
            }
            search.buf += tail;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Performs a search based on the parameters setup
        /// in the Search constructor.
        /// </summary>
        /// <param name="doMorphs">Specify if morphs should be searched</param>
        /// <param name="thePartOfSpeech">The Part Of Speech to perform the search on</param>
        public void Do_search(bool doMorphs, string thePartOfSpeech)
        {
            if (parts == null)
            {
                parts = new Hashtable();
            }

            Search s = new Search(word, PartOfSpeech.Of(thePartOfSpeech), sch, whichsense, netData);

            s.Do_search(doMorphs);
            parts[thePartOfSpeech] = s;
            buf += s.buf;
        }
Ejemplo n.º 6
0
        private Option(string a, string m, string p, int h, string b)
        {
            arg = a;
            if (m[0] == '-')
            {
                sch = new SearchType(true, m.Substring(1));
            }
            else
            {
                sch = new SearchType(false, m);
            }

            pos   = PartOfSpeech.Of(p.ToLower());
            helpx = h;
            label = b;
            id    = opts.Count;
            opts.Add(this);
        }
Ejemplo n.º 7
0
        public Morph(string s, PartOfSpeech p, WordNetData netdata)
        {
            netData = netdata;

            string origstr = s;

            pos = p;
            if (pos?.Clss == "SATELLITE")
            {
                pos = PartOfSpeech.Of("adj");
            }
            /* Assume string hasnt had spaces substitued with _ */
            str       = origstr.Replace(' ', '_').ToLower();
            searchstr = "";
            cnt       = str.Split('_').Length;
            svprep    = 0;
            firsttime = true;
        }
Ejemplo n.º 8
0
        public void OverviewFor(string t, string p, ref bool b, ref SearchSet obj, List <Search> list)
        {
            SearchSet ss = null;

            if (string.IsNullOrWhiteSpace(p))
            {
                OverviewFor(t, PartsOfSpeech.Adjective.ToString(), ref b, ref obj, list);
                OverviewFor(t, PartsOfSpeech.Adverb.ToString(), ref b, ref obj, list);
                OverviewFor(t, PartsOfSpeech.Noun.ToString(), ref b, ref obj, list);
                OverviewFor(t, PartsOfSpeech.Verb.ToString(), ref b, ref obj, list);

                ss = obj;
            }
            else
            {
                PartOfSpeech pos = PartOfSpeech.Of(p);

                if (!string.IsNullOrWhiteSpace(pos?.Key))
                {
                    ss = netData.Is_defined(t, pos);
                    Morph ms = new Morph(t, pos, netData);
                    hasmatch = AddSearchFor(t, pos, list);

                    //TODO: if this isn't reset then morphs aren't checked on subsequent searches - check for side effects of resetting this manually
                    if (!hasmatch)
                    {
                        string m;
                        // loop through morphs (if there are any)
                        while ((m = ms.Next()) != null)
                        {
                            if (m != t)
                            {
                                ss += netData.Is_defined(m, pos);
                                AddSearchFor(m, pos, list);
                            }
                        }
                    }
                }
            }

            b   = ss?.NonEmpty ?? false;
            obj = ss;
        }
Ejemplo n.º 9
0
        // From the WordNet Manual (http://wordnet.princeton.edu/man/wnsearch.3WN.html)
        // index_lookup() finds searchstr in the index file for pos and returns a pointer
        // to the parsed entry in an Index data structure. searchstr must exactly match the
        // form of the word (lower case only, hyphens and underscores in the same places) in
        // the index file. NULL is returned if a match is not found.
        public Index(string word, PartOfSpeech partOfSpeech, WordNetData netdata)
        {
            netData = netdata;
            int j;

            if (word == "" || (!char.IsLetter(word[0]) && !char.IsNumber(word[0])))
            {
                return;
            }

            string line = netData.BinSearch(word, partOfSpeech);

            if (line == null)
            {
                return;
            }

            string[] st = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);

            if (st.Length >= 6)
            {
                int stI = 0;
                wd        = st[stI++];                  /* the word */
                pos       = PartOfSpeech.Of(st[stI++]); /* the part of speech */
                sense_cnt = int.Parse(st[stI++]);       /* collins count */

                int ptruse_cnt = int.Parse(st[stI++]);  /* number of pointers types */
                ptruse = new PointerType[ptruse_cnt];
                for (j = 0; j < ptruse_cnt; j++)
                {
                    ptruse[j] = PointerType.Of(st[stI++]);
                }

                int off_cnt = int.Parse(st[stI++]);
                offs         = new int[off_cnt];
                tagsense_cnt = int.Parse(st[stI++]);
                for (j = 0; j < off_cnt; j++)
                {
                    offs[j] = int.Parse(st[stI++]);
                }
            }
        }
Ejemplo n.º 10
0
        private void Catword(int wdnum, int adjmarker, int antflag)
        {
            search.buf += Deadjify(words[wdnum].word);

            /* Print additional lexicographer information and WordNet sense
             * number as indicated by flags */
            if (words[wdnum].uniq != 0)
            {
                search.buf += "" + words[wdnum].uniq;
                isDirty     = true;             // TDMS 19 July 2006 - attempt to tie the logic which
                // populates buf to the logic that defines whether the
                // synset is populated with relevant information
            }

            int s = Getsearchsense(wdnum + 1);

            words[wdnum].wnsns = s;
            if (WordNetOption.Opt("-s").flag)
            {
                search.buf += "#" + s;
                isDirty     = true;             // TDMS 19 July 2006 - attempt to tie the logic which
                // populates buf to the logic that defines whether the
                // synset is populated with relevant information
            }

            /* For adjectives, append adjective marker if present, and
             * print antonym if flag is passed */
            if (pos.Key == "adj")
            {
                if (adjmarker > 0)
                {
                    search.buf += "" + adj_marker.mark;
                    isDirty     = true;                 // TDMS 19 July 2006 - attempt to tie the logic which
                    // populates buf to the logic that defines whether the
                    // synset is populated with relevant information
                }
                if (antflag > 0)
                {
                    StrAnt(PartOfSpeech.Of("adj"), wdnum + 1, "(vs. ", ")");
                }
            }
        }
Ejemplo n.º 11
0
        internal void PartsAll(PointerType ptp)
        {
            int         hasptr  = 0;
            PointerType ptrbase = PointerType.Of((ptp.Ident == HMERONYM) ? "HASMEMBERPTR" : "ISMEMBERPTR");

            /* First, print out the MEMBER, STUFF, PART info for this synset */
            for (int i = 0; i < 3; i++)
            {
                if (Has(ptrbase + i))
                {
                    TracePtrs(ptrbase + i, PartOfSpeech.Of("noun"), i);
                    hasptr++;
                }
            }
            /* Print out MEMBER, STUFF, PART info for hypernyms on HMERONYM search only */
            if (hasptr > 0 && ptp.Ident == HMERONYM)
            {
                search.Mark();

                TraceInherit(ptrbase, PartOfSpeech.Of("noun"), 1);
            }
        }
Ejemplo n.º 12
0
        /// <summary>Returns a list of Synonyms for a given word</summary>
        /// <param name="word">the word</param>
        /// <param name="pos">The Part of speech of a word</param>
        /// <param name="includeMorphs">include morphology? (fuzzy matching)</param>
        /// <returns>An array of strings containing the synonyms found</returns>
        /// <remarks>
        /// Note that my usage of 'Synonyms' here is not the same as hypernyms as defined by
        /// WordNet. Synonyms in this sense are merely words in the same SynSet as the given
        /// word. Hypernyms are found by tracing the pointers in a given synset.
        /// </remarks>
        public string[] FindSynonyms(string word, PartsOfSpeech pos, bool includeMorphs)
        {
            // get an index to a synset collection
            word = word.ToLower();
            Index index = new Index(word, PartOfSpeech.Of(pos), netData);

            // none found?
            if (index == null)
            {
                if (!includeMorphs)
                {
                    return(null);
                }

                // check morphs
                Morph  morphs = new Morph(word, PartOfSpeech.Of(pos), netData);
                string morph;
                while ((morph = morphs.Next()) != null)
                {
                    index = new Index(morph, PartOfSpeech.Of(pos), netData);
                    if (index != null)
                    {
                        break;
                    }
                }
            }

            // still none found?
            if (index == null)
            {
                return(null);
            }

            // at this point we will always have a valid index
            return(LookupSynonyms(index));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Trace adjective antonyms.
        /// </summary>
        internal void TraceAdjAnt()
        {
            SynonymSet    newsynptr;
            int           i, j;
            AdjSynSetType anttype = AdjSynSetType.DirectAnt;
            SynonymSet    simptr, antptr;
            string        similar = "        => ";

            /* This search is only applicable for ADJ synsets which have
             * either direct or indirect antonyms (not valid for pertainyms). */
            if (sstype == AdjSynSetType.DirectAnt || sstype == AdjSynSetType.IndirectAnt)
            {
                Strsns(sense + 1);
                search.buf += "\n";
                /* if indirect, get cluster head */
                if (sstype == AdjSynSetType.IndirectAnt)
                {
                    anttype = AdjSynSetType.IndirectAnt;

                    i = 0;
                    while (ptrs[i].ptp.Ident != SIMPTR)
                    {
                        i++;
                    }

                    newsynptr = new SynonymSet(ptrs[i].off, PartOfSpeech.Of("adj"), this, netData);
                }
                else
                {
                    newsynptr = this;
                }
                /* find antonyms - if direct, make sure that the antonym ptr we're looking at is from this word */
                for (i = 0; i < newsynptr.ptrs.Length; i++)
                {
                    if (newsynptr.ptrs[i].ptp.Ident == ANTPTR &&                     // TDMS 11 JUL 2006 // mnemonic=="ANTPTR" &&
                        ((anttype == AdjSynSetType.DirectAnt &&
                          newsynptr.ptrs[i].sce == newsynptr.whichword) ||
                         anttype == AdjSynSetType.IndirectAnt))
                    {
                        /* read the antonym's synset and print it.  if a direct antonym, print it's satellites. */
                        antptr = new SynonymSet(newsynptr.ptrs[i].off, PartOfSpeech.Of("adj"), this, netData);
                        search.WordsFrom(antptr);
                        // TDMS 6 Oct 2005 - build hierarchical results
                        if (senses == null)
                        {
                            senses = new List <SynonymSet>();
                        }
                        //TODO: check the ptrs reference
                        antptr.thisptr = newsynptr.ptrs[i];  // TDMS 17 Nov 2005 - add this pointer type
                        senses.Add(antptr);
                        if (anttype == AdjSynSetType.DirectAnt)
                        {
                            antptr.Str("", "\n", 1, 0, 1, 1);
                            for (j = 0; j < antptr.ptrs.Length; j++)
                            {
                                if (antptr.ptrs[j].ptp.Ident == SIMPTR) // TDMS 11 JUL 2006 - changed to INT //.mnemonic=="SIMPTR")
                                {
                                    simptr = new SynonymSet(antptr.ptrs[j].off, PartOfSpeech.Of("adj"), this, netData);
                                    search.WordsFrom(simptr);
                                    simptr.Str(similar, "\n", 1, 0, 0, 1);
                                    // TDMS 6 Oct 2005 - build hierarchical results
                                    if (antptr.senses == null)
                                    {
                                        antptr.senses = new List <SynonymSet>();
                                    }

                                    antptr.senses.Add(simptr);
                                }
                            }
                        }
                        else
                        {
                            antptr.StrAnt("\n", anttype, 1);
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
 public WordNetHelp(string s, string p)
     : this(s, PartOfSpeech.Of(p))
 {
 }
Ejemplo n.º 15
0
        private void Parse(string s, PartOfSpeech fpos, string word)
        {
            int j;

            string[] st  = s.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
            int      stI = 0;
            int      off = int.Parse(st[stI++]);

            fnum = int.Parse(st[stI++]);
            string       f   = st[stI++];
            PartOfSpeech pos = PartOfSpeech.Of(f);

            if (pos.Clss == "SATELLITE")
            {
                sstype = AdjSynSetType.IndirectAnt;
            }

            int wcnt = int.Parse(st[stI++], NumberStyles.HexNumber);

            words = new Lexeme[wcnt];
            for (j = 0; j < wcnt; j++)
            {
                words[j] = new Lexeme
                {
                    word = st[stI++],
                    uniq = int.Parse(st[stI++], NumberStyles.HexNumber)
                };

                // Thanh Dao 7 Nov 2005 - Added missing word sense values
                int ss = Getsearchsense(j + 1);
                words[j].wnsns = ss;

                if (words[j].word.ToLower() == word)
                {
                    whichword = j + 1;
                }
            }
            int pcnt = int.Parse(st[stI++]);

            ptrs = new Pointer[pcnt];
            for (j = 0; j < pcnt; j++)
            {
                string p = st[stI++];
                ptrs[j] = new Pointer(p);
                if (fpos.Key == "adj" && sstype == AdjSynSetType.DontKnow)
                {
                    if (ptrs[j].ptp.Ident == ANTPTR)                     // TDMS 11 JUL 2006 - change comparison to int //.mnemonic=="ANTPTR")
                    {
                        sstype = AdjSynSetType.DirectAnt;
                    }
                    else if (ptrs[j].ptp.Ident == PERTPTR) // TDMS 11 JUL 2006 - change comparison to int //mnemonic=="PERTPTR")
                    {
                        sstype = AdjSynSetType.Pertainym;
                    }
                }
                ptrs[j].off = int.Parse(st[stI++]);
                ptrs[j].pos = PartOfSpeech.Of(st[stI++]);
                int sx = int.Parse(st[stI++], NumberStyles.HexNumber);
                ptrs[j].sce = sx >> 8;
                ptrs[j].dst = sx & 0xff;
            }
            f = st[stI++];
            if (f != "|")
            {
                int fcnt = int.Parse(f);
                for (j = 0; j < fcnt; j++)
                {
                    f = st[stI++];                     // +
                    Usage fr = Usage.Frame(int.Parse(st[stI++]));
                    frames.Add(new SynSetFrame(fr, int.Parse(st[stI++], NumberStyles.HexNumber)));
                }
                f = st[stI++];
            }
            defn = s.Substring(s.IndexOf('|') + 1);
        }
Ejemplo n.º 16
0
        private WordInfo LookupWordMorphs(string word)
        {
            // OVERVIEW: This functions only gets called when the word was not found with
            //           an exact match. So, enumerate all the parts of speech, then enumerate
            //           all of the word's morphs in each category. Perform a lookup on each
            //           morph and save the morph/strength/part-of-speech data sets. Finally,
            //           loop over all the data sets and then pick the strongest one.

            ArrayList wordinfos = new ArrayList();

            // for each part of speech...
            for (int i = 0; i < enums.Length; i++)
            {
                // get a valid part of speech
                PartsOfSpeech pos = enums[i];
                if (pos == PartsOfSpeech.None)
                {
                    continue;
                }

                // generate morph list
                Morph  morphs = new Morph(word, PartOfSpeech.Of(pos), netData);
                string morph;
                while ((morph = morphs.Next()) != null)
                {
                    // get an index to a synset collection
                    Index index = new Index(morph, PartOfSpeech.Of(pos), netData);

                    // none found?
                    if (index == null)
                    {
                        continue;
                    }

                    // save the wordinfo
                    WordInfo wordinfo = GetMorphInfo(wordinfos, morph);
                    wordinfo.senseCounts[i] = index.sense_cnt;
                }
            }

            // search the wordinfo list for the best match
            WordInfo bestWordInfo = new WordInfo();
            int      maxStrength  = 0;

            foreach (WordInfo wordinfo in wordinfos)
            {
                // for each part of speech...
                int maxSenseCount = 0;
                int strength      = 0;
                for (int i = 0; i < enums.Length; i++)
                {
                    // get a valid part of speech
                    PartsOfSpeech pos = enums[i];
                    if (pos == PartsOfSpeech.None)
                    {
                        continue;
                    }

                    // determine part of speech and strength
                    strength += wordinfo.senseCounts[i];
                    if (wordinfo.senseCounts[i] > maxSenseCount)
                    {
                        maxSenseCount         = wordinfo.senseCounts[i];
                        wordinfo.partOfSpeech = pos;
                    }
                }

                // best match?
                if (strength > maxStrength)
                {
                    maxStrength  = strength;
                    bestWordInfo = wordinfo;
                }
            }

            return(bestWordInfo);
        }
Ejemplo n.º 17
0
        static WordNetHelp()
        {
            PartOfSpeech noun     = PartOfSpeech.Of("noun");
            PartOfSpeech verb     = PartOfSpeech.Of("verb");
            PartOfSpeech adj      = PartOfSpeech.Of("adj");
            PartOfSpeech adv      = PartOfSpeech.Of("adv");
            string       freqhelp =
                "Display familiarity and polysemy information for the search string. \n" +
                "The polysemy count is obtained from WordNet, and is the number of \n" +
                "senses represented in the database. \n";

            noun.help["FREQ"] = freqhelp;
            verb.help["FREQ"] = freqhelp;
            adj.help["FREQ"]  = freqhelp;
            adv.help["FREQ"]  = freqhelp;
            string grephelp =
                "Print all strings in the database which contain the search string \n" +
                "as an individual word, or as the first or last string in a word or \n" +
                "collocation. \n";

            noun.help["WNGREP"]   = grephelp;
            verb.help["WNGREP"]   = grephelp;
            adj.help["WNGREP"]    = grephelp;
            adv.help["WNGREP"]    = grephelp;
            noun.help["HYPERPTR"] =
                "Display synonyms and immediate `hypernyms' of synsets containing \n" +
                "the search string.  Synsets are ordered by frequency of occurrence.  \n" +
                "\n" +
                "Hypernym is the generic term used to designate a whole class of \n" +
                "specific instances.  Y is a hypernym of X if X is a (kind of) Y. \n" +
                "\n" +
                "Hypernym synsets are preceded by \"=>\". \n";
            noun.help["RELATIVES"] =
                "Display synonyms and immediate `hypernyms' of synsets containing \n" +
                "the search string.  Synsets are grouped by similarity of meaning. \n" +
                "\n" +
                "Hypernym is the generic term used to designate a whole class of \n" +
                "specific instances.  Y is a hypernym of X if X is a (kind of) Y. \n" +
                "\n" +
                "Hypernym synsets are preceded by \"=>\". \n";
            noun.help["ANTPTR"] =
                "Display synsets containing `direct anotnyms' of the search string.  \n" +
                "\n" +
                "Direct antonyms are a pair of words between which there is an \n" +
                "associative bond built up by co-occurrences. \n" +
                "\n" +
                "Antonym synsets are preceded by \"=>\". \n";
            noun.help["COORDS"] =
                "Display the coordinates (sisters) of the search string.  This search \n" +
                "prints the immediate `hypernym' for each synset which contains the \n" +
                "search string and the hypernym's immediate `hyponyms'. \n" +
                "\n" +
                "Hypernym is the generic term used to designate a whole class of \n" +
                "specific instances.  Y is a hypernym of X if X is a (kind of) Y. \n" +
                "\n" +
                "Hyponym is the generic term used to designate a member of a class. \n" +
                "X is a hyponym of Y if X is a (kind of) Y.  \n" +
                "\n" +
                "Coordinate words are words that have the same hypernym.\n" +
                "\n" +
                "Hypernym synsets are preceded by \"->\", and hyponym synsets are \n" +
                "preceded by \"=>\". \n";
            noun.help["-HYPERPTR"] =
                "Recursively display `hypernym' (superordinate) tree for the search \n" +
                "string. \n" +
                "\n" +
                "Hypernym is the generic term used to designate a whole class of \n" +
                "specific instances.  Y is a hypernym of X if X is a (kind of) Y. \n" +
                "\n" +
                "Hypernym synsets are preceded by \"=>\", and are indented from \n" +
                "the left according to their level in the hierarchy. \n";
            noun.help["HYPOPTR"] =
                "Display immediate `hyponyms' (subordinates) for the search string. \n" +
                "\n" +
                "Hyponym is the generic term used to designate a member of a class. \n" +
                "X is a hyponym of Y if X is a (kind of) Y.  \n" +
                "\n" +
                "Hyponym synsets are preceded by \"=>\". \n";
            noun.help["-HYPOPTR"] =
                "Display `hyponym' (subordinate) tree for the search string.  This is \n" +
                "a recursive search which finds the hyponyms of each hyponym.  \n" +
                "\n" +
                "Hyponym is the generic term used to designate a member of a class. \n" +
                "X is a hyponym of Y if X is a (kind of) Y.  \n" +
                "\n" +
                "Hyponym synsets are preceded by \"=>\", and are indented from the left \n" +
                "according to their level in the hierarchy. \n";
            noun.help["HOLONYM"] =
                "Display all `holonyms' of the search string. \n" +
                "\n" +
                "A holonym is the name of the whole of which the 'meronym' names a part. \n" +
                "Y is a holonym of X if X is a part of Y. \n" +
                "\n" +
                "A meronym is the name of a constituent part, the substance of, or a \n" +
                "member of something.  X is a meronym of Y if X is a part of Y. \n" +
                "\n" +
                "Holonym synsets are preceded with either the string \"MEMBER OF\", \n" +
                "\"PART OF\" or \"SUBSTANCE OF\" depending on the specific type of holonym. \n";
            noun.help["-HHOLONYM"] =
                "Display `holonyms' for search string tree.  This is a recursive search \n" +
                "that prints all the holonyms of the search string and all of the \n" +
                "holonym's holonyms. \n" +
                "\n" +
                "A holonym is the name of the whole of which the `meronym' names a part. \n" +
                "Y is a holonym of X if X is a part of Y. \n" +
                "\n" +
                "A meronym is the name of a constituent part, the substance of, or a \n" +
                "member of something.  X is a meronym of Y if X is a part of Y. \n" +
                "\n" +
                "Holonym synsets are preceded with either the string \"MEMBER OF\", \n" +
                "\"PART OF\" or \"SUBSTANCE OF\" depending on the specific \n" +
                "type of holonym.  Synsets are indented from the left according to \n" +
                "their level in the hierarchy. \n";
            noun.help["MERONYM"] =
                "Display all `meronyms' of the search string.  \n" +
                "\n" +
                "A meronym is the name of a constituent part, the substance of, or a \n" +
                "member of something.  X is a meronym of Y if X is a part of Y. \n" +
                "\n" +
                "A holonym is the name of the whole of which the `meronym' names a part. \n" +
                "Y is a holonym of X if X is a part of Y. \n" +
                "\n" +
                "Meronym synsets are preceded with either the string \"HAS MEMBER\", \n" +
                "\"HAS PART\" or \"HAS SUBSTANCE\" depending on the specific type of holonym. \n";
            noun.help["-HMERONYM"] =
                "Display `meronyms' for search string tree.  This is a recursive search \n" +
                "the prints all the meronyms of the search string and all of its \n" +
                "`hypernyms'.  \n" +
                "\n" +
                "A meronym is the name of a constituent part, the substance of, or a \n" +
                "member of something.  X is a meronym of Y if X is a part of Y. \n" +
                "\n" +
                "A holonym is the name of the whole of which the `meronym' names a part. \n" +
                "Y is a holonym of X if X is a part of Y. \n" +
                "\n" +
                "Hypernym is the generic term used to designate a whole class of \n" +
                "specific instances.  Y is a hypernym of X if X is a (kind of) Y. \n" +
                "\n" +
                "Meronym synsets are preceded with either the string \"HAS MEMBER\", \n" +
                "\"HAS PART\" or \"HAS SUBSTANCE\" depending on the specific type of \n" +
                "holonym.  Synsets are indented from the left according to their level \n" +
                "in the hierarchy. \n";
            noun.help["ATTRIBUTE"] =
                "Display adjectives for which search string is an attribute. \n";
            verb.help["HYPERPTR"] =
                "Display synonyms and immediate `troponyms' of synsets containing \n" +
                "the search string.  \n" +
                "\n" +
                "A troponym is a verb expressing a specific manner elaboration of another \n" +
                "verb.  X is a troponym of Y if to X is to Y in some manner. \n" +
                "\n" +
                "Troponym synsets are preceded by \"=>\". \n";
            verb.help["VERBGROUP"] =
                "Display synonyms and immediate `troponyms' of synsets containing \n" +
                "the search string.  Synsets are grouped by similarity of meaning. \n" +
                "\n" +
                "A troponym is a verb expressing a specific manner elaboration of another \n" +
                "verb.  X is a troponym of Y if to X is to Y in some manner. \n" +
                "\n" +
                "Troponym synsets are preceded by \"=>\". \n";
            verb.help["ANTPTR"] =
                "Display synsets containing `direct anotnyms' of the search string.  \n" +
                "\n" +
                "Direct antonyms are a pair of words between which there is an \n" +
                "associative bond built up by co-occurrences. \n" +
                "\n" +
                "Antonym synsets are preceded by \"=>\". \n";
            verb.help["-HYPERPTR"] =
                "Recursively display `hypernym' tree for the search string.  For verbs,\n" +
                "'hypernyms' are refered to as `troponyms'. \n" +
                "\n" +
                "A troponym is a verb expressing a specific manner elaboration of another \n" +
                "verb.  X is a troponym of Y if to X is to Y in some manner. \n" +
                "\n" +
                "Troponym synsets are preceded by \"=>\". \n" +
                "\n" +
                "Troponym synsets are preceded by \"=>\", and are indented from \n" +
                "the left according to their level in the hierarchy. \n";
            verb.help["-HYPOPTR"] =
                "Display `hyponym' tree for the search string.  This is \n" +
                "a recursive search which finds the hyponyms of each hyponym.  \n" +
                "\n" +
                "For verbs, hyponyms indicate particular ways to perform a function. \n" +
                "X is a hyponym of Y if to X is a particular way to Y. \n" +
                "\n" +
                "Hyponym synsets are preceded by \"=>\", and are indented from the left \n" +
                "according to their level in the hierarchy. \n";
            verb.help["ENTAILPTR"] =
                "Recursively display `entailment' relations of the search string.  \n" +
                "\n" +
                "The action represented by the verb X entails Y if X cannot be done \n" +
                "unless Y is, or has been, done. \n" +
                "\n" +
                "Entailment synsets are preceded by \"=>\", and are indented from the left \n" +
                "according to their level in the hierarchy. \n";
            verb.help["CAUSETO"] =
                "Recursively display `cause to' relations of the search string. \n" +
                "\n" +
                "The action represented by the verb X causes the action represented by \n" +
                "the verb Y. \n" +
                "\n" +
                "`Cause to' synsets are preceded by \"=>\", and are indented from the left \n" +
                "according to their level in the hierarch.  \n";
            verb.help["FRAMES"] =
                "Display applicable verb sentence `frames' for the search string. \n" +
                "\n" +
                "A frame is a sentence template illustrating the usage of a verb. \n" +
                "\n" +
                "Verb sentence frames are preceded with the string \"*>\" if a sentence \n" +
                "frame is acceptable for all of the words in the synset, and with \"=>\" \n" +
                "if a sentence frame is acceptable for the search string only.  \n";
            adj.help["SIMPTR"] =
                "Display synonyms and synsets related to synsets containing \n" +
                "the search string.  If the search string is in a `head synset' \n" +
                "the 'cluster's' `satellite synsets' are displayed.  If the search \n" +
                "string is in a satellite synset, its head synset is displayed. \n" +
                "If the search string is a `pertainym' the word or synset that it \n" +
                "pertains to is displayed. \n" +
                "\n" +
                "A cluster is a group of adjective synsets that are organized around \n" +
                "antonymous pairs or triplets.  An adjective cluster contains two or more \n" +
                "head synsets which contan antonyms.  Each head synset has one or more \n" +
                "satellite synsets. \n" +
                "\n" +
                "A head synset contains at least one word which has a `direct antonym' \n" +
                "in another head synset of the same cluster. \n" +
                "\n" +
                "A satellite synset represents a concept that is similar in meaning to \n" +
                "the concept represented by its head synset. \n" +
                "\n" +
                "Direct antonyms are a pair of words between which there is an \n" +
                "associative bond built up by co-occurrences. \n" +
                "\n" +
                "Direct antonyms are printed in parentheses following the adjective. \n" +
                "The position of an adjective in relation to the noun may be restricted \n" +
                "to the prenominal, postnominal or predicative position.  Where present \n" +
                "these restrictions are noted in parentheses. \n" +
                "\n" +
                "A pertainym is a relational adjective, usually defined by such phrases \n" +
                "as \"of or pertaining to\" and which does not have an antonym.  It pertains \n" +
                "to a noun or another pertainym. \n" +
                "\n" +
                "Senses contained in head synsets are displayed above the satellites, \n" +
                "which are indented and preceded by \"=>\".  Senses contained in \n" +
                "satellite synsets are displayed with the head synset below.  The head \n" +
                "synset is preceded by \"=>\". \n" +
                "\n" +
                "Pertainym senses display the word or synsets that the search string \n" +
                "pertains to. \n";
            adj.help["ANTPTR"] =
                "Display synsets containing antonyms of the search string. If the \n" +
                "search string is in a `head synset' the `direct antonym' is displayed \n" +
                "along with the head synset's `satellite synsets'.  If the search \n" +
                "string is in a satellite synset, its indirect antonym is displayed \n" +
                "via the head synset \n" +
                "\n" +
                "A head synset contains at least one word which has a `direct antonym' \n" +
                "in another head synset of the same cluster. \n" +
                "\n" +
                "A satellite synset represents a concept that is similar in meaning to \n" +
                "the concept represented by its head synset. \n" +
                "\n" +
                "Direct antonyms are a pair of words between which there is an \n" +
                "associative bond built up by co-occurrences. \n" +
                "\n" +
                "Direct antonyms are printed in parentheses following the adjective. \n" +
                "The position of an adjective in relation to the noun may be restricted \n" +
                "to the prenominal, postnominal or predicative position.  Where present \n" +
                "these restrictions are noted in parentheses. \n" +
                "\n" +
                "Senses contained in head synsets are displayed, followed by the \n" +
                "head synset containing the search string's direct antonym and its \n" +
                "similar synsets, which are indented and preceded by \"=>\".  Senses \n" +
                "contained in satellite synsets are displayed followed by the indirect \n" +
                "antonym via the satellite's head synset. \n";
            adj.help["ATTRIBUTE"] =
                "Display nouns which are attributes of search string. \n";
            adv.help["SIMPTR"] =
                "Display synonyms and synsets related to synsets containing \n" +
                "the search string.  If the search string is a `pertainym' the word \n" +
                "or synset that it pertains to is displayed. \n" +
                "\n" +
                "A pertainym is a relational adverb which is derived from an adjective. \n" +
                "\n" +
                "Pertainym senses display the word that the search string is derived from \n" +
                "and the adjective synset which contains the word.  If the adjective synset \n" +
                "is a satellite synset, its head synset is also displayed. \n";
            adv.help["ANTPTR"] =
                "Display synsets containing `direct antonyms' of the search string.  \n" +
                "\n" +
                "Direct antonyms are a pair of words between which there is an \n" +
                "associative bond built up by co-occurrences. \n" +
                "\n" +
                "Antonym synsets are preceded by \"=>\". \n";
        }
Ejemplo n.º 18
0
 public Exceptions(string word, string p, WordNetData netdata)
     : this(word, PartOfSpeech.Of(p), netdata)
 {
 }
Ejemplo n.º 19
0
 public Morph(string s, string p, WordNetData netdata)
     : this(s, PartOfSpeech.Of(p), netdata)
 {
 }
Ejemplo n.º 20
0
 public Search(string theWord, bool doMorphs, string thePartOfSpeech, string theSearchType, int sn, WordNetData netdata)
     : this(theWord, doMorphs, PartOfSpeech.Of(thePartOfSpeech), new SearchType(theSearchType), sn, netdata)
 {
 }
Ejemplo n.º 21
0
        private string Morphprep(string s)
        {
            string excWord, lastwd = null;
            int    i, offset, cnt, rest, last;
            string word, end, retval;

            /* Assume that the verb is the first word in the phrase.  Strip it
             * off, check for validity, then try various morphs with the
             * rest of the phrase tacked on, trying to find a match. */

            rest = s.IndexOf('_');
            last = s.LastIndexOf('_');
            end  = "";
            if (rest != last)
            {             // more than 2 words
                lastwd = Morphword(s.Substring(last + 1));
                if (lastwd != null)
                {
                    end = s.Substring(rest, last - rest + 1) + lastwd;
                }
            }
            word = s.Substring(0, rest);
            for (i = 0; i < word.Length; i++)
            {
                if (!char.IsLetterOrDigit(word[i]))
                {
                    return(null);
                }
            }

            offset = offsets[PartOfSpeech.Of("verb").Ident];
            cnt    = cnts[PartOfSpeech.Of("verb").Ident];
            /* First try to find the verb in the exception list */
            Exceptions e = new Exceptions(word, PartOfSpeech.Of("verb"), netData);

            while ((excWord = e.Next()) != null && excWord != word)
            {
                retval = excWord + s.Substring(rest);
                if (netData.Is_defined(retval, PartOfSpeech.Of("verb")).NonEmpty)
                {
                    return(retval);
                }
                else if (lastwd != null)
                {
                    retval = excWord + end;
                    if (netData.Is_defined(retval, PartOfSpeech.Of("verb")).NonEmpty)
                    {
                        return(retval);
                    }
                }
            }
            for (i = 0; i < cnt; i++)
            {
                if ((excWord = Wordbase(word, i + offset)) != null && excWord != word) // ending is different
                {
                    retval = excWord + s.Substring(rest);
                    if (netData.Is_defined(retval, PartOfSpeech.Of("verb")).NonEmpty)
                    {
                        return(retval);
                    }
                    else if (lastwd != null)
                    {
                        retval = excWord + end;
                        if (netData.Is_defined(retval, PartOfSpeech.Of("verb")).NonEmpty)
                        {
                            return(retval);
                        }
                    }
                }
            }

            retval = word + s.Substring(rest);
            if (s != retval)
            {
                return(retval);
            }

            if (lastwd != null)
            {
                retval = word + end;
                if (s != retval)
                {
                    return(retval);
                }
            }
            return(null);
        }