Imported from Yousa-Mirage/jiebaRS (
AGENTS.md). Install upstream withnpx skills add Yousa-Mirage/jiebaRS. Copyright stays with the author.
Repository Guidelines
jiebaRS is an R package for fast Chinese text segmentation, part-of-speech
tagging, and keyword extraction (TF-IDF, TextRank), powered by a Rust backend
(jieba-rs) bridged with extendr.
Project Structure & Module Organization
R/contains the public R API and internal helpers. Roxygen comments generate files inman/and exports inNAMESPACE.src/contains the R native entrypoint and build configuration. The Rust implementation is undersrc/rust/src/; its Cargo manifest and lockfile are insrc/rust/. Rust functions exposed to R carry#[extendr]; this generatesR/extendr-wrappers.R, which must never be edited by hand.tests/testthat/contains edition-3 tests, snapshots, and optional real dictionary fixtures undertests/testthat/fixtures/.data-raw/stores source stopword files and generation scripts. Compiled package data is stored indata/.README.RmdandREADME_en.Rmdare the README sources.README.mdandREADME_en.mdare generated outputs.
Build, Test, and Development Commands
just documentbuilds Rust-generated wrappers, regenerates R documentation, and rebuilds both README files.just testruns the R testthat suite and Rust tests.just formatrunsr-airfor R files andcargo fmtfor Rust files.just checkrunsjarl, spelling checks, and Rust Clippy with warnings as errors.just pkg-checkruns the package check;just siterebuilds READMEs and the pkgdown site.
Run focused R tests with, for example,
Rscript -e "devtools::test(filter = 'cidian')".
After changing Rust functions marked #[extendr] or any Roxygen comments, run
just document so R/extendr-wrappers.R, man/, and both READMEs are
regenerated; commit those generated outputs rather than hand-editing them.
Coding Style & Naming Conventions
Use two-space indentation in R, the base |> pipe, and snake_case names.
Use standard Rust formatting with cargo fmt and keep the Rust side
compatible with rustc >= 1.85. Keep public R functions
documented with Roxygen and keep internal generated wrappers out of the user
reference where appropriate.
Testing Guidelines
Name R tests tests/testthat/test-<feature>.R; place snapshots in
tests/testthat/_snaps/. Add focused tests for every user-facing behavior and
run both R and Rust tests before submitting changes. Tests may run in parallel;
avoid shared writable temporary files and use testthat temporary paths.
Commit & Pull Request Guidelines
Use short conventional-style subjects such as fix(build): support Windows ARM64, docs: ..., or test: .... Work on a feature branch rather than
main. A pull request should explain the behavior change, list validation
commands and platform-specific checks, link related issues, and include
regenerated documentation when source comments or README sources changed.
