// Connection = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\anik\Documents\anik.mdf;Integrated Security=True;Connect Timeout=30");
        private void New_CLick(object sender, EventArgs e)
        {
            languageInformation = new LanguageInformation();

            LanguageDataShow();
            MessageBox.Show("f**k up cc");
        }
 public static IEnumerable <string> GetSentencesEnumerable(
     this ITextProcessor textProcessor,
     string text,
     LanguageInformation languageInformation)
 {
     return(textProcessor.GetSentencesEnumerable(text)
            .Where(sentence => languageInformation.IsAllLettersAllowed(sentence)));
 }
 public static IEnumerable <string> GetNormalizedWordsEnumerable(
     this ITextProcessor textProcessor,
     string text,
     LanguageInformation languageInformation)
 {
     return(textProcessor.GetWordsEnumerable(text)
            .Select(word => textProcessor.NormalizeWord(word))
            .Where(word => languageInformation.IsAllLettersAllowed(word))
            .Where(word => word.Length > 0)
            .Distinct());
 }
示例#4
0
        private LanguageInformation TryGetLanguageInformation(string filename)
        {
            LanguageInformation languageInformation = null;

            if (ErrorHandler.Succeeded(_textManager.MapFilenameToLanguageSID(filename, out var fileLanguageGuid)))
            {
                _languageInformationByLanguageGuid.TryGetValue(fileLanguageGuid, out languageInformation);
            }

            return(languageInformation);
        }
示例#5
0
        public async static Task <LanguageInformation> DetectLanguagesAsync(List <string> documents)
        {
            LanguageInformation detectedLanguage = null;

            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", Common.CoreConstants.TextAnalyticsSubscriptionKey);

            DocumentsInfo documentsInfo = new DocumentsInfo()
            {
                documents = new List <DocumentInfo>()
            };

            foreach (var document in documents)
            {
                documentsInfo.documents.Add(new DocumentInfo()
                {
                    id = Guid.NewGuid().ToString(), text = document
                });
            }

            var payload = new HttpStringContent(JsonConvert.SerializeObject(documentsInfo));

            payload.Headers.ContentType = new HttpMediaTypeHeaderValue("application/json");

            var response = await client.PostAsync(new Uri($"{CogsExplorer.Common.CoreConstants.CognitiveServicesBaseUrl}/text/analytics/v2.0/languages"), payload);

            try
            {
                var results = await response.Content.ReadAsStringAsync();

                var languageResults = JsonConvert.DeserializeObject <DocumentLanguageResult>(results);

                if (languageResults.documents.Count() > 0)
                {
                    var primaryLanguage = languageResults.documents.FirstOrDefault().detectedLanguages.FirstOrDefault();

                    detectedLanguage = new LanguageInformation()
                    {
                        DisplayName  = primaryLanguage.name,
                        Abbreviation = primaryLanguage.iso6391Name,
                    };
                }
            }
            catch (Exception ex)
            {
            }

            return(detectedLanguage);
        }
示例#6
0
 public void IsAllLettersAllowed_ShouldThrow_WhenInputIsNull(
     LanguageInformation info)
 {
     Assert.Throws <ArgumentNullException>(() => info.IsAllLettersAllowed(null !));
 }
示例#7
0
 public SemanticChecker(Context context)
 {
     _context    = context;
     _lang       = LanguageInformation.Instance;
     _dispatcher = new AstVisitorDispatcher(this);
 }
示例#8
0
 public IEnumerable <Sentence> ProcessBookContent(BookId bookId, string content, LanguageInformation languageInformation)
 {
     return(_textProcessor.GetSentencesEnumerable(content, languageInformation)
            .Where(sentence => sentence.Length >= MinSentenceLengthCharacters)
            .Select((sentence, sentenceIndex) => _sentenceFactory.CreateSentence(bookId, sentence, sentenceIndex)));
 }