Exemplo n.º 1
0
        public static CustomBreaker NewCustomBreaker()
        {
            if (s_thaiDic == null)
            {
                if (s_dicProvider == null)
                {
                    //no dictionary provider
                    return(null);
                }
                InitAllDics();
            }
            var breaker = new CustomBreaker();

            breaker.EngBreakingEngine.EngCustomAbbrvDic = s_enAbbrvDic; //optional
            breaker.EngBreakingEngine.EnableCustomAbbrv = true;         //optional
            //
            var thBreaker = new ThaiDictionaryBreakingEngine();

            //thBreaker.DontMergeLastIncompleteWord = true;
            thBreaker.SetDictionaryData(s_thaiDic);
            breaker.AddBreakingEngine(thBreaker);
            //
            var laoBreak = new LaoDictionaryBreakingEngine();

            laoBreak.SetDictionaryData(s_laoDic);
            breaker.AddBreakingEngine(laoBreak);
            return(breaker);
        }
Exemplo n.º 2
0
        public static CustomBreaker NewCustomBreaker()
        {
            InitAllDics();

            var breaker = new CustomBreaker();

            if (s_enAbbrvDic != null)
            {
                breaker.EngBreakingEngine.EngCustomAbbrvDic = s_enAbbrvDic; //optional
                breaker.EngBreakingEngine.EnableCustomAbbrv = true;         //optional
            }

            if (s_thaiDic != null)
            {
                var thBreaker = new ThaiDictionaryBreakingEngine();
                //thBreaker.DontMergeLastIncompleteWord = true;
                thBreaker.SetDictionaryData(s_thaiDic);
                breaker.AddBreakingEngine(thBreaker);
            }

            if (s_laoDic != null)
            {
                var laoBreak = new LaoDictionaryBreakingEngine();
                laoBreak.SetDictionaryData(s_laoDic);
                breaker.AddBreakingEngine(laoBreak);
            }

            //
            var bidiBreak = new TextBreak.BidiBreakEngine();

            breaker.AddBreakingEngine(bidiBreak);
            return(breaker);
        }
Exemplo n.º 3
0
        static void InitAllDics()
        {
            if (thaiDicBreakingEngine == null)
            {
                var customDic = new CustomDic();
                thaiDicBreakingEngine = new ThaiDictionaryBreakingEngine();
                thaiDicBreakingEngine.SetDictionaryData(customDic);//add customdic to the breaker
                customDic.SetCharRange(thaiDicBreakingEngine.FirstUnicodeChar, thaiDicBreakingEngine.LastUnicodeChar);

                using (Stream data = s_dataProvider.GetDataStream("thaidict.txt"))
                {
                    customDic.LoadFromDataStream(data);
                }
            }
            if (laoDicBreakingEngine == null)
            {
                var customDic = new CustomDic();
                laoDicBreakingEngine = new LaoDictionaryBreakingEngine();
                laoDicBreakingEngine.SetDictionaryData(customDic);//add customdic to the breaker
                customDic.SetCharRange(laoDicBreakingEngine.FirstUnicodeChar, laoDicBreakingEngine.LastUnicodeChar);
                using (Stream data = s_dataProvider.GetDataStream("laodict.txt"))
                {
                    customDic.LoadFromDataStream(data);
                }
            }
        }
Exemplo n.º 4
0
        static void InitAllDics()
        {
            if (thaiDicBreakingEngine == null)
            {
                var customDic = new CustomDic();
                thaiDicBreakingEngine = new ThaiDictionaryBreakingEngine();
                thaiDicBreakingEngine.SetDictionaryData(customDic);//add customdic to the breaker
                customDic.SetCharRange(thaiDicBreakingEngine.FirstUnicodeChar, thaiDicBreakingEngine.LastUnicodeChar);
                customDic.LoadSortedUniqueWordList(s_dicProvider.GetSortedUniqueWordList("thai"));
            }

            if (laoDicBreakingEngine == null)
            {
                var customDic = new CustomDic();
                laoDicBreakingEngine = new LaoDictionaryBreakingEngine();
                laoDicBreakingEngine.SetDictionaryData(customDic);//add customdic to the breaker
                customDic.SetCharRange(laoDicBreakingEngine.FirstUnicodeChar, laoDicBreakingEngine.LastUnicodeChar);
                customDic.LoadSortedUniqueWordList(s_dicProvider.GetSortedUniqueWordList("lao"));
            }
        }