explicit checks in while and if
This commit is contained in:
parent
1f2eee449e
commit
b02a30a2fd
@ -84,7 +84,7 @@ async function apiTextParse(text, optionsContext) {
|
|||||||
const translator = utilBackend().translator;
|
const translator = utilBackend().translator;
|
||||||
|
|
||||||
const results = [];
|
const results = [];
|
||||||
while (text) {
|
while (text.length > 0) {
|
||||||
const term = [];
|
const term = [];
|
||||||
const [definitions, sourceLength] = await translator.findTerms(text, {}, options);
|
const [definitions, sourceLength] = await translator.findTerms(text, {}, options);
|
||||||
if (definitions.length > 0) {
|
if (definitions.length > 0) {
|
||||||
@ -116,7 +116,7 @@ async function apiTextParseMecab(text, optionsContext) {
|
|||||||
for (const parsedLine of rawResults[mecabName]) {
|
for (const parsedLine of rawResults[mecabName]) {
|
||||||
for (const {expression, reading, source} of parsedLine) {
|
for (const {expression, reading, source} of parsedLine) {
|
||||||
const term = [];
|
const term = [];
|
||||||
if (expression && reading) {
|
if (expression !== null && reading !== null) {
|
||||||
for (const {text, furigana} of jpDistributeFuriganaInflected(
|
for (const {text, furigana} of jpDistributeFuriganaInflected(
|
||||||
expression,
|
expression,
|
||||||
jpKatakanaToHiragana(reading),
|
jpKatakanaToHiragana(reading),
|
||||||
|
@ -122,7 +122,7 @@ class QueryParser {
|
|||||||
|
|
||||||
async setPreview(text) {
|
async setPreview(text) {
|
||||||
const previewTerms = [];
|
const previewTerms = [];
|
||||||
while (text) {
|
while (text.length > 0) {
|
||||||
const tempText = text.slice(0, 2);
|
const tempText = text.slice(0, 2);
|
||||||
previewTerms.push([{text: Array.from(tempText)}]);
|
previewTerms.push([{text: Array.from(tempText)}]);
|
||||||
text = text.slice(2);
|
text = text.slice(2);
|
||||||
|
Loading…
Reference in New Issue
Block a user