Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MarkdownTokenizer.cs
1using System;
2using System.Text;
3using System.Threading.Tasks;
4using Waher.Content;
10
12{
17 {
22 {
23 }
24
30 public Grade Supports(Type Type)
31 {
32 if (Type == typeof(MarkdownDocument))
33 return Grade.Ok;
34 else
35 return Grade.NotAtAll;
36 }
37
43 public Grade Supports(string Extension)
44 {
45 if (Extension == "md")
46 return Grade.Ok;
47 else
48 return Grade.NotAtAll;
49 }
50
56 public async Task Tokenize(object Value, TokenizationProcess Process)
57 {
58 if (Value is MarkdownDocument Doc)
59 await Tokenize(Doc, Process);
60 }
61
67 public static async Task Tokenize(MarkdownDocument Doc, TokenizationProcess Process)
68 {
69 StringBuilder sb = new StringBuilder();
70
71 Append(sb, Doc.Description);
72 Append(sb, Doc.Author);
73 Append(sb, Doc.Keywords);
74 Append(sb, Doc.Subtitle);
75 Append(sb, Doc.Title);
76
77 await Doc.GeneratePlainText(sb);
78 StringTokenizer.Tokenize(sb.ToString(), Process);
79 }
80
81 private static void Append(StringBuilder sb, string[] Strings)
82 {
83 if (!(Strings is null))
84 {
85 foreach (string s in Strings)
86 sb.AppendLine(s);
87 }
88 }
89
95 public async Task Tokenize(FileReference Reference, TokenizationProcess Process)
96 {
97 string Text = await Resources.ReadAllTextAsync(Reference.FileName);
99
100 await Tokenize(Doc, Process);
101 }
102 }
103}
Contains a markdown document. This markdown document class supports original markdown,...
string[] Author
Author(s) of document.
string[] Subtitle
Subtitle of document.
string[] Description
Description of document.
async Task< string > GeneratePlainText()
Generates Plain Text from the markdown text.
static Task< MarkdownDocument > CreateAsync(string MarkdownText, params Type[] TransparentExceptionTypes)
Contains a markdown document. This markdown document class supports original markdown,...
Static class managing loading of resources stored as embedded resources or in content files.
Definition: Resources.cs:15
static async Task< string > ReadAllTextAsync(string FileName)
Reads a text file asynchronously.
Definition: Resources.cs:205
Tokenizes contents defined in a Markdown document.
Grade Supports(string Extension)
How well the file tokenizer supports files of a given extension.
Grade Supports(Type Type)
If the interface understands objects such as Type .
static async Task Tokenize(MarkdownDocument Doc, TokenizationProcess Process)
Tokenizes a Markdown document.
MarkdownTokenizer()
Tokenizes contents defined in a Markdown document.
async Task Tokenize(FileReference Reference, TokenizationProcess Process)
Tokenizes an object.
async Task Tokenize(object Value, TokenizationProcess Process)
Tokenizes an object.
Contains a reference to an indexed file.
CaseInsensitiveString FileName
Name of collection hosting object.
Task Tokenize(object Value, TokenizationProcess Process)
Tokenizes an object.
Contains information about a tokenization process.
Interface for file tokenizers. Best tokenizer is selected
Interface for full-text-search tokenizers
Definition: ITokenizer.cs:12
Grade
Grade enumeration
Definition: Grade.cs:7