Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ParametersTokenizer.cs
1using System;
3using System.Reflection;
4using System.Threading.Tasks;
11
13{
18 {
23 {
24 }
25
31 public Grade Supports(Type Type)
32 {
33 if (typeInfo.IsAssignableFrom(Type))
34 return Grade.Ok;
35 else
36 return Grade.NotAtAll;
37 }
38
39 private static readonly TypeInfo typeInfo = typeof(IEnumerable<Parameter>).GetTypeInfo();
40
46 public async Task Tokenize(object Value, TokenizationProcess Process)
47 {
48 if (Value is IEnumerable<Parameter> Parameters)
49 await Tokenize(Parameters, null, Process);
50 }
51
58 public static async Task Tokenize(IEnumerable<Parameter> Parameters,
60 {
61 if (!(Parameters is null))
62 {
63 foreach (Parameter Parameter in Parameters)
64 {
66 Process.DocumentIndexOffset++; // Make sure sequences of keywords don't cross element boundaries.
67 }
68 }
69 }
70
75 public Task Prepare(string Definition)
76 {
77 return Task.CompletedTask;
78 }
79
85 public async Task<object> Evaluate(object Instance)
86 {
87 if (Instance is Contract Contract)
88 return Contract.Parameters;
89 else if (Instance is GenericObject Obj)
90 {
91 if (Obj.TryGetFieldValue("Parameters", out object Obj2) &&
92 Obj2 is Array A)
93 {
94 if (A.Length == 0)
95 return Array.Empty<Parameter>();
96
97 ChunkedList<Parameter> Parameters = new ChunkedList<Parameter>(A.Length);
98
99 foreach (object Item in A)
100 {
101 if (Item is GenericObject GenParameter &&
102 await Database.Specialize(GenParameter) is Parameter Parameter)
103 {
104 Parameters.Add(Parameter);
105 }
106 else if (Item is Parameter Parameter2)
107 Parameters.Add(Parameter2);
108 }
109
110 return Parameters;
111 }
112
113 return null;
114 }
115 else if (Instance is IEnumerable<Parameter> Parameters)
116 return Parameters;
117 else
118 return null;
119 }
120 }
121}
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:21
static Task< object > Specialize(GenericObject Object)
Creates a specialized representation of a generic object.
Definition: Database.cs:2483
Contains information about a tokenization process.
uint DocumentIndexOffset
Document Index Offset. Used to identify sequences of tokens in a document.
Generic object. Contains a sequence of properties.
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
Interface for full-text-search tokenizers
Definition: ITokenizer.cs:12
Grade
Grade enumeration
Definition: Grade.cs:7