|
1 | | -import { compound, throwError } from "../../misc/misc.ts"; |
| 1 | +import { throwError } from "../../misc/misc.ts"; |
2 | 2 | import { extractResultError } from "../compound.ts"; |
3 | | -import { settings } from "../settings.ts"; |
4 | 3 | import { |
5 | 4 | Clause, |
6 | 5 | ContextClause, |
@@ -121,50 +120,6 @@ export const MULTIPLE_MODIFIERS_RULES: ReadonlyArray< |
121 | 120 | (modifiers) => |
122 | 121 | modifiers.filter(modifierIsNumeric).length <= 1 || |
123 | 122 | 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 | | - }, |
168 | 123 | ]; |
169 | 124 | export const PHRASE_RULES: ReadonlyArray<(phrase: Phrase) => boolean> = [ |
170 | 125 | // disallow preverb modifiers other than "ala" |
@@ -427,15 +382,3 @@ function phraseHasTopLevelEmphasis(phrase: Phrase) { |
427 | 382 | return phrase.emphasis != null; |
428 | 383 | } |
429 | 384 | } |
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 | | -} |
0 commit comments