Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PageMetaDataTokenizer.cs
1using System;
2using System.Text;
3using System.Threading.Tasks;
9
11{
16 {
21 {
22 }
23
29 public Grade Supports(Type Type)
30 {
31 if (Type == typeof(PageMetaData))
32 return Grade.Ok;
33 else
34 return Grade.NotAtAll;
35 }
36
42 public async Task Tokenize(object Value, TokenizationProcess Process)
43 {
44 if (Value is PageMetaData Data)
45 await Tokenize(Data, Process);
46 }
47
53 public static Task Tokenize(PageMetaData Data, TokenizationProcess Process)
54 {
55 StringBuilder sb = new StringBuilder();
56 bool First = true;
57
58 Append(sb, ref First, Data.Determiner);
59 Append(sb, ref First, Data.Title);
60 Append(sb, ref First, Data.Description);
61 Append(sb, ref First, Data.SiteName);
62 Append(sb, ref First, Data.Locale);
63 Append(sb, ref First, Data.LocaleAlternate);
64
65 if (!(Data.Images is null))
66 {
67 foreach (ImageInformation Info in Data.Images)
68 Append(sb, ref First, Info.Description);
69 }
70
71 StringTokenizer.Tokenize(sb.ToString(), Process);
72
73 return Task.CompletedTask;
74 }
75
76 private static void Append(StringBuilder Text, ref bool First, string[] Value)
77 {
78 if (!(Value is null))
79 {
80 foreach (string s in Value)
81 Append(Text, ref First, s);
82 }
83 }
84
85 private static void Append(StringBuilder Text, ref bool First, string Value)
86 {
87 if (!string.IsNullOrEmpty(Value))
88 {
89 if (First)
90 First = false;
91 else
92 Text.Append(' ');
93
94 Text.Append(Value);
95 }
96 }
97 }
98}
Image information, as defined by the Open Graph protocol.
string Description
A description of what is in the image (not a caption). If not defined, null is returned.
Contains meta-data about a page.
Definition: PageMetaData.cs:17
ImageInformation[] Images
Image representing page.
string Description
A description of the page.
string Title
Title of page.
string Determiner
A word that appears before the title.
string Locale
Locale of information.
string SiteName
Name of web site publishing page
string[] LocaleAlternate
Alternate locales
Tokenizes meta-data information about some Internet Content.
static Task Tokenize(PageMetaData Data, TokenizationProcess Process)
Tokenizes an HTML document.
Grade Supports(Type Type)
If the interface understands objects such as Type .
async Task Tokenize(object Value, TokenizationProcess Process)
Tokenizes an object.
PageMetaDataTokenizer()
Tokenizes meta-data information about some Internet Content.
Task Tokenize(object Value, TokenizationProcess Process)
Tokenizes an object.
Contains information about a tokenization process.
Interface for full-text-search tokenizers
Definition: ITokenizer.cs:12
Grade
Grade enumeration
Definition: Grade.cs:7