How takenet/textc-csharp works
Project type and purpose
• This is an open-source .NET class library (Takenet.Textc) for building text‐command applications via natural-language parsing.
• It provides a tokenization/parser engine, a command‐processing pipeline, a context abstraction (with a Redis extension), plus sample console apps and unit tests.
File structure
• Top-level solution (Takenet.Textc.sln) with four projects under src/:
– Core engine: Takenet.Textc
– Redis context extension: Takenet.Textc.Extensions.Redis
– Sample/demo app: Takenet.Textc.Samples
– Unit tests: Takenet.Textc.UnitTests
• Core project folders highlight architectural layers:
– Csdl (DSL parser)
– Metadata (attributes for token types)
– PreProcessors (text normalization pipeline)
– Splitters, SyntaxParser (tokenizer)
– Types (built-in/regex/phonetic token types)
– Scorers (match-ranking strategies)
– Processors (command binding & output handling)
– RequestContext abstraction and default in-memory implementation
• Extension project: implements IRequestContext with RedisRequestContext.
• Sample project: a console host that wires up TextProcessor, command processors, and optional Redis context.
• UnitTests project covers core modules (token types, parser, scoring, context).
README for additional insights
• Describes pipeline: input → tokenization (Csdl syntaxes) → best-match scoring → Expression → CommandProcessor → OutputProcessor.
• Explains context usage (in-memory vs Redis), CSDL syntax language, optional/contextual tokens and parsing anchors.
• Lists built-in token types and processing stages.
• Client (Console App or any host)
• TextProcessor (the engine)
• PreProcessors pipeline (TextNormalizer, ToLowerCase, etc.)
• SyntaxParser / CsdlParser
• Token types registry (Word, Integer, LDWord, DMWord, RegexWord, Text, etc.)
• Scorers (Ratio, MatchCount)
• IRequestContext (InMemoryContext or RedisRequestContext)
• CommandProcessors (ReflectionCommandProcessor, DelegateCommandProcessor)
• OutputProcessors (DelegateOutputProcessor or custom)
• External Store (Redis) for context persistence (optional)
• Unit tests (validate each component—shown as side-car)
1. Client → TextProcessor.ProcessAsync(input, context)
2. TextProcessor feeds input through PreProcessors → cleaned text
3. Cleaned text + context → SyntaxParser (CsdlParser + token types)
4. Parser produces one or more Expression candidates → Scorers select best
5. Best Expression + context → CommandProcessor binds tokens to method parameters
6. Method invocation returns result → OutputProcessor handles/display result
7. CommandProcessor or contextual tokens may update IRequestContext
8. IRequestContext writes to in-memory dictionary or Redis service
c. Architectural patterns & principles
• Pipeline/Chain of Responsibility for text preprocessing
• Strategy pattern for token types and scoring algorithms
• Plugin/extension points: ICommandProcessor, IOutputProcessor, ITextPreProcessor, IRequestContext
• DSL parsing via CsdlParser (builder/factory for Syntax objects)
• Dependency Inversion: consumers depend on interfaces (IRequestContext, ITextProcessor)
d. Key technologies & frameworks
• .NET / C# class libraries
• NuGet packaging (.nuspec files in core & extension projects)
• AppVeyor CI for builds
• Redis (via Takenet.Textc.Extensions.Redis)
• nCruch projects for test runs
Final advice
• Every pipeline step and extension point—even rarely used ones (e.g., text splitters)
• Don’t overthink: break the system into as many meaningful components as it already is, then show how they connect.