Пример #1
0
            public override Status Step(Vector pos, out Vector stepped, out float stepLength)
            {
                // One predictor step.
                Status status = Predictor.Step(pos, out stepped, out stepLength);

                if (status != Status.OK)
                {
                    return(status);
                }
                // Now, step until the corrector reaches a critical point.
                Vector point;
                Vector next = stepped;

                if (CheckPosition(next) != Status.OK)
                {
                    StepBorder(pos, out stepped, out stepLength);
                    return(CheckPosition(stepped));
                }
                int step = -1;

                do
                {
                    step++;
                    point  = next;
                    status = Corrector.Step(point, out next, out stepLength);
                } while (status == Status.OK && step < Corrector.MaxNumSteps);

                if (status == Status.CP)
                {
                    return(Status.OK);
                }
                return(status);
            }
Пример #2
0
    private static void Main(string[] args)
    {
        Linguist  linguist;
        Corrector corrector;

        try
        {
            linguist  = Linguist.Parse(Console.ReadLine());
            corrector = Corrector.Parse(Console.ReadLine());
        }

        catch (ArgumentException argumentException)
        {
            Console.WriteLine(argumentException.Message);
            return;
        }

        string text = Console.ReadLine();


        int totalSalary = 0;

        string editedText = linguist.EditHeader(text);

        totalSalary += linguist.CountSalary(text, editedText);

        text         = editedText;
        editedText   = corrector.EditHeader(text);
        totalSalary += corrector.CountSalary(text, editedText);

        Console.WriteLine(editedText);
        Console.WriteLine(totalSalary);
    }
Пример #3
0
        private async void correctButton_Click(object sender, EventArgs e)
        {
            correctButton.Enabled = false;

            Corrector corrector = new Corrector(seconds, milliseconds, filename, move);
            await corrector.correctAsync();

            correctButton.Enabled = true;
        }
Пример #4
0
 /// <summary>
 /// Корректировка коллекции юнитов подпредложения
 /// </summary>
 /// <param name="current">текущий юнит</param>
 /// <param name="corrector">преобразователь</param>
 /// <param name="units">юниты для корректировки</param>
 private void CorrectUnits(UnitTextBase current, Corrector corrector, params UnitTextBase[] units)
 {
     if (units.Any())
     {
         List <UnitTextBase> collection = Units.ToList();
         corrector(collection, current, units);
         Units = collection.ToArray();
     }
 }
        public void HsvToColorTest()
        {
            Color c  = Color.FromArgb(17, 25, 33);
            Color c2 = Corrector.HsvToColor(c.GetHue(), c.GetSaturation(), c.GetBrightness());

            Assert.AreEqual(c.R, c2.R);
            Assert.AreEqual(c.G, c2.G);
            Assert.AreEqual(c.B, c2.B);
        }
Пример #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            Corrector corrector = new Corrector(cImage)
            {
                Alpha = trackBar1.Value
            };
            Form2 f2 = new Form2(corrector.Process());

            f2.Show();
        }
Пример #7
0
            public void Generate1DeletionForWord_EquivalentGivenList()
            {
                var           generated  = Corrector.GenerateDeletions("orange", 1);
                List <String> equivalent = new List <String>()
                {
                    "range", "oange", "ornge", "orage", "orane", "orang"
                };

                CollectionAssert.AreEquivalent(generated, equivalent);
            }
Пример #8
0
        private static Corrector GetCorrector(Mock <ICorrectionStrategyFactory> factory, Mock <IStatefulCorrectionStrategy> strategy, Mock <ICorrectionStrategyManager> manager, Mock <ICorrectionSettings> settings, Mock <ILogger <Corrector> > logger)
        {
            manager.Setup(s => s.SetStrategy(strategy.Object)).Verifiable();
            strategy.Setup(s => s.Apply(It.IsAny <Image <Gray, byte> >())).Returns(new Image <Gray, byte>(1, 1));
            factory.Setup(f => f.Create(It.IsAny <string>())).Returns(strategy.Object);

            var result = new Corrector(factory.Object, manager.Object, settings.Object, logger.Object);

            manager.Verify();

            return(result);
        }
