/// <summary>
        ///     Find a normalizer for the specified column definition, and if it is input or output.
        /// </summary>
        /// <param name="colDef">The column definition.</param>
        /// <param name="isInput">True if the column is input.</param>
        /// <returns>The normalizer to use.</returns>
        private INormalizer FindNormalizer(ColumnDefinition colDef, bool isInput)
        {
            INormalizer norm = null;

            if (isInput)
            {
                if (_inputNormalizers.ContainsKey(colDef.DataType))
                {
                    norm = _inputNormalizers[colDef.DataType];
                }
            }
            else
            {
                if (_outputNormalizers.ContainsKey(colDef.DataType))
                {
                    norm = _outputNormalizers[colDef.DataType];
                }
            }

            if (norm == null)
            {
                throw new EncogError("No normalizer defined for input=" + isInput + ", type=" + colDef.DataType);
            }
            return(norm);
        }
Exemplo n.º 2
0
 public RecordNormalizers()
 {
     this.SomeNormalizer = Substitute.For<INormalizer>();
     this.SomeNormalizer.Normalize(SomeValue).Returns(NormalizedValue);
     this.ExceptionNormalizer = Substitute.For<INormalizer>();
     this.ExceptionNormalizer.When(x => x.Normalize(SomeValue)).Do(x => { throw new NormalizeException(); });
 }
Exemplo n.º 3
0
 public static Func <Node, double> WeightFunc(INormalizer c, INormalizer p)
 {
     return(n =>
     {
         return c.Normalize(n.Capacity) * p.Normalize(n.Price);
     });
 }
Exemplo n.º 4
0
 public UserProvider(
     AuthContext context,
     INormalizer normalizer)
     : base(context)
 {
     _normalizer = normalizer;
 }
Exemplo n.º 5
0
        public TextPreprocessor(ITokenizer tokenizer,
                                IStopwords stopwords,
                                INormalizer normalizer,
                                IStemmer stemmer)
        {
            if (tokenizer == null)
            {
                throw new MLException("TextPreprocessor.ctor(tokenizer=null)");
            }
            if (stopwords == null)
            {
                throw new MLException("TextPreprocessor.ctor(stopwords=null)");
            }
            if (normalizer == null)
            {
                throw new MLException("TextPreprocessor.ctor(normalizer=null)");
            }
            if (stemmer == null)
            {
                throw new MLException("TextPreprocessor.ctor(stemmer=null)");
            }

            m_Tokenizer  = tokenizer;
            m_Stopwords  = stopwords;
            m_Normalizer = normalizer;
            m_Stemmer    = stemmer;
        }
        /// <inheritdoc />
        public String DenormalizeColumn(ColumnDefinition colDef, bool isInput,
                                        IMLData data, int dataColumn)
        {
            INormalizer norm = FindNormalizer(colDef, isInput);

            return(norm.DenormalizeColumn(colDef, data, dataColumn));
        }
Exemplo n.º 7
0
        IList <Line> EvaluateWholeEveningTime(Network ann, Track track, INormalizer velocityNormalizer, Line[] morning)
        {
            const int hvc = AnnInput.HistoricalVelocitiesCount;
            var       lastLinesOfMorning =
                morning.Where(x => x.Time <= TimeConstants.T18).Reverse().Take(hvc + 1).Reverse().ToArray();
            var input = new TimeAnnInput
            {
                Time = lastLinesOfMorning.Last().Time
            };

            while (!Close10(input.Time, TimeConstants.T18))
            {
                double next = ann.Compute(input)[0];
                input = input.Shift(next, input.Time.AddMinutes(TimeConstants.Interval));
            }

            var res = new List <Line>();

            for (int i = TimeConstants.EarlyEvening; i < TimeConstants.LastMeasurement; i++)
            {
                double next = ann.Compute(input)[0];
                res.Add(new Line {
                    Day = track.Day, Street = track.Street, Time = TimeConstants.EveningTime(i), Velocity = velocityNormalizer.Denormalize(next)
                });

                input = input.Shift(next, TimeConstants.EveningTime(i + 1));
            }

            return(res);
        }
Exemplo n.º 8
0
        public CLARANS(
            T[] items,
            INormalizer <T> normalizer,
            IDistance <T> distance,
            int k,
            int maxNeighbour,
            int numLocal,
            int degreeOfParallelism = 4)
        {
            _normalizer   = normalizer;
            _distance     = distance;
            _n            = items.Length;
            _k            = k;
            _maxNeighbour = maxNeighbour;
            _numLocal     = numLocal;

            var itemsNorm = normalizer
                            .Normalize(items)
                            .ToArray();

            var claransResult = Enumerable.Range(0, numLocal)
                                .AsParallel()
                                .WithDegreeOfParallelism(degreeOfParallelism)
                                .Select(_ => OptimizeOne(itemsNorm))
                                .MaxBy(result => result.TotalClusterDistance);

            Result = new Result <T>(
                items,
                _distance,
                _k,
                claransResult.MedoidIndices,
                claransResult.ClusterNums);
        }
        /// <inheritdoc />
        public int NormalizeColumn(ColumnDefinition colDef, bool isInput,
                                   String value, double[] outputData, int outputColumn)
        {
            INormalizer norm = FindNormalizer(colDef, isInput);

            return(norm.NormalizeColumn(colDef, value, outputData, outputColumn));
        }
