Esempio n. 1
0
        internal void seealso()
        {
            /* Find all SEEALSO pointers from the searchword and print the
             * word or synset pointed to. */
            string prefix;             // = "      Also See-> ";

            //WN3.0 added updated wording for verb see also
            if (pos.name == "verb")
            {
                prefix = "      Phrasal Verb-> ";
            }
            else
            {
                prefix = "      Also See-> ";
            }

            for (int i = 0; i < ptrs.Length; i++)
            {
                Pointer p = ptrs[i];
                if (p.ptp.ident == SEEALSOPTR &&
                    (p.sce == 0 || (p.sce == whichword)))
                {
                    SynSet cursyn      = new SynSet(p.off, p.pos, "", this);
                    bool   svwnsnsflag = WNOpt.opt("-s").flag;
                    WNOpt.opt("-s").flag = true;
                    cursyn.str(prefix, "", 0,
                               (p.dst == 0) ? 0 : p.dst, 0, 0);
                    prefix = "; ";
                }
            }
        }
Esempio n. 2
0
        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;
            }
            int s = getsearchsense(wdnum + 1);

            words[wdnum].wnsns = s;
            if (WNOpt.opt("-s").flag)
            {
                search.buf += "#" + s;
            }

            /* For adjectives, append adjective marker if present, and
             * print antonym if flag is passed */
            if (pos.name == "adj")
            {
                if (adjmarker > 0)
                {
                    search.buf += "" + adj_marker.mark;
                }
                if (antflag > 0)
                {
                    strAnt(PartOfSpeech.of("adj"), wdnum + 1, "(vs. ", ")");
                }
            }
        }
Esempio n. 3
0
 void strsense(int sense)
 {
     /* Append lexicographer filename after Sense # if flag is set. */
     if (WNOpt.opt("-a").flag)
     {
         search.buf += "\nSense " + sense + " in file \"" + WNDB.lexfiles[fnum] + "\"\n";
     }
     else
     {
         search.buf += "\nSense " + sense + "\n";
     }
 }
