Skip to content

Conversation

@sffc
Copy link
Member

@sffc sffc commented Nov 4, 2025

#7216

I called the tool experimental_segmenter and didn't add the benchmark plumbing since that is out of scope.

CC @opnuub @SahandFarhoodi

@sffc sffc requested a review from Manishearth November 4, 2025 06:48
@sffc
Copy link
Member Author

sffc commented Nov 4, 2025

Run the tool like this:

$ cargo run --release --all-features --example experimental_segmenter -- adaboost "鉴于对人类"
Output:
|鉴于|对|人类|
1000 repetitions done in: 5.990191ms

Snapshot on my machine in this PR:

$ cargo run --release --all-features --example experimental_segmenter -- dict "鉴于对人类家庭所有成员的固有尊严及其平等的和不得完的权利的承认,乃是世界自由 、正义与和平的基脚"
Output:
|鉴于|对|人类|家庭|所有|成员|的|固有|尊严|及其|平等|的|和|不得|完|的|权利|的|承认|,|乃是|世界|自由|、|正义|与|和平|的|基|脚|
1000 repetitions done in: 14.331306ms

$ cargo run --release --all-features --example experimental_segmenter -- adaboost "鉴于对人类家庭所有成员的固有尊严及其平等的和不得完的权利的承认,乃是世界 自由、正义与和平的基脚"
Output:
|鉴于|对|人类|家庭|所有|成员|的|固有|尊严|及|其平等|的|和|不得|完|的|权利|的|承认|,|乃|是|世界|自由|、|正义|与|和平|的|基脚|
1000 repetitions done in: 62.541793ms

$ cargo run --release --all-features --example experimental_segmenter -- dict "โดยที่การยอมรับนับถือเกียรติศักดิ์ประจำตัว และสิทธิเท่าเทียมกันและโอนมิได้ของบรรดา สมาชิก ทั้ง หลายแห่งครอบครัว มนุษย์เป็นหลักมูลเหตุแห่งอิสรภาพ ความยุติธรรม และสันติภาพในโลก"
Output:
|โดยที่|การ|ยอมรับ|นับถือ|เกียรติศักดิ์|ประจำ|ตัว| |และ|สิทธิ|เท่า|เทียม|กัน|และ|โอน|มิได้|ของ|บรรดา| |สมาชิก| |ทั้ง| |หลาย|แห่ง|ครอบครัว| |มนุษย์|เป็น|หลัก|มูล|เหตุ|แห่ง|อิสรภาพ| |ความ|ยุติธรรม| |และ|สันติภาพ|ใน|โลก|
1000 repetitions done in: 22.134186ms

$ cargo run --release --all-features --example experimental_segmenter -- lstm "โดยที่การยอมรับนับถือเกียรติศักดิ์ประจำตัว และสิทธิเท่าเทียมกันและโอนมิได้ของบรรดา สมาชิก ทั้ง หลายแห่งครอบครัว มนุษย์เป็นหลักมูลเหตุแห่งอิสรภาพ ความยุติธรรม และสันติภาพในโลก"
Output:
|โดย|ที่|การ|ยอม|รับ|นับถือ|เกียรติศักดิ์|ประจำ|ตัว| |และ|สิทธิ|เท่าเทียม|กัน|และ|โอน|มิ|ได้|ของ|บรรดา| |สมาชิก| |ทั้ง| |หลาย|แห่ง|ครอบครัว| |มนุษย์|เป็น|หลักมูลเหตุ|แห่ง|อิสรภาพ| |ความ|ยุติ|ธรรม| |และ|สันติภาพ|ใน|โลก|
1000 repetitions done in: 2.263691291s

$ cargo run --release --all-features --example experimental_segmenter -- cnn "โดยที่การยอมรับนับถือเกียรติศักดิ์ประจำตัว และสิทธิเท่าเทียมกันและโอนมิได้ของบรรดา สมาชิก ทั้ง หลายแห่งครอบครัว มนุษย์เป็นหลักมูลเหตุแห่งอิสรภาพ ความยุติธรรม และสันติภาพในโลก"
Output:
|โดย|ที่|การ|ยอม|รับ|นับถือ|เกียรติศักดิ์|ประจำ|ตัว| |และ|สิทธิ|เท่า|เทียม|กัน|และ|โอน|มิ|ได้|ของ|บรรดา| |สมาชิก| |ทั้ง| |หลาย|แห่ง|ครอบครัว| |มนุษย์|เป็น|หลัก|มูล|เหตุ|แห่ง|อิสรภาพ| |ความ|ยุติธรรม| |และ|สันติภาพ|ใน|โลก|
1000 repetitions done in: 3.075162331s

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand all the details here but this looks cool!

@sffc sffc merged commit f3cff8c into unicode-org:main Nov 6, 2025
30 checks passed
@sffc sffc deleted the experimental_segmenter branch November 6, 2025 21:46
@sffc
Copy link
Member Author

sffc commented Nov 12, 2025

Seems I need to add the example boilerplate or else CI gets angry. #7241

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants