Skip to content
CAI
Software that uses CAICheck a score

overtrue/pinyin

57.7

Adequate · 17 November 2026

252.6k

lines of production code

PHP

primary language

5

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a PHP library for converting Chinese text to Pinyin, featuring a v6.0 rewrite that introduces a strategy-based architecture for balancing memory usage and performance. It provides a fluent API with specialized methods for handling names, phrases, and permalinks, supported by an expanded pronunciation database and a CLI tool for data management and conversion.

Features

New CLI tool and build script for Pinyin data management

This change introduces a new command-line interface (\bin/pinyin\) and a data build script (\bin/build\) for the Pinyin library. The CLI allows users to convert Chinese text to pinyin using various methods (sentence, fullSentence, name, passportName, phrase, permalink, heteronym, chars, abbr, nameAbbr) with options for JSON output, tone styles, and compact formatting. The build script automates the download and processing of pinyin data sources (characters, words, heteronyms, surnames) to generate the necessary data files for the library.

bin · high confidence

New benchmark suite for comparing Pinyin conversion strategies

Added a new benchmark suite in the \benchmark\ directory to evaluate and compare the performance of different Pinyin conversion strategies (Memory Optimized, Cached, and Smart). The suite includes \run.php\ and \compare-strategies.php\ scripts that measure execution time and memory usage across various text lengths and scenarios (cold start, warm cache, batch processing), generating HTML reports to help users choose the most efficient strategy for their specific use case.

benchmark · high confidence

Behavioural changes

Expanded Chinese pronunciation database with corrected readings and new character sets

The data layer has been significantly updated to improve pronunciation accuracy and coverage. The \chars.php\ file was replaced with a new version containing over 177,000 entries, adding support for many rare and variant Chinese characters. The \surnames.php\ file was also replaced, providing a comprehensive list of multi-character and polyphonic surnames with their correct pronunciations. Additionally, the \words-\*.php\ files were refreshed to include thousands of new multi-character word entries, ensuring that complex terms and proper nouns are recognized. Several specific pronunciation errors were corrected, including the reading of '琢' (now correctly mapped to 'zhuó' instead of 'zhuo' in some contexts), '炔' (corrected to 'que'), and '仆区' (corrected to 'pú ōu').

data · high confidence

Major v6.0 rewrite with strategy-based conversion and new API

The library has been rewritten for version 6.0, introducing a new fluent API and a factory-based architecture that allows users to choose between three conversion strategies: Memory Optimized (default, low memory), Cached (fastest, higher memory), and Smart (balanced). The new \Pinyin\ class provides dedicated static methods for specific use cases, including \name()\ for surname-aware conversion, \passportName()\ for official document formatting, \phrase()\, \sentence()\, and \fullSentence()\ for different text granularities, and \abbr()\ which now supports preserving English words. The conversion engine now uses a \ConverterInterface\ and \Collection\ class, replacing the previous implementation to improve performance and flexibility.

src · high confidence

Version 6.0.0 release with performance optimization strategies

This release introduces a new performance optimization strategy system that allows users to choose between Memory Optimized (\~400KB), Cached (\~4MB), and Smart (600KB-1.5MB) modes via new static methods like \Pinyin::useMemoryOptimized()\, \Pinyin::useCached()\, and \Pinyin::useSmart()\. The default strategy has changed to Memory Optimized to significantly reduce memory usage, while maintaining full backward compatibility with existing 5.x API calls. The release also includes new benchmarking tools and updated documentation reflecting these architectural changes.

(repo-wide) · high confidence

Test coverage

Added comprehensive test suite for Pinyin library components

Added PHPUnit tests covering the Collection class (construction, iteration, JSON serialization, and ArrayAccess), the ConverterFactory (strategy selection, default strategy management, and context-based recommendations), and the three converter strategies (MemoryOptimized, Cached, and Smart) to verify functional parity, tone style handling, surname resolution, and memory usage characteristics. Additional tests validate the Pinyin facade's static method chaining, strategy switching, and specific conversion behaviors for names, phrases, and permalinks.

tests · high confidence

Dependencies

Update project dependencies and PHP version requirement

The composer.json manifest has been updated to require PHP 8.1 or higher. Development dependencies have been upgraded to phpunit ^10.5/11.5/12.0, brainmaestro/composer-git-hooks ^3.0, nunomaduro/termwind ^1.0/2.0, and laravel/pint ^1.10.

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 58.1 → 57.7 (-0.4)
  • Rubric changed (rubric-2026.11.2 → rubric-2026.11.4) — scores are not directly comparable.

Lenses

  • Code Health 99.4 → 99.3 (-0.1)
  • Architecture 64.8 → 62.6 (-2.2)
  • Maturity 54.4 → 54.4 (0.0)
  • Readiness 50.2 → 50.2 (0.0)
  • Security 82.4 → 82.4 (0.0)

Resolved (1)

  • No ADRs found

New (3)

  • Circular dependency (src/ConverterFactory.php)
  • Edited copies of one member (3 members, 18+ corresponding lines) (src/Converters/CachedConverter.php)
  • No ADRs found (composer.json)

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

overtrue/pinyin was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 17 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 5d6537e39ae906f1125d44a66188717c5a463de0 — the exact code this score is about.
  • Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.85+preprod-eba6548ac50f.