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); }
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); }
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; }
/// <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); }
private void button2_Click(object sender, EventArgs e) { Corrector corrector = new Corrector(cImage) { Alpha = trackBar1.Value }; Form2 f2 = new Form2(corrector.Process()); f2.Show(); }
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); }
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); }
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; } } }
public void IsPossibleForOneDeletion_ReturnTrue() { Assert.IsTrue(Corrector.IsPossibleMissprint("Hello", "hllo", 1)); }
public void IsPossibleForTwoAdjastedDeletions_ReturnFalse() { Assert.IsFalse(Corrector.IsPossibleMissprint("Hello", "heo", 2)); }
public void IsPossibleForLastDeleted_ReturnTrue() { Assert.IsTrue(Corrector.IsPossibleMissprint("hello", "hell", 1)); }
public void Length0Max5_Return0() { Assert.AreEqual(Corrector.MaxDeletionsForWordLength(0, 5), 0); }
public void IsPossibleForTwoSeparateWithSameLetter_returnTrue() { Assert.IsTrue(Corrector.IsPossibleMissprint("helll", "hel", 2)); }
public void IsPossibleForThreeAdjastedWithSameLetterAtTheBegin_returnFalse() { Assert.IsFalse(Corrector.IsPossibleMissprint("hhhhelo", "helo", 3)); }
internal CorrectorShould(Corrector corrector) : base(corrector) { this.corrector = corrector; }
public void Length1Max2_Return1() { Assert.AreEqual(Corrector.MaxDeletionsForWordLength(1, 2), 1); }
public void InitializeDictionay() { dict = new Corrector(0); }
public void Generate3DeletionsForShorterWord_EmptyList() { var generated = Corrector.GenerateDeletions("cats", 3); Assert.IsTrue(generated.Count == 0); }
public void IsPossibleForTwoSeparateDeletions_ReturnTrue() { Assert.IsTrue(Corrector.IsPossibleMissprint("Hello", "hlo", 2)); }
public void Length10_Return5() { Assert.AreEqual(Corrector.MaxDeletionsForWordLength(10), 5); }
public void Length5Max2_Return2() { Assert.AreEqual(Corrector.MaxDeletionsForWordLength(5, 2), 2); }
public void Length5Max10_Return3() { Assert.AreEqual(Corrector.MaxDeletionsForWordLength(5, 10), 3); }