1 Commits

Author SHA1 Message Date
kazuki
dd07b763f4 fix: vocabulary export (#152)
* fix: vocabulary export

* fix: export only plain phrase
2024-12-06 12:48:30 +01:00

View File

@@ -43,7 +43,7 @@
buildIndex($chords, $osLayout).then(searchIndex.set);
});
function encodeChord(chord: ChordInfo, osLayout: Map<string, string>) {
function encodeChord(chord: ChordInfo, osLayout: Map<string, string>, onlyPhrase: boolean = false) {
const plainPhrase: string[] = [""];
const extraActions: string[] = [];
const extraCodes: string[] = [];
@@ -103,6 +103,10 @@
return result ?? `0x${it.toString(16)}`;
});
if (onlyPhrase) {
return plainPhrase.join();
}
return [
...plainPhrase,
`+${input.join("+")}`,
@@ -182,7 +186,7 @@
function downloadVocabulary() {
const vocabulary = new Set(
$chords.map((it) =>
"phrase" in it ? plainPhrase(it.phrase, $osLayout).trim() : "",
"phrase" in it ? encodeChord(it, $osLayout, true).trim() : "",
),
);
vocabulary.delete("");