Skip to content

Commit fabe66e

Browse files
Merge pull request #13 from word-view/translation-parent-field
Add translation parent field
2 parents 00f739e + 4807c27 commit fabe66e

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1+
@file:Suppress("PropertyName")
2+
13
package cc.wordview.gengolex.word
24

35
/**
46
* Represents a word in any given language.
57
*
68
* @property parent Identifier used to associate a word to a global equivalent of it (basically the translation of it in english)
79
* @property word The word itself in the respective language
10+
* @property translation_parent The parent used to look for translations
811
* @property representable Indicates whether this word is representable by an image/illustration
912
* @property pronunciation How the word is spelled
1013
*/
1114
open class Word(
1215
val parent: String,
1316
val word: String,
17+
val translation_parent: String? = null,
1418
val representable: Boolean = false,
1519
val pronunciation: String? = null,
1620
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package parser
2+
3+
import GengolexTest
4+
import cc.wordview.gengolex.Language
5+
import cc.wordview.gengolex.Parser
6+
import kotlin.test.Test
7+
import kotlin.test.assertEquals
8+
9+
class TranslationParentFieldTest : GengolexTest() {
10+
@Test
11+
fun japanese() {
12+
val parser = Parser(Language.JAPANESE, dictionaries)
13+
val word = parser.findWords("悲しみどうでもいい").single()
14+
assertEquals("sadness", word.translation_parent)
15+
}
16+
17+
@Test
18+
fun japanese_noTranslationParent() {
19+
val parser = Parser(Language.JAPANESE, dictionaries)
20+
val word = parser.findWords("雨が降る").single()
21+
assertEquals(null, word.translation_parent)
22+
}
23+
}

src/test/resources/dictionaries/kanji/others.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,18 @@
3131
"representable": true
3232
}
3333
]
34+
},
35+
{
36+
"parent": "sad",
37+
"word": "",
38+
"representable": true,
39+
"derivations": [
40+
{
41+
"parent": "sad",
42+
"translation_parent": "sadness",
43+
"word": "悲しみ",
44+
"representable": true
45+
}
46+
]
3447
}
3548
]

0 commit comments

Comments
 (0)