Пример #9
0
 public static async Task <AlgorithmProfile> Profile(Corrector corrector)
 {
     return(await Task.Run(() => OneChangedLetter.Aggregate <Changed, ProfileAccumulator, AlgorithmProfile>(
                               new ProfileAccumulator(0, 0, 0, 0), (aggregate, word) =>
     {
         var iteration = ProfileIteration(corrector, word);
         return aggregate with
         {
             Count = aggregate.Count + 1,
             TotalTime = aggregate.TotalTime + iteration.Speed,
             TotalFound = aggregate.TotalFound + (iteration.Success == SuggestEvaluation.Found ? 1 : 0),
             TimeForFound = aggregate.TimeForFound + (iteration.Success == SuggestEvaluation.Found ? iteration.Speed : 0)
         };
     },
        public IEnumerable <LoadState> Broadcast()
        {
            ILinearSolver   mK0 = Info.Stiffness(State.Displacement);
            Vector <double> Dv0 = mK0.Solve(Info.ReferenceLoad);
            double          k0  = Info.ReferenceLoad.DotProduct(Dv0);

            while (true)
            {
                LoadIncrementalState prediction = Predictor.Predict(State, k0, Info);
                State = State.Add(prediction);
                Result <LoadIncrementalState> correctionResult = Corrector.Correct(State, prediction, Info);
                if (correctionResult.IsSuccess)
                {
                    State = State.Add(correctionResult.Value);
                    yield return(State);
                }
                else
                {
                    break;
                }
            }
        }
Пример #11
0
 public void IsPossibleForOneDeletion_ReturnTrue()
 {
     Assert.IsTrue(Corrector.IsPossibleMissprint("Hello", "hllo", 1));
 }
Пример #12
0
 public void IsPossibleForTwoAdjastedDeletions_ReturnFalse()
 {
     Assert.IsFalse(Corrector.IsPossibleMissprint("Hello", "heo", 2));
 }
Пример #13
0
 public void IsPossibleForLastDeleted_ReturnTrue()
 {
     Assert.IsTrue(Corrector.IsPossibleMissprint("hello", "hell", 1));
 }
Пример #14
0
 public void Length0Max5_Return0()
 {
     Assert.AreEqual(Corrector.MaxDeletionsForWordLength(0, 5), 0);
 }
Пример #15
0
 public void IsPossibleForTwoSeparateWithSameLetter_returnTrue()
 {
     Assert.IsTrue(Corrector.IsPossibleMissprint("helll", "hel", 2));
 }
Пример #16
0
 public void IsPossibleForThreeAdjastedWithSameLetterAtTheBegin_returnFalse()
 {
     Assert.IsFalse(Corrector.IsPossibleMissprint("hhhhelo", "helo", 3));
 }
Пример #17
0
 internal CorrectorShould(Corrector corrector) : base(corrector)
 {
     this.corrector = corrector;
 }
Пример #18
0
 public void Length1Max2_Return1()
 {
     Assert.AreEqual(Corrector.MaxDeletionsForWordLength(1, 2), 1);
 }
Пример #19
0
 public void InitializeDictionay()
 {
     dict = new Corrector(0);
 }
Пример #20
0
            public void Generate3DeletionsForShorterWord_EmptyList()
            {
                var generated = Corrector.GenerateDeletions("cats", 3);

                Assert.IsTrue(generated.Count == 0);
            }
Пример #21
0
 public void IsPossibleForTwoSeparateDeletions_ReturnTrue()
 {
     Assert.IsTrue(Corrector.IsPossibleMissprint("Hello", "hlo", 2));
 }
Пример #22
0
 public void Length10_Return5()
 {
     Assert.AreEqual(Corrector.MaxDeletionsForWordLength(10), 5);
 }
Пример #23
0
 public void Length5Max2_Return2()
 {
     Assert.AreEqual(Corrector.MaxDeletionsForWordLength(5, 2), 2);
 }
Пример #24
0
 public void Length5Max10_Return3()
 {
     Assert.AreEqual(Corrector.MaxDeletionsForWordLength(5, 10), 3);
 }