Esempio n. 1
0
        /// <summary>
        /// load profiles
        /// </summary>
        /// <returns>false if load success</returns>
        private bool LoadProfile()
        {
            string profileDirectory = Get("directory");

            try
            {
                if (profileDirectory != null)
                {
                    DetectorFactory.LoadProfile(profileDirectory);
                }
                else
                {
                    DetectorFactory.LoadProfile();
                }

                long?seed = GetLong("seed");
                if (seed != null)
                {
                    DetectorFactory.SetSeed((int)seed);
                }

                return(false);
            }
            catch (LangDetectException e)
            {
                Console.Error.WriteLine("ERROR: " + e);
                return(true);
            }
        }
Esempio n. 2
0
        public void testFactoryFromJsonString()
        {
            DetectorFactory.Clear();
            List <string> profiles = new List <string>();

            profiles.Add(JSON_LANG1);
            profiles.Add(JSON_LANG2);
            DetectorFactory.LoadProfile(profiles);
            IList <string> langList = DetectorFactory.GetLangList();

            Assert.AreEqual(langList.Count, 2);
            Assert.AreEqual(langList[0], "lang1");
            Assert.AreEqual(langList[1], "lang2");
        }