Update dictionary schema to support pitch accent data

This commit is contained in:
toasted-nutbread 2020-02-23 14:03:37 -05:00
parent a0c4ce779d
commit 93f7278586
4 changed files with 105 additions and 8 deletions

View File

@ -13,13 +13,71 @@
}, },
{ {
"type": "string", "type": "string",
"enum": ["freq"], "enum": ["freq", "pitch"],
"description": "Type of data. \"freq\" corresponds to frequency information." "description": "Type of data. \"freq\" corresponds to frequency information; \"pitch\" corresponds to pitch information."
}, },
{ {
"type": ["string", "number"],
"description": "Data for the term/expression." "description": "Data for the term/expression."
} }
],
"oneOf": [
{
"items": [
{},
{"enum": ["freq"]},
{
"type": ["string", "number"],
"description": "Frequency information for the term or expression."
}
]
},
{
"items": [
{},
{"enum": ["pitch"]},
{
"type": ["object"],
"description": "Pitch accent information for the term or expression.",
"required": [
"reading",
"pitches"
],
"additionalProperties": false,
"properties": {
"reading": {
"type": "string",
"description": "Reading for the term or expression."
},
"pitches": {
"type": "array",
"description": "List of different pitch accent information for the term and reading combination.",
"additionalItems": {
"type": "object",
"required": [
"position"
],
"additionalProperties": false,
"properties": {
"position": {
"type": "integer",
"description": "Mora position of the pitch accent downstep. A value of 0 indicates that the word does not have a downstep (heiban).",
"minimum": 0
},
"tags": {
"type": "array",
"description": "List of tags for this pitch accent.",
"items": {
"type": "string",
"description": "Tag for this pitch accent. This typically corresponds to a certain type of part of speech."
}
}
}
}
}
}
}
]
}
] ]
} }
} }

View File

@ -0,0 +1,4 @@
[
["ptag1", "pcategory1", 0, "ptag1 notes", 0],
["ptag2", "pcategory2", 0, "ptag2 notes", 0]
]

View File

@ -1,5 +1,39 @@
[ [
["打", "freq", 1], ["打", "freq", 1],
["打つ", "freq", 2], ["打つ", "freq", 2],
["打ち込む", "freq", 3] ["打ち込む", "freq", 3],
[
"打ち込む",
"pitch",
{
"reading": "うちこむ",
"pitches": [
{"position": 0},
{"position": 3}
]
}
],
[
"打ち込む",
"pitch",
{
"reading": "ぶちこむ",
"pitches": [
{"position": 0},
{"position": 3}
]
}
],
[
"お手前",
"pitch",
{
"reading": "おてまえ",
"pitches": [
{"position": 2, "tags": ["ptag1"]},
{"position": 2, "tags": ["ptag2"]},
{"position": 0, "tags": ["ptag2"]}
]
}
]
] ]

View File

@ -231,8 +231,8 @@ async function testDatabase1() {
true true
); );
vm.assert.deepStrictEqual(counts, { vm.assert.deepStrictEqual(counts, {
counts: [{kanji: 2, kanjiMeta: 2, terms: 32, termMeta: 3, tagMeta: 12}], counts: [{kanji: 2, kanjiMeta: 2, terms: 32, termMeta: 6, tagMeta: 14}],
total: {kanji: 2, kanjiMeta: 2, terms: 32, termMeta: 3, tagMeta: 12} total: {kanji: 2, kanjiMeta: 2, terms: 32, termMeta: 6, tagMeta: 14}
}); });
// Test find* functions // Test find* functions
@ -648,9 +648,10 @@ async function testFindTermMetaBulk1(database, titles) {
} }
], ],
expectedResults: { expectedResults: {
total: 1, total: 3,
modes: [ modes: [
['freq', 1] ['freq', 1],
['pitch', 2]
] ]
} }
}, },