Exemplo n.º 10
0
 public FullTextIndex(string[] stopWords, Dictionary <char, char> normalizationTable)
 {
     normalizer      = new Normalizer(normalizationTable);
     stopWordsFilter = new StopWordsFilter(new HashSet <string>(stopWords), normalizer);
     documents       = new Dictionary <string, Document>();
     parser          = new TextParser();
 }
Exemplo n.º 11
0
 public FullTextIndex()
 {
     stopWordsFilter = new StopWordsFilter();
     normalizer      = new Normalizer();
     documents       = new Dictionary <string, Document>();
     parser          = new TextParser();
 }
Exemplo n.º 12
0
 public TeamsController(ITeamRepository teamRepo, IMapper mapper, IOrganizationRepository orgRepo, IUserRepository userRepo)
 {
     this.userRepo   = userRepo;
     this.orgRepo    = orgRepo;
     this.mapper     = mapper;
     this.teamRepo   = teamRepo;
     this.normailzer = new NameNormalizer();
 }
 public NormalizationEnginePhase(
     INormalizer normalizer,
     IWordExtractor wordExtractor,
     IAppEnvironment <NormalizationEnginePhase> appEnvironment) : base(appEnvironment)
 {
     this.normalizer    = normalizer;
     this.wordExtractor = wordExtractor;
 }
Exemplo n.º 14
0
 public UserService(
     UserRepository repository,
     IPasswordService passwordService,
     INormalizer normalizer)
 {
     _repository      = repository;
     _passwordService = passwordService;
     _normalizer      = normalizer;
 }
Exemplo n.º 15
0
        internal static Result <User> Create(CreateUserDto dto, INormalizer normalizer, IPasswordService passwordService)
        {
            User user = null;

            return(UserFullname.Create(dto.Firstname, dto.Lastname)
                   .Tap(n => user = new User(n))
                   .Bind(_ => user.UpdateEmail(dto.Email, normalizer))
                   .Bind(() => user.SetPassword(dto.Password, passwordService))
                   .Map(() => user));
        }
 public GitHubPullRequestReaderFactory(string productHeaderValue, INormalizer bodyNormalizer)
 {
     if (string.IsNullOrWhiteSpace(productHeaderValue))
     {
         throw new ArgumentNullException(nameof(productHeaderValue));
     }
     _productHeaderValue = productHeaderValue;
     _bodyNormalizer     = bodyNormalizer ?? throw new ArgumentNullException(nameof(bodyNormalizer));
     _clientsByApiKey    = new Dictionary <string, GitHubClient>(StringComparer.Ordinal);
 }
Exemplo n.º 17
0
 public static void NormalizeTracks(Track[] tracks, INormalizer normalizer)
 {
     foreach (var track in tracks)
     {
         foreach (var line in track.Lines)
         {
             line.Velocity = normalizer.Normalize(line.Velocity.Value);
         }
     }
 }
Exemplo n.º 18
0
        public void Register(Type type, INormalizer normalizer)
        {
            if (typeNormalizers.ContainsKey(type))
            {
                const string Format  = "The type '{0}' has already specified the normalizer '{1}'.";
                var          message = string.Format(Format, type.Name, normalizer.GetType().Name);
                throw new ArgumentException(message);
            }

            typeNormalizers.Add(type, normalizer);
        }
Exemplo n.º 19
0
 public RecommenderSystem()
 {
     _resourceManager        = new ResourceManager();
     _bookParser             = new BookParser();
     _itemProfilesManager    = new ItemProfileManager();
     _normalizationManager   = new NormalizationManager();
     _userProfilesManager    = new UserProfileManager();
     _tfidfManager           = new TFIDFManager();
     _userPredictionsManager = new UserPredictionsManager();
     _printer   = new Printer();
     _stopwatch = new Stopwatch();
 }
