Skip to content
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
2 changes: 1 addition & 1 deletion src/base/number_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ constexpr absl::string_view kRomanNumbersSmall[] = {
"", "ⅰ", "ⅱ", "ⅲ", "ⅳ", "ⅴ", "ⅵ", "ⅶ", "ⅷ", "ⅸ", "ⅹ", "ⅺ", "ⅻ", ""};

constexpr absl::string_view kCircledNumbers[] = {
"", "①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨", "⑩",
"⓪", "①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨", "⑩",
"⑪", "⑫", "⑬", "⑭", "⑮", "⑯", "⑰", "⑱", "⑲", "⑳", "㉑",
"㉒", "㉓", "㉔", "㉕", "㉖", "㉗", "㉘", "㉙", "㉚", "㉛", "㉜",
"㉝", "㉞", "㉟", "㊱", "㊲", "㊳", "㊴", "㊵", "㊶", "㊷", "㊸",
Expand Down
14 changes: 14 additions & 0 deletions src/base/number_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,20 @@ TEST(NumberUtilTest, ArabicToOtherFormsTest) {
EXPECT_EQ(output[4].value, "₅");
EXPECT_EQ(output[4].style, NumberUtil::NumberString::NUMBER_SUBSCRIPT);

arabic = "0";
output.clear();
EXPECT_TRUE(NumberUtil::ArabicToOtherForms(arabic, &output));
ASSERT_EQ(output.size(), 3);

EXPECT_EQ(output[0].value, "⓪");
EXPECT_EQ(output[0].style, NumberUtil::NumberString::NUMBER_CIRCLED);

EXPECT_EQ(output[1].value, "⁰");
EXPECT_EQ(output[1].style, NumberUtil::NumberString::NUMBER_SUPERSCRIPT);

EXPECT_EQ(output[2].value, "₀");
EXPECT_EQ(output[2].style, NumberUtil::NumberString::NUMBER_SUBSCRIPT);

arabic = "0123456789";
output.clear();
EXPECT_FALSE(NumberUtil::ArabicToOtherForms(arabic, &output));
Expand Down
1 change: 1 addition & 0 deletions src/data/symbol/categorized.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ $ HALF どる だらー だら つうか $ たんい
㈧ ARROW かっこ8 かっこはち
㈨ ARROW かっこ9 かっこきゅう
㈩ ARROW かっこ10 かっこじゅう
⓪ ARROW きごう まる0 まるぜろ まるれい
① ARROW きごう まる1 まるいち
② ARROW きごう まる2 まるに
③ ARROW きごう まる3 まるさん
Expand Down
1 change: 1 addition & 0 deletions src/data/symbol/ordering_rule.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ _
Expand Down
4 changes: 4 additions & 0 deletions src/data/symbol/symbol.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ POS CHAR Reading (space separated) description additional description category m
記号 ∟ すうがく ちょっかく 直角 SYMBOL
記号 ∮ すうがく いんてぐらる せきぶん へいろせきぶん けいさん ふぁい けいろせきぶん しゅうかいせきぶん 閉路積分記号 SYMBOL
記号 ℵ あれふ SYMBOL U+2135
数 ⓪ きごう まる0 まるぜろ まるれい 丸数字 SYMBOL number rewriter
数 ① きごう まる1 まるいち 丸数字 SYMBOL number rewriter
数 ② きごう まる2 まるに 丸数字 SYMBOL number rewriter
数 ③ きごう まる3 まるさん 丸数字 SYMBOL number rewriter
Expand Down Expand Up @@ -1344,6 +1345,7 @@ POS CHAR Reading (space separated) description additional description category m
記号 ❥ きごう はーと ハート ROTATED HEAVY BLACK HEART BULLET (U+2765) U+2765
記号 ❦ きごう はーと ハート FLORAL HEART (U+2766) U+2766
記号 ❧ きごう はーと ハート ROTATED FLORAL HEART BULLET (U+2767) U+2767
数 ⓿ きごう まる0 まるぜろ まるれい 丸数字 NEGATIVE CIRCLED DIGIT ZERO (U+24FF) U+24FF
数 ❶ きごう まる1 まるいち 丸数字 DINGBAT NEGATIVE CIRCLED DIGIT ONE (U+2776) U+2776
数 ❷ きごう まる2 まるに 丸数字 DINGBAT NEGATIVE CIRCLED DIGIT TWO (U+2777) U+2777
数 ❸ きごう まる3 まるさん 丸数字 DINGBAT NEGATIVE CIRCLED DIGIT THREE (U+2778) U+2778
Expand All @@ -1354,6 +1356,7 @@ POS CHAR Reading (space separated) description additional description category m
数 ❽ きごう まる8 まるはち 丸数字 DINGBAT NEGATIVE CIRCLED DIGIT EIGHT (U+277D) U+277D
数 ❾ きごう まる9 まるきゅう まるく 丸数字 DINGBAT NEGATIVE CIRCLED DIGIT NINE (U+277E) U+277E
数 ❿ きごう まる10 まるじゅう 丸数字 DINGBAT NEGATIVE CIRCLED NUMBER TEN (U+277F) U+277F
数 🄋 きごう まる0 まるぜろ まるれい 丸数字 DINGBAT CIRCLED SANS-SERIF DIGIT ZERO (U+1F10B) U+1F10B
数 ➀ きごう まる1 まるいち 丸数字 DINGBAT CIRCLED SANS-SERIF DIGIT ONE (U+2780) U+2780
数 ➁ きごう まる2 まるに 丸数字 DINGBAT CIRCLED SANS-SERIF DIGIT TWO (U+2781) U+2781
数 ➂ きごう まる3 まるさん 丸数字 DINGBAT CIRCLED SANS-SERIF DIGIT THREE (U+2782) U+2782
Expand All @@ -1364,6 +1367,7 @@ POS CHAR Reading (space separated) description additional description category m
数 ➇ きごう まる8 まるはち 丸数字 DINGBAT CIRCLED SANS-SERIF DIGIT EIGHT (U+2787) U+2787
数 ➈ きごう まる9 まるきゅう まるく 丸数字 DINGBAT CIRCLED SANS-SERIF DIGIT NINE (U+2788) U+2788
数 ➉ きごう まる10 まるじゅう 丸数字 DINGBAT CIRCLED SANS-SERIF NUMBER TEN (U+2789) U+2789
数 🄌 きごう まる0 まるぜろ まるれい 丸数字 DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT ZERO (U+1F10C) U+1F10C
数 ➊ きごう まる1 まるいち 丸数字 DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT ONE (U+278A) U+278A
数 ➋ きごう まる2 まるに 丸数字 DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT TWO (U+278B) U+278B
数 ➌ きごう まる3 まるさん 丸数字 DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT THREE (U+278C) U+278C
Expand Down
42 changes: 25 additions & 17 deletions src/rewriter/number_rewriter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,13 @@ TEST_F(NumberRewriterTest, SpecialFormBoundaries) {
std::unique_ptr<NumberRewriter> number_rewriter(CreateNumberRewriter());
Segments segments;

// These special forms doesn't have zeros.
// Roman numerals don't have zeros.
Segment* seg = SetupSegments(pos_matcher_, "0", &segments);
EXPECT_TRUE(number_rewriter->Rewrite(default_request_, &segments));
EXPECT_FALSE(HasDescription(*seg, kMaruNumberDescription));
EXPECT_FALSE(HasDescription(*seg, kRomanCapitalDescription));
EXPECT_FALSE(HasDescription(*seg, kRomanNoCapitalDescription));
// "0" has superscripts and subscripts
// "0" has a circled number, superscripts and subscripts.
EXPECT_TRUE(HasDescription(*seg, kMaruNumberDescription));
EXPECT_TRUE(HasDescription(*seg, kSuperscriptDescription));
EXPECT_TRUE(HasDescription(*seg, kSubscriptDescription));

Expand Down Expand Up @@ -474,7 +474,7 @@ TEST_F(NumberRewriterTest, NumberIsZero) {

EXPECT_TRUE(number_rewriter->Rewrite(default_request_, &segments));

EXPECT_EQ(seg->candidates_size(), 6);
EXPECT_EQ(seg->candidates_size(), 7);

EXPECT_EQ(seg->candidate(0).value, "0");
EXPECT_EQ(seg->candidate(0).content_value, "0");
Expand All @@ -492,13 +492,17 @@ TEST_F(NumberRewriterTest, NumberIsZero) {
EXPECT_EQ(seg->candidate(3).content_value, "零");
EXPECT_EQ(seg->candidate(3).description, kOldKanjiDescription);

EXPECT_EQ(seg->candidate(4).value, "");
EXPECT_EQ(seg->candidate(4).content_value, "");
EXPECT_EQ(seg->candidate(4).description, kSuperscriptDescription);
EXPECT_EQ(seg->candidate(4).value, "");
EXPECT_EQ(seg->candidate(4).content_value, "");
EXPECT_EQ(seg->candidate(4).description, kMaruNumberDescription);

EXPECT_EQ(seg->candidate(5).value, "₀");
EXPECT_EQ(seg->candidate(5).content_value, "₀");
EXPECT_EQ(seg->candidate(5).description, kSubscriptDescription);
EXPECT_EQ(seg->candidate(5).value, "⁰");
EXPECT_EQ(seg->candidate(5).content_value, "⁰");
EXPECT_EQ(seg->candidate(5).description, kSuperscriptDescription);

EXPECT_EQ(seg->candidate(6).value, "₀");
EXPECT_EQ(seg->candidate(6).content_value, "₀");
EXPECT_EQ(seg->candidate(6).description, kSubscriptDescription);

seg->clear_candidates();
}
Expand All @@ -518,7 +522,7 @@ TEST_F(NumberRewriterTest, NumberIsZeroZero) {

EXPECT_TRUE(number_rewriter->Rewrite(default_request_, &segments));

EXPECT_EQ(seg->candidates_size(), 6);
EXPECT_EQ(seg->candidates_size(), 7);

EXPECT_EQ(seg->candidate(0).value, "00");
EXPECT_EQ(seg->candidate(0).content_value, "00");
Expand All @@ -536,13 +540,17 @@ TEST_F(NumberRewriterTest, NumberIsZeroZero) {
EXPECT_EQ(seg->candidate(3).content_value, "零");
EXPECT_EQ(seg->candidate(3).description, kOldKanjiDescription);

EXPECT_EQ(seg->candidate(4).value, "⁰");
EXPECT_EQ(seg->candidate(4).content_value, "⁰");
EXPECT_EQ(seg->candidate(4).description, kSuperscriptDescription);
EXPECT_EQ(seg->candidate(4).value, "⓪");
EXPECT_EQ(seg->candidate(4).content_value, "⓪");
EXPECT_EQ(seg->candidate(4).description, kMaruNumberDescription);

EXPECT_EQ(seg->candidate(5).value, "⁰");
EXPECT_EQ(seg->candidate(5).content_value, "⁰");
EXPECT_EQ(seg->candidate(5).description, kSuperscriptDescription);

EXPECT_EQ(seg->candidate(5).value, "₀");
EXPECT_EQ(seg->candidate(5).content_value, "₀");
EXPECT_EQ(seg->candidate(5).description, kSubscriptDescription);
EXPECT_EQ(seg->candidate(6).value, "₀");
EXPECT_EQ(seg->candidate(6).content_value, "₀");
EXPECT_EQ(seg->candidate(6).description, kSubscriptDescription);

seg->clear_candidates();
}
Expand Down