Search by

r34117y / kwg-parser

r34117y

Extract word lists from Kurnia Word Graph (KWG) files.

Package info

github.com/r34117y/kwg-parser

pkg:composer/r34117y/kwg-parser

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-08-27 13:53 UTC

This package is auto-updated.

Last update: 2026-08-27 14:04:40 UTC


README

KWG Parser extracts word lists from Kurnia Word Graph (KWG) files used by computer Scrabble tools.

Installation

composer require r34117y/kwg-parser

Usage

use Agrzelec\KwgParser\KwgWordExtractor;
use Agrzelec\KwgParser\KwgWordListWriter;

$extractor = new KwgWordExtractor();
$words = $extractor->extract('/path/to/NWL23.kwg');

$writer = new KwgWordListWriter();
$writer->write('/path/to/words.txt', $words);

Extraction returns a deterministic alphabetically sorted list<string>. Saving writes exactly one word per line using UTF-8-compatible plain text.

Supported Alphabets

The extractor recognizes common real-world lexicon filename prefixes and applies the matching alphabet automatically. Supported alphabets are English, Catalan, Dutch, French, German, Norwegian, Polish, Slovene, and Spanish.

This allows national alphabet KWGs with tile values beyond Z, such as NSF25.kwg, OSPS52.kwg, RD29.kwg, and SLV26.kwg, to produce stable UTF-8 word lists. Unknown lexicon filename prefixes use the English alphabet by default and fail clearly if the KWG contains tile values that cannot be resolved.

Errors

Agrzelec\KwgParser\Exception\InvalidKwgFileException is thrown when a KWG path is missing, unreadable, empty, truncated, malformed, uses unresolvable tile labels, or is not a supported KWG file.

Agrzelec\KwgParser\Exception\WordListWriteException is thrown when the destination text file cannot be created or written.

Quality

composer test
composer analyse
composer cs-check
composer check

Versioning

This package follows Semantic Versioning. Public API compatibility is maintained across patch and minor releases within the same major version; breaking public API changes are reserved for major releases.