C# Class ABB.Swum.Utilities.LibFileLoader

Contains various utility functions for loading library data files.
Show file Open project: abb-iss/Swum.NET

Public Methods

Method Description
ReadStemFile ( string path ) : string>.Dictionary

Reads a word stem file and parses it into a dictionary. The file is assumed to contain one entry per line, with each entry of the format "[word] [stem]". If the file contains duplicate entries for a given word, only the last entry will be in the dictionary.

ReadVerbParticleFile ( string path ) : HashSet>.Dictionary

Reads the verb particle file at the given path and reads it into a Dictionary. Each line of the file should be in the format: [verb] [particle]. The returned Dictionary maps a particle to a set of verbs.

ReadWordCount ( string path ) : int>.Dictionary

Reads a word count file and parses it into a dictionary. The file is assumed to contain one entry per line, with each entry of the format "[count] [word]". Count must be a non-negative whole number. If the file contains duplicate entries for a given word, only the last entry will be in the dictionary. Words are converted to lower case before being added to the dictionary.

ReadWordCount ( string path, bool keepOriginalCasing ) : int>.Dictionary

Reads a word count file and parses it into a dictionary. The file is assumed to contain one entry per line, with each entry of the format "[count] [word]". Count must be a non-negative whole number. If the file contains duplicate entries for a given word, only the last entry will be in the dictionary. Words are converted to lower case before being added to the dictionary.

ReadWordCount ( string path, bool keepOriginalCase, Func includeFunction ) : int>.Dictionary

Reads a word count file and parses it into a dictionary. The file is assumed to contain one entry per line, with each entry of the format "[count] [word]". Count must be a non-negative whole number. If the file contains duplicate entries for a given word, only the last entry will be in the dictionary.

ReadWordList ( ) : HashSet

Reads a file containing a list of words, and returns it as a set. The file is assumed to contain a single word on each line. Duplicate words will be ignored. Words are converted to lower case before being added.

ReadWordList ( bool keepOriginalCase ) : HashSet

Reads a file containing a list of words, and returns it as a set. The file is assumed to contain a single word on each line. Duplicate words will be ignored.

WriteWordCount ( int>.Dictionary wordCount, string path ) : void

Writes a word count dictionary to a file. Each dictionary entry is written in the format "[count] [word]".

Method Details

ReadStemFile() public static method

Reads a word stem file and parses it into a dictionary. The file is assumed to contain one entry per line, with each entry of the format "[word] [stem]". If the file contains duplicate entries for a given word, only the last entry will be in the dictionary.
public static ReadStemFile ( string path ) : string>.Dictionary
path string The file to read.
return string>.Dictionary

ReadVerbParticleFile() public static method

Reads the verb particle file at the given path and reads it into a Dictionary. Each line of the file should be in the format: [verb] [particle]. The returned Dictionary maps a particle to a set of verbs.
public static ReadVerbParticleFile ( string path ) : HashSet>.Dictionary
path string The verb particle file to read.
return HashSet>.Dictionary

ReadWordCount() public static method

Reads a word count file and parses it into a dictionary. The file is assumed to contain one entry per line, with each entry of the format "[count] [word]". Count must be a non-negative whole number. If the file contains duplicate entries for a given word, only the last entry will be in the dictionary. Words are converted to lower case before being added to the dictionary.
public static ReadWordCount ( string path ) : int>.Dictionary
path string The file to read.
return int>.Dictionary

ReadWordCount() public static method

Reads a word count file and parses it into a dictionary. The file is assumed to contain one entry per line, with each entry of the format "[count] [word]". Count must be a non-negative whole number. If the file contains duplicate entries for a given word, only the last entry will be in the dictionary. Words are converted to lower case before being added to the dictionary.
public static ReadWordCount ( string path, bool keepOriginalCasing ) : int>.Dictionary
path string The file to read.
keepOriginalCasing bool If True, words are added to the dictionary in their original case. If False, words are converted to lower case.
return int>.Dictionary

ReadWordCount() public static method

Reads a word count file and parses it into a dictionary. The file is assumed to contain one entry per line, with each entry of the format "[count] [word]". Count must be a non-negative whole number. If the file contains duplicate entries for a given word, only the last entry will be in the dictionary.
public static ReadWordCount ( string path, bool keepOriginalCase, Func includeFunction ) : int>.Dictionary
path string The file to read.
keepOriginalCase bool If True, words are added to the dictionary in their original case. If False, words are converted to lower case.
includeFunction Func A function specifying whether or not to include a given entry from the file. /// This takes a string and uint as parameters and returns True if the entry should be included and False otherwise.
return int>.Dictionary

ReadWordList() public static method

Reads a file containing a list of words, and returns it as a set. The file is assumed to contain a single word on each line. Duplicate words will be ignored. Words are converted to lower case before being added.
public static ReadWordList ( ) : HashSet
return HashSet

ReadWordList() public static method

Reads a file containing a list of words, and returns it as a set. The file is assumed to contain a single word on each line. Duplicate words will be ignored.
public static ReadWordList ( bool keepOriginalCase ) : HashSet
keepOriginalCase bool If True, words are added to the set in their original case. If False, words are converted to lower case.
return HashSet

WriteWordCount() public static method

Writes a word count dictionary to a file. Each dictionary entry is written in the format "[count] [word]".
public static WriteWordCount ( int>.Dictionary wordCount, string path ) : void
wordCount int>.Dictionary The word count dictionary to write.
path string The file to write to.
return void