Example #1
0
        public DetectedLanguageResponse DetectLanguage(LanguageDetectRequest model)
        {
            IEnumerable <Tuple <LanguageInfo, double> > matches = _identifier.Identify(model.TextForLanguageClassification);
            DetectedLanguageResponse detectedLanguageResponse   = FormatResponse(matches, model);

            return(detectedLanguageResponse);
        }
Example #2
0
        public DetectedLanguageResponse DetectLanguage(LanguageDetectRequest model)
        {
            IEnumerable<Tuple<LanguageInfo, double>> matches = _identifier.Identify(model.TextForLanguageClassification);
            DetectedLanguageResponse detectedLanguageResponse = FormatResponse(matches, model);

            return detectedLanguageResponse;
        }
Example #3
0
 private DetectedLanguageResponse FormatResponse(IEnumerable<Tuple<LanguageInfo, double>> matches, LanguageDetectRequest model)
 {
     List<DetectedLangage> responseList = matches.Select(
         match => _builder.BuildFromResult(match.Item1, match.Item2))
         .ToList();
     return new DetectedLanguageResponse(responseList, model.TextForLanguageClassification);
 }
Example #4
0
        private DetectedLanguageResponse FormatResponse(IEnumerable <Tuple <LanguageInfo, double> > matches, LanguageDetectRequest model)
        {
            List <DetectedLangage> responseList = matches.Select(
                match => _builder.BuildFromResult(match.Item1, match.Item2))
                                                  .ToList();

            return(new DetectedLanguageResponse(responseList, model.TextForLanguageClassification));
        }
 private static bool ModelIsInvalid(LanguageDetectRequest model)
 {
     return model == null || string.IsNullOrWhiteSpace(model.TextForLanguageClassification);
 }