Esempio n. 1
0
        /// <summary>
        /// Creates a segmenter that reads sentences from a text file.
        /// </summary>
        /// <param name="filePath">File path.</param>
        /// <param name="isUtf8">Indicates whether file has UTF-8 encoding. Unicode assumed otherwise.</param>
        /// <param name="language">Language to use.</param>
        /// <returns>Text file segmenter.</returns>
        public TextFileSegmenter CreateTextFileSegmenter(string filePath, bool isUtf8, Languages language)
        {
            var h = GrammarApi.sol_CreateSentenceBroker(GetEngineHandle(), filePath, isUtf8 ? "utf-8" : "unicode", (int)language);

            if (h == IntPtr.Zero)
            {
                throw new InvalidOperationException("Failed to create the segmenter!");
            }

            return(new TextFileSegmenter(h));
        }