Skip to content

Commit 4e2480e

Browse files
committed
remove unnecessary setting
1 parent 2de43e5 commit 4e2480e

File tree

3 files changed

+1
-61
lines changed

3 files changed

+1
-61
lines changed

src/parser/filter.ts

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { compound, throwError } from "../../misc/misc.ts";
1+
import { throwError } from "../../misc/misc.ts";
22
import { extractResultError } from "../compound.ts";
3-
import { settings } from "../settings.ts";
43
import {
54
Clause,
65
ContextClause,
@@ -121,50 +120,6 @@ export const MULTIPLE_MODIFIERS_RULES: ReadonlyArray<
121120
(modifiers) =>
122121
modifiers.filter(modifierIsNumeric).length <= 1 ||
123122
throwError(new UnrecognizedError("multiple number words")),
124-
125-
// disallow duplicate modifiers when disabled by settings
126-
(modifiers) => {
127-
if (settings.separateRepeatedModifiers) {
128-
return true;
129-
} else {
130-
const words = modifiers.flatMap((modifier) => {
131-
switch (modifier.type) {
132-
case "simple":
133-
if (modifier.word.type !== "number") {
134-
return [modifier.word.word];
135-
} else {
136-
return [];
137-
}
138-
case "pi":
139-
if (
140-
modifier.phrase.type === "simple" &&
141-
modifier.phrase.headWord.type !== "number"
142-
) {
143-
return [modifier.phrase.headWord.word];
144-
} else {
145-
return [];
146-
}
147-
case "name":
148-
case "nanpa":
149-
return [];
150-
}
151-
});
152-
const duplicate = getDuplicate(words);
153-
if (duplicate.size === 0) {
154-
return true;
155-
} else {
156-
const repeatConjunction = false;
157-
const list = compound(
158-
[...duplicate].map((word) => `"${word}"`),
159-
"and",
160-
repeatConjunction,
161-
);
162-
throw new UnrecognizedError(
163-
`duplicate ${list} in modifier`,
164-
);
165-
}
166-
}
167-
},
168123
];
169124
export const PHRASE_RULES: ReadonlyArray<(phrase: Phrase) => boolean> = [
170125
// disallow preverb modifiers other than "ala"
@@ -427,15 +382,3 @@ function phraseHasTopLevelEmphasis(phrase: Phrase) {
427382
return phrase.emphasis != null;
428383
}
429384
}
430-
function getDuplicate<T>(iterable: Iterable<T>) {
431-
const unique: Set<T> = new Set();
432-
const duplicates: Set<T> = new Set();
433-
for (const value of iterable) {
434-
if (unique.has(value)) {
435-
duplicates.add(value);
436-
} else {
437-
unique.add(value);
438-
}
439-
}
440-
return duplicates;
441-
}

src/settings.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export type Settings = {
88
quantity: Redundancy;
99
tense: Redundancy;
1010
xAlaXPartialParsing: boolean;
11-
separateRepeatedModifiers: boolean;
1211
};
1312
// the default value may change, also change `index.html`
1413
export const defaultSettings: Readonly<Settings> = Object.freeze({
@@ -18,7 +17,6 @@ export const defaultSettings: Readonly<Settings> = Object.freeze({
1817
quantity: "both",
1918
tense: "both",
2019
xAlaXPartialParsing: false,
21-
separateRepeatedModifiers: false,
2220
});
2321
// this global constant is mutable
2422
export const settings: Settings = Object.seal({ ...defaultSettings });

src/settings_frontend.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const UPDATERS: Readonly<{ [K in keyof Settings]: Updater<Settings[K]> }> = {
4545
quantity: REDUNDANCY_UPDATER,
4646
tense: REDUNDANCY_UPDATER,
4747
xAlaXPartialParsing: BOOL_UPDATER,
48-
separateRepeatedModifiers: BOOL_UPDATER,
4948
};
5049
const KEYS = Object.keys(UPDATERS) as ReadonlyArray<keyof Settings>;
5150

0 commit comments

Comments
 (0)