Microsoft.Bot.Builder.FormFlow.Advanced.Language Class Reference

Language related utilities. More...

Static Public Member Functions

static string ANormalization (string input)
 Switch 'a' before consonants and 'an' before vowels. More...
 
static bool ArticleOrNone (string word)
 Test a word for articles or noise. More...
 
static string BuildList (IEnumerable< string > values, string separator, string lastSeparator)
 Given a list of string values generate a proper English list. More...
 
static string CamelCase (string original)
 Break a string into words based on _ and case changes. More...
 
static string[] GenerateTerms (string phrase, int maxLength)
 Generate regular expressions to match word sequences in original string. More...
 
static bool NoiseResponse (string word)
 Test to see if a word can be ignored in a resposne. More...
 
static bool NoiseWord (string word)
 Test to see if a word is all noise. More...
 
static IEnumerable< string > NonNoiseWords (IEnumerable< string > words)
 Test words to see if they are all ignorable in a response. More...
 
static bool NonWord (string word)
 Test to see if word is all punctuation or white space. More...
 
static string Normalize (string value, CaseNormalization normalization)
 Normalize a string. More...
 
static IEnumerable< string > OptionalPlurals (IEnumerable< string > words)
 Make sure all words end with an optional s. More...
 
static IEnumerable< string > WordBreak (string input)
 Break input into words. More...
 

Static Public Attributes

static HashSet< string > Articles = new HashSet<string>(Resources.LanguageArticles.SplitList())
 Language articles. More...
 
static HashSet< string > StopWords = new HashSet<string>(Resources.LanguageStopWords.SplitList())
 Language stop words. More...
 
static Regex WordBreaker = new Regex(@"\w+", RegexOptions.Compiled)
 Regular expression to break a string into words. More...
 

Detailed Description

Language related utilities.

Definition at line 46 of file Language.cs.

Member Function Documentation

static string Microsoft.Bot.Builder.FormFlow.Advanced.Language.ANormalization ( string  input)
inlinestatic

Switch 'a' before consonants and 'an' before vowels.

Parameters
inputString to fix.
Returns
String with 'a' and 'an' normalized.

This is not perfect because English is complex, but does a reasonable job.

Definition at line 247 of file Language.cs.

static bool Microsoft.Bot.Builder.FormFlow.Advanced.Language.ArticleOrNone ( string  word)
inlinestatic

Test a word for articles or noise.

Parameters
wordWord to test.
Returns
True if word is NonWord(string) or Articles.

Definition at line 108 of file Language.cs.

static string Microsoft.Bot.Builder.FormFlow.Advanced.Language.BuildList ( IEnumerable< string >  values,
string  separator,
string  lastSeparator 
)
inlinestatic

Given a list of string values generate a proper English list.

Parameters
valuesValue in list.
separatorSeparator between all elements except last.
lastSeparatorLast element separator.
Returns
Value in a proper English list.

Definition at line 283 of file Language.cs.

static string Microsoft.Bot.Builder.FormFlow.Advanced.Language.CamelCase ( string  original)
inlinestatic

Break a string into words based on _ and case changes.

Parameters
originalOriginal string.
Returns
String with words on case change or _ boundaries.

Definition at line 146 of file Language.cs.

static string [] Microsoft.Bot.Builder.FormFlow.Advanced.Language.GenerateTerms ( string  phrase,
int  maxLength 
)
inlinestatic

Generate regular expressions to match word sequences in original string.

Parameters
phraseOriginal string to be processed.
maxLengthMaximum phrase length to support.
Returns
Array of regular expressions to match subsequences in input.

This function will call CamelCase(string) and then will generate sub-phrases up to maxLength. For example an enumeration of AngusBeefAndGarlicPizza would generate: 'angus?', 'beefs?', 'garlics?', 'pizzas?', 'angus? beefs?', 'garlics? pizzas?' and 'angus beef and garlic pizza'. You can call it directly, or it is used when FieldReflector<T> generates terms or when TermsAttribute is used with a TermsAttribute.MaxPhrase argument.

Definition at line 215 of file Language.cs.

static bool Microsoft.Bot.Builder.FormFlow.Advanced.Language.NoiseResponse ( string  word)
inlinestatic

Test to see if a word can be ignored in a resposne.

Parameters
wordWord to test.
Returns
True if word is a NonWord(string) or a StopWords.

Definition at line 96 of file Language.cs.

static bool Microsoft.Bot.Builder.FormFlow.Advanced.Language.NoiseWord ( string  word)
inlinestatic

Test to see if a word is all noise.

Parameters
wordWord to test.
Returns
True if word is a number, a NonWord(string) or a StopWords.

Definition at line 82 of file Language.cs.

static IEnumerable<string> Microsoft.Bot.Builder.FormFlow.Advanced.Language.NonNoiseWords ( IEnumerable< string >  words)
inlinestatic

Test words to see if they are all ignorable in a response.

Parameters
words
Returns

Definition at line 118 of file Language.cs.

static bool Microsoft.Bot.Builder.FormFlow.Advanced.Language.NonWord ( string  word)
inlinestatic

Test to see if word is all punctuation or white space.

Parameters
wordWord to check.
Returns
True if word is all punctuation or white space.

Definition at line 63 of file Language.cs.

static string Microsoft.Bot.Builder.FormFlow.Advanced.Language.Normalize ( string  value,
CaseNormalization  normalization 
)
inlinestatic

Normalize a string.

Parameters
valueThe value to normalize.
normalizationThe normalization to apply.
Returns
A normalized string.

Definition at line 304 of file Language.cs.

static IEnumerable<string> Microsoft.Bot.Builder.FormFlow.Advanced.Language.OptionalPlurals ( IEnumerable< string >  words)
inlinestatic

Make sure all words end with an optional s.

Parameters
wordsWords to pluralize.
Returns
Enumeration of plural word regex.

Definition at line 189 of file Language.cs.

static IEnumerable<string> Microsoft.Bot.Builder.FormFlow.Advanced.Language.WordBreak ( string  input)
inlinestatic

Break input into words.

Parameters
inputString to be broken.
Returns
Enumeration of words.

Definition at line 133 of file Language.cs.

Member Data Documentation

HashSet<string> Microsoft.Bot.Builder.FormFlow.Advanced.Language.Articles = new HashSet<string>(Resources.LanguageArticles.SplitList())
static

Language articles.

Definition at line 56 of file Language.cs.

HashSet<string> Microsoft.Bot.Builder.FormFlow.Advanced.Language.StopWords = new HashSet<string>(Resources.LanguageStopWords.SplitList())
static

Language stop words.

Definition at line 51 of file Language.cs.

Regex Microsoft.Bot.Builder.FormFlow.Advanced.Language.WordBreaker = new Regex(@"\w+", RegexOptions.Compiled)
static

Regular expression to break a string into words.

Definition at line 126 of file Language.cs.


The documentation for this class was generated from the following file: