Exemple #1
0
        /// <summary>
        /// Attempts to find translation suggestions based the specified options in SuggestionRequest object.
        /// </summary>
        /// <param name="request">Suggestion Parameters</param>
        /// <returns>Array of <see cfer='SuggestionResult'/></returns>
        public SuggestionResult[] Suggest(SuggestionRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (string.IsNullOrWhiteSpace(request.Source) == true)
            {
                throw new ArgumentException("SuggestionRequest.Source");
            }
            if (SourceCulture == null)
            {
                throw new InvalidProviderConfigurationException("SourceCulture");
            }
            if (TargetCulture == null)
            {
                throw new InvalidProviderConfigurationException("TargetCulture");
            }
            if (supportedLanguages == null)
            {
                throw new InvalidProviderConfigurationException("support languages has not been initialized");
            }

            return(TAUSDataAccess.GetSegmentSuggestions(SourceCulture, TargetCulture, request.Source, request.ProviderMaxResults));
        }
        public List <MovieDTO> ProccessSuggestionRequest(SuggestionRequest req)
        {
            req = PrepareSuggestionRequest(req);
            var genresIds = ProccessGenresByText(req.Audio);

            var user = UsersManagementIntegration.GetUserByEmail(req.UserEmail);

            var movies      = new List <MovieDTO>();
            var page        = 1;
            var quantMovies = 20;

            while (movies.Count < quantMovies)
            {
                var moviesResult = TheMovieDbIntegration.GetMovies(genresIds, page, "true", "false").Results;
                if (moviesResult.Count == 0)
                {
                    continue;
                }

                int difference = quantMovies - movies.Count;
                moviesResult = moviesResult.Take(difference).ToList();

                movies.AddRange(FilterMoviesListByUser(moviesResult, user));
                page++;
            }

            movies = movies.OrderByDescending(x => x.Popularity).ToList();
            movies = OrderMovies(movies);

            return(movies);
        }
        /// <summary>
        /// Attempts to find translation suggestions based the specified options in SuggestionRequest object.
        /// </summary>
        /// <param name="request">Suggestion Parameters</param>
        /// <returns>A list of suggestion result</returns>
        public SuggestionResult[] Suggest(SuggestionRequest request)
        {
            Logger.Log($"SYSTRAN8TranslationProvider Suggest start request:{request.Source} source:{mSelectedLanguagePair?.Source} target:{mSelectedLanguagePair?.Target}");
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (string.IsNullOrWhiteSpace(request.Source))
            {
                throw new ArgumentException("SuggestionRequest.Source");
            }
            if (mSelectedLanguagePair == null)
            {
                throw new InvalidProviderConfigurationException("No language pait selected");
            }
            if (mSupportedLanguagePairs == null)
            {
                throw new InvalidProviderConfigurationException("supported language pairs has not been initialized");
            }

            var suggestResult = new SuggestionResult
            {
                RequestId        = request.RequestId,
                Source           = request.Source,
                ProviderName     = Localizable.ProviderDisplayName,
                TranslationState = new TranslationState {
                    State = TransState.NoMatch, SubState = "no match found"
                },
                TranslationType = new TranslationType {
                    Type = TransType.MachineTranslation
                }
            };

            try
            {
                var target = mService.TranslateAsync(mSelectedLanguagePair.Source, mSelectedLanguagePair.Target, null, request.Source).ConfigureAwait().Result;

                suggestResult.Target           = target;
                suggestResult.TranslationState = new TranslationState {
                    State = TransState.NeedsReview
                };
                suggestResult.Confidence = 100;
                //suggestResult.Properties = GetMetadata(trans);
            }
            catch (Exception exception)
            {
                suggestResult.TranslationState = new TranslationState {
                    State = TransState.Fail
                };
                suggestResult.Errors.Add(new ProviderErrorLog()
                {
                    Category = ErrorCategory.Translation, InnerException = exception, Severity = ErrorSeverity.Error
                });
            }
            Logger.Log($"SYSTRAN8TranslationProvider Suggest end request:{request.Source} source:{mSelectedLanguagePair?.Source} target:{mSelectedLanguagePair?.Target} result:{suggestResult?.Target}");
            return(new[] { suggestResult });
        }
Exemple #4
0
        public MovieDTO Get([FromQuery(Name = "userEmail")] string userEmail,
                            [FromQuery(Name = "time")] string time)
        {
            var req = new SuggestionRequest()
            {
                UserEmail = userEmail,
                Time      = time
            };

            return(_suggestionService.ProccessImFeelingLuckyRequest(req));
        }
Exemple #5
0
        public List <MovieDTO> Get([FromQuery(Name = "userEmail")] string userEmail,
                                   [FromQuery(Name = "audio")] string audio)
        {
            var req = new SuggestionRequest()
            {
                UserEmail = userEmail,
                Audio     = audio
            };

            return(_suggestionService.ProccessSuggestionRequest(req));
        }
        public MovieDTO ProccessImFeelingLuckyRequest(SuggestionRequest req)
        {
            _tempIntegration.DeleteOld();

            var genresIds = ProccessGenresByTime(req.Time);

            var user = UsersManagementIntegration.GetUserByEmail(req.UserEmail);

            var movie = new MovieDTO();
            var page  = 1;

            while (movie.Id == 0)
            {
                var moviesResult = TheMovieDbIntegration.GetMovies(genresIds, page, "true", "false").Results;
                if (moviesResult.Count == 0)
                {
                    genresIds = "";
                    continue;
                }

                foreach (var movieResult in moviesResult)
                {
                    var moviesList = new List <MovieDTO> {
                        movieResult
                    };
                    movie = FilterMoviesListByUser(moviesList, user, true).FirstOrDefault();
                    if (movie != null)
                    {
                        break;
                    }
                }

                page++;
            }

            _tempIntegration.InsertOne(new TempMovieDTO()
            {
                MovieId   = movie.Id,
                UserEmail = user.Email,
                CreatedOn = DateTime.Now
            });
            return(movie);
        }
 public void ArchiveSuggestion(SuggestionRequest SuggestionRequest)
 {
     _suggestionService.ArhiveSuggestion(SuggestionRequest.Id);
 }
 public SuggestionModel AddSuggestion(SuggestionRequest SuggestionReq)
 {
     return _suggestionService.AddSuggestion(SuggestionReq.SuggestionDesc);
 }
 public SeatingOptionNotAvailable(SuggestionRequest suggestionRequest) : base(suggestionRequest)
 {
 }
Exemple #10
0
 public void ArchiveSuggestion(SuggestionRequest SuggestionRequest)
 {
     _suggestionService.ArhiveSuggestion(SuggestionRequest.Id);
 }
Exemple #11
0
 public SuggestionModel AddSuggestion(SuggestionRequest SuggestionReq)
 {
     return(_suggestionService.AddSuggestion(SuggestionReq.SuggestionDesc));
 }
 private SuggestionRequest PrepareSuggestionRequest(SuggestionRequest req)
 {
     req.Audio = req.Audio.ToLower();
     return(req);
 }