/// <summary> /// Trace meronyms. /// </summary> /// <param name="pbase"></param> /// <param name="fpos"></param> /// <param name="depth"></param> 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); SynSet cursyn = new SynSet(pt.off, pt.pos, this); search.wordsFrom(cursyn); cursyn.str("=> ", "\n", 1, 0, 0, 1); // TDMS 6 Oct 2005 - build hierarchical results // TODO: verify this if (this.senses == null) { this.senses = new SynSetList(); } cursyn.thisptr = pt; // TDMS 17 Nov 2005 - add this pointer type // TODO: This is adding senses incorrectly this.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(); }
/// <summary> /// Trace nominalizations. /// </summary> /// <param name="ptp"></param> internal void tracenomins(PointerType ptp) //,PartOfSpeech fpos) { /* * int j; * int idx = 0; * ArrayList prlist = new ArrayList(); */ for (int i = 0; i < ptrs.Length; i++) { Pointer pt = ptrs[i]; // TDMS 26/8/05 changed DERIVATION to NOMINALIZATIONS - verify this if (pt.ptp.Ident == NOMINALIZATIONS && (pt.sce == 0 || pt.sce == whichword)) { if (!search.prflag) { strsns(sense + 1); search.prflag = true; } spaces("TRACEP", 0); SynSet cursyn = new SynSet(pt.off, pt.pos, this); search.wordsFrom(cursyn); cursyn.str("RELATED TO-> ", "\n", 0, 0, 0, 0); // TDMS 6 Oct 2005 - build hierarchical results // TODO: verify this if (this.senses == null) { this.senses = new SynSetList(); } cursyn.thisptr = pt; // TDMS 17 Nov 2005 - add this pointer type this.senses.Add(cursyn); cursyn.tracePtrs(ptp, cursyn.pos, 0); /* * for (j = 0; j < idx; j++) * { * //#ifdef FOOP * // if (synptr->ptroff[i] == prlist[j]) * // { * // break; * // } * //#endif * } * * if (j == idx) * { * prlist.Add(pt.off); * spaces("TRACEP",2); * cursyn.str("=> ","\n",1,0,0,1); * } */ } } }
/// <summary> /// Trace coordinate terms. /// </summary> /// <param name="ptp"></param> /// <param name="fpos"></param> /// <param name="depth"></param> internal void traceCoords(PointerType ptp, PartOfSpeech fpos, int depth) { for (int i = 0; i < ptrs.Length; i++) { Pointer pt = ptrs[i]; /* WN2.0 * if (pt.ptp.mnemonic=="HYPERPTR" && * (pt.sce==0 || * pt.sce==whichword)) */ // WN2.1 if statement change - TDMS if ((pt.ptp.Ident == HYPERPTR || pt.ptp.Ident == INSTANCE) && ((pt.sce == 0) || (pt.sce == whichword))) { if (!search.prflag) { strsns(sense + 1); search.prflag = true; } spaces("TRACEC", depth); SynSet cursyn = new SynSet(pt.off, pt.pos, this); search.wordsFrom(cursyn); cursyn.str("-> ", "\n", 1, 0, 0, 1); cursyn.tracePtrs(ptp, cursyn.pos, depth); // 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); if (depth > 0) { depth = depthcheck(depth); cursyn.traceCoords(ptp, cursyn.pos, depth + 1); // TDMS 6 Oct 2005 - build hierarchical results // TODO: verify this if (this.senses == null) { this.senses = new SynSetList(); } cursyn.thisptr = pt; // TDMS 17 Nov 2005 - add this pointer type this.senses.Add(cursyn); } } } }
void doRelList(Index idx, RelList rellist) { int i; bool flag; SynSet synptr; BitSet outsenses = new BitSet(300); prflag = true; for (RelList rel = rellist; rel != null; rel = rel.next) { flag = false; for (i = 0; i < idx.offs.Length; i++) { if (rel.senses[i] && !outsenses[i]) { flag = true; synptr = new SynSet(idx.offs[i], pos, "", this, i); synptr.strsns(i + 1); synptr.tracePtrs(PointerType.of("HYPERPTR"), pos, 0); synptr.frames.Clear(); // TDMS 03 Jul 2006 - frames get added in wordnet.cs after filtering // TDMS 11 Oct 2005 - build hierarchical results senses.Add(synptr); outsenses[i] = true; } } if (flag) { buf += "--------------\n"; } } for (i = 0; i < idx.offs.Length; i++) { if (!outsenses[i]) { synptr = new SynSet(idx.offs[i], pos, "", this, i); synptr.strsns(i + 1); synptr.tracePtrs(PointerType.of("HYPERPTR"), pos, 0); synptr.frames.Clear(); // TDMS 03 Jul 2006 - frames get added in wordnet.cs after filtering // TDMS 11 Oct 2005 - build hierarchical results senses.Add(synptr); buf += "---------------\n"; } } }
/// <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); } } } }
void doRelList(Index idx, RelList rellist) { int i; bool flag; SynSet synptr; BitSet outsenses = new BitSet(300); prflag = true; for (RelList rel = rellist; rel != null; rel = rel.next) { flag = false; for (i = 0; i < idx.offs.Length; i++) if (rel.senses[i] && !outsenses[i]) { flag = true; synptr = new SynSet(idx.offs[i], pos, "", this, i); synptr.strsns(i + 1); synptr.tracePtrs(PointerType.of("HYPERPTR"), pos, 0); synptr.frames.Clear(); // TDMS 03 Jul 2006 - frames get added in wordnet.cs after filtering // TDMS 11 Oct 2005 - build hierarchical results senses.Add(synptr); outsenses[i] = true; } if (flag) buf += "--------------\n"; } for (i = 0; i < idx.offs.Length; i++) if (!outsenses[i]) { synptr = new SynSet(idx.offs[i], pos, "", this, i); synptr.strsns(i + 1); synptr.tracePtrs(PointerType.of("HYPERPTR"), pos, 0); synptr.frames.Clear(); // TDMS 03 Jul 2006 - frames get added in wordnet.cs after filtering // TDMS 11 Oct 2005 - build hierarchical results senses.Add(synptr); buf += "---------------\n"; } }
// From the WordNet Manual (http://wordnet.princeton.edu/man/wnsearch.3WN.html) // findtheinfo() is the primary search algorithm for use with database interface // applications. Search results are automatically formatted, and a pointer to the // text buffer is returned. All searches listed in WNHOME/include/wnconsts.h can be // done by findtheinfo(). void findtheinfo() { SynSet cursyn = null; Indexes ixs = new Indexes(word, pos); Index idx = null; int depth = sch.rec ? 1 : 0; senses = new SynSetList(); switch (sch.ptp.mnemonic) { case "OVERVIEW": WNOverview(); break; case "FREQ": if (countSenses == null) { countSenses = new ArrayList(); } while ((idx = ixs.next()) != null) { countSenses.Add(idx.offs.Length); buf += "Sense " + countSenses.Count + ": " + idx.offs.Length; } break; case "WNGREP": if (!(customgrep == null)) { strings = customgrep.wngrep(word, pos); } else { strings = WNDB.wngrep(word, pos); } for (int wi = 0; wi < strings.Count; wi++) { buf += (string)strings[wi] + "\n"; } break; case "VERBGROUP": goto case "RELATIVES"; case "RELATIVES": while ((idx = ixs.next()) != null) { relatives(idx); } break; default: /* look at all spellings of word */ while ((idx = ixs.next()) != null) { /* Print extra sense msgs if looking at all senses */ if (whichsense == ALLSENSES) { buf += "\n"; } /* Go through all of the searchword's senses in the * database and perform the search requested. */ for (int sense = 0; sense < idx.offs.Length; sense++) { if (whichsense == ALLSENSES || whichsense == sense + 1) { prflag = false; /* Determine if this synset has already been done * with a different spelling. If so, skip it. */ for (int j = 0; j < senses.Count; j++) { SynSet ss = (SynSet)senses[j]; if (ss.hereiam == idx.offs[sense]) { goto skipit; } } cursyn = new SynSet(idx, sense, this); //TODO: moved senses.add(cursyn) from here to each case and handled it differently according to search - this handling needs to be verified to ensure the filter is not to limiting switch (sch.ptp.mnemonic) { case "ANTPTR": if (pos.name == "adj") { cursyn.traceAdjAnt(); } else { cursyn.tracePtrs(sch.ptp, pos, depth); } if (cursyn.isDirty) { // TDMS 25 Oct 2005 - restrict to relevant values cursyn.frames.Clear(); // TDMS 03 Jul 2006 - frames get added in wordnet.cs after filtering senses.Add(cursyn); } /* * if (cursyn.senses != null ) * if (cursyn.senses.isDirty) * { // TDMS 25 Oct 2005 - restrict to relevant values * cursyn.frames.Clear(); // TDMS 03 Jul 2006 - frames get added in wordnet.cs after filtering * senses.Add(cursyn); * } */ // perform the senses restrictions based upon pos /* * switch(pos.name) { * case "verb": * if (cursyn.senses != null) // TDMS 25 Oct 2005 - restrict to relevant values * senses.Add(cursyn); * break; * * default: * if (cursyn.senses != null && cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values * senses.Add(cursyn); * break; * } */ break; case "COORDS": //eg. search for 'car', select Noun -> 'Coordinate Terms' cursyn.traceCoords(PointerType.of("HYPOPTR"), pos, depth); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values { senses.Add(cursyn); } /* * if (cursyn.senses != null ) * if (cursyn.senses.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values * senses.Add(cursyn); */ break; case "FRAMES": //eg. search for 'right', select Verb -> 'Sample Sentences' cursyn.strFrame(true); // TDMS 03 JUL 2006 fixed relevancy check if (cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values if (cursyn.isDirty) { senses.Add(cursyn); } /* * if (cursyn.frames.Count != 0) // TDMS 03 Jul 2006 - only add frame if there are any retrieved * senses.Add(cursyn); */ break; case "MERONYM": //eg. search for 'car', select Noun -> 'Meronym' senses.isDirty = false; cursyn.tracePtrs(PointerType.of("HASMEMBERPTR"), pos, depth); cursyn.tracePtrs(PointerType.of("HASSTUFFPTR"), pos, depth); cursyn.tracePtrs(PointerType.of("HASPARTPTR"), pos, depth); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values { senses.Add(cursyn); } /* * if (cursyn.senses != null ) * if (cursyn.senses.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values * senses.Add(cursyn); */ break; case "HOLONYM": //eg. search for 'car', select Noun -> 'Holonyms' cursyn.tracePtrs(PointerType.of("ISMEMBERPTR"), pos, depth); cursyn.tracePtrs(PointerType.of("ISSTUFFPTR"), pos, depth); cursyn.tracePtrs(PointerType.of("ISPARTPTR"), pos, depth); // if (cursyn.senses != null && cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values // senses.Add(cursyn); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values { senses.Add(cursyn); } /* * if (cursyn.senses != null ) * if (cursyn.senses.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values * senses.Add(cursyn); */ break; case "HMERONYM": //eg. search for 'car', select Noun -> 'Meronyms Tree' cursyn.partsAll(sch.ptp); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values { senses.Add(cursyn); } // senses.Add(SearchTrack.ssParent); /* * if (cursyn.senses != null ) * if (cursyn.senses.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values * senses.Add(cursyn); */ // if (cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values // senses.Add(cursyn); break; case "HHOLONYM": cursyn.partsAll(sch.ptp); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values { senses.Add(cursyn); } /* * if (cursyn.senses != null) // && cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values * senses.Add(cursyn); */ break; case "SEEALSOPTR": cursyn.seealso(); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values { senses.Add(cursyn); } /* * if (cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values * senses.Add(cursyn); */ break; case "SIMPTR": goto case "HYPERPTR"; case "SYNS": goto case "HYPERPTR"; case "HYPERPTR": //eg. search for 'car', select Noun -> 'Synonyms/Hypernyms, ordered by estimated frequency' wordsFrom(cursyn); cursyn.strsns(sense + 1); prflag = true; cursyn.tracePtrs(sch.ptp, pos, depth); if (pos.name == "adj") { cursyn.tracePtrs(PointerType.of("PERTPTR"), pos, depth); cursyn.tracePtrs(PointerType.of("PPLPTR"), pos, depth); } else if (pos.name == "adv") { cursyn.tracePtrs(PointerType.of("PERTPTR"), pos, depth); } if (pos.name == "verb") { cursyn.strFrame(false); } if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values { senses.Add(cursyn); } // senses.Add(cursyn); break; case "NOMINALIZATIONS": // 26/8/05 - changed "DERIVATION" to "NOMINALIZATIONS" - this needs to be verified // derivation - TDMS cursyn.tracenomins(sch.ptp); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values { senses.Add(cursyn); } /* * if (cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values * senses.Add(cursyn); */ break; //WN3.0 case "PERTPTR": cursyn.strsns(sense + 1); prflag = true; cursyn.tracePtrs(PointerType.of("PERTPTR"), pos, depth); break; case "CLASSIFICATION": goto case "CLASS"; case "CLASS": //eg. search for 'car', select Noun -> 'Domain Terms' cursyn.traceclassif(sch.ptp, new SearchType(false, sch.ptp)); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values { senses.Add(cursyn); } /* * if (cursyn.senses != null ) * if (cursyn.senses.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values * senses.Add(cursyn); */ break; case "HYPOPTR": //eg. search for 'car', select Noun -> 'Hyponyms' cursyn.tracePtrs(sch.ptp, pos, depth); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values { senses.Add(cursyn); } /* * if (cursyn.senses != null ) * if (cursyn.senses.isDirty) * { // TDMS 25 Oct 2005 - restrict to relevant values * cursyn.frames.Clear(); // TDMS 03 Jul 2006 - frames get added in wordnet.cs after filtering * senses.Add(cursyn); * } */ break; default: cursyn.tracePtrs(sch.ptp, pos, depth); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values { senses.Add(cursyn); } /* * if (cursyn.senses != null ) * if (cursyn.senses.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values * senses.Add(cursyn); */ break; } skipit: ; } } } break; } }
// From the WordNet Manual (http://wordnet.princeton.edu/man/wnsearch.3WN.html) // findtheinfo() is the primary search algorithm for use with database interface // applications. Search results are automatically formatted, and a pointer to the // text buffer is returned. All searches listed in WNHOME/include/wnconsts.h can be // done by findtheinfo(). void findtheinfo() { SynSet cursyn = null; Indexes ixs = new Indexes(word, pos); Index idx = null; int depth = sch.rec ? 1 : 0; senses = new SynSetList(); switch (sch.ptp.mnemonic) { case "OVERVIEW": WNOverview(); break; case "FREQ": if (countSenses == null) countSenses = new ArrayList(); while ((idx = ixs.next()) != null) { countSenses.Add(idx.offs.Length); buf += "Sense " + countSenses.Count + ": " + idx.offs.Length; } break; case "WNGREP": strings = WNDB.wngrep(word, pos); for (int wi = 0; wi < strings.Count; wi++) buf += (string)strings[wi] + "\n"; break; case "VERBGROUP": goto case "RELATIVES"; case "RELATIVES": while ((idx = ixs.next()) != null) relatives(idx); break; default: /* look at all spellings of word */ while ((idx = ixs.next()) != null) { /* Print extra sense msgs if looking at all senses */ if (whichsense == ALLSENSES) buf += "\n"; /* Go through all of the searchword's senses in the database and perform the search requested. */ for (int sense = 0; sense < idx.offs.Length; sense++) if (whichsense == ALLSENSES || whichsense == sense + 1) { prflag = false; /* Determine if this synset has already been done with a different spelling. If so, skip it. */ for (int j = 0; j < senses.Count; j++) { SynSet ss = (SynSet)senses[j]; if (ss.hereiam == idx.offs[sense]) goto skipit; } cursyn = new SynSet(idx, sense, this); //TODO: moved senses.add(cursyn) from here to each case and handled it differently according to search - this handling needs to be verified to ensure the filter is not to limiting switch (sch.ptp.mnemonic) { case "ANTPTR": if (pos.name == "adj") cursyn.traceAdjAnt(); else cursyn.tracePtrs(sch.ptp, pos, depth); if (cursyn.isDirty) { // TDMS 25 Oct 2005 - restrict to relevant values cursyn.frames.Clear(); // TDMS 03 Jul 2006 - frames get added in wordnet.cs after filtering senses.Add(cursyn); } /* if (cursyn.senses != null ) if (cursyn.senses.isDirty) { // TDMS 25 Oct 2005 - restrict to relevant values cursyn.frames.Clear(); // TDMS 03 Jul 2006 - frames get added in wordnet.cs after filtering senses.Add(cursyn); } */ // perform the senses restrictions based upon pos /* switch(pos.name) { case "verb": if (cursyn.senses != null) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); break; default: if (cursyn.senses != null && cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); break; } */ break; case "COORDS": //eg. search for 'car', select Noun -> 'Coordinate Terms' cursyn.traceCoords(PointerType.of("HYPOPTR"), pos, depth); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); /* if (cursyn.senses != null ) if (cursyn.senses.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); */ break; case "FRAMES": //eg. search for 'right', select Verb -> 'Sample Sentences' cursyn.strFrame(true); // TDMS 03 JUL 2006 fixed relevancy check if (cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values if (cursyn.isDirty) senses.Add(cursyn); /* if (cursyn.frames.Count != 0) // TDMS 03 Jul 2006 - only add frame if there are any retrieved senses.Add(cursyn); */ break; case "MERONYM": //eg. search for 'car', select Noun -> 'Meronym' senses.isDirty = false; cursyn.tracePtrs(PointerType.of("HASMEMBERPTR"), pos, depth); cursyn.tracePtrs(PointerType.of("HASSTUFFPTR"), pos, depth); cursyn.tracePtrs(PointerType.of("HASPARTPTR"), pos, depth); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); /* if (cursyn.senses != null ) if (cursyn.senses.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); */ break; case "HOLONYM": //eg. search for 'car', select Noun -> 'Holonyms' cursyn.tracePtrs(PointerType.of("ISMEMBERPTR"), pos, depth); cursyn.tracePtrs(PointerType.of("ISSTUFFPTR"), pos, depth); cursyn.tracePtrs(PointerType.of("ISPARTPTR"), pos, depth); // if (cursyn.senses != null && cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values // senses.Add(cursyn); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); /* if (cursyn.senses != null ) if (cursyn.senses.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); */ break; case "HMERONYM": //eg. search for 'car', select Noun -> 'Meronyms Tree' cursyn.partsAll(sch.ptp); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); // senses.Add(SearchTrack.ssParent); /* if (cursyn.senses != null ) if (cursyn.senses.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); */ // if (cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values // senses.Add(cursyn); break; case "HHOLONYM": cursyn.partsAll(sch.ptp); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); /* if (cursyn.senses != null) // && cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); */ break; case "SEEALSOPTR": cursyn.seealso(); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); /* if (cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); */ break; case "SIMPTR": goto case "HYPERPTR"; case "SYNS": goto case "HYPERPTR"; case "HYPERPTR": //eg. search for 'car', select Noun -> 'Synonyms/Hypernyms, ordered by estimated frequency' wordsFrom(cursyn); cursyn.strsns(sense + 1); prflag = true; cursyn.tracePtrs(sch.ptp, pos, depth); if (pos.name == "adj") { cursyn.tracePtrs(PointerType.of("PERTPTR"), pos, depth); cursyn.tracePtrs(PointerType.of("PPLPTR"), pos, depth); } else if (pos.name == "adv") cursyn.tracePtrs(PointerType.of("PERTPTR"), pos, depth); if (pos.name == "verb") cursyn.strFrame(false); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); // senses.Add(cursyn); break; case "NOMINALIZATIONS": // 26/8/05 - changed "DERIVATION" to "NOMINALIZATIONS" - this needs to be verified // derivation - TDMS cursyn.tracenomins(sch.ptp); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); /* if (cursyn.sense != 0) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); */ break; //WN3.0 case "PERTPTR": cursyn.strsns(sense + 1); prflag = true; cursyn.tracePtrs(PointerType.of("PERTPTR"), pos, depth); break; case "CLASSIFICATION": goto case "CLASS"; case "CLASS": //eg. search for 'car', select Noun -> 'Domain Terms' cursyn.traceclassif(sch.ptp, new SearchType(false, sch.ptp)); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); /* if (cursyn.senses != null ) if (cursyn.senses.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); */ break; case "HYPOPTR": //eg. search for 'car', select Noun -> 'Hyponyms' cursyn.tracePtrs(sch.ptp, pos, depth); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); /* if (cursyn.senses != null ) if (cursyn.senses.isDirty) { // TDMS 25 Oct 2005 - restrict to relevant values cursyn.frames.Clear(); // TDMS 03 Jul 2006 - frames get added in wordnet.cs after filtering senses.Add(cursyn); } */ break; default: cursyn.tracePtrs(sch.ptp, pos, depth); if (cursyn.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); /* if (cursyn.senses != null ) if (cursyn.senses.isDirty) // TDMS 25 Oct 2005 - restrict to relevant values senses.Add(cursyn); */ break; } skipit: ; } } break; } }
/// <summary> /// Trace meronyms. /// </summary> /// <param name="pbase"></param> /// <param name="fpos"></param> /// <param name="depth"></param> 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); SynSet cursyn = new SynSet(pt.off, pt.pos, this); search.wordsFrom(cursyn); cursyn.str("=> ", "\n", 1, 0, 0, 1); // TDMS 6 Oct 2005 - build hierarchical results // TODO: verify this if (this.senses == null) this.senses = new SynSetList(); cursyn.thisptr = pt; // TDMS 17 Nov 2005 - add this pointer type // TODO: This is adding senses incorrectly this.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(); }
/// <summary> /// Trace nominalizations. /// </summary> /// <param name="ptp"></param> internal void tracenomins(PointerType ptp) //,PartOfSpeech fpos) { /* int j; int idx = 0; ArrayList prlist = new ArrayList(); */ for (int i = 0; i < ptrs.Length; i++) { Pointer pt = ptrs[i]; // TDMS 26/8/05 changed DERIVATION to NOMINALIZATIONS - verify this if (pt.ptp.ident == NOMINALIZATIONS && (pt.sce == 0 || pt.sce == whichword)) { if (!search.prflag) { strsns(sense + 1); search.prflag = true; } spaces("TRACEP", 0); SynSet cursyn = new SynSet(pt.off, pt.pos, this); search.wordsFrom(cursyn); cursyn.str("RELATED TO-> ", "\n", 0, 0, 0, 0); // TDMS 6 Oct 2005 - build hierarchical results // TODO: verify this if (this.senses == null) this.senses = new SynSetList(); cursyn.thisptr = pt; // TDMS 17 Nov 2005 - add this pointer type this.senses.Add(cursyn); cursyn.tracePtrs(ptp, cursyn.pos, 0); /* for (j = 0; j < idx; j++) { //#ifdef FOOP // if (synptr->ptroff[i] == prlist[j]) // { // break; // } //#endif } if (j == idx) { prlist.Add(pt.off); spaces("TRACEP",2); cursyn.str("=> ","\n",1,0,0,1); } */ } } }
/// <summary> /// Trace coordinate terms. /// </summary> /// <param name="ptp"></param> /// <param name="fpos"></param> /// <param name="depth"></param> internal void traceCoords(PointerType ptp, PartOfSpeech fpos, int depth) { for (int i = 0; i < ptrs.Length; i++) { Pointer pt = ptrs[i]; /* WN2.0 if (pt.ptp.mnemonic=="HYPERPTR" && (pt.sce==0 || pt.sce==whichword)) */ // WN2.1 if statement change - TDMS if ((pt.ptp.ident == HYPERPTR || pt.ptp.ident == INSTANCE) && ((pt.sce == 0) || (pt.sce == whichword))) { if (!search.prflag) { strsns(sense + 1); search.prflag = true; } spaces("TRACEC", depth); SynSet cursyn = new SynSet(pt.off, pt.pos, this); search.wordsFrom(cursyn); cursyn.str("-> ", "\n", 1, 0, 0, 1); cursyn.tracePtrs(ptp, cursyn.pos, depth); // 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); if (depth > 0) { depth = depthcheck(depth); cursyn.traceCoords(ptp, cursyn.pos, depth + 1); // TDMS 6 Oct 2005 - build hierarchical results // TODO: verify this if (this.senses == null) this.senses = new SynSetList(); cursyn.thisptr = pt; // TDMS 17 Nov 2005 - add this pointer type this.senses.Add(cursyn); } } } }
/// <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); } } } }