예제 #1
0
 /// <summary> Initializes the new instance. </summary>
 /// <param name="text">Text to iterate</param>
 /// <param name="lang">Language info</param>
 /// <exception cref="ArgumentNullException">If any argument is NULL</exception>
 public SentenceIterator(string text, ILangInfo lang)
 {
     if (text == null)
     {
         throw new ArgumentNullException(nameof(text));
     }
     _lang      = lang ?? throw new ArgumentNullException(nameof(lang));
     _charSet   = text.ToCharArray();
     _puncMarks = _lang.PuncMarks;
     _textKit   = new TextKit(new[] { SpecChars.WS, SpecChars.CR, SpecChars.NL });
 }
예제 #2
0
 /// <summary> Initializes the new instance. </summary>
 /// <param name="text">Text that contains the words to iterate</param>
 /// <param name="lang">Language info</param>
 /// <exception cref="ArgumentNullException">If any argument is NULL</exception>
 public WordIterator(string text, ILangInfo lang)
 {
     if (text == null)
     {
         throw new ArgumentNullException(nameof(text));
     }
     _lang          = lang ?? throw new ArgumentNullException(nameof(lang));
     _charSet       = text.ToCharArray();
     _buffer        = new char[100];
     _wordSeparator = lang.WordSeparator;
     _textKit       = new TextKit(new[] { SpecChars.WS, SpecChars.CR, SpecChars.NL });
 }
예제 #3
0
        /// <summary>
        /// Returns TRUE if the punctuation mark at the specified index of the given <paramref name="charSet"/>
        /// indicates a special language construction like an URL, date or time instant.
        /// </summary>
        /// <param name="charSet">Character set</param>
        /// <param name="pmIndex">Punctuation mark index</param>
        /// <param name="lang">Language info</param>
        /// <returns>TRUE or FALSE</returns>
        public bool IsSpecialTerm(char[] charSet, int pmIndex, ILangInfo lang)
        {
            if (IsUrl(charSet, pmIndex))
            {
                return(true);
            }
            if (IsDate(charSet, pmIndex, lang.DateSeparator))
            {
                return(true);
            }
            if (IsTime(charSet, pmIndex, lang.TimeSeparator))
            {
                return(true);
            }

            return(false);
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance that operates with the specified <paramref name="lang"/>.
 /// </summary>
 /// <param name="lang">Language information</param>
 public SentenceDetector(ILangInfo lang)
 {
     _lang = lang ?? throw new ArgumentNullException(nameof(lang));
 }