Exemple #1
0
        /// <summary>
        /// Traces pointer hierarchy.
        /// </summary>
        /// <param name="stp"></param>
        /// <param name="fpos"></param>
        /// <param name="depth"></param>
        internal void tracePtrs(SearchType stp, PartOfSpeech fpos, int depth)
        {
            int         i;
            SynSet      cursyn;
            PointerType ptp = stp.ptp;
            string      prefix;
            int         realptr;     // WN2.1

            for (i = 0; i < ptrs.Length; i++)
            {
                Pointer pt = ptrs[i];
                // following if statement is WN2.1 - TDMS
                if ((ptp.Ident == HYPERPTR && (pt.ptp.Ident == HYPERPTR ||
                                               pt.ptp.Ident == INSTANCE)) ||
                    (ptp.Ident == HYPOPTR && (pt.ptp.Ident == HYPOPTR ||
                                              pt.ptp.Ident == INSTANCES)) ||
                    ((pt.ptp == ptp) &&
                     ((pt.sce == 0) ||
                      (pt.sce == whichword))))
                {
                    realptr = pt.ptp.Ident;                 /* WN2.1 deal with INSTANCE */
                    if (!search.prflag)                     // print sense number and synset
                    {
                        strsns(sense + 1);
                    }
                    search.prflag = true;
                    spaces("TRACEP", depth + (stp.rec ? 2 : 0));
                    //					switch (ptp.mnemonic)
                    // TDMS 11 JUL 2006 - changed switch to ident	switch (pt.ptp.mnemonic) // TDMS - WN2.1 MOD
                    switch (pt.ptp.Ident)                     // TDMS 11 JUL 2006 - changed switch to ident
                    {
                    case PERTPTR:
                        if (fpos.name == "adv")                                 // TDMS "adverb")
                        {
                            prefix = "Derived from " + pt.pos.name + " ";
                        }
                        else
                        {
                            prefix = "Pertains to " + pt.pos.name + " ";
                        }
                        break;

                    case ANTPTR:                             // TDMS 26/8/05
                        if (fpos.name == "adj")              //TODO: which adjective will fall into the below?
                        {
                            prefix = "Antonym of ";
                        }
                        else
                        {
                            prefix = "";
                        }
                        break;

                    case PPLPTR:
                        prefix = "Participle of verb";
                        break;

                    case INSTANCE:
                        prefix = "INSTANCE OF=> ";
                        break;

                    case INSTANCES:
                        prefix = "HAS INSTANCE=> ";
                        break;

                    case HASMEMBERPTR:
                        prefix = "   HAS MEMBER: ";
                        break;

                    case HASSTUFFPTR:
                        prefix = "   HAS SUBSTANCE: ";
                        break;

                    case HASPARTPTR:
                        prefix = "   HAS PART:  ";
                        break;

                    case ISMEMBERPTR:
                        prefix = "   MEMBER OF:  ";
                        break;

                    case ISSTUFFPTR:                             // TDMS 26/8/05
                        prefix = "   SUBSTANCE OF: ";
                        break;

                    case ISPARTPTR:                             // TDMS 26/8/05
                        prefix = "   PART OF: ";
                        break;

                    default:
                        prefix = "=> ";
                        break;
                    }

                    /* Read synset pointed to */
                    cursyn = new SynSet(pt.off, pt.pos, this);
                    search.wordsFrom(cursyn);

                    // TDMS 6 Oct 2005 - build hierarchical results

                    if (this.senses == null)
                    {
                        this.senses = new SynSetList();
                    }
                    cursyn.thisptr = pt;                      // TDMS 17 Nov 2005 - add this pointer type
                    this.senses.Add(cursyn);

                    /* For Pertainyms and Participles pointing to a specific
                     * sense, indicate the sense then retrieve the synset
                     * pointed to and other info as determined by type.
                     * Otherwise, just print the synset pointed to. */
                    if ((ptp.Ident == PERTPTR || ptp.Ident == PPLPTR) &&
                        pt.dst != 0)
                    {
                        string tbuf = " (Sense " + cursyn.getsearchsense(pt.dst) + ")";
                        cursyn.str(prefix, tbuf, 0, pt.dst, 0, 1);
                        if (ptp.Ident == PPLPTR)                         // adj pointing to verb
                        {
                            cursyn.str("     =>", "\n", 1, 0, 1, 1);
                            cursyn.tracePtrs(PointerType.of("HYPERPTR"), cursyn.pos, 0);
                        }
                        else if (fpos.name == "adv")                         // adverb pointing to adjective
                        {
                            cursyn.str("     =>", "\n", 0, 0, (pos.clss == "SATELLITE") ? 0 : 1, 1);
                            // cursyn.traceptrs(HYPERPTR,pos,0);
                        }
                        else                          // adjective pointing to noun
                        {
                            cursyn.str("     =>", "\n", 1, 0, 1, 1);
                            cursyn.tracePtrs(PointerType.of("HYPERPTR"), pos, 0);
                        }
                    }
                    else
                    {
                        cursyn.str(prefix, "\n", 1, 0, 1, 1);
                    }

                    /* For HOLONYMS and MERONYMS, keep track of last one
                     * printed in buffer so results can be truncated later. */
                    if (ptp.Ident >= PointerType.of("ISMEMBERPTR").Ident&&
                        ptp.Ident <= PointerType.of("HASPARTPTR").Ident)
                    {
                        search.mark();
                    }
                    if (depth > 0)
                    {
                        depth = cursyn.depthcheck(depth);
                        cursyn.tracePtrs(ptp, cursyn.pos, depth + 1);
                    }
                }
            }
        }