/* find the example sentence references in the example sentence index file */ bool findExample() { bool retval = false; StreamReader fp = new StreamReader(WNDB.path + "SENTIDX.VRB"); Byte[] b = System.Text.Encoding.Unicode.GetBytes(fp.ReadToEnd()); MemoryStream ms = new MemoryStream(b); //StreamReader fp = new StreamReader(mms); int wdnum = whichword - 1; Lexeme lx = words[wdnum]; string tbuf = lx.word + "%" + pos.ident + ":" + fnum + ":" + lx.uniq + "::"; string str = WNDB.binSearch(tbuf, ms); //fp); if (str != null) { str = str.Substring(lx.word.Length + 11); StrTok st = new StrTok(str, ' ', ',', '\n'); string offset; while ((offset = st.next()) != null) { getExample(offset, lx.word); retval = true; } } fp.Close(); return(retval); }
public Exceptions(string word, PartOfSpeech pos) { line = WNDB.binSearch(word, excfps[pos.ident]); if (line != null) { endlp = line.IndexOf(' '); } }
public Exceptions(string word, PartOfSpeech pos) { line = WNDB.binSearch(word, (StreamReader)excfps[pos.key]); if (line != null) { endlp = line.IndexOf(' '); } }
void getExample(string off, string wd) { StreamReader fp = new StreamReader(WNDB.path + "SENTS.VRB"); string line = WNDB.binSearch(off, fp); line = line.Substring(line.IndexOf(' ') + 1); search.buf += " EX: " + line.Replace("%s", wd); fp.Close(); }
void getExample(string off, string wd) { StreamReader fp = WNDB.GetStreamReader(WNDB.path + "SENTS.VRB"); string line = WNDB.binSearch(off, fp); line = line.Substring(line.IndexOf(' ') + 1); search.buf += " EX: " + line.Replace("%s", wd); fp.Close(); 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 }
void getExample(string off, string wd) { StreamReader fp = new StreamReader(WNDB.path + "SENTS.VRB"); Byte[] b = System.Text.Encoding.Unicode.GetBytes(fp.ReadToEnd()); MemoryStream ms = new MemoryStream(b); string line = WNDB.binSearch(off, ms); //fp); line = line.Substring(line.IndexOf(' ') + 1); search.buf += " EX: " + line.Replace("%s", wd); fp.Close(); 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 }
public Exceptions(string word, PartOfSpeech pos) { if (laststr != ((System.IO.FileStream)(excfps[pos.ident].BaseStream)).Name) { laststr = ((System.IO.FileStream)(excfps[pos.ident].BaseStream)).Name; StreamReader fs = excfps[pos.ident]; Byte[] b = System.Text.Encoding.Unicode.GetBytes(fs.ReadToEnd()); excfps[pos.ident].BaseStream.Seek(0, SeekOrigin.Begin); exc = new MemoryStream(b); } line = WNDB.binSearch(word, exc); //excfps[pos.ident]); if (line != null) { endlp = line.IndexOf(' '); } }
/* From search.c: * Find word in index file and return parsed entry in data structure. * Input word must be exact match of string in database. */ // From the WordNet Manual (http://wordnet.princeton.edu/man/wnsearch.3WN.html) // index_lookup() finds searchstr in the index file for pos and returns a pointer // to the parsed entry in an Index data structure. searchstr must exactly match the // form of the word (lower case only, hyphens and underscores in the same places) in // the index file. NULL is returned if a match is not found. public static Index lookup(string word, PartOfSpeech pos) { int j; if (word == "") { return(null); } // TDMS 14 Aug 2005 - changed to allow for numbers as well // because the database contains searches that can start with // numerals //if (!char.IsLetter(word[0])) if (!char.IsLetter(word[0]) && !char.IsNumber(word[0])) { return(null); } string line = WNDB.binSearch(word, pos); if (line == null) { return(null); } Index idx = new Index(); StrTok st = new StrTok(line); idx.wd = st.next(); /* the word */ idx.pos = PartOfSpeech.of(st.next()); /* the part of speech */ idx.sense_cnt = int.Parse(st.next()); /* collins count */ int ptruse_cnt = int.Parse(st.next()); /* number of pointers types */ idx.ptruse = new PointerType[ptruse_cnt]; for (j = 0; j < ptruse_cnt; j++) { idx.ptruse[j] = PointerType.of(st.next()); } int off_cnt = int.Parse(st.next()); idx.offs = new int[off_cnt]; idx.tagsense_cnt = int.Parse(st.next()); for (j = 0; j < off_cnt; j++) { idx.offs[j] = int.Parse(st.next()); } return(idx); }
/* find the example sentence references in the example sentence index file */ bool findExample() { bool retval = false; StreamReader fp = new StreamReader(WNDB.path + "SENTIDX.VRB"); int wdnum = whichword - 1; Lexeme lx = words[wdnum]; string tbuf = lx.word + "%" + pos.ident + ":" + fnum + ":" + lx.uniq + "::"; string str = WNDB.binSearch(tbuf, fp); if (str != null) { str = str.Substring(lx.word.Length + 11); StrTok st = new StrTok(str, ' ', ',', '\n'); string offset; while ((offset = st.next()) != null) { getExample(offset, lx.word); retval = true; } } fp.Close(); return(retval); }