/// <summary> /// Detects the sentences in the specified input. /// </summary> /// <param name="input">The input.</param> /// <param name="detector">The detector.</param> /// <returns>The sentences.</returns> public Sentence[] Detect(Token[] input, SentenceDetectorLanguage detector) { if (!Detectors.ContainsKey(detector)) { return(Array.Empty <Sentence>()); } return(Detectors[detector].DetectSentences(input)); }
private bool CheckIfTagExists(Detection detection) { if (!Detectors.ContainsKey(detection.HostName)) { Tag removedTag; var removed = Tags.TryRemove(detection.TagId, out removedTag); //TODO: Shouldn't a TagRemoved event be fired here? return(false); } return(Tags.ContainsKey(detection.TagId)); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultSentenceDetector"/> class. /// </summary> /// <param name="detectors">The detectors.</param> /// <param name="tokenizer">The tokenizer.</param> public DefaultSentenceDetector(IEnumerable <IDetector> detectors, ITokenizer tokenizer) { Detectors = detectors.Where(x => x.GetType().Assembly != typeof(DefaultSentenceDetector).Assembly).ToDictionary(x => x.Name); foreach (var Detector in detectors.Where(x => x.GetType().Assembly == typeof(DefaultSentenceDetector).Assembly && !Detectors.ContainsKey(x.Name))) { Detectors.Add(Detector.Name, Detector); } Tokenizer = tokenizer; }