Enhance project metadata and refactor core classes
Updated project files for `Beam.Dynamic`, `Beam.Exports`, `Beam.Temporary.Cli`, and `Beam` to include additional metadata and specific package versions. Refactored `DataBindings` and `ResolvedBindings` to records, added a new `Text` property in `Binding.cs`, and introduced `ParseNumbers` in `OnlineCleaner`. New classes `PuppetContext` and `PuppetUnitDownloader` added for Playwright integration. Introduced `ImmutableState` struct and `UnitDownloaderBinary` class for improved download management. Updated tests in `UnitTest1.cs` for number localization. Added `Beam.Puppeteer` project to the solution.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using HtmlAgilityPack;
|
||||
using Microsoft.Recognizers.Text.Number;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -25,6 +27,19 @@ namespace Beam.Dynamic {
|
||||
});
|
||||
}
|
||||
|
||||
public static List<int> ParseNumbers(string text, string from) {
|
||||
var results = NumberRecognizer.RecognizeNumber(text, from, NumberOptions.None, false);
|
||||
var resolved = results.Select((x) => {
|
||||
if (x.Resolution.TryGetValue("value", out var value) && double.TryParse(value.ToString(), out var number))
|
||||
return (int?)number;
|
||||
return null;
|
||||
})
|
||||
.Where((x) => x.HasValue).ToList();
|
||||
if (resolved.Count == 0)
|
||||
return [];
|
||||
return resolved.Select((x) => x!.Value).ToList();
|
||||
}
|
||||
|
||||
public static string Clean(string? onlineText) {
|
||||
if (string.IsNullOrWhiteSpace(onlineText))
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user