kana icon indicating copy to clipboard operation
kana copied to clipboard

Add direct kana conversion and utility functions

Open manab-pr opened this issue 2 months ago • 0 comments

Summary

This PR introduces new features and improvements to enhance Japanese text processing capabilities in the library.

New Features

  • Direct Kana Conversion

    • HiraganaToKatakana() – Convert hiragana to katakana
    • KatakanaToHiragana() – Convert katakana to hiragana
  • Character Detection

    • ContainsKana() – Check if string contains kana
    • ContainsHiragana() – Check if string contains hiragana
    • ContainsKatakana() – Check if string contains katakana
    • ContainsKanji() – Check if string contains kanji
  • Character Counting

    • CountKana() – Count all kana characters
    • CountHiragana() – Count hiragana characters
    • CountKatakana() – Count katakana characters
    • CountKanji() – Count kanji characters
    • CountRomaji() – Count romaji (Latin) characters

Improvements

  • Added empty string handling for all conversion functions
  • Introduced named constants for special kana (小さいつ, ん, ー)
  • Refactored code to replace magic strings with constants
  • Fixed typo in IsKanji documentation

Testing

  • Added unit tests for all new functions
  • Verified empty string edge cases
  • Included benchmark tests for performance validation

Documentation

  • Updated README.md with examples for new functions
  • Added go.mod for Go module support

Test Plan

All tests pass successfully:

go test -v
go test -bench=.

manab-pr avatar Oct 01 '25 06:10 manab-pr