Exemplo n.º 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="repoOwner"></param>
        /// <param name="repoName"></param>
        /// <param name="client">This client instance may be used across GitHubRepoPullRequestReader instances</param>
        /// <param name="bodyNormalizer">This is a string normalizer used for cleansing content, general PR bodies</param>
        public GitHubRepoPullRequestReader(string repoOwner, string repoName, GitHubClient client, INormalizer bodyNormalizer)
        {
            _repoOwner = string.IsNullOrWhiteSpace(repoOwner)
                ? throw new ArgumentNullException(nameof(repoOwner))
                : repoOwner;

            _repoName = string.IsNullOrWhiteSpace(repoName)
                ? throw new ArgumentNullException(nameof(repoName))
                : repoName;

            _client         = client ?? throw new ArgumentNullException(nameof(client));
            _bodyNormalizer = bodyNormalizer ?? throw new ArgumentNullException(nameof(bodyNormalizer));
        }
Exemplo n.º 21
0
 public ProjectsController(
     IProjectRepository projectRepo,
     IOrganizationRepository orgRepo,
     IPhotoRepository photoRepo,
     IMapper mapper,
     ITeamRepository teamRepo,
     IUserRepository userRepo)
 {
     this.photoRepo   = photoRepo;
     this.mapper      = mapper;
     this.teamRepo    = teamRepo;
     this.userRepo    = userRepo;
     this.orgRepo     = orgRepo;
     this.projectRepo = projectRepo;
     this.normalizer  = new NameNormalizer();
 }
Exemplo n.º 22
0
 public OrganizationsController(
     IOrganizationRepository orgRepo,
     IUserRepository userRepo,
     IPhotoRepository photoRepo,
     IMapper mapper,
     IInvitationRepository invitationRepo,
     IMemberRepository memberRepo)
 {
     this.photoRepo      = photoRepo;
     this.mapper         = mapper;
     this.invitationRepo = invitationRepo;
     this.memberRepo     = memberRepo;
     this.userRepo       = userRepo;
     this.orgRepo        = orgRepo;
     this.normalizer     = new NameNormalizer();
 }
Exemplo n.º 23
0
        public void Normalize(INormalizer normalizer, bool inputs, bool targets)
        {
            if (!inputs && !targets)
            {
                return;
            }

            normalizer.UpdateParams(this, inputs, targets);

            for (int i = 0; i < Length; i++)
            {
                Data D = internalArray[i];

                internalArray[i] = new Data
                                   (
                    inputs ? D.Inputs.Select(X => normalizer.Normalize(X)).ToShape(InputShape) : D.Inputs,
                    targets ? D.Targets.Select(X => normalizer.Normalize(X)).ToShape(TargetShape) : D.Targets
                                   );
            }
        }
Exemplo n.º 24
0
        private Result UpdateEmail(string email, INormalizer normalizer)
        {
            if (string.IsNullOrEmpty(email))
            {
                return(Result.Failure("Email cannot be empty."));
            }

            if (email.Length > 255)
            {
                return(Result.Failure("Email cannot be greater than 255 characters long."));
            }

            var match = Regex.IsMatch(email, "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}");

            if (!match)
            {
                return(Result.Failure("Email address is not valid."));
            }

            Email           = email;
            NormalizedEmail = normalizer.Normalize(email);

            return(Result.Success());
        }
Exemplo n.º 25
0
 public NormalizedIndexScan(IIndexScan underlyingIndexScan, INormalizer normalizer)
 {
     this.underlyingIndexScan = underlyingIndexScan;
     this.normalizer          = normalizer;
 }
 public SorensenDiceCoefficientIndex(int nGramSize, INormalizer normalizer) : base(nGramSize, normalizer)
 {
 }
        /// <inheritdoc />
        public int NormalizedSize(ColumnDefinition colDef, bool isInput)
        {
            INormalizer norm = FindNormalizer(colDef, isInput);

            return(norm.OutputSize(colDef));
        }
 /// <summary>
 ///     Assign a normalizer to the specified column type for output.
 /// </summary>
 /// <param name="colType">The column type.</param>
 /// <param name="norm">The normalizer.</param>
 public void AssignOutputNormalizer(ColumnType colType, INormalizer norm)
 {
     _outputNormalizers[colType] = norm;
 }
Exemplo n.º 29
0
 public UserRepository(SoproplDbContext context)
 {
     this.context    = context;
     this.normalizer = new NameNormalizer();
 }
Exemplo n.º 30
0
 internal Result Update(UpdateUserDto dto, INormalizer normalizer)
 {
     return(Name.Update(dto.Firstname, dto.Lastname)
            .Bind(() => UpdateEmail(dto.Email, normalizer)));
 }
 /// <summary>
 ///     Assign a normalizer to the specified column type for output.
 /// </summary>
 /// <param name="colType">The column type.</param>
 /// <param name="norm">The normalizer.</param>
 public void AssignOutputNormalizer(ColumnType colType, INormalizer norm)
 {
     _outputNormalizers[colType] = norm;
 }
Exemplo n.º 32
0
 public IntersectionCountIndex(int nGramSize, INormalizer normalizer) : base(nGramSize, normalizer)
 {
 }