public void Launch() { var documents = _documentProvider.GetDocuments(_inputDirectory); var tokenizer = new WordDocumentTokenizer(); var inverseIndex = new InverceIndex<string, IDocument>(tokenizer); inverseIndex.AddDocuments(documents); var searcher = new InformationRetrieval.Common.BooleanSearcher(inverseIndex); while (true) { var input = Console.ReadLine(); if (!string.IsNullOrWhiteSpace(input)) { var resultDocs = searcher.ProcessQuery(input); Console.WriteLine(string.Join("\n", resultDocs.Select(d => d.FilePath))); } } }
private static void Main(string[] args) { var directory = args[0]; var documents = new Fb2ZoneDocumentProvider().GetDocuments(directory); var tokenizer = new WordDocumentTokenizer(); var index = new InverceIndex<string, IDocument>(tokenizer); index.AddDocuments(documents); while (true) { var input = Console.ReadLine(); var token = tokenizer.Tokenize(input).FirstOrDefault(); if (token != null) { Console.WriteLine(string.Join("\n", index.GetDocumentsWithScore(token).Select(t => $"{t.Item1.FilePath}\tScore:{t.Item2}"))); } } }
private static void Main(string[] args) { var inputDirectory = args[0]; var documents = DocumentProvider.GetDocuments(inputDirectory); var tokenizer = new PhraseDocumentTokenizer(new PartOfSpeechTagger()); var inverseIndex = new InverceIndex<Phrase, Document>(tokenizer); inverseIndex.AddDocuments(documents); var searcher = new PhraseQueryExecutor(inverseIndex); while (true) { var input = Console.ReadLine(); if (!string.IsNullOrWhiteSpace(input)) { var resultDocs = searcher.ProcessQuery(input); Console.WriteLine(string.Join("\n", resultDocs.Select(d => d.FilePath))); } } }