Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Reading Parse Edgecase #7

Merged
merged 2 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.2.0",
"version": "1.3.0",
"scripts": {
"test": "ava"
},
Expand Down
6 changes: 3 additions & 3 deletions src/readingParse.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ function parseReadingFromBrackets(bracketContent, term) {

const readings = bracketContent.split(commaRegex);

const noKanji = readings.filter((reading) => !kanjiRegex.test(reading));
const noKanji = readings.filter((reading) => !reading.match(kanjiRegex));

const latinRegex = /[a-zA-Z]/g;
const termHasLatin = latinRegex.test(term);
const termHasLatin = term.match(latinRegex);

const readingCandidates = termHasLatin
? noKanji
: noKanji.filter((reading) => !latinRegex.test(reading));
: noKanji.filter((reading) => !reading.match(latinRegex));

if (readingCandidates.length > 0) {
let reading = readingCandidates[0];
Expand Down
7 changes: 6 additions & 1 deletion src/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ const testCases = [
line: `<http://ja.dbpedia.org/resource/スピン構造> <http://www.w3.org/2000/01/rdf-schema#comment> "微分幾何学において、向き付け可能リーマン多様体 (M, g) 上のスピン構造(スピンこうぞう、英: spin structure)は、付随するの定義を可能にし、微分幾何学におけるスピノルの概念を生じる。 数理物理学、特に場の量子論へ広く応用され、電荷を持たないフェルミオンに関する任意の理論の定義にスピン構造は必須である。純粋数学的にも、微分幾何学や代数的位相幾何学、K-理論などに於いてスピン構造は興味の対象である。スピン構造はに対する基礎付けを成す。"@ja .`,
term: 'スピン構造',
expectedReading: 'スピンこうぞう',
}
},
{
line: `<http://ja.dbpedia.org/resource/クルガン> <http://www.w3.org/2000/01/rdf-schema#comment> "クルガン(ロシア語: кургáн、英語: ,kurgan)は、ユーラシア大陸中緯度のステップ帯に分布する、青銅器時代の土あるいは積石のマウンドを伴う墳墓である。墳丘墓の一種で、日本の古墳に近い。 「クルガン」はトルコ語起源のスラヴ人の単語である。"@ja .`,
term: 'クルガン',
expectedReading: '',
},
],
},
{
Expand Down