Esempio n. 4
0
        internal void strAnt(PartOfSpeech pos, int wdnum, string head, string tail)
        {
            int i, j, wdoff;

            /* Go through all the pointers looking for anotnyms from the word
             * indicated by wdnum.  When found, print all the antonym's
             * antonym pointers which point back to wdnum. */
            for (i = 0; i < ptrs.Length; i++)
            {
                Pointer pt = ptrs[i];
                if (pt.ptp.ident == ANTPTR && pt.sce == wdnum)
                {
                    SynSet psyn = new SynSet(pt.off, pos, this);
                    for (j = 0; j < psyn.ptrs.Length; j++)
                    {
                        Pointer ppt = psyn.ptrs[j];
                        if (ppt.ptp.ident == ANTPTR &&
                            ppt.dst == wdnum &&
                            ppt.off == hereiam)
                        {
                            wdoff       = ppt.sce > 0 ? ppt.sce - 1 : 0;
                            search.buf += head;

                            /* Construct buffer containing formatted antonym,
                             * then add it onto end of return buffer */
                            search.buf += deadjify(psyn.words[wdoff].word);

                            /* Print additional lexicographer information and
                             * WordNet sense number as indicated by flags */
                            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 (search.prlexid && psyn.words[wdoff].uniq != 0)
                            {
                                search.buf += psyn.words[wdoff].uniq;
                            }
                            int s = getsearchsense(wdoff + 1);
                            psyn.words[wdoff].wnsns = s;
                            if (WNOpt.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
                            }
                            search.buf += tail;
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        void strAnt(string tail, AdjSynSetType attype, int definition)
        {
            int  i, wdcnt;
            bool first = true;

            if (WNOpt.opt("-o").flag)
            {
                search.buf += "(" + hereiam + ") ";
            }
            if (WNOpt.opt("-a").flag)
            {
                search.buf    += "<" + WNDB.lexfiles[fnum] + "> ";
                search.prlexid = true;
            }
            else
            {
                search.prlexid = false;
            }
            /* 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 (WNOpt.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;
        }
Esempio n. 6
0
        void strAnt(string tail, AdjSynSetType attype, int definition)
        {
            int  i, wdcnt;
            bool first = true;

            if (WNOpt.opt("-o").flag)
            {
                search.buf += "(" + hereiam + ") ";
            }
            if (WNOpt.opt("-a").flag)
            {
                search.buf    += "<" + WNDB.lexfiles[fnum] + "> ";
                search.prlexid = true;
            }
            else
            {
                search.prlexid = false;
            }
            /* 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 (WNOpt.opt("-g").flag&&  defn != null && definition != 0)
            {
                search.buf += " -- " + defn;
            }
            search.buf += tail;
        }
Esempio n. 7
0
        void strsense(int sense)
        {
            /* Append lexicographer filename after Sense # if flag is set. */
            if (WNOpt.opt("-a").flag)
            {
                search.buf += "\nSense " + sense + " in file \"" + WNDB.lexfiles[fnum] + "\"\n";
            }
            else
            {
                search.buf += "\nSense " + sense + "\n";
            }

            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
        }
Esempio n. 8
0
        internal void str(string head, string tail, int definition, int wdnum, int antflag, int markerflag)
        {
            int i, wdcnt;

            search.buf += head;

            /* Precede synset with additional information as indicated
             * by flags */
            if (WNOpt.opt("-o").flag)
            {
                search.buf += "(" + hereiam + ") ";
            }
            if (WNOpt.opt("-a").flag)
            {
                search.buf    += "<" + WNDB.lexfiles[fnum] + "> ";
                search.prlexid = true;
            }
            else
            {
                search.prlexid = false;
            }
            if (wdnum > 0)
            {
                catword(wdnum - 1, markerflag, antflag);
            }
            else
            {
                for (i = 0, wdcnt = words.Length; i < wdcnt; i++)
                {
                    catword(i, markerflag, antflag);
                    if (i < wdcnt - 1)
                    {
                        search.buf += ", ";
                    }
                }
            }
            if (definition != 0 && WNOpt.opt("-g").flag&& defn != null)
            {
                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;
        }
Esempio n. 9
0
        internal void str(string head, string tail, int definition, int wdnum, int antflag, int markerflag)
        {
            int i, wdcnt;

            search.buf += head;

            /* Precede synset with additional information as indiecated
             * by flags */
            if (WNOpt.opt("-o").flag)
            {
                search.buf += "(" + hereiam + ") ";
            }
            if (WNOpt.opt("-a").flag)
            {
                search.buf    += "<" + WNDB.lexfiles[fnum] + "> ";
                search.prlexid = true;
            }
            else
            {
                search.prlexid = false;
            }
            if (wdnum > 0)
            {
                catword(wdnum - 1, markerflag, antflag);
            }
            else
            {
                for (i = 0, wdcnt = words.Length; i < wdcnt; i++)
                {
                    catword(i, markerflag, antflag);
                    if (i < wdcnt - 1)
                    {
                        search.buf += ", ";
                    }
                }
            }
            if (definition != 0 && WNOpt.opt("-g").flag&& defn != null)
            {
                search.buf += " -- " + defn;
            }

            search.buf += tail;
        }
Esempio n. 10
0
        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 (WNOpt.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.name == "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. ", ")");
                }
            }
        }
Esempio n. 11
0
        internal void seealso()
        {
            /* Find all SEEALSO pointers from the searchword and print the
             * word or synset pointed to. */
            string prefix = "      Also See-> ";

            for (int i = 0; i < ptrs.Length; i++)
            {
                Pointer p = ptrs[i];
                if (p.ptp.mnemonic == "SEEALSOPTR" &&
                    (p.sce == 0 || (p.sce == whichword)))
                {
                    SynSet cursyn      = new SynSet(p.off, p.pos, "", this);
                    bool   svwnsnsflag = WNOpt.opt("-s").flag;
                    WNOpt.opt("-s").flag = true;
                    cursyn.str(prefix, "", 0,
                               (p.dst == 0)?0:p.dst, 0, 0);
                    prefix = "; ";
                }
            }
        }
Esempio n. 12
0
        void WNOverview()
        {
            Index idx;

            //senses = new ArrayList();
            senses = new SynSetList();
            Indexes ixs = new Indexes(word, pos);

            while ((idx = ixs.next()) != null)
            {
                buf += "\n";

                /* Print synset for each sense.  If requested, precede
                 * synset with synset offset and/or lexical file information.*/
                for (int sens = 0; sens < idx.offs.Length; sens++)
                {
                    for (int j = 0; j < senses.Count; j++)
                    {
                        SynSet ss = (SynSet)senses[j];
                        if (ss.hereiam == idx.offs[sens])
                        {
                            goto skipit;
                        }
                    }
                    SynSet cursyn = new SynSet(idx, sens, this);

                    bool svdflag = WNOpt.opt("-g").flag;
                    WNOpt.opt("-g").flag = true;
                    bool svaflag = WNOpt.opt("-a").flag;
                    WNOpt.opt("-a").flag = WNOpt.opt("-A").flag;
                    bool svoflag = WNOpt.opt("-o").flag;
                    WNOpt.opt("-o").flag = WNOpt.opt("-O").flag;

                    cursyn.str("" + (sens + 1) + ". ", "\n", 1, 0, 0, 0);

                    WNOpt.opt("-g").flag = svdflag;
                    WNOpt.opt("-a").flag = svaflag;
                    WNOpt.opt("-o").flag = svoflag;
                    wordsFrom(cursyn);
                    cursyn.frames.Clear();                     // TDMS 03 Jul 2006 - frames get added in wordnet.cs after filtering
                    senses.Add(cursyn);
skipit:
                    ;
                }
                /* Print sense summary message */
                if (senses.Count > 0)
                {
                    taggedSenses = 0;

                    if (senses.Count == 1)
                    {
                        buf += "\nThe " + pos.name + " " + idx.wd + " has 1 sense";
                    }
                    else
                    {
                        buf += "\nThe " + pos.name + " " + idx.wd + " has " + senses.Count + " senses";
                    }
                    if (idx.tagsense_cnt > 0)
                    {
                        taggedSenses = idx.tagsense_cnt;
                        buf         += " (first " + idx.tagsense_cnt + " from tagged texts)\n";
                    }
                    else
                    {
                        buf += " (no senses from tagged texts)\n";
                    }
                }
            }
        }
Esempio n. 13
0
        void Parse(string s, PartOfSpeech fpos, string word)
        {
            int    j;
            StrTok st  = new StrTok(s);
            int    off = int.Parse(st.next());

            fnum = int.Parse(st.next());
            string       f   = st.next();
            PartOfSpeech pos = PartOfSpeech.of(f);

            if (pos.clss == "SATELLITE")
            {
                sstype = AdjSynSetType.IndirectAnt;
            }
            int wcnt = int.Parse(st.next(), NumberStyles.HexNumber);

            words = new Lexeme[wcnt];
            for (j = 0; j < wcnt; j++)
            {
                words[j]      = new Lexeme();
                words[j].word = st.next();
                words[j].uniq = int.Parse(st.next(), 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.next());

            ptrs = new Pointer[pcnt];
            for (j = 0; j < pcnt; j++)
            {
                string p = st.next();
                ptrs[j] = new Pointer(p);
                if (fpos.name == "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.next());
                ptrs[j].pos = PartOfSpeech.of(st.next());
                int sx = int.Parse(st.next(), NumberStyles.HexNumber);
                ptrs[j].sce = sx >> 8;
                ptrs[j].dst = sx & 0xff;
            }
            f = st.next();
            if (f != "|")
            {
                int fcnt = int.Parse(f);
                for (j = 0; j < fcnt; j++)
                {
                    f = st.next();                     // +
                    Frame fr = Frame.frame(int.Parse(st.next()));
                    frames.Add(new SynSetFrame(fr, int.Parse(st.next(), NumberStyles.HexNumber)));
                }
                f = st.next();
            }
            defn = "";

            if (WNOpt.opt("-o").flag)
            {
                defn = " (Synset offset:" + hereiam + ") ";
            }
            if (WNOpt.opt("-a").flag)
            {
                defn += " (" + WNDB.lexfiles[fnum] + ") ";
            }
            if (WNOpt.opt("-g").flag)
            {
                search.buf += " -- " + defn;
            }

            defn += s.Substring(s.IndexOf('|') + 1);
        }