From f609f09e89dd93ae78e28a17fb890fbec3068b8f Mon Sep 17 00:00:00 2001 From: isamu Date: Mon, 30 Nov 2026 08:04:45 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20topic-predicate-distance=20reads=20?= =?UTF-8?q?=E3=80=9C=E3=81=AB=E3=81=A4=E3=81=84=E3=81=A6=E3=81=AF=20as=20a?= =?UTF-8?q?=20later=20clause's=20own=20topic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../chaff/rules/topic-predicate-distance.yaml | 6 ++--- .../src/detectors/topic-predicate-distance.ts | 3 ++- text/packages/chaff/src/topic-clause.ts | 26 +++++++++++++------ .../lexicons/topic-phrase-particle.yaml | 7 +++++ text/test/test_topic_predicate_distance.ts | 12 +++++++++ 5 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 text/packages/lang-ja/lexicons/topic-phrase-particle.yaml diff --git a/text/packages/chaff/rules/topic-predicate-distance.yaml b/text/packages/chaff/rules/topic-predicate-distance.yaml index e53c5612c..91c06daff 100644 --- a/text/packages/chaff/rules/topic-predicate-distance.yaml +++ b/text/packages/chaff/rules/topic-predicate-distance.yaml @@ -3,7 +3,7 @@ layer: L3 status: stable how_to_find: topic-predicate-distance requires: [pos] -extra_word_lists: [topic-clause-close, statute-article-opener, topic-adverb] +extra_word_lists: [topic-clause-close, statute-article-opener, topic-adverb, topic-phrase-particle] languages: [ja] severity: info @@ -45,8 +45,8 @@ example: 来週は、新しい担当者の紹介、先月から続く予算の見直し、春の本社移転の準備、秋の採用計画の確認、年末の懇親会の段取りを話し合います。そのため定例会議は二時間に延長します。 not_flagged: - ja: 主題(名詞+は)の無い文、鉤括弧で引いたものの中、上限までの距離は見ません。主題の述語が先の節で閉じる文(「この計画は簡単ではありませんが、…」「〜であって、…」、後ろの節に別の主語がある「〜ではなく、」「〜であるため、」「〜の想定のため、」(後ろが話し手の頼み(〜していただけると、〜いただきたい)でもよい)「〜であり、」(主題との間に別の主題(〜は)が無く、文末がまた繋辞か「〜がある」でないとき。主題が行いを名詞にしたもの(〜することは重要であり、…影響を及ぼす可能性があります)なら、後ろに別の主語があれば文末は何でもよい。後ろの主語は節を名詞にしたもの(〜することが求められている)でもよく、文末の名詞に「が」の主語が付くとき(〜を図ることが必要である)や、最後の読点の後に行いを名詞にした主語(〜を行うことも、〜を図ることが)があるときは繋辞で終わっても)、受け身の「〜され、」(受け身の主語が名詞(支部が置かれ)でなく、後ろに時を言うのではない名詞の新しい主題(〜の議論は)が立ち、主題との間に別の主題が無いとき)、繋辞の理由「〜ものですから、」「〜であるので、」(後ろに時を言うのではない名詞の新しい主題(私たちは)が立ち、主題との間に別の主題が無いとき)、読点を挟まない「〜は〜で、」「〜であるならば、」「〜にあるところ、」「〜ており、」、受け身で伝える引用「〜だと言われているが」、主題と「〜ますが、」「〜ましたが、」(打ち消しの「〜ませんが、」「〜ませんでしたが、」も)の間に別の主語が無く、その後ろが別の主語(〜が)の節を経て新しい主題(〜は、〜には)に移る文か、直後に名詞の新しい主題(〜ましたが、赤澤大臣は…、〜ておりますが、本事業は、…)が立って文末まで続く文、主題が行いを名詞にしたもの(〜することは差し控えますが、…)、主題からそこまでに別の主語が無い「〜ことから、」「〜つつ、」「〜としても、」「〜こととし、」、問いの「〜のか、」(語は語彙表 topic-clause-close)、述語の後ろに丸数字の番号(③)が来て一行に詰まった箇条の次の項目が始まるところ、「〜のは」の主題が「という」で名詞に掛かる節の中で繋辞の述語を得て、その名詞句が読点で終わるところ(〜来てほしいのは日本であったという調査の結果、…)、主題が読点を挟まずに「〜という〜」の節の中で述語を得て、その名詞句の後の読点の後ろに名詞の新しい主題が立つところ(食の大部分は家庭が担っているという実態を踏まえれば、食に関する指導は、…))は、その節の終わりまでを数えます。後ろの節の主語には「〜のほとんどは」も数えます。副詞になる「は」(最後は=結局のところ。語は語彙表 topic-adverb)は主題と読みません。前に名詞や「の」が付けば(交渉の最後は)主題です。時や場面を言う「は」(今夜は、当日は、〜ときは)の後ろに別の主題があれば、その主題から数えます。時や場面を言う主題(決定後は、普及以前は)は、「〜ますが、」「〜でしたが、」の後ろに別の主語があれば、間に別の主語があってもそこまでを数えます。法令でも契約でもない文書が条文をそのまま載せた文(「第7条 …」、形は語彙表 statute-article-opener)は、書き手が直せる文ではないので数えません。英語の文書には使いません。 - en: Sentences with no topic (noun + は), quotations in 「」, and distances up to the limit are not counted. When the topic gets its own predicate in an earlier clause (〜ではありませんが, 〜であって; 〜ではなく, 〜であるため, 〜の想定のため (or followed by the speaker asking a favour, as in 〜していただけると, 〜いただきたい), 〜であり (when no other topic stands between and the sentence does not end on a copula or 〜がある again, or ends on anything when the topic is an act made a noun and a subject of its own follows (〜することは重要であり、…影響を及ぼす可能性があります); the later subject may be a clause made a noun, 〜することが求められている, and when the final noun has a subject of its own with が, 〜を図ることが必要である, or an act made a noun with が or も follows the last comma, 〜を行うことも重要な役割である, the sentence may end on a copula), a passive 〜され whose own subject is not a noun (支部が置かれ), followed by a new topic on a noun that does not set the time (〜の議論は) with no other topic between, a copula's reason 〜ものですから or 〜であるので followed by a new topic on a noun that does not set the time (私たちは) with no other topic between, 〜は〜で with no comma between, 〜であるならば, 〜にあるところ or 〜ており followed by a clause with its own subject; a passive report 〜だと言われているが; 〜ますが or 〜ましたが (or the negative 〜ませんが, 〜ませんでしたが) with no other subject between the topic and it, followed by a clause with a subject of its own (〜が) and then a new topic (〜は, 〜には), or straight away by a noun as a new topic that runs to the end (〜ましたが、赤澤大臣は…, 〜ておりますが、本事業は、…), or always when the topic is an act made a noun (〜することは差し控えますが、…); 〜ことから, 〜つつ, 〜としても, 〜こととし or a question's 〜のか with no other subject between the topic and it, from the topic-clause-close word list; a circled number (③) after a predicate, where a list run into one line starts its next item; a 〜のは topic that gets its copula inside a clause という makes a noun's content, when that noun phrase ends at a comma, as in 〜来てほしいのは日本であったという調査の結果、…; a topic that gets its predicate, with no comma between, inside a clause という makes a noun's content, when a new topic on a noun follows the comma after that noun phrase, as in 食の大部分は家庭が担っているという実態を踏まえれば、食に関する指導は、…), the count stops at that clause's end. A later clause's subject may be a part, as in 〜のほとんどは. A は that makes an adverb of the noun before it (最後は, in the end; the words are in the topic-adverb word list) is not a topic; with a noun or の before it (交渉の最後は) it is. When a は that sets the time or the case (今夜は, 当日は, 〜ときは) is followed by another topic, the count starts from that topic. A topic that sets the time or the case (決定後は, 普及以前は) ends at 〜ますが or 〜でしたが when a subject of its own follows, even with another subject between. An article of a statute that a document of another kind quotes as it stands (第7条 …, the forms in the statute-article-opener word list) is not the writer's sentence and is not counted. Not used on English documents. + ja: 主題(名詞+は)の無い文、鉤括弧で引いたものの中、上限までの距離は見ません。主題の述語が先の節で閉じる文(「この計画は簡単ではありませんが、…」「〜であって、…」、後ろの節に別の主語がある「〜ではなく、」「〜であるため、」「〜の想定のため、」(後ろが話し手の頼み(〜していただけると、〜いただきたい)でもよい)「〜であり、」(主題との間に別の主題(〜は)が無く、文末がまた繋辞か「〜がある」でないとき。主題が行いを名詞にしたもの(〜することは重要であり、…影響を及ぼす可能性があります)なら、後ろに別の主語があれば文末は何でもよい。後ろの主語は節を名詞にしたもの(〜することが求められている)でもよく、文末の名詞に「が」の主語が付くとき(〜を図ることが必要である)や、最後の読点の後に行いを名詞にした主語(〜を行うことも、〜を図ることが)があるときは繋辞で終わっても)、受け身の「〜され、」(受け身の主語が名詞(支部が置かれ)でなく、後ろに時を言うのではない名詞の新しい主題(〜の議論は)が立ち、主題との間に別の主題が無いとき)、繋辞の理由「〜ものですから、」「〜であるので、」(後ろに時を言うのではない名詞の新しい主題(私たちは)が立ち、主題との間に別の主題が無いとき)、読点を挟まない「〜は〜で、」「〜であるならば、」「〜にあるところ、」「〜ており、」、受け身で伝える引用「〜だと言われているが」、主題と「〜ますが、」「〜ましたが、」(打ち消しの「〜ませんが、」「〜ませんでしたが、」も)の間に別の主語が無く、その後ろが別の主語(〜が)の節を経て新しい主題(〜は、〜には)に移る文か、直後に名詞の新しい主題(〜ましたが、赤澤大臣は…、〜ておりますが、本事業は、…)が立って文末まで続く文、主題が行いを名詞にしたもの(〜することは差し控えますが、…)、主題からそこまでに別の主語が無い「〜ことから、」「〜つつ、」「〜としても、」「〜こととし、」、問いの「〜のか、」(語は語彙表 topic-clause-close)、述語の後ろに丸数字の番号(③)が来て一行に詰まった箇条の次の項目が始まるところ、「〜のは」の主題が「という」で名詞に掛かる節の中で繋辞の述語を得て、その名詞句が読点で終わるところ(〜来てほしいのは日本であったという調査の結果、…)、主題が読点を挟まずに「〜という〜」の節の中で述語を得て、その名詞句の後の読点の後ろに名詞の新しい主題が立つところ(食の大部分は家庭が担っているという実態を踏まえれば、食に関する指導は、…))は、その節の終わりまでを数えます。後ろの節の主語には「〜のほとんどは」も、「〜については」「〜に関しては」(語は語彙表 topic-phrase-particle)も数えます。副詞になる「は」(最後は=結局のところ。語は語彙表 topic-adverb)は主題と読みません。前に名詞や「の」が付けば(交渉の最後は)主題です。時や場面を言う「は」(今夜は、当日は、〜ときは)の後ろに別の主題があれば、その主題から数えます。時や場面を言う主題(決定後は、普及以前は)は、「〜ますが、」「〜でしたが、」の後ろに別の主語があれば、間に別の主語があってもそこまでを数えます。法令でも契約でもない文書が条文をそのまま載せた文(「第7条 …」、形は語彙表 statute-article-opener)は、書き手が直せる文ではないので数えません。英語の文書には使いません。 + en: Sentences with no topic (noun + は), quotations in 「」, and distances up to the limit are not counted. When the topic gets its own predicate in an earlier clause (〜ではありませんが, 〜であって; 〜ではなく, 〜であるため, 〜の想定のため (or followed by the speaker asking a favour, as in 〜していただけると, 〜いただきたい), 〜であり (when no other topic stands between and the sentence does not end on a copula or 〜がある again, or ends on anything when the topic is an act made a noun and a subject of its own follows (〜することは重要であり、…影響を及ぼす可能性があります); the later subject may be a clause made a noun, 〜することが求められている, and when the final noun has a subject of its own with が, 〜を図ることが必要である, or an act made a noun with が or も follows the last comma, 〜を行うことも重要な役割である, the sentence may end on a copula), a passive 〜され whose own subject is not a noun (支部が置かれ), followed by a new topic on a noun that does not set the time (〜の議論は) with no other topic between, a copula's reason 〜ものですから or 〜であるので followed by a new topic on a noun that does not set the time (私たちは) with no other topic between, 〜は〜で with no comma between, 〜であるならば, 〜にあるところ or 〜ており followed by a clause with its own subject; a passive report 〜だと言われているが; 〜ますが or 〜ましたが (or the negative 〜ませんが, 〜ませんでしたが) with no other subject between the topic and it, followed by a clause with a subject of its own (〜が) and then a new topic (〜は, 〜には), or straight away by a noun as a new topic that runs to the end (〜ましたが、赤澤大臣は…, 〜ておりますが、本事業は、…), or always when the topic is an act made a noun (〜することは差し控えますが、…); 〜ことから, 〜つつ, 〜としても, 〜こととし or a question's 〜のか with no other subject between the topic and it, from the topic-clause-close word list; a circled number (③) after a predicate, where a list run into one line starts its next item; a 〜のは topic that gets its copula inside a clause という makes a noun's content, when that noun phrase ends at a comma, as in 〜来てほしいのは日本であったという調査の結果、…; a topic that gets its predicate, with no comma between, inside a clause という makes a noun's content, when a new topic on a noun follows the comma after that noun phrase, as in 食の大部分は家庭が担っているという実態を踏まえれば、食に関する指導は、…), the count stops at that clause's end. A later clause's subject may be a part, as in 〜のほとんどは, or stand on a compound particle, as in 〜については and 〜に関しては (the topic-phrase-particle word list). A は that makes an adverb of the noun before it (最後は, in the end; the words are in the topic-adverb word list) is not a topic; with a noun or の before it (交渉の最後は) it is. When a は that sets the time or the case (今夜は, 当日は, 〜ときは) is followed by another topic, the count starts from that topic. A topic that sets the time or the case (決定後は, 普及以前は) ends at 〜ますが or 〜でしたが when a subject of its own follows, even with another subject between. An article of a statute that a document of another kind quotes as it stands (第7条 …, the forms in the statute-article-opener word list) is not the writer's sentence and is not counted. Not used on English documents. level_meaning: ja: 主題から述語まで {limit} 字まで en: up to {limit} {limit|character|characters} between the topic and the predicate diff --git a/text/packages/chaff/src/detectors/topic-predicate-distance.ts b/text/packages/chaff/src/detectors/topic-predicate-distance.ts index 55b98a7df..9fcfc135f 100644 --- a/text/packages/chaff/src/detectors/topic-predicate-distance.ts +++ b/text/packages/chaff/src/detectors/topic-predicate-distance.ts @@ -7,6 +7,7 @@ import { overLimit, ownTokens } from "./sentence-load.ts"; const CLOSER_LEXICON = "topic-clause-close"; const ARTICLE_LEXICON = "statute-article-opener"; const ADVERB_LEXICON = "topic-adverb"; +const PHRASE_PARTICLE_LEXICON = "topic-phrase-particle"; /** * Whether the sentence is an article of a statute quoted in another kind of document (第7条 … in a manual): the law's wording, @@ -21,7 +22,7 @@ const quotesArticle = (doc: ProseDocument, genre: string | undefined): ((sentenc /** The distance from the sentence's topic (〜は) to the end, where its predicate is. Needs the language's tokens. */ export const topicPredicateDistance: Detector = (doc, options) => { const patterns = (lexicon: string): string[] => (doc.lexicons[lexicon] ?? []).map((entry) => entry.pattern); - const words: TopicClauseWords = { closers: patterns(CLOSER_LEXICON), adverbs: patterns(ADVERB_LEXICON) }; + const words: TopicClauseWords = { closers: patterns(CLOSER_LEXICON), adverbs: patterns(ADVERB_LEXICON), phraseParticles: patterns(PHRASE_PARTICLE_LEXICON) }; const quoted = quotesArticle(doc, options.genre); return overLimit((sentence) => (sentence.tokens === undefined || quoted(sentence) ? undefined : topicDistance(ownTokens(sentence), words)))(doc, options); }; diff --git a/text/packages/chaff/src/topic-clause.ts b/text/packages/chaff/src/topic-clause.ts index 18eac9256..4993d56d1 100644 --- a/text/packages/chaff/src/topic-clause.ts +++ b/text/packages/chaff/src/topic-clause.ts @@ -45,10 +45,18 @@ const isNarrowedPart = (tokens: readonly Token[], at: number): boolean => /** The word before at heads a subject of its own: a noun (法律は), or a part a の phrase narrows (処理のほとんどは). */ const headsSubject = (tokens: readonly Token[], at: number): boolean => isOwnNoun(tokens[at - 1]) || isNarrowedPart(tokens, at - 1); +/** は on a compound particle after a noun of its own (販売については, 販売に関しては): a topic of its own, as 販売は is. */ +const isPhraseTopicAt = (tokens: readonly Token[], at: number, phraseParticles: readonly string[]): boolean => { + const particle = tokens[at - 1]; + return particle?.pos === "ADP" && phraseParticles.includes(particle.surface) && isOwnNoun(tokens[at - 2]); +}; + /** A subject of its own at at: は on its head anywhere, or が on its head when lastComma is before it (-1 to take every が). */ -const isOwnSubjectAt = (tokens: readonly Token[], at: number, lastComma: number): boolean => { +const isOwnSubjectAt = (tokens: readonly Token[], at: number, lastComma: number, phraseParticles: readonly string[]): boolean => { const token = tokens[at]; - return token !== undefined && headsSubject(tokens, at) && (isParticle(token, "は") || (isParticle(token, "が") && at > lastComma)); + if (token === undefined) return false; + if (isParticle(token, "は") && isPhraseTopicAt(tokens, at, phraseParticles)) return true; + return headsSubject(tokens, at) && (isParticle(token, "は") || (isParticle(token, "が") && at > lastComma)); }; /** @@ -56,9 +64,9 @@ const isOwnSubjectAt = (tokens: readonly Token[], at: number, lastComma: number) * noun with が that the final predicate takes (no comma after it: 動きが見られ始めている). A noun with が inside a condition * (債務者が請求した場合、) is not one. -1 when there is none. A clause has a subject of its own after it when this is past it. */ -const lastOwnSubject = (tokens: readonly Token[], last: number): number => { +const lastOwnSubject = (tokens: readonly Token[], last: number, phraseParticles: readonly string[]): number => { const lastComma = tokens.findLastIndex((token, at) => at < last && isComma(token)); - return tokens.findLastIndex((_, at) => at < last && isOwnSubjectAt(tokens, at, lastComma)); + return tokens.findLastIndex((_, at) => at < last && isOwnSubjectAt(tokens, at, lastComma, phraseParticles)); }; /** The words of the clause after a comma at from, up to the next clause stopped by a comma, or the sentence's last word. */ @@ -279,6 +287,8 @@ export type TopicClauseWords = { readonly closers: readonly string[]; /** Nouns that は makes an adverb of (最後は, in the end): the topic-adverb lexicon. Such a は is no topic. */ readonly adverbs?: readonly string[]; + /** Compound particles a topic stands on (について, に関して): the topic-phrase-particle lexicon. */ + readonly phraseParticles?: readonly string[]; }; const NO_WORDS: TopicClauseWords = { closers: [] }; @@ -343,11 +353,11 @@ const isNounPrefix = (token: Token | undefined): boolean => token?.pos === "ADJ" * it) and は straight after the comma is a topic of its own that the rest of the sentence is said of, when no subject of its own * (が) follows it. A phrase before は (〜した行為は) is not one. */ -const newNameTopicRunsToEnd = (tokens: readonly Token[], comma: number, last: number): boolean => { +const newNameTopicRunsToEnd = (tokens: readonly Token[], comma: number, last: number, subject: number): boolean => { const start = isNounPrefix(tokens[comma + 1]) ? comma + 2 : comma + 1; const topic = tokens.findIndex((token, index) => index >= start && !isNameWord(token)); const wa = tokens[topic]; - return topic > start && wa !== undefined && isParticle(wa, "は") && lastOwnSubject(tokens, last) <= topic; + return topic > start && wa !== undefined && isParticle(wa, "は") && subject <= topic; }; /** @@ -363,7 +373,7 @@ const closesWithPoliteGa = (tokens: readonly Token[], topic: number, at: number, if (!isPoliteGa(tokens, at) || !isComma(tokens[at + 1])) return false; if (isSettingTopic(tokens, topic)) return newTopicAfter(tokens, at + 1, last) || subject > at || finalGaAfter(tokens, at, last); if (subjectBetween(tokens, topic, at)) return false; - if (isActTopic(tokens, topic) || newNameTopicRunsToEnd(tokens, at + 1, last)) return true; + if (isActTopic(tokens, topic) || newNameTopicRunsToEnd(tokens, at + 1, last, subject)) return true; const comma = tokens.findIndex((token, index) => index > at + 1 && index < last && isComma(token)); const ga = tokens.findIndex( (token, index) => index > at + 1 && index < (comma === -1 ? last : comma) && isParticle(token, "が") && headsSubject(tokens, index), @@ -438,7 +448,7 @@ const closesTopicInNounClause = (tokens: readonly Token[], topic: number, at: nu * topic's predicate is the one the sentence ends on. */ export const topicClauseEnd = (tokens: readonly Token[], topic: number, last: number, words: TopicClauseWords = NO_WORDS): number | undefined => { - const subject = lastOwnSubject(tokens, last); + const subject = lastOwnSubject(tokens, last, words.phraseParticles ?? []); const closes = (at: number): boolean => closesSurely(tokens, at, last) || (closesIfNewSubject(tokens, at) && (subject > at || requestAfter(tokens, at, last))) || diff --git a/text/packages/lang-ja/lexicons/topic-phrase-particle.yaml b/text/packages/lang-ja/lexicons/topic-phrase-particle.yaml new file mode 100644 index 000000000..892601fd6 --- /dev/null +++ b/text/packages/lang-ja/lexicons/topic-phrase-particle.yaml @@ -0,0 +1,7 @@ +# 名詞の後ろで「は」と組んで主題を立てる複合の助詞(販売については、販売に関しては)。解析器は一語の助詞と読む。 +# topic-predicate-distance は、「〜については」を「〜は」と同じく後ろの節の主題として読む(〜を行っており、これらの販売については、…)。 +id: topic-phrase-particle +language: ja +entries: + - pattern: について + - pattern: に関して diff --git a/text/test/test_topic_predicate_distance.ts b/text/test/test_topic_predicate_distance.ts index 3ec674469..966502778 100644 --- a/text/test/test_topic_predicate_distance.ts +++ b/text/test/test_topic_predicate_distance.ts @@ -153,6 +153,18 @@ describe("topic-predicate-distance: 述語のすぐ後ろで閉じる節(topic }); describe("topic-predicate-distance: 後ろの節の主語", () => { + it("「〜ており、」の後ろの「〜については」「〜に関しては」も後ろの節の主題として読む(自作)", () => { + const about = + "当社は、主として家庭用の調理器具と収納用品の製造及び販売を行っており、これらの製品の販売については、製品を引き渡した時点で顧客が製品の支配を獲得すると判断していることから、その時点で収益を認識しております。"; + assert.deepEqual(distances(about), []); + const regarding = + "当社は、主として家庭用の調理器具と収納用品の製造及び販売を行っており、これらの製品の販売に関しては、製品を引き渡した時点で顧客が製品の支配を獲得すると判断していることから、その時点で収益を認識しております。"; + assert.deepEqual(distances(regarding), []); + const same = + "当社は、主として家庭用の調理器具と収納用品の製造及び販売を行っており、これらの製品を販売する際には、製品を引き渡した時点で顧客が製品の支配を獲得すると判断していることから、その時点で収益を認識しております。"; + assert.equal(distances(same).length, 1); + }); + it("「〜の大半は」「〜のほとんどは」も後ろの節の主語として読む(自作)", () => { const narrowed = "この装置は古い型であるため、これらの部品のほとんどはもう製造元では作られておらず、修理のたびに中古の市場で探すか、同じ働きをする別の部品を取り寄せて、一つずつ合うかどうかを確かめながら長く使い続けています。"; From e657b346b4d7de936d82d5b26fa9cf8e604f7897 Mon Sep 17 00:00:00 2001 From: isamu Date: Mon, 30 Nov 2026 09:30:36 +0900 Subject: [PATCH 2/2] fix: topic-predicate-distance keeps the name-topic check as it was Co-Authored-By: Claude Opus 5.5 --- text/packages/chaff/src/topic-clause.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/text/packages/chaff/src/topic-clause.ts b/text/packages/chaff/src/topic-clause.ts index 4993d56d1..a22801cd7 100644 --- a/text/packages/chaff/src/topic-clause.ts +++ b/text/packages/chaff/src/topic-clause.ts @@ -353,11 +353,11 @@ const isNounPrefix = (token: Token | undefined): boolean => token?.pos === "ADJ" * it) and は straight after the comma is a topic of its own that the rest of the sentence is said of, when no subject of its own * (が) follows it. A phrase before は (〜した行為は) is not one. */ -const newNameTopicRunsToEnd = (tokens: readonly Token[], comma: number, last: number, subject: number): boolean => { +const newNameTopicRunsToEnd = (tokens: readonly Token[], comma: number, last: number): boolean => { const start = isNounPrefix(tokens[comma + 1]) ? comma + 2 : comma + 1; const topic = tokens.findIndex((token, index) => index >= start && !isNameWord(token)); const wa = tokens[topic]; - return topic > start && wa !== undefined && isParticle(wa, "は") && subject <= topic; + return topic > start && wa !== undefined && isParticle(wa, "は") && lastOwnSubject(tokens, last, []) <= topic; }; /** @@ -373,7 +373,7 @@ const closesWithPoliteGa = (tokens: readonly Token[], topic: number, at: number, if (!isPoliteGa(tokens, at) || !isComma(tokens[at + 1])) return false; if (isSettingTopic(tokens, topic)) return newTopicAfter(tokens, at + 1, last) || subject > at || finalGaAfter(tokens, at, last); if (subjectBetween(tokens, topic, at)) return false; - if (isActTopic(tokens, topic) || newNameTopicRunsToEnd(tokens, at + 1, last, subject)) return true; + if (isActTopic(tokens, topic) || newNameTopicRunsToEnd(tokens, at + 1, last)) return true; const comma = tokens.findIndex((token, index) => index > at + 1 && index < last && isComma(token)); const ga = tokens.findIndex( (token, index) => index > at + 1 && index < (comma === -1 ? last : comma) && isParticle(token, "が") && headsSubject(tokens, index),