Skip to content

Enhancement: 國際化 word boundary 檢查 #4

@HCYT

Description

@HCYT

來源

問題描述

目前 non_word_boundaries 是硬編碼的 ASCII 字符集:

self.non_word_boundaries = set(string.digits + string.ascii_letters + '_')

這對非 ASCII 語言不夠友好。

建議方案

使用 Python 的 \W regex class 或 Unicode category 來判斷 word boundary:

import unicodedata

def is_word_char(char):
    category = unicodedata.category(char)
    return category.startswith(('L', 'N'))  # Letter or Number

考量

  • 效能影響:需要 benchmark 測試
  • 向後兼容:可能需要新增參數 unicode_boundaries=True

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions