Skip to content

Port PR14140 and PR16881 to GO - #17102

Merged
yuzhichang merged 2 commits into
infiniflow:mainfrom
qinling0210:port_to_go
Jul 21, 2026
Merged

yuzhichang merged 2 commits into
infiniflow:mainfrom
qinling0210:port_to_go

Conversation

@qinling0210

Copy link
Copy Markdown
Contributor

Summary

Port
#14140
#16881

@qinling0210 qinling0210 self-assigned this Jul 20, 2026
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 20, 2026
@qinling0210 qinling0210 added the ci Continue Integration label Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds runtime language selection across ingestion, Go, C, and C++ tokenizer layers. Updates stemming, lemmatization, POS handling, stopword filtering, analyzer state, and CSV/Q&A/tag parsing for multiline records.

Changes

Language-aware tokenization

Layer / File(s) Summary
C++ analyzer language and token flow
internal/binding/cpp/rag_analyzer.*
Adds language-normalized stemmer initialization, conditional lemmatization, stopword filtering, direct POS decoding, and member-controlled analysis flags.
Language configuration API bridge
internal/binding/cpp/rag_analyzer_c_api.*, internal/binding/rag_analyzer*, internal/tokenizer/tokenizer.go
Exposes SetLanguage through C and Go APIs and applies the configured language to acquired analyzers.
Ingestion language propagation and record parsing
internal/ingestion/component/*, internal/ingestion/task/pipeline_executor.go
Propagates lang through pipeline outputs and tokenizer consumers, and separates tab parsing from multiline CSV parsing in chunkers.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: 💞 feature, ☯️ refactor

Suggested reviewers: yingfeng, yuzhichang, jinhai-cn

Poem

I’m a rabbit with tokens to spare,
Setting each language with care.
CSV lines curl, stems gently align,
Stopwords hop out of the line.
Through Go and C++ the words now flow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: porting PR14140 and PR16881 to Go.
Description check ✅ Passed The description includes the required Summary section and identifies the two upstream PRs being ported.

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/ingestion/component/chunker/qa.go`:
- Around line 308-358: Update extractQATextCSV to distinguish io.EOF from
non-EOF errors returned by csv.Reader.Read: stop only at EOF, and continue
processing after recoverable malformed-row parse errors so later Q&A pairs are
not silently discarded. Preserve the existing record handling and line-offset
mapping, while ensuring any record/error state needed to represent the malformed
row does not prevent subsequent reads.
- Around line 121-123: Update the Q&A chunking flow around
ContentLtks/ContentSmLtks to derive the language from c.param.Lang, defaulting
to English when unset, rather than inputs["lang"]; set the tokenizer language
once before iterating qaPairs, and extend the Chinese test coverage to verify
both content token fields.

In `@internal/ingestion/component/tokenizer.go`:
- Around line 623-629: Update the documentation comment for the tokenizer
language handling to remove the stale statement that setting the language is a
no-op, since the implementation now invokes tokenizer.SetLanguage. Keep the
existing description of the Python behavior and backward-compatible default
accurate.

In `@internal/tokenizer/tokenizer.go`:
- Around line 465-471: The tokenizer’s global language state causes races and
lets pooled analyzers retain a previous task’s language. In
internal/tokenizer/tokenizer.go (465-471), remove SetLanguage; also remove
globalLang at 80, update withAnalyzer (411-414) and withAnalyzerResult (431-434)
to accept a language and always apply it, using the established fallback such as
English when unspecified. In internal/ingestion/component/extractor.go (599 and
637) and internal/ingestion/component/chunker/tag.go (111-117), replace
SetLanguage calls by passing in.lang or lang directly to the tokenization API.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 412607c7-49bb-4dc6-bd7c-aa6a2ea61610

📥 Commits

Reviewing files that changed from the base of the PR and between 6454104 and 566a4f3.

📒 Files selected for processing (17)
  • internal/binding/cpp/rag_analyzer.cpp
  • internal/binding/cpp/rag_analyzer.h
  • internal/binding/cpp/rag_analyzer_c_api.cpp
  • internal/binding/cpp/rag_analyzer_c_api.h
  • internal/binding/cpp/rag_analyzer_c_api_debug.cpp
  • internal/binding/rag_analyzer.go
  • internal/binding/rag_analyzer_nocgo.go
  • internal/ingestion/component/chunker/qa.go
  • internal/ingestion/component/chunker/tag.go
  • internal/ingestion/component/extractor.go
  • internal/ingestion/component/globals/globals.go
  • internal/ingestion/component/parser.go
  • internal/ingestion/component/parser_dispatch.go
  • internal/ingestion/component/tokenizer.go
  • internal/ingestion/component/tokenizer_test.go
  • internal/ingestion/task/pipeline_executor.go
  • internal/tokenizer/tokenizer.go

Comment thread internal/tokenizer/tokenizer.go Resolved
@qinling0210
qinling0210 marked this pull request as draft July 20, 2026 08:16
@qinling0210
qinling0210 marked this pull request as ready for review July 21, 2026 08:38
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 21, 2026
@yuzhichang

Copy link
Copy Markdown
Member

LGTM

@yuzhichang
yuzhichang merged commit 0189ca3 into infiniflow:main Jul 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants