internal Search(string w, PartOfSpeech p, SearchType s, int sn) { word = w; pos = p; sch = s; whichsense = sn; }
public WNHelp(SearchType s, PartOfSpeech p) : this((s.rec ? "-" : "") + s.ptp.mnemonic, p) { }
Opt(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); }
public Search(string w, bool doMorphs, PartOfSpeech p, SearchType s, int sn) : this(w, p, s, sn) { if (p != null) do_search(doMorphs); }
/// <summary> /// Trace classification. /// </summary> /// <param name="ptp"></param> /// <param name="stp"></param> internal void traceclassif(PointerType ptp, SearchType stp) //,PartOfSpeech fpos) { int j; int idx = 0; //int svwnsnsflag; string head = ""; int LASTTYPE = PointerType.of("CLASS").ident; int OVERVIEW = (LASTTYPE + 9); int MAXSEARCH = OVERVIEW; int CLASSIF_START = (MAXSEARCH + 1); int CLASSIF_CATEGORY = (CLASSIF_START); /* ;c */ int CLASSIF_USAGE = (CLASSIF_START + 1); /* ;u */ int CLASSIF_REGIONAL = (CLASSIF_START + 2); /* ;r */ int CLASSIF_END = CLASSIF_REGIONAL; int CLASS_START = (CLASSIF_END + 1); int CLASS_CATEGORY = (CLASS_START); /* -c */ int CLASS_USAGE = (CLASS_START + 1); /* -u */ int CLASS_REGIONAL = (CLASS_START + 2); /* -r */ int CLASS_END = CLASS_REGIONAL; //long prlist[1024]; ArrayList prlist = new ArrayList(); for (int i = 0; i < ptrs.Length; i++) { Pointer pt = ptrs[i]; if (((pt.ptp.ident >= CLASSIF_START) && (pt.ptp.ident <= CLASSIF_END) && stp.ptp.ident == PointerType.of("CLASSIFICATION").ident) || ((pt.ptp.ident >= CLASS_START) && (pt.ptp.ident <= CLASS_END) && stp.ptp.ident == PointerType.of("CLASS").ident)) { if (!search.prflag) { strsns(sense + 1); search.prflag = true; } SynSet cursyn = new SynSet(pt.off, pt.pos, this); // 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); for (j = 0; j < idx; j++) { if (pt.off == Convert.ToInt16(prlist[j])) { break; } } if (j == idx) { prlist.Add(pt.off); spaces("TRACEP", 0); if (pt.ptp.ident == CLASSIF_CATEGORY) head = "TOPIC->("; // WN2.1 - TDMS // head = "CATEGORY->("; else if (pt.ptp.ident == CLASSIF_USAGE) head = "USAGE->("; else if (pt.ptp.ident == CLASSIF_REGIONAL) head = "REGION->("; else if (pt.ptp.ident == CLASS_CATEGORY) head = "TOPIC_TERM->("; // WN2.1 - TDMS // head = "CATEGORY_TERM->("; else if (pt.ptp.ident == CLASS_USAGE) head = "USAGE_TERM->("; else if (pt.ptp.ident == CLASS_REGIONAL) head = "REGION_TERM->("; head += pt.pos.name; head += ") "; //svwnsnsflag = wnsnsflag; //wnsnsflag = 1; // printsynset(head, cursyn, "\n", DEFOFF, ALLWORDS, // SKIP_ANTS, SKIP_MARKER); cursyn.str(head, "\n", 0, 0, 0, 0); //wnsnsflag = svwnsnsflag; } } } }
/// <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); } } } }
/// <summary> /// Trace classification. /// </summary> /// <param name="ptp"></param> /// <param name="stp"></param> internal void traceclassif(PointerType ptp, SearchType stp) //,PartOfSpeech fpos) { int j; int idx = 0; //int svwnsnsflag; string head = ""; int LASTTYPE = PointerType.of("CLASS").ident; int OVERVIEW = (LASTTYPE + 9); int MAXSEARCH = OVERVIEW; int CLASSIF_START = (MAXSEARCH + 1); int CLASSIF_CATEGORY = (CLASSIF_START); /* ;c */ int CLASSIF_USAGE = (CLASSIF_START + 1); /* ;u */ int CLASSIF_REGIONAL = (CLASSIF_START + 2); /* ;r */ int CLASSIF_END = CLASSIF_REGIONAL; int CLASS_START = (CLASSIF_END + 1); int CLASS_CATEGORY = (CLASS_START); /* -c */ int CLASS_USAGE = (CLASS_START + 1); /* -u */ int CLASS_REGIONAL = (CLASS_START + 2); /* -r */ int CLASS_END = CLASS_REGIONAL; //long prlist[1024]; ArrayList prlist = new ArrayList(); for (int i = 0; i < ptrs.Length; i++) { Pointer pt = ptrs[i]; if (((pt.ptp.ident >= CLASSIF_START) && (pt.ptp.ident <= CLASSIF_END) && stp.ptp.ident == PointerType.of("CLASSIFICATION").ident) || ((pt.ptp.ident >= CLASS_START) && (pt.ptp.ident <= CLASS_END) && stp.ptp.ident == PointerType.of("CLASS").ident)) { if (!search.prflag) { strsns(sense + 1); search.prflag = true; } SynSet cursyn = new SynSet(pt.off, pt.pos, this); // 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); for (j = 0; j < idx; j++) { if (pt.off == Convert.ToInt16(prlist[j])) { break; } } if (j == idx) { prlist.Add(pt.off); spaces("TRACEP", 0); if (pt.ptp.ident == CLASSIF_CATEGORY) { head = "TOPIC->("; // WN2.1 - TDMS } // head = "CATEGORY->("; else if (pt.ptp.ident == CLASSIF_USAGE) { head = "USAGE->("; } else if (pt.ptp.ident == CLASSIF_REGIONAL) { head = "REGION->("; } else if (pt.ptp.ident == CLASS_CATEGORY) { head = "TOPIC_TERM->("; // WN2.1 - TDMS } // head = "CATEGORY_TERM->("; else if (pt.ptp.ident == CLASS_USAGE) { head = "USAGE_TERM->("; } else if (pt.ptp.ident == CLASS_REGIONAL) { head = "REGION_TERM->("; } head += pt.pos.name; head += ") "; //svwnsnsflag = wnsnsflag; //wnsnsflag = 1; // printsynset(head, cursyn, "\n", DEFOFF, ALLWORDS, // SKIP_ANTS, SKIP_MARKER); cursyn.str(head, "\n", 0, 0, 0, 0); //wnsnsflag = svwnsnsflag; } } } }
/// <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); } } } }