Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
WildcardKeyword.cs
2using System.Text.RegularExpressions;
3using System.Threading.Tasks;
5
7{
12 {
17 public WildcardKeyword(string Keyword)
18 : this(Keyword + "*", "*")
19 {
20 }
21
27 public WildcardKeyword(string Keyword, string Wildcard)
28 : base(Database.WildcardToRegex(Keyword, Wildcard))
29 {
30 this.Keyword = Keyword;
31 this.Wildcard = Wildcard;
32 }
33
37 public string Keyword { get; }
38
42 public string Wildcard { get; }
43
47 public override int OrderComplexity => this.Keyword.Length;
48
50 public override bool Equals(object obj)
51 {
52 return obj is WildcardKeyword k && this.Keyword == k.Keyword && this.Wildcard == k.Wildcard;
53 }
54
56 public override string ToString()
57 {
58 return this.Keyword;
59 }
60
66 public override async Task<IEnumerable<KeyValuePair<string, TokenReferences>>> GetTokenReferences(SearchProcess Process)
67 {
68 int i = this.Keyword.IndexOf(this.Wildcard);
69 if (i <= 0)
70 return await base.GetTokenReferences(Process);
71
72 string Preamble = this.Keyword.Substring(0, i);
73 char[] Characters = Preamble.ToCharArray();
74 Characters[i - 1]++;
75 string ToExclusive = new string(Characters);
76
78 KeyValuePair<string, object>[] Records = await Process.Index.GetEntriesAsync(Preamble, ToExclusive);
79
80 foreach (KeyValuePair<string, object> Rec in Records)
81 {
82 Match M = this.Parsed.Match(Rec.Key);
83 if (M.Success && M.Index == 0 && M.Length == Rec.Key.Length && Rec.Value is TokenReferences References)
84 Result.Add(new KeyValuePair<string, TokenReferences>(Rec.Key, References));
85 }
86
87 return Result;
88 }
89 }
90}
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:21
Abstract base class for keywords.
Definition: Keyword.cs:11
virtual async Task< bool > Process(SearchProcess Process)
Processes the keyword in a search process.
Definition: Keyword.cs:67
abstract Task< IEnumerable< KeyValuePair< string, TokenReferences > > > GetTokenReferences(SearchProcess Process)
Gets available token references.
Contains information about a search process.
WildcardKeyword(string Keyword)
Represents a plain keyword, where keyword acts as a prefix.
WildcardKeyword(string Keyword, string Wildcard)
Represents a wildcard keyword.
override async Task< IEnumerable< KeyValuePair< string, TokenReferences > > > GetTokenReferences(SearchProcess Process)
Gets available token references.
override int OrderComplexity
Order complexity (within category) of keyword
Contains a sequence of object references that include the token in its indexed text properties.
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54