Desktop: the filters and position search of ChessBase for every database

- chess-import pgn_catalog: the tags of a PGN as ChessBase's filters, sorting and name
  suggestions (tournament «Event (place) year», dates with any separator, rating, ECO,
  length counted when there is no PlyCount, comments without clock marks); the quick
  search (Filter::text) for PGN and ChessBase, ё folded as е; which fields a database
  has. The PGN scan counts main-line and all moves and real comments; the position
  table's memory is reckoned from the moves.
- Desktop: one view for all databases (large_db.rs): the PGN table and its small board
  are gone; the quick search in the header with its chip, Ctrl+F twice to the filters;
  downloaded databases sorted newest first by date; texts' checkbox only where there are
  texts; an empty result says which field no game has; position search without memory
  says so on the board and its chip; a reread keeps the conditions.
- Bench: the quick search on a large base.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-23 23:39:31 +03:00
parent e8deec7b27
commit 29ffff3de9
13 changed files with 1855 additions and 868 deletions

View file

@ -124,6 +124,16 @@ cargo test -p chess-import # модульные + фор
cargo run -p chess-import --example convert -- "Book.cbv" > book.pgn # PGN в stdout, заметки в stderr
```
## Фильтры PGN (`pgn_catalog.rs`)
Каталог тегов PGN с теми же фильтрами, сортировкой и подсказками имён, что у ChessBase (`Filter`, `NameFilter`, `Names` и `fold` общие из `chessbase/base.rs`), для единого экрана библиотеки (`docs/design/large-databases.md` §9). Строится один раз при первом запросе (в фоновом проходе фильтра), на партию — номера игроков и турнира, дата, Эло, результат, ECO, длина и признаки; десятки байт на партию.
- Турнир — как у ChessBase: «Event (место) год»; место из `Site`, если это не `?` и не ссылка. Год — из `Date`, иначе из `UTCDate`; разделители `.`, `-`, `/`.
- Длина — `PlyCount`, иначе полуходы основной линии, посчитанные при сканировании (`GameEntry::main_plies`); `all_plies` (с вариантами) даёт оценку памяти для таблицы позиций.
- «С комментариями» — `has_text_comments`: текст помимо команд `[%…]` (часы онлайн-партий — не комментарии).
- Быстрый поиск (`Filter::text`) — каждое слово в каком-нибудь поле: игроки, турнир, комментатор, место, ECO, дата. У ChessBase — игроки, турнир, комментатор, ECO, год (таблицы по годам и кодам ECO: Mega — около 0,1 с).
- Сортировка по дате — по времени партии (`UTCDate` + `UTCTime`, иначе `Date`): так скачанные партии идут свежими сверху.
## Поиск по позиции (PGN)
Модуль `crates/chess-import/src/pgn_positions.rs` (решение 13 в `docs/decisions.md`). Работает для PGN-файлов и для всего, что конвертируется в `PgnDatabase`: малые ChessBase (`.cbh` < 20 000 записей, `.cbv`) и архивы. Общие типы — `position.rs`.