/// <summary> /// Summarizes the specified input using the specified <paramref name="sentenceDetector"/> and <paramref name="tokenizer"/>. /// </summary> /// <param name="input">The input string to be summarized.</param> /// <param name="sentenceDetector">The sentence detector.</param> /// <param name="tokenizer">The tokenizer.</param> /// <returns>The summarized string.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="sentenceDetector"/> /// or /// <paramref name="tokenizer"/> /// </exception> public string Summarize(string input, ISentenceDetector sentenceDetector, ITokenizer tokenizer) { if (string.IsNullOrEmpty(input)) { return(string.Empty); } if (sentenceDetector == null) { throw new ArgumentNullException(nameof(sentenceDetector)); } if (tokenizer == null) { throw new ArgumentNullException(nameof(tokenizer)); } var doc = new Document("x-unspecified", input); var anl = new AggregateAnalyzer { new SentenceDetectorAnalyzer(sentenceDetector), new TokenizerAnalyzer(tokenizer) }; anl.Analyze(doc); return(ProcessSummarization(doc)); }
public void LoadModels() { _analyzer = new AggregateAnalyzer { @"models\en-sent.bin", @"models\en-token.bin", @"models\en-pos-maxent.bin" }; }
public void Setup() { // initialize the analyzer analyzer = new AggregateAnalyzer { Tests.GetFullPath("/opennlp/models/en-sent.bin"), Tests.GetFullPath("/opennlp/models/en-token.bin"), Tests.GetFullPath("/opennlp/models/en-ner-money.bin"), // en-ner-person don't detect Bart as a person :( Tests.GetFullPath("/opennlp/models/en-pos-maxent.bin"), Tests.GetFullPath("/opennlp/models/en-chunker.bin"), Tests.GetFullPath("/opennlp/models/en-parser-chunking.bin") }; }
public static void LoadAnalyzationData(string sent, string token, string pos, string chunker, string tags, string nouns) { analyzer = new AggregateAnalyzer { sent, token, pos, chunker }; wordStemmer = new EnglishStemmer(); tripletService = new TripletService(new ReplyTripletService(), new QuestionTripletService()); string[] lines = File.ReadAllLines(tags); POSTagValues = JObject.Parse(lines[0]); LowValueNouns = new List <string>(File.ReadAllLines(nouns)); }
/// <summary> /// Summarizes the specified input using the specified <paramref name="sentenceDetector"/> and <paramref name="tokenizer"/>. /// </summary> /// <param name="input">The input string to be summarized.</param> /// <param name="sentenceDetector">The sentence detector.</param> /// <param name="tokenizer">The tokenizer.</param> /// <returns>The summarized string.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="sentenceDetector"/> /// or /// <paramref name="tokenizer"/> /// </exception> public string Summarize(string input, ISentenceDetector sentenceDetector, ITokenizer tokenizer) { if (string.IsNullOrEmpty(input)) return string.Empty; if (sentenceDetector == null) throw new ArgumentNullException("sentenceDetector"); if (tokenizer == null) throw new ArgumentNullException("tokenizer"); var doc = new Document("x-unspecified", input); var anl = new AggregateAnalyzer { new SentenceDetectorAnalyzer(sentenceDetector), new TokenizerAnalyzer(tokenizer) }; anl.Analyze(doc); return ProcessSummarization(doc); }