public static void Main(string[] args) { var testImagePath = "./phototest.tif"; if (args.Length > 0) { testImagePath = args[0]; } try { var logger = new FormattedConsoleLogger(); var resultPrinter = new ResultPrinter(logger); using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) { using (var img = Pix.LoadFromFile(testImagePath)) { using (logger.Begin("Process image")) { var i = 1; using (var page = engine.Process(img)) { var text = page.GetText(); logger.Log("Text: {0}", text); logger.Log("Mean confidence: {0}", page.GetMeanConfidence()); using (var iter = page.GetIterator()) { iter.Begin(); do { if (i % 2 == 0) { using (logger.Begin("Line {0}", i)) { do { using (logger.Begin("Word Iteration")) { if (iter.IsAtBeginningOf(PageIteratorLevel.Block)) { logger.Log("New block"); } if (iter.IsAtBeginningOf(PageIteratorLevel.Para)) { logger.Log("New paragraph"); } if (iter.IsAtBeginningOf(PageIteratorLevel.TextLine)) { logger.Log("New line"); } logger.Log("word: " + iter.GetText(PageIteratorLevel.Word)); ResultIterator testiter = iter.Clone (); logger.Log("from clone: " + testiter.GetText(PageIteratorLevel.Word)); } } while (iter.Next(PageIteratorLevel.TextLine, PageIteratorLevel.Word)); } } i++; } while (iter.Next(PageIteratorLevel.Para, PageIteratorLevel.TextLine)); } } } } } } catch (Exception e) { Trace.TraceError(e.ToString()); Console.WriteLine("Unexpected Error: " + e.Message); Console.WriteLine("Details: "); Console.WriteLine(e.ToString()); } Console.Write("Press any key to continue . . . "); Console.ReadKey(true); }
public MainWindow() { InitializeComponent(); OutputResultControl = new ResultPrinter(txtDebug); _cancellationTokenSource = new Dictionary <string, CancellationTokenSource>(4); }
private void PrintSimulationConcentrations(bool normalize = false) { if (normalize) { ResultPrinter.Print(""); for (var i = 0; i < SCur.Length; i++) { ResultPrinter.Print($"SCur[{i}] = {SCur[i] / Biosensor.S0}"); } ResultPrinter.Print(""); for (var i = 0; i < PCur.Length; i++) { ResultPrinter.Print($"PCur[{i}] = {PCur[i] / Biosensor.S0}"); } } else { ResultPrinter.Print(""); for (var i = 0; i < SCur.Length; i++) { ResultPrinter.Print($"SCur[{i}] = {SCur[i]}"); } ResultPrinter.Print(""); for (var i = 0; i < PCur.Length; i++) { ResultPrinter.Print($"PCur[{i}] = {PCur[i]}"); } } }
public void StartMethod() { var fArr = DataGenerator.Generate(CountOfElements); var sortingResult = SortAlgorithm.Sort(fArr); ResultPrinter.Write(PathToFile, sortingResult); }
/// <summary> /// Write parameters for result /// </summary> public void PrintParameters() { ResultPrinter.Print("*********" + Biosensor.Name + "*********"); ResultPrinter.Print(""); ResultPrinter.Print(""); ResultPrinter.Print("====Parameters===="); ResultPrinter.Print($"Height: {Biosensor.Height} m"); ResultPrinter.Print($"Km: {Biosensor.Km} M"); ResultPrinter.Print($"S0: {Biosensor.S0} M"); ResultPrinter.Print($"Vmax: {Biosensor.VMax} M/s"); ResultPrinter.Print($"Time step: {SimulationParameters.t} s"); ResultPrinter.Print($"Steps: {SimulationParameters.N}"); ResultPrinter.Print($"Decay rate: {SimulationParameters.DecayRate}"); ResultPrinter.Print(""); ResultPrinter.Print("====Main parameters===="); ResultPrinter.Print($"Diffusion module: " + $"{Biosensor.VMax * Biosensor.EnzymeLayer.Height * Biosensor.EnzymeLayer.Height / (Biosensor.EnzymeLayer.Substrate.DiffusionCoefficient * Biosensor.Km)}"); ResultPrinter.Print(""); if (Biosensor is BaseHomogenousBiosensor homogenousBiosensor) { ResultPrinter.Print("*********Homogenization*********"); ResultPrinter.Print($"Use Homogenization: {homogenousBiosensor.IsHomogenized}"); ResultPrinter.Print($"Use EffectiveDiffusionCoefficent: {homogenousBiosensor.UseEffectiveDiffusionCoefficent}"); ResultPrinter.Print($"Use EffectiveReactionCoefficent: {homogenousBiosensor.UseEffectiveReactionCoefficent}"); ResultPrinter.Print(""); } if (Biosensor is BaseMicroreactorBiosensor microreactorBiosensor) { ResultPrinter.Print("*********Microreactor parameters*********"); ResultPrinter.Print($"Microreactor radius: {microreactorBiosensor.MicroReactorRadius}"); ResultPrinter.Print($"Unit radius: {microreactorBiosensor.UnitRadius}"); ResultPrinter.Print(""); } if (Biosensor is BasePerforatedMembraneBiosensor basePerforatedMembraneBiosensor) { ResultPrinter.Print("*********Perforated membrane parameters*********"); ResultPrinter.Print($"Hole radius: {basePerforatedMembraneBiosensor.HoleRadius}"); ResultPrinter.Print($"Half distance between holes: {basePerforatedMembraneBiosensor.HalfDistanceBetweenHoles}"); ResultPrinter.Print($"Enzyme height in hole: {basePerforatedMembraneBiosensor.EnzymeHoleHeight}"); ResultPrinter.Print(""); } foreach (var biosensorLayer in Biosensor.Layers) { ResultPrinter.Print($"{biosensorLayer.Type}:"); ResultPrinter.Print($"Height: {biosensorLayer.Height} m"); ResultPrinter.Print($"Dp: {biosensorLayer.Product.DiffusionCoefficient} m2/s"); ResultPrinter.Print($"Ds: {biosensorLayer.Substrate?.DiffusionCoefficient} m2/s"); ResultPrinter.Print($"Steps count: {biosensorLayer.N}"); ResultPrinter.Print($"Step: {biosensorLayer.H} M"); ResultPrinter.Print(""); } }
public static void Run() { DIConfig.DI.Unregister <IBenchmarkService>(); DIConfig.DI.Register <IBenchmarkService, JsonLdHashingBenchmarkService>(serviceKey: typeof(JsonLdHashingBenchmarkService)); var appRunner = new BenchmarkAppRunner(); var benchmarkResults = appRunner.RunParticularBenchmarkWithinGivenContext(typeof(JsonLdHashingBenchmarkService)); ResultPrinter.PrintResults(typeof(JsonLdHashingApp).Name, benchmarkResults); }
public static void Run() { DIConfig.ConfigCircleDotHash(); DIConfig.ConfigAllegroGraphTriplestore(); DIConfig.DI.Unregister <IBenchmarkService>(); DIConfig.DI.Register <IBenchmarkService, CircleDotHashingBlockCreationBenchmarkService>(serviceKey: typeof(CircleDotHashingBlockCreationBenchmarkService)); var appRunner = new BenchmarkAppRunner(); var benchmarkResults = appRunner.RunParticularBenchmarkWithinGivenContext(typeof(CircleDotHashingBlockCreationBenchmarkService)); ResultPrinter.PrintResults(typeof(CircleDotHashingBlockCreationApp).Name, benchmarkResults); }
static int Main(string[] args) { // Using reflection determine available commands Dictionary <Type, CaseInsensitiveList> availableCommands = ReflectionHelper.GetCommands(); List <PSCommand> userCommands = null; // If no arguments are provided to the executable, show help if (args.Length == 0) { Console.WriteLine("== NoPowerShell v1.0 ==\r\nUrl: Website: https://github.com/bitsadmin\r\nUsage: NoPowerShell.exe [Command] [Parameters] | [Command2] [Parameters2] etc.\r\n"); userCommands = new List <PSCommand>(1) { new GetCommandCommand(null) }; } // Parse pipes in commandline arguments and commands within pipes else { userCommands = PipeParser.ParseArguments(args, availableCommands); } // Add output to console if no explicit output is provided Type lastCommand = userCommands[userCommands.Count - 1].GetType(); bool justOutput = false; if (lastCommand != typeof(FormatListCommand) && lastCommand != typeof(FormatTableCommand)) { justOutput = true; } CommandResult result = null; try { // Execute commands in pipeline foreach (PSCommand command in userCommands) { result = command.Execute(result); } } catch (Exception e) { Console.Write(e.ToString()); return(-1); } // Output to screen if (justOutput) { ResultPrinter.OutputResults(result); } return(0); }
private void PrintSimulationResults(Stopwatch stopwatch, double I, bool printConcentrations = true, bool normalize = false) { ResultPrinter.Print(""); ResultPrinter.Print("----------------------------------------------------"); ResultPrinter.Print($"Simulation time: {stopwatch.ElapsedMilliseconds} ms"); ResultPrinter.Print($"Current = {I} A/mm2"); if (printConcentrations) { PrintSimulationConcentrations(normalize); } }
// Show ZeroCondition and First condition and two model condition public void ShowValidationValues() { var simulation = new AnalyticSimulation(); var firstOrderCurrent = simulation.GetFirstOrderAnalyticSolution(Biosensor, SimulationParameters); var zeroOrderCurrent = simulation.GetZeroOrderAnalyticSolution(Biosensor, SimulationParameters); ResultPrinter.Print("====Analytic validations===="); ResultPrinter.Print($"First order current: {firstOrderCurrent } A/mm^2"); ResultPrinter.Print($"Zero order current: {zeroOrderCurrent } A/mm^2"); ResultPrinter.Print(""); }
private static void RunBasicAlgorithms(TspSolver solver, string coordinatesPath, string resultsPath) { var resultPrinter = new ResultPrinter() .AddPrinter(new ConsolePrinter(), new ConsoleContentBuilder(solver.SolvingStatistics)) .AddPrinter(new FilePrinter(resultsPath, $"{DateTime.Now.Date.ToFileTime()}_results.txt"), new FileContentBuilder(solver.SolvingStatistics, coordinatesPath)); SolveAndPrint(solver, new NearestNeighborAlgorithm(Steps, new EdgeFinder()), "NEAREST NEIGHBOR", resultPrinter); SolveAndPrint(solver, new GreedyCycleAlgorithm(Steps, new EdgeFinder()), "GREEDY CYCLE", resultPrinter); SolveAndPrint(solver, new NearestNeighborAlgorithm(Steps, new GraspEdgeFinder(3)), "NEAREST NEIGHBOR GRASP", resultPrinter); SolveAndPrint(solver, new GreedyCycleAlgorithm(Steps, new GraspEdgeFinder(3)), "GREEDY CYCLE GRASP", resultPrinter); }
private static void Main() { Console.Setup(); Console.PrintHeading("Task 4 Permutations of numbers"); ResultPrinter printer = new ResultPrinter(Console); int[] collection = { 1, 2, 3, 4 }; int subsetSize = 4; CombinatoricsGen<int> combo = new PermutationsGenerator<int>(subsetSize, collection); printer.DispalyResults(collection, collection.Length, combo); }
public override void Run() { ConsoleWriter writer = new ConsoleWriter(); ResultPrinter resultPrinter = new ResultPrinter(new StreamWriter(results), writer); SnapshotLoader loader = new SnapshotLoader(snapshotPath); IList<HistorySnapshot> shapshots = loader.LoadSnapshots(); for (int snapshotLength = 100; snapshotLength >= 80; snapshotLength = snapshotLength - 10) { ExperimentWatcher experiment = new ExperimentWatcher(writer, snapshotLength, name, shapshots); experiment.Start(); resultPrinter.Prefix = snapshotLength + ", "; resultPrinter.PrintResult(experiment.Results); } resultPrinter.Close(); }
private static void Main() { Console.Setup(); Console.PrintHeading("Task 5 Print Ordered Subsets of K from Set of N"); string[] mainSet = { "hi", "a", "b" }; int subsetLength = 2; var printer = new ResultPrinter(Console); CombinatoricsGen <string> combo = new PermutationsWithRepetition <string>(subsetLength, mainSet); printer.DispalyResults(mainSet, subsetLength, combo); }
private static void Main() { Console.ConsoleMio.Setup(); Console.ConsoleMio.PrintHeading("Task 6 All Subsets of K Strings"); var printr = new ResultPrinter(Console.ConsoleMio); string[] collection = { "test", "rock", "fun" }; int size = 2; CombinatoricsGen <string> combo = new CombinatoricsesRegular <string>(size, collection); printr.DispalyResults(collection, 2, combo); }
private static void Main() { Console.Setup(); Console.PrintHeading("Task 4 Permutations of numbers"); ResultPrinter printer = new ResultPrinter(Console); int[] collection = { 1, 2, 3, 4 }; int subsetSize = 4; CombinatoricsGen <int> combo = new PermutationsGenerator <int>(subsetSize, collection); printer.DispalyResults(collection, collection.Length, combo); }
private static void Main() { Console.Setup(); Console.PrintHeading("Task 5 Print Ordered Subsets of K from Set of N"); string[] mainSet = { "hi", "a", "b" }; int subsetLength = 2; var printer = new ResultPrinter(Console); CombinatoricsGen<string> combo = new PermutationsWithRepetition<string>(subsetLength, mainSet); printer.DispalyResults(mainSet, subsetLength, combo); }
public override void Run() { ConsoleWriter writer = new ConsoleWriter(); ResultPrinter resultPrinter = new ResultPrinter(new StreamWriter(results), writer); SnapshotLoader loader = new SnapshotLoader(source); IList<HistorySnapshot> snapshots = loader.LoadSnapshots(); ISet<string> names = ProcessNamesExtractor.GetProcessNames(snapshots); foreach (string name in names) { //Console.WriteLine(name); ExperimentWatcher experiment = new ExperimentWatcher(writer, 20, name, snapshots); experiment.Start(); resultPrinter.Prefix = name + ": "; resultPrinter.PrintResult(experiment.Results); } resultPrinter.Close(); }
public override CommandResult Execute(CommandResult pipeIn) { string[] properties = _arguments.Get <StringArgument>("Property").Value.Split(','); _results.Output = CommandResult.OutputType.List; if (pipeIn == null) { return(null); } foreach (ResultRecord result in pipeIn) { // Show all columns if (properties[0] == string.Empty) { _results.Add(result); } // Show only specific columns else { ResultRecord newResult = new ResultRecord(); foreach (string attr in properties) { if (result.ContainsKey(attr)) { newResult.Add(attr, result[attr]); } else { newResult.Add(attr, null); } } _results.Add(newResult); } } ResultPrinter.OutputResults(_results); return(_results); }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Please provide input file path as first parameter"); } else { // in production I would use a DI container like Autofac var inputFilePath = args[0]; var inputWordRepository = new InputWordRepository(inputFilePath); var resultPrinter = new ResultPrinter(); var wordCombineHandler = new WordCombineHandler(inputWordRepository, resultPrinter); wordCombineHandler.Handle(); } Console.ReadKey(); }
private static void Main() { Console.Setup(); Console.PrintHeading("Task 2 Generate All Combinations With Duplicates"); int[] collection = { 1, 2, 3, 4, 5 }; int combinationSetsLength = 2; CombinatoricsGen <int> combo = new CombinatoricsesWithDuplicates <int>(combinationSetsLength, collection); var resultPrinter = new ResultPrinter(Console); resultPrinter.DispalyResults(collection, combinationSetsLength, combo); Console.PrintHeading("Task 3 Generate All Regular Combinations"); combo = new CombinatoricsesRegular <int>(combinationSetsLength, collection); resultPrinter.DispalyResults(collection, combinationSetsLength, combo); }
private static void UseGenerics() { //call service, dal, etc. var result = new Result<int, string>() { Success = true, Data = 5, Description = "its just a number really" }; var result2 = new Result<string, bool>() { Success = false, Data = "Peniel Tambama", Description = false }; var helper = new ResultPrinter(); helper.Print(result); Console.ReadLine(); }
public void ReversePAs_Should_Not_Error_When_Value_Larger_Than_Size() { ResultPrinter.ReversePad("12345678901"); }
public static void Main(string[] args) { var testImagePath = "./phototest.tif"; if (args.Length > 0) { testImagePath = args[0]; } try { var logger = new FormattedConsoleLogger(); var resultPrinter = new ResultPrinter(logger); using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) { using (var img = Pix.LoadFromFile(testImagePath)) { using (logger.Begin("Process image")) { var i = 1; using (var page = engine.Process(img)) { var text = page.GetText(); logger.Log("Text: {0}", text); logger.Log("Mean confidence: {0}", page.GetMeanConfidence()); using (var iter = page.GetIterator()) { iter.Begin(); do { if (i % 2 == 0) { using (logger.Begin("Line {0}", i)) { do { using (logger.Begin("Word Iteration")) { if (iter.IsAtBeginningOf(PageIteratorLevel.Block)) { logger.Log("New block"); } if (iter.IsAtBeginningOf(PageIteratorLevel.Para)) { logger.Log("New paragraph"); } if (iter.IsAtBeginningOf(PageIteratorLevel.TextLine)) { logger.Log("New line"); } logger.Log("word: " + iter.GetText(PageIteratorLevel.Word)); } } while (iter.Next(PageIteratorLevel.TextLine, PageIteratorLevel.Word)); } } i++; } while (iter.Next(PageIteratorLevel.Para, PageIteratorLevel.TextLine)); } } } } } } catch (Exception e) { Trace.TraceError(e.ToString()); Console.WriteLine("Unexpected Error: " + e.Message); Console.WriteLine("Details: "); Console.WriteLine(e.ToString()); } Console.Write("Press any key to continue . . . "); Console.ReadKey(true); }
public OCR(String imagePath) { try { var logger = new FormattedConsoleLogger(); var resultPrinter = new ResultPrinter(logger); using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) { using (var img = Pix.LoadFromFile(imagePath)) { using (logger.Begin("Process image")) { var i = 1; using (var page = engine.Process(img)) { Text = page.GetText(); logger.Log("Text: {0}", Text); logger.Log("Mean confidence: {0}", page.GetMeanConfidence()); using (var iter = page.GetIterator()) { iter.Begin(); do { if (i % 2 == 0) { using (logger.Begin("Line {0}", i)) { do { using (logger.Begin("Word Iteration")) { if (iter.IsAtBeginningOf(PageIteratorLevel.Block)) { logger.Log("New block"); } if (iter.IsAtBeginningOf(PageIteratorLevel.Para)) { logger.Log("New paragraph"); } if (iter.IsAtBeginningOf(PageIteratorLevel.TextLine)) { logger.Log("New line"); } logger.Log("word: " + iter.GetText(PageIteratorLevel.Word)); } } while (iter.Next(PageIteratorLevel.TextLine, PageIteratorLevel.Word)); } } i++; } while (iter.Next(PageIteratorLevel.Para, PageIteratorLevel.TextLine)); } } } } } } catch (Exception e) { Trace.TraceError(e.ToString()); Console.WriteLine("Unexpected Error: " + e.Message); Console.WriteLine("Details: "); Console.WriteLine(e.ToString()); } }
static int Main(string[] args) { // Using reflection determine available commands Dictionary <Type, CaseInsensitiveList> availableCommands = ReflectionHelper.GetCommands(); List <PSCommand> userCommands = null; // If no arguments are provided to the executable, show help if (args.Length == 0) { Console.WriteLine("== NoPowerShell v{0} ==\r\nWebsite: {1}\r\n{2}", VERSION, WEBSITE, USAGE); userCommands = new List <PSCommand>(1) { new GetCommandCommand(null) }; } // Parse pipes in commandline arguments and commands within pipes else { string error = null; try { userCommands = PipeParser.ParseArguments(args, availableCommands); } catch (ParameterBindingException ex) { error = ex.Message; } catch (CommandNotFoundException ex) { error = string.Join("", new string[] { ex.Message, HELP }); } if (error != null) { WriteError(error); return(-1); } } // Add output to console if no explicit output is provided Type lastCommand = userCommands[userCommands.Count - 1].GetType(); bool justOutput = false; if (lastCommand != typeof(FormatListCommand) && lastCommand != typeof(FormatTableCommand)) { justOutput = true; } CommandResult result = null; #if DEBUG // Execute commands in pipeline foreach (PSCommand command in userCommands) { result = command.Execute(result); } #else PSCommand mostRecentCommand = null; try { // Execute commands in pipeline foreach (PSCommand command in userCommands) { mostRecentCommand = command; result = command.Execute(result); } } catch (NoPowerShellException e) { WriteError(string.Format("{0} : {1}", mostRecentCommand.ToString(), e.Message)); return(-1); } catch (Exception e) { WriteError(string.Format("{0} : {1}", mostRecentCommand.ToString(), e.ToString())); return(-1); } #endif // Output to screen if (justOutput) { ResultPrinter.OutputResults(result); } return(0); }
public void PadToSize_Should_Not_Error_When_Value_Larger_Than_Size() { ResultPrinter.PadToSize("1234567890", 9); }
static void Main() { Initialize(); TakePicture picture = new TakePicture(); var testImagePath = @"depth.png"; try { var logger = new FormattedConsoleLogger(); var resultPrinter = new ResultPrinter(logger); using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) { using (var img = Pix.LoadFromFile(testImagePath)) { using (logger.Begin("Process image")) { var i = 1; using (var page = engine.Process(img)) { var text = page.GetText(); logger.Log("Text: {0}", text); if (File.Exists(@"output.txt")) { File.Delete(@"output.txt"); } using (var Stream = File.Open(@"output.txt", FileMode.OpenOrCreate)) { using (var writer = new BinaryWriter(Stream, Encoding.UTF8)) { writer.Write(text.Where(c => char.IsDigit(c)).ToArray()); } Stream.Close(); } logger.Log("Mean confidence: {0}", page.GetMeanConfidence()); using (var iter = page.GetIterator()) { iter.Begin(); do { if (i % 2 == 0) { using (logger.Begin("Line {0}", i)) { do { using (logger.Begin("Word Iteration")) { if (iter.IsAtBeginningOf(PageIteratorLevel.Block)) { logger.Log("New block"); } if (iter.IsAtBeginningOf(PageIteratorLevel.Para)) { logger.Log("New paragraph"); } if (iter.IsAtBeginningOf(PageIteratorLevel.TextLine)) { logger.Log("New line"); } logger.Log("word: " + iter.GetText(PageIteratorLevel.Word)); } } while (iter.Next(PageIteratorLevel.TextLine, PageIteratorLevel.Word)); } } i++; } while (iter.Next(PageIteratorLevel.Para, PageIteratorLevel.TextLine)); } } } } } } catch (Exception e) { Trace.TraceError(e.ToString()); Console.WriteLine("Unexpected Error: " + e.Message); Console.WriteLine("Details: "); Console.WriteLine(e.ToString()); } Console.Write("Press any key to continue . . . "); Console.ReadKey(true); }
public static void Main(string[] args) { try { var logger = new FormattedConsoleLogger(); var resultPrinter = new ResultPrinter(logger); using (var engine = new Engine(@"./tessdata", "eng", EngineMode.Default)) { using (var img = Pix.LoadFromFile("./phototest.tif")) { using (logger.Begin("Image")) { var i = 1; using (var iter = engine.Process(img)) { iter.Begin(); do { if (i % 2 == 0) { using(logger.Begin("Line {0}", i)) { do { using (logger.Begin("Word Iteration")) { if (iter.IsAtBeginningOf(PageIteratorLevel.Block)) { logger.Log("New block"); } if (iter.IsAtBeginningOf(PageIteratorLevel.Para)) { logger.Log("New paragraph"); } if (iter.IsAtBeginningOf(PageIteratorLevel.TextLine)) { logger.Log("New line"); } logger.Log("word: " + iter.GetText(PageIteratorLevel.Word)); } } while (iter.Next(PageIteratorLevel.TextLine, PageIteratorLevel.Word)); } } i++; } while (iter.Next(PageIteratorLevel.Para, PageIteratorLevel.TextLine)); } } } } } catch (Exception e) { Trace.TraceError(e.ToString()); Console.WriteLine("Unexpected Error: " + e.Message); Console.WriteLine("Details: "); Console.WriteLine(e.ToString()); } Console.Write("Press any key to continue . . . "); Console.ReadKey(true); }