Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

キーワードのロックは単語の文字数が多いものから順にすべき #231

Open
holosand8 opened this issue Dec 14, 2022 · 0 comments
Labels

Comments

@holosand8
Copy link

Describe the bug/バグの概要
dictionary.yml によるキーワードのロックを行う際は、単語の文字数が多いものから順に処理すべきです。
現状は HashSet のエントリのイテレートの順番に依存しているため、とある単語が別の単語を内包しているようなケースで、意図しない変換が行われる可能性があります。

Server and version/サーバーとバージョン

  • Server: Paper 1.19.3-323
  • Server version (Minecraft version) : 1.19.3
  • Other plugins: none
  • LunaChat version : 3.0.16

To Reproduce/再現手順

  1. 下記の通り単語を登録します
/ch dic add oosubame オオスバメ
/ch dic add subame スバメ
/ch dic add kokoromori ココロモリ
/ch dic add koromori コロモリ
/ch dic add neitio ネイティオ
/ch dic add neiti ネイティ
  1. 登録した単語を使用してチャットを送信します
subametooosubame (スバメと大スバメ)
oosubametosubame (大スバメとスバメ)
koromoritokokoromori (コロモリとこコロモリ)
kokoromoritokoromori (小コロモリとコロモリ)
neititoneitio (ネイティとネイティお)
neitiotoneiti (ネイティおとネイティ)

Expected behavior/期待する結果
上述の辞書登録およびチャット内容を送信した場合、ユーザーは下記のように変換されることを期待します。

subametooosubame (スバメとオオスバメ)
oosubametosubame (オオスバメとスバメ)
koromoritokokoromori (コロモリとココロモリ)
kokoromoritokoromori (ココロモリとコロモリ)
neititoneitio (ネイティとネイティオ)
neitiotoneiti (ネイティオとネイティ)

現状は、はじめにヒットした文字数の少ない単語のほうが優先的にロックされてしまうため、意図通りの結果になっていません。

Additional context/備考
このバグを解消するためには com.github.ucchyocean.lc3.japanizeJapanizer クラスの下記のコードを修正すれば良いと思われます。

for ( String dickey : dictionary.keySet() ) {
  // (中略)
}

このコードでは HashSet の中身をそのままイテレートしていますが、そうではなく、HashSet を List に変換した上で文字数の多い順にソートしてからイテレートすることにより、意図通りの変換が行われるようになります。

nafu-at added a commit to mofucraft/LunaChat that referenced this issue Dec 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant