Skip to content

feat: add CJK word segmentation for graph query #1013

Closed

Description

@candy-Tong

Problem

graphify query does not segment CJK (Chinese/Japanese/Korean) text. Searching for "页面路由" treats it as one opaque string, so nodes with label "路由" are not found. Only searching for the exact substring "路由" works.

Root Cause

_query_terms() in serve.py splits queries by whitespace only. CJK text has no spaces between words, so "页面路由" becomes a single term. The substring matching (t in norm_label) is one-directional — it checks if the term is inside the label, not the reverse.

Proposed Solution

Add jieba-based CJK word segmentation to _query_terms():

  • "页面路由" → terms = ["页面", "路由", "页面路由"]
  • Segmented terms enable substring matching ("路由" matches nodes with "路由" in label)
  • Original term kept for exact matching ("页面路由" gets EXACT_MATCH_BONUS)
  • Falls back to character bigrams when jieba is not installed
  • jieba added as optional dependency: pip install graphifyy[cjk]

MR

#1000

Activity

  1. safishamsi commented on May 26, 2026

    @safishamsi
    Member

    Resolved in v0.8.19 via #1026 — Chinese compound tokens are now split using jieba (with bigram fallback when jieba is not installed). Install with pip install "graphifyy[chinese]".

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions