Skip to content

Commit

Permalink
chore(developer): removes indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jahorton committed Aug 2, 2024
1 parent aa37f20 commit f28f7b9
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions developer/src/kmc-model/src/build-trie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,40 +187,40 @@ function* enumerateLines(lines: string[]): Generator<LineNoAndText> {
}
}

/**
* An **opaque** type for a string that is exclusively used as a search key in
* the trie. There should be a function that converts arbitrary strings
* (queries) and converts them into a standard search key for a given language
* model.
*
* Fun fact: This opaque type has ALREADY saved my bacon and found a bug!
*/
type SearchKey = string & { _: 'SearchKey'};

/**
* A function that converts a string (word form or query) into a search key
* (secretly, this is also a string).
*/
export interface SearchTermToKey {
(wordform: string): SearchKey;
}
/**
* An **opaque** type for a string that is exclusively used as a search key in
* the trie. There should be a function that converts arbitrary strings
* (queries) and converts them into a standard search key for a given language
* model.
*
* Fun fact: This opaque type has ALREADY saved my bacon and found a bug!
*/
type SearchKey = string & { _: 'SearchKey'};

/**
* Builds a trie from a word list.
*
* @param wordlist The wordlist with non-negative weights.
* @param keyFunction Function that converts word forms into indexed search keys
* @returns A JSON-serialiable object that can be given to the TrieModel constructor.
*/
export function buildTrie(wordlist: WordList, keyFunction: SearchTermToKey): object {
let collater = new TrieBuilder(keyFunction);

buildFromWordList(collater, wordlist, keyFunction);
return {
totalWeight: collater.getTotalWeight(),
root: collater.getRoot()
}
/**
* A function that converts a string (word form or query) into a search key
* (secretly, this is also a string).
*/
export interface SearchTermToKey {
(wordform: string): SearchKey;
}

/**
* Builds a trie from a word list.
*
* @param wordlist The wordlist with non-negative weights.
* @param keyFunction Function that converts word forms into indexed search keys
* @returns A JSON-serialiable object that can be given to the TrieModel constructor.
*/
export function buildTrie(wordlist: WordList, keyFunction: SearchTermToKey): object {
let collater = new TrieBuilder(keyFunction);

buildFromWordList(collater, wordlist, keyFunction);
return {
totalWeight: collater.getTotalWeight(),
root: collater.getRoot()
}
}

/**
* Populates the trie with the contents of an entire wordlist.
Expand Down

0 comments on commit f28f7b9

Please sign in to comment.