Skip to content

Commit 21c4236

Browse files
committed
capitalization support, lowerCaseMode toggleable
1 parent 28d3981 commit 21c4236

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/components/EditableDocument/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const colourStyles = {
7272
export default function EditableDocument({
7373
initialText = "",
7474
onChange,
75+
lowerCaseMode = false,
7576
phraseBank = [],
7677
validator = () => []
7778
}: {
@@ -109,7 +110,7 @@ export default function EditableDocument({
109110

110111
const loadOptions = async text => {
111112
let bestOption
112-
text = text.toLowerCase()
113+
if (lowerCaseMode) text = text.toLowerCase()
113114
const scRes = spellChecker.lookup(text)
114115
if (scRes.found || phraseBank.includes(text))
115116
return [createOption(text, green[500])]

src/components/Transcriber/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default ({
88
initialTranscriptionText,
99
onChange,
1010
audio,
11+
lowerCaseMode,
1112
phraseBank: phraseBankParam,
1213
validator
1314
}: TranscriberProps) => {
@@ -28,7 +29,7 @@ export default ({
2829
p.startsWith("http") && (p.endsWith(".txt") || p.endsWith(".csv"))
2930
)
3031
) {
31-
const fullPhraseBank = []
32+
let fullPhraseBank = []
3233
for (const url of phraseBankParam) {
3334
let found
3435
const saveName = `NLP_ANNOTATOR_PHRASE_BANK_${url}`
@@ -39,13 +40,16 @@ export default ({
3940
} catch (e) {}
4041
}
4142
if (!found) {
42-
const urlPhrases = (await fetch(url).then(res => res.text()))
43-
.split("\n")
44-
.map(a => a.trim().toLowerCase())
43+
const urlPhrases = (await fetch(url).then(res => res.text())).split(
44+
"\n"
45+
)
4546
window.localStorage[saveName] = JSON.stringify(urlPhrases)
4647
fullPhraseBank.push(...urlPhrases)
4748
}
4849
}
50+
if (lowerCaseMode) {
51+
fullPhraseBank = fullPhraseBank.map(a => a.toLowerCase())
52+
}
4953
changePhraseBank(fullPhraseBank)
5054
} else if (Array.isArray(phraseBankParam)) {
5155
changePhraseBank(phraseBankParam)

0 commit comments

Comments
 (0)