Exemplo n.º 1
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;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
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;
        }
Exemplo 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";
            }

            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
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
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. ", ")");
                }
            }
        }
Exemplo n.º 6
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.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 = "; ";
                }
            }
        }
Exemplo n.º 7
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";
                    }
                }
            }
        }