public static void Main(string[] args) { string filepath = "t8.shakespeare.txt"; string indexpath = "index"; Document document; Token token; DocumentReader reader = new DocumentReader(filepath); ITokeniser tokeniser = new TokeniserFilter(new SimpleTokeniser()); SimpleIndexer indexer = new SimpleIndexer(); SimpleIndexWriter writer = new SimpleIndexWriter(indexpath); while ((document = reader.ReadDocument()) != null) { tokeniser.SetDocument(document); while ((token = tokeniser.GetToken()) != null) { indexer.indexToken(token); } } indexer.writeIndex(writer); IndexReader indexReader = new IndexReader(indexpath); VocabularyEntry entry = indexReader.GetVocabularyEntry("william"); string line = indexReader.GetPostingsListLine(entry.ByteOffset); Console.WriteLine(entry); Console.WriteLine(line); }
public int GetOrAddIndex(string word) { var wordObj = _words.GetOrAdd(word, x => VocabularyEntry.Create(GetNextIndex(), x)); wordObj.IncementOccurred(); return(wordObj.TermId); }
public virtual IActionResult CreateVocabularyEntry([FromRoute][Required] string id, [FromBody] VocabularyEntry vocabularyEntry) { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... // return StatusCode(200, default(string)); string exampleJson = null; var example = exampleJson != null ? JsonConvert.DeserializeObject <string>(exampleJson) : default(string); //TODO: Change the data returned return(new ObjectResult(example)); }
public virtual IActionResult PutVocabularyEntry([FromRoute][Required] string id, [FromRoute][Required] string elementId, [FromBody] VocabularyEntry vocabularyEntry) { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... // return StatusCode(200); throw new NotImplementedException(); }