示例#1
0
文件: tests.py 项目: santoshpy/manabi
    def test_furigana_positions_with_kanji_and_ascii_spaces(self):
        _, furigana_positions = inject_furigana(u"foobar   学び")

        self.assertEqual(furigana_positions[0][FURIGANA_POSITION_START], 9)
        self.assertEqual(furigana_positions[0][FURIGANA_POSITION_END], 10)
        self.assertEqual(furigana_positions[0][FURIGANA_POSITION_FURIGANA],
                         u"まな")
示例#2
0
文件: tests.py 项目: santoshpy/manabi
    def test_furigana_positions_with_kanji_and_hiragana_prefix_and_ascii_spaces(
            self):
        _, furigana_positions = inject_furigana(u"foo   で背を寄せる")

        self.assertEqual(furigana_positions[0][FURIGANA_POSITION_START], 7)
        self.assertEqual(furigana_positions[0][FURIGANA_POSITION_END], 8)
        self.assertEqual(furigana_positions[0][FURIGANA_POSITION_FURIGANA],
                         u"せ")
示例#3
0
文件: tests.py 项目: aehlke/manabi
    def test_furigana_positions_with_kanji_and_ascii(self):
        _, furigana_positions = inject_furigana("学びfoobar学び")

        self.assertEqual(furigana_positions[0][FURIGANA_POSITION_START], 0)
        self.assertEqual(furigana_positions[0][FURIGANA_POSITION_END], 1)
        self.assertEqual(furigana_positions[0][FURIGANA_POSITION_FURIGANA], "まな")

        self.assertEqual(furigana_positions[1][FURIGANA_POSITION_START], 8)
        self.assertEqual(furigana_positions[1][FURIGANA_POSITION_END], 9)
        self.assertEqual(furigana_positions[1][FURIGANA_POSITION_FURIGANA], "まな")
示例#4
0
def inject_furigana(request):
    try:
        text = request.data['text']
    except KeyError:
        raise ValidationError("Must supply text parameter.")

    text_with_furigana, furigana_positions = inject.inject_furigana(text)

    return Response({
        'text_with_furigana': text_with_furigana,
        'furigana_positions': furigana_positions,
    })
示例#5
0
文件: tests.py 项目: aehlke/manabi
    def test_furigana_positions_with_kanji(self):
        _, furigana_positions = inject_furigana("背を寄せる")

        se_kanji = furigana_positions[0]
        self.assertEqual(se_kanji[FURIGANA_POSITION_START], 0)
        self.assertEqual(se_kanji[FURIGANA_POSITION_END], 1)
        self.assertEqual(se_kanji[FURIGANA_POSITION_FURIGANA], "せ")

        yoseru_kanji = furigana_positions[1]
        self.assertEqual(yoseru_kanji[FURIGANA_POSITION_START], 2)
        self.assertEqual(yoseru_kanji[FURIGANA_POSITION_END], 3)
        self.assertEqual(yoseru_kanji[FURIGANA_POSITION_FURIGANA], "よ")
示例#6
0
文件: tests.py 项目: santoshpy/manabi
    def test_furigana_positions_with_kanji(self):
        _, furigana_positions = inject_furigana(u"背を寄せる")

        se_kanji = furigana_positions[0]
        self.assertEqual(se_kanji[FURIGANA_POSITION_START], 0)
        self.assertEqual(se_kanji[FURIGANA_POSITION_END], 1)
        self.assertEqual(se_kanji[FURIGANA_POSITION_FURIGANA], u"せ")

        yoseru_kanji = furigana_positions[1]
        self.assertEqual(yoseru_kanji[FURIGANA_POSITION_START], 2)
        self.assertEqual(yoseru_kanji[FURIGANA_POSITION_END], 3)
        self.assertEqual(yoseru_kanji[FURIGANA_POSITION_FURIGANA], u"よ")
示例#7
0
文件: tests.py 项目: aehlke/manabi
    def test_furigana_positions_with_kanji_and_hiragana_prefix_and_ascii_spaces(self):
        _, furigana_positions = inject_furigana("foo   で背を寄せる")

        self.assertEqual(furigana_positions[0][FURIGANA_POSITION_START], 7)
        self.assertEqual(furigana_positions[0][FURIGANA_POSITION_END], 8)
        self.assertEqual(furigana_positions[0][FURIGANA_POSITION_FURIGANA], "せ")
示例#8
0
文件: tests.py 项目: aehlke/manabi
 def test_kanji_and_ascii_spaces(self):
     text_with_furigana, _ = inject_furigana("foobar   学び")
     self.assertEqual("foobar   |学《まな》び", text_with_furigana)
示例#9
0
文件: tests.py 项目: aehlke/manabi
 def test_expression_with_kanji(self):
     text_with_furigana, _ = inject_furigana("背を寄せる")
     self.assertEqual("|背《せ》を|寄《よ》せる", text_with_furigana)
示例#10
0
文件: tests.py 项目: aehlke/manabi
 def test_plain_ascii_text(self):
     ascii_text = 'foo bar'
     text_with_furigana, _ = inject_furigana(ascii_text)
     self.assertEqual(ascii_text, text_with_furigana)
示例#11
0
文件: tests.py 项目: santoshpy/manabi
 def test_kanji_and_ascii_spaces(self):
     text_with_furigana, _ = inject_furigana(u"foobar   学び")
     self.assertEqual(u"foobar   |学《まな》び", text_with_furigana)
示例#12
0
文件: tests.py 项目: santoshpy/manabi
 def test_expression_with_kanji(self):
     text_with_furigana, _ = inject_furigana(u"背を寄せる")
     self.assertEqual(u"|背《せ》を|寄《よ》せる", text_with_furigana)
示例#13
0
文件: tests.py 项目: santoshpy/manabi
 def test_plain_ascii_text(self):
     ascii_text = u'foo bar'
     text_with_furigana, _ = inject_furigana(ascii_text)
     self.assertEqual(ascii_text, text_with_furigana)