예제 #1
0
 public void InitLanguages()
 {
     string encoding;
     var langs = Parser.DeserializeLangs(File.ReadAllText(@"..\..\langs.xml"), File.ReadAllText(@"..\..\stylers.xml"), out encoding);
     var langDetector = new LangDetector();
     langDetector.InitLanguages(langs, encoding);
 }
예제 #2
0
        public void CheckAutodetection()
        {
            string encoding;
            var langs = Parser.DeserializeLangs(File.ReadAllText(@"..\..\langs.xml"), File.ReadAllText(@"..\..\stylers.xml"), out encoding);
            var langDetector = new LangDetector();
            langDetector.InitLanguages(langs, encoding);

            var langFilePaths = Directory.GetFiles(@"..\..\Data");
            var detectedLangs = new Dictionary<string, NppLanguage>();
            int matchedItems = 0;
            foreach (var langFile in langFilePaths)
            {
                var langData = File.ReadAllText(langFile);
                var detectedLang = langDetector.DetectLanguage(langData);
                detectedLangs.Add(Path.GetFileName(langFile), detectedLang);
                if (langDetector.ExtensionLangs[Utils.GetExtensionWithoutDot(langFile)] == detectedLang)
                    matchedItems++;
            }
        }