Ejemplo n.º 1
0
        public string IdentifyLanguage(Models.Text doc)
        {
            string text = doc.RawText;
            var    li   = LanguageIdentifier.New(AppDomain.CurrentDomain.BaseDirectory + "/classifiers/LangId/langprofiles-word-1_5-nfc-10k.bin.gz", "Vector", -1);
            var    lang = li.Identify(text); // Calling the language identifier -- it

            return(lang);
        }
Ejemplo n.º 2
0
 public string ProfileCheck(string owner, string lang_prof, string text)
 {
     var path = System.IO.Path.Combine(_env.WebRootPath, "Content", "UserData", owner, lang_prof, (lang_prof ?? "").Substring(0, lang_prof.LastIndexOf('_')) + ".bin.gz");
     var lip = LanguageIdentifier.New(path, "Vector", -1);
     var cleaner = Cleaning.MakeCleaner("none");
     List<string> wrds = new List<string>();
     (text ?? "").Split('.', StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(t => wrds.AddRange(t.Split(' ', StringSplitOptions.RemoveEmptyEntries)));
     return string.Join(',', wrds.Select(t => lip.Identify(cleaner(t))).Distinct());
 }
Ejemplo n.º 3
0
 public List<Models.LangModel> ProfilePost()
 {
     string owner = HttpContext.Request.Form["owner"];
     string lang_prof = HttpContext.Request.Form["lang_prof"];
     var path = System.IO.Path.Combine(_env.WebRootPath, "Content", "UserData", owner, lang_prof, (lang_prof ?? "").Substring(0, lang_prof.LastIndexOf('_')) + ".bin.gz");
     var lip = LanguageIdentifier.New(path, "Vector", -1);
     string text = HttpContext.Request.Form["text"];
     var cleaner = Cleaning.MakeCleaner("none");
     List<string> wrds = new List<string>();
     (text ?? "").Split('.', StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(t => wrds.AddRange(t.Split(' ', StringSplitOptions.RemoveEmptyEntries)));
     return wrds.Select(t => lip.Identify(cleaner(t))).GroupBy(t => t).Select(t1 => new Models.LangModel() { lang = t1.Key, count = t1.Count() }).ToList();
 }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc()
            .AddJsonOptions(opts =>
            {
                opts.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddCors(options => options.AddPolicy("CorsPolicy",
                                                          builder =>
            {
                builder.AllowAnyMethod()
                .AllowAnyHeader()
                .AllowAnyOrigin();
            }));

            var li = LanguageIdentifier.New(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "Data", "langprofiles-char-1_5-nfc-all.bin.gz"), "Vector", -1);

            services.AddSingleton <LanguageIdentifier>(li);

            services.AddCors(options => options.AddPolicy("CorsPolicy",
                                                          builder =>
            {
                builder.AllowAnyMethod().AllowAnyHeader()
                .AllowAnyOrigin();
            }));

            services.AddSignalR(hubOptions =>
            {
                hubOptions.EnableDetailedErrors = true;
                hubOptions.KeepAliveInterval    = TimeSpan.FromMinutes(1);
            });
        }