@chaffjs/lang-ja 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/english-run.d.ts.map +1 -1
- package/dist/english-run.js +2 -1
- package/dist/english-run.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/initial-stop.d.ts +23 -0
- package/dist/initial-stop.d.ts.map +1 -0
- package/dist/initial-stop.js +33 -0
- package/dist/initial-stop.js.map +1 -0
- package/dist/list-line.d.ts +12 -1
- package/dist/list-line.d.ts.map +1 -1
- package/dist/list-line.js +79 -11
- package/dist/list-line.js.map +1 -1
- package/dist/pos.d.ts.map +1 -1
- package/dist/pos.js +7 -1
- package/dist/pos.js.map +1 -1
- package/dist/quoted-line-stop.d.ts +4 -0
- package/dist/quoted-line-stop.d.ts.map +1 -0
- package/dist/quoted-line-stop.js +18 -0
- package/dist/quoted-line-stop.js.map +1 -0
- package/lexicons/abbreviation-mention.yaml +9 -0
- package/lexicons/addressee-prefix.yaml +6 -0
- package/lexicons/addressee-title.yaml +35 -0
- package/lexicons/adversative-ga-causal.yaml +11 -0
- package/lexicons/adversative-ga-prefatory.yaml +27 -0
- package/lexicons/alternative-clause-label.yaml +7 -0
- package/lexicons/asker-heading.yaml +14 -0
- package/lexicons/bracket-annotation.yaml +8 -0
- package/lexicons/bracket-width.yaml +6 -0
- package/lexicons/case-party-joiner.yaml +7 -0
- package/lexicons/cited-title-action.yaml +13 -0
- package/lexicons/common-acronym.yaml +7 -1
- package/lexicons/comparative-baseline.yaml +8 -1
- package/lexicons/comparison-marker.yaml +7 -0
- package/lexicons/count-hedge.yaml +5 -0
- package/lexicons/defined-term-group-suffix.yaml +6 -0
- package/lexicons/demonstrative-not-opener.yaml +14 -0
- package/lexicons/empty-intensifier.yaml +2 -0
- package/lexicons/final-period.yaml +27 -0
- package/lexicons/fixed-name-ending.yaml +22 -0
- package/lexicons/headnote-heading.yaml +9 -0
- package/lexicons/honorific-group.yaml +9 -0
- package/lexicons/humble-own-act.yaml +15 -0
- package/lexicons/kanji-known-word.yaml +14 -0
- package/lexicons/licence-word.yaml +7 -0
- package/lexicons/line-head-tag.yaml +10 -0
- package/lexicons/link-label-ending.yaml +11 -0
- package/lexicons/list-conjunction.yaml +13 -0
- package/lexicons/list-note-lead.yaml +2 -0
- package/lexicons/list-suffix.yaml +6 -0
- package/lexicons/necessity-purpose.yaml +13 -0
- package/lexicons/neutral-request.yaml +9 -0
- package/lexicons/newsletter-issue.yaml +10 -0
- package/lexicons/ngram-fixed-ending.yaml +9 -0
- package/lexicons/notice-header.yaml +10 -0
- package/lexicons/numbering-counter.yaml +13 -0
- package/lexicons/organisation-unit.yaml +2 -0
- package/lexicons/orthographic-variant-comparative.yaml +8 -0
- package/lexicons/orthographic-variant-conjunction.yaml +4 -0
- package/lexicons/orthographic-variant-distinct.yaml +5 -0
- package/lexicons/orthographic-variant-idiom.yaml +3 -0
- package/lexicons/orthographic-variant-judging.yaml +11 -0
- package/lexicons/orthographic-variant-katakana-sense.yaml +8 -0
- package/lexicons/orthographic-variant-two-readings.yaml +14 -0
- package/lexicons/orthographic-variant-voice.yaml +8 -0
- package/lexicons/orthographic-variant-whole-word.yaml +6 -0
- package/lexicons/placeholder-division.yaml +8 -0
- package/lexicons/placeholder-word.yaml +63 -1
- package/lexicons/prepositive-abbreviation.yaml +9 -0
- package/lexicons/quoted-wording-cue.yaml +14 -0
- package/lexicons/range-kana-unit.yaml +16 -0
- package/lexicons/reference-prefix.yaml +12 -0
- package/lexicons/rejected-wording.yaml +18 -0
- package/lexicons/relative-start.yaml +8 -0
- package/lexicons/request-deadline-section.yaml +12 -0
- package/lexicons/request-prohibition.yaml +9 -0
- package/lexicons/requirement-open-end.yaml +8 -0
- package/lexicons/sentence-start-word.yaml +59 -0
- package/lexicons/spelling-mention.yaml +9 -0
- package/lexicons/superlative-owner.yaml +6 -0
- package/lexicons/superlative-phrase.yaml +13 -0
- package/lexicons/superlative-suffix.yaml +5 -0
- package/lexicons/telling-cue.yaml +12 -0
- package/lexicons/term-source-marker.yaml +11 -0
- package/lexicons/title-ending.yaml +13 -1
- package/package.json +1 -1
- package/src/english-run.ts +2 -1
- package/src/index.ts +13 -4
- package/src/initial-stop.ts +58 -0
- package/src/list-line.ts +102 -13
- package/src/pos.ts +14 -1
- package/src/quoted-line-stop.ts +20 -0
package/src/pos.ts
CHANGED
|
@@ -161,7 +161,10 @@ const toToken = (morpheme: Morpheme, start: number, { passive, echo, light, raDr
|
|
|
161
161
|
pos: isPassiveForm(morpheme) ? "AUX" : upos(morpheme.pos, morpheme.pos_detail_1),
|
|
162
162
|
...(morpheme.basic_form === "*" ? {} : { lemma: morpheme.basic_form }),
|
|
163
163
|
...(typeof morpheme.reading !== "string" || morpheme.reading === "*" ? {} : { reading: morpheme.reading }),
|
|
164
|
-
...
|
|
164
|
+
...withAdverbial(
|
|
165
|
+
withRaDropped(withEcho(withWordStatus(featuresOf(morpheme, passive), isBound(morpheme), light), echo), raDropped),
|
|
166
|
+
isAdverbialNoun(morpheme),
|
|
167
|
+
),
|
|
165
168
|
});
|
|
166
169
|
|
|
167
170
|
/**
|
|
@@ -195,6 +198,16 @@ const withEcho = (found: { features?: Readonly<Record<string, string>> }, echo:
|
|
|
195
198
|
const withRaDropped = (found: { features?: Readonly<Record<string, string>> }, raDropped: boolean): { features?: Readonly<Record<string, string>> } =>
|
|
196
199
|
raDropped ? { features: { ...found.features, PotentialRa: "Dropped" } } : found;
|
|
197
200
|
|
|
201
|
+
/**
|
|
202
|
+
* 副詞としても使える名詞(IPADIC の「副詞可能」: 今夜・当日・午前、その日の「日」、午前中の「中」)。今夜は来る、のように助詞なしで
|
|
203
|
+
* 時や量を言える。日本語に固有の印で、UD の FEATS の言語別拡張。非自立名詞や接尾の印はそのまま残す。
|
|
204
|
+
*/
|
|
205
|
+
const isAdverbialNoun = (morpheme: Morpheme): boolean =>
|
|
206
|
+
morpheme.pos === "名詞" && (morpheme.pos_detail_1 === "副詞可能" || morpheme.pos_detail_2 === "副詞可能");
|
|
207
|
+
|
|
208
|
+
const withAdverbial = (found: { features?: Readonly<Record<string, string>> }, adverbial: boolean): { features?: Readonly<Record<string, string>> } =>
|
|
209
|
+
adverbial ? { features: { ...found.features, Adverbial: "Yes" } } : found;
|
|
210
|
+
|
|
198
211
|
/**
|
|
199
212
|
* 数(名詞,数)。UPOS では名詞に寄せるので、数であることは UD の NumType=Card で渡す。
|
|
200
213
|
* 決まった言い回し(二人三脚、三日坊主、一人ひとり、十分)は辞書が一語として持つので、数にはならない。
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Span } from "chaffjs/plugin";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 句点で閉じた引用が行の終わりにあるとき(「…こたえる。」の後で改行)、分割器は括弧の組の後ろで文を切らず、次の行の文まで
|
|
5
|
+
* 一つの文にする。演説や宣誓の引用を一行ずつ置いた文書では、次の行は別の文である。
|
|
6
|
+
* 文末の記号 + 閉じ括弧 + 改行で切る。次の行が「と」や読点で始まるもの(「…。」\nと述べた)は引用が文の途中にあるので切らない。
|
|
7
|
+
*/
|
|
8
|
+
const QUOTE_AT_LINE_END = /[。.!?!?][」』))】〉》]\]]+[ \t\u3000]*(?=\r?\n)/gu;
|
|
9
|
+
const CONTINUES = /^\s*[と、,。」』))]/u;
|
|
10
|
+
|
|
11
|
+
/** span の文を、行の終わりで閉じた引用ごとに分けた span。切れ目が無ければ span そのもの一つ。 */
|
|
12
|
+
export const splitAtQuotedLineEnds = (text: string, span: Span): Span[] => {
|
|
13
|
+
const sentence = text.slice(span.start, span.end);
|
|
14
|
+
const cuts = [...sentence.matchAll(QUOTE_AT_LINE_END)]
|
|
15
|
+
.map((match) => match.index + match[0].length)
|
|
16
|
+
.filter((end) => !CONTINUES.test(sentence.slice(end)) && sentence.slice(end).trim() !== "");
|
|
17
|
+
const starts = [0, ...cuts.map((end) => end + (/^\s+/u.exec(sentence.slice(end))?.[0].length ?? 0))];
|
|
18
|
+
const ends = [...cuts, sentence.length];
|
|
19
|
+
return starts.map((start, index) => ({ start: span.start + start, end: span.start + (ends[index] ?? start) }));
|
|
20
|
+
};
|