diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b201cf9..6cdb0d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,8 @@ name: release # release-please keeps a "chore: release" PR up to date from conventional commits on main. -# Merging that PR tags js-vX.Y.Z / spec-vX.Y.Z / python-vX.Y.Z, creates the GitHub Releases, and -# publishes to npm and PyPI. +# Merging that PR tags js-vX.Y.Z / spec-vX.Y.Z / python-vX.Y.Z / rust-vX.Y.Z, creates the GitHub +# Releases, and publishes to npm, PyPI and (once enabled) crates.io. on: push: @@ -13,6 +13,10 @@ on: description: "Re-publish an existing python release tag to PyPI (e.g. python-v0.2.0). Leave empty for a normal release-please run." required: false default: "" + rust_tag: + description: "Re-publish an existing rust release tag to crates.io (e.g. rust-v0.5.0). Leave empty for a normal release-please run." + required: false + default: "" permissions: {} @@ -33,6 +37,9 @@ jobs: python_release_created: ${{ steps.release.outputs['python--release_created'] }} python_tag_name: ${{ steps.release.outputs['python--tag_name'] }} python_version: ${{ steps.release.outputs['python--version'] }} + rust_release_created: ${{ steps.release.outputs['rust--release_created'] }} + rust_tag_name: ${{ steps.release.outputs['rust--tag_name'] }} + rust_version: ${{ steps.release.outputs['rust--version'] }} steps: - uses: googleapis/release-please-action@v4 id: release @@ -233,3 +240,88 @@ jobs: EOF # The npm release (js-vX.Y.Z) stays "Latest"; don't touch that flag here. gh release edit "$TAG" --notes-file notes.md + + # crates.io trusted publishing (OIDC, no stored token). It can only be configured for a crate + # that already exists, so the very first `cargo publish` is done by the maintainer by hand. + # After that: on crates.io add a trusted publisher for 4matic/trackparse, workflow release.yml, + # environment "crates", then set the repository variable CRATES_PUBLISH to "true". + publish-crates: + needs: release-please + if: vars.CRATES_PUBLISH == 'true' && (needs.release-please.outputs.rust_release_created == 'true' || (github.event_name == 'workflow_dispatch' && inputs.rust_tag != '')) + runs-on: ubuntu-latest + environment: + name: crates + url: https://crates.io/crates/trackparse + permissions: + contents: write # attach the .crate file to the GitHub Release + id-token: write # crates.io trusted publishing (OIDC) + steps: + - name: Resolve the release tag + id: tag + env: + RELEASED_TAG: ${{ steps.tag.outputs.tag }} + RELEASED_VERSION: ${{ steps.tag.outputs.version }} + INPUT_TAG: ${{ inputs.rust_tag }} + run: | + if [ -n "$INPUT_TAG" ]; then + if ! printf '%s' "$INPUT_TAG" | grep -Eq '^rust-v[0-9]+\.[0-9]+\.[0-9]+$'; then + echo "rust_tag must look like rust-vX.Y.Z" >&2 + exit 1 + fi + tag="$INPUT_TAG" + version="${INPUT_TAG#rust-v}" + else + tag="$RELEASED_TAG" + version="$RELEASED_VERSION" + fi + echo "tag=$tag" >> "$GITHUB_OUTPUT" + echo "version=$version" >> "$GITHUB_OUTPUT" + - uses: actions/checkout@v4 + with: + ref: ${{ steps.tag.outputs.tag }} + # The runner image ships stable Rust; no third-party toolchain action in the publishing job. + - run: rustup update stable --no-self-update && rustup default stable + - name: Verify versions are in sync + env: + TAG_VERSION: ${{ steps.tag.outputs.version }} + run: | + rs_version=$(python3 -c 'import tomllib; print(tomllib.load(open("rust/Cargo.toml", "rb"))["package"]["version"])') + spec_version=$(cat spec/VERSION) + echo "rust=$rs_version spec=$spec_version tag=$TAG_VERSION" + test "$rs_version" = "$TAG_VERSION" + test "$spec_version" = "$TAG_VERSION" + - name: Test + working-directory: rust + run: cargo test --all-features + - name: Package + working-directory: rust + run: cargo package + - uses: rust-lang/crates-io-auth-action@3268eb413133e2960fa4ae0e963ca76380c54cd9 # v1.0.6 + id: auth + - name: Publish to crates.io + working-directory: rust + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} + run: cargo publish + - name: Attach the crate file and install notes to the GitHub Release + working-directory: rust + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ steps.tag.outputs.tag }} + VERSION: ${{ steps.tag.outputs.version }} + run: | + gh release upload "$TAG" target/package/*.crate --clobber + highlights="../.github/release-notes/${VERSION}.md" + { + if [ -f "$highlights" ]; then cat "$highlights"; echo; fi + gh release view "$TAG" --json body --jq .body + echo + echo "### Install" + echo + echo '```sh' + echo "cargo add trackparse@${VERSION}" + echo '```' + echo + echo "crates.io: https://crates.io/crates/trackparse/${VERSION} · docs: https://docs.rs/trackparse/${VERSION}" + } > notes.md + gh release edit "$TAG" --notes-file notes.md diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..b503f08 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,74 @@ +name: rust + +on: + push: + branches: [main] + pull_request: + paths: + - "rust/**" + - "spec/**" + # The compare job diffs the crate against the built JS package. + - "js/src/**" + - "scripts/compare-ports.mjs" + - ".github/workflows/rust.yml" + +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # stable, and the minimum supported Rust version from rust/Cargo.toml (rust-version). + toolchain: [stable, "1.74.0"] + defaults: + run: + working-directory: rust + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + with: + workspaces: rust + - uses: actions/setup-node@v4 + with: + node-version: 24 + - name: Data codegen is up to date + run: node scripts/gen_data.mjs --check + - if: matrix.toolchain == 'stable' + run: cargo fmt --check + - if: matrix.toolchain == 'stable' + run: cargo clippy --all-targets --all-features -- -D warnings + # Every shared fixture, the invariants and the API tests. + - run: cargo test --locked + - if: matrix.toolchain == 'stable' + run: cargo test --all-features + - if: matrix.toolchain == 'stable' + name: The crate packages cleanly + run: cargo publish --dry-run + + # Every fixture input through the built JS package and the Rust crate: full outputs must match. + compare: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: rust + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm --filter trackparse build + - run: node scripts/compare-ports.mjs --only=rust diff --git a/.github/workflows/spec.yml b/.github/workflows/spec.yml index 4216ec2..4d4e045 100644 --- a/.github/workflows/spec.yml +++ b/.github/workflows/spec.yml @@ -34,11 +34,13 @@ jobs: run: pnpm --filter @trackparse/fixture-gen test - name: Port data codegen is up to date run: pnpm --filter trackparse gen:data:check - - name: js, python and spec versions are linked + - name: js, python, rust and spec versions are linked run: | js_version=$(node -p "require('./js/package.json').version") py_version=$(python3 -c 'import tomllib; print(tomllib.load(open("python/pyproject.toml", "rb"))["project"]["version"])') + rs_version=$(python3 -c 'import tomllib; print(tomllib.load(open("rust/Cargo.toml", "rb"))["package"]["version"])') spec_version=$(cat spec/VERSION) - echo "js=$js_version python=$py_version spec=$spec_version" + echo "js=$js_version python=$py_version rust=$rs_version spec=$spec_version" test "$js_version" = "$spec_version" test "$py_version" = "$spec_version" + test "$rs_version" = "$spec_version" diff --git a/.gitignore b/.gitignore index d8877ba..d816ccf 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,6 @@ python/dist/ # Rust target/ -rust/Cargo.lock # Editors / OS .DS_Store diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 5c30d36..8e281b2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,5 +1,6 @@ { "js": "0.4.0", "spec": "0.4.0", - "python": "0.4.0" + "python": "0.4.0", + "rust": "0.4.0" } diff --git a/AGENTS.md b/AGENTS.md index 59bae05..808cd2d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -78,23 +78,52 @@ python/ PyPI package `trackparse` (Python 3.9+, zero deps, uv tests/ runner.py, match.py, test_fixtures.py, test_properties.py (Hypothesis), test_api.py, test_match.py, test_tracklist_api.py, test_tracklist_properties.py, skip.json (only ever shrinks) -rust/ planned crates.io port (README stub only) +rust/ crates.io package `trackparse` (Rust 1.74+, one dependency, no unsafe; + a release-please component, first crates.io publish still to do) + src/lib.rs public API: parse, parse_with, parse_artists(_with), format_track(_with), + normalize, all_artists, Parser, SPEC_VERSION; re-exports every type and + option at the crate root (`types` and `options` are private modules) + src/types.rs public structs and enums (mirror the schemas): to_json(), and + as_str() / from_name() / ALL / Display / FromStr on the enums + src/options.rs ParseOptions, FormatOptions, KeywordOptions (#[non_exhaustive], chained + setters from ::new()) + resolved forms + src/*.rs one module per js/src file, same rule IDs in comments: parser, normalize, + mode, scanner, prefix, classify, separator, artists, credits, title, + assemble, format, words, digits, tables, context + src/tracklist/ public `trackparse::tracklist` (parse_tracklist(_with), apply_edits(_with)), + one module per js/src/tracklist file (mod.rs is index.ts) + src/json.rs hand-written JSON value, parser and writer with JS number formatting + src/wire.rs the JSON door (doc-hidden): every function with loose JSON arguments, + for the fixtures and the cross-port diff + src/serde_support.rs serde impls behind the `serde` feature + src/data.rs GENERATED from spec/data + spec/VERSION (never edit) + src/unicode_tables.rs GENERATED: categories L and Lu, the lowercase mapping (never edit) + src/value.rs the static value type data.rs is written in + scripts/gen_data.mjs codegen for data.rs and unicode_tables.rs (--check for CI) + scripts/dump_primitives.mjs expected R0 primitive values from JS, into tests/data/ + examples/dump.rs Rust side of compare-ports (JSONL in, JSON out, through wire) + tests/ fixtures.rs (every shared fixture + the conformance report), api.rs, + tracklist_api.rs, tracklist_properties.rs (R13.11 invariants), serde.rs, + data/primitives.json (from dump_primitives.mjs), skip.json (only ever shrinks) site/ documentation site + playground (Astro + Starlight, GitHub Pages) astro.config.mjs base /trackparse, sidebar - src/content/docs/ the pages (Markdown/MDX, JS + Python tabs on every example); + src/content/docs/ the pages (Markdown/MDX, JS + Python + Rust tabs on every example); reference/spec.md is generated from spec/SPEC.md src/components/ HeroDemo, Playground (runs js/ in the browser), Feature, Stats src/lib/ trackview.ts (highlight + field rendering), icons.ts (Lucide SVG strings) scripts/sync-spec.mjs copies spec/SPEC.md into the docs at build time -scripts/compare-ports.mjs every fixture through js/dist and the Python port, diffs the full outputs - (parseTracklist and applyEdits included) +scripts/compare-ports.mjs every fixture through js/dist, the Python port and the Rust crate, diffs + the full outputs (parseTracklist and applyEdits included); + --only=python or --only=rust for one port scripts/corpus-check.mjs R13 against a private tracklist corpus (JSONL in spec/corpus/), via js/dist scripts/dump_py.py Python side of compare-ports (JSONL in, to_dict() JSON out) .github/workflows/ js.yml (full suite on Node 22/24; compat: fixtures vs built dist on Node 18/20), python.yml (lint, mypy, pytest on 3.9–3.14; build: fixtures vs installed wheel), + rust.yml (codegen drift, fmt, clippy, cargo test on stable and 1.74, + publish dry run; compare: Rust vs built JS on every fixture), spec.yml (fixture validation, generated/codegen drift, generator tests, - js/python/spec version link), release.yml (release-please + npm and PyPI - publish), pages.yml (build site/, deploy to GitHub Pages), + js/python/rust/spec version link), release.yml (release-please + npm, PyPI + and crates.io publish), pages.yml (build site/, deploy to GitHub Pages), pr-title.yml (conventional PR titles) .github/release-notes/ optional hand-written highlights prepended to a GitHub Release release-please-config.json, .release-please-manifest.json release automation (never hand-edit the manifest) @@ -107,8 +136,9 @@ js/CHANGELOG.md, spec/CHANGELOG.md, python/CHANGELOG.md generated by release-p - Never change a port's behaviour without a fixture that pins the new behaviour. If a fix needs no fixture change, it is a bug fix; if an existing `expected` changes, it is a behaviour change. -- Never hand-edit `spec/fixtures/generated/**`, `js/src/data.generated.ts` or - `python/src/trackparse/_data.py`. Regenerate them. +- Never hand-edit `spec/fixtures/generated/**`, `js/src/data.generated.ts`, + `python/src/trackparse/_data.py`, `rust/src/data.rs` or `rust/src/unicode_tables.rs`. Regenerate + them. - Word lists live **only** in `spec/data/`. Ports compile them into source with codegen; never copy a list into port code by hand, never hard-code a keyword in a scanner. - The fixtures, not any one implementation, are the source of truth. When SPEC.md and a fixture @@ -133,16 +163,16 @@ js/CHANGELOG.md, spec/CHANGELOG.md, python/CHANGELOG.md generated by release-p expected output must come from the atoms, never from running a parser. If a combination becomes ambiguous, reject it in `model.ts` (`problem()`) instead of guessing. Then `pnpm gen:fixtures` and commit the output. -4. **Codegen.** If `spec/data` or `spec/VERSION` changed: `pnpm gen:data` and, in `python/`, - `uv run python scripts/gen_data.py`. -5. **Implementation.** Change every port (JS and Python today). Cite rule IDs in comments. +4. **Codegen.** If `spec/data` or `spec/VERSION` changed: `pnpm gen:data`, in `python/` + `uv run python scripts/gen_data.py`, and in `rust/` `node scripts/gen_data.mjs`. +5. **Implementation.** Change every port (JS, Python and Rust today). Cite rule IDs in comments. 6. **Conformance.** `pnpm test` and `pnpm conformance` must be green: 100% of fixtures, schema-valid output, property tests passing, `pnpm gen:check` clean. Same for Python (`uv run pytest`, - `uv run python scripts/conformance.py`), then `node scripts/compare-ports.mjs` must report 0 - differences. + `uv run python scripts/conformance.py`) and Rust (`cargo test`, and the report with + `TRACKPARSE_REPORT=1`), then `node scripts/compare-ports.mjs` must report 0 differences. 7. **Docs.** Update the site pages and README sections that describe the rule (see - [Documentation site and READMEs](#documentation-site-and-readmes)), with JavaScript and Python - examples whose outputs you ran, and `pnpm docs:build` green. + [Documentation site and READMEs](#documentation-site-and-readmes)), with JavaScript, Python and + Rust examples whose outputs you ran, and `pnpm docs:build` green. 8. **Commit message.** Conventional commits; the message *is* the changelog entry (see [Versioning and release](#versioning-and-release)). Any change to an existing `expected` value is a behaviour change and must be a `feat` (or carry `!`), never a `fix`/`chore`. Don't touch @@ -206,10 +236,21 @@ Python (run inside `python/`; uv picks up `.python-version` and `uv.lock`): | `uv run python scripts/conformance.py` | Pass rate per fixture file and per rule ID | | `uv build` | Build the sdist and wheel into `dist/` | -Cross-port check, from the repo root (needs `uv`): +Rust (run inside `rust/`; Rust 1.74 or newer, Node for the codegen): + +| Command | What it does | +|---|---| +| `cargo test` | Every fixture, the R13.11 invariants, API tests, doc tests (CI also runs `--all-features`) | +| `TRACKPARSE_REPORT=1 cargo test --test fixtures -- --nocapture` | Pass rate per fixture file and per rule ID | +| `node scripts/gen_data.mjs` | Regenerate `src/data.rs` and `src/unicode_tables.rs`; `--check` fails if stale | +| `cargo fmt --check` · `cargo clippy --all-targets --all-features -- -D warnings` | Format check and lint (the panic lints are in `Cargo.toml`) | +| `cargo publish --dry-run` | The crate packages cleanly | + +Cross-port check, from the repo root (needs `uv` and `cargo`): ```sh pnpm --filter trackparse build && node scripts/compare-ports.mjs # must print "differences: 0" +node scripts/compare-ports.mjs --only=rust # one port against JS ``` Corpus check for R13 changes, when you have the private corpus (JSONL, one object per tracklist @@ -235,7 +276,9 @@ Before pushing, mirror CI: `pnpm lint && pnpm --filter trackparse typecheck && p pnpm build && pnpm --filter trackparse size && pnpm --filter trackparse check:package && pnpm --filter trackparse compat && pnpm gen:check && pnpm --filter @trackparse/fixture-gen validate`, and in `python/` `uv run python scripts/gen_data.py --check && uv run ruff check . && uv run ruff format --check . && -uv run mypy --strict src && uv run pytest && uv build`. +uv run mypy --strict src && uv run pytest && uv build`, and in `rust/` +`node scripts/gen_data.mjs --check && cargo fmt --check && +cargo clippy --all-targets --all-features -- -D warnings && cargo test && cargo test --all-features`. ## Fixture authoring @@ -271,14 +314,14 @@ PR: |---|---| | a rule's behaviour (R1–R12) | the guide for that area (`guides/what-it-understands`, `artists`, `versions`, `junk-and-flags`, `modes`, `formatting`), the root README tables | | tracklists (R13) | `guides/tracklists`, `guides/editing-tracklists`, `reference/tracklist`, `reference/warnings` | -| a function, option, field or type | `reference/parse`, `reference/options`, `reference/functions` or `reference/tracklist`; the API sections of `js/README.md` and `python/README.md` | +| a function, option, field or type | `reference/parse`, `reference/options`, `reference/functions` or `reference/tracklist`; the API sections of `js/README.md`, `python/README.md` and `rust/README.md` | | a warning code | `reference/warnings` | | fixture counts, file counts, the size budget | `components/Stats.astro`, `index.mdx`, `start/introduction`, `project/testing`, `project/ports`, the root README "At a glance" and "How it's tested" | | a port, a command, CI or the release flow | `project/ports`, `project/contributing`, `project/testing` ("Run it yourself") | | `spec/SPEC.md` | nothing by hand: `reference/spec` is generated from it at build time | -**Every code example is bilingual.** There are no per-language pages. Each example on the site is a -pair of synced tabs, with the JavaScript example first: +**Every code example is trilingual.** There are no per-language pages. Each example on the site is +three synced tabs, in the order JavaScript, Python, Rust: ````mdx @@ -295,6 +338,13 @@ parse("Noisia - Stigma (2015)").year; // 2015 parse("Noisia - Stigma (2015)").year # 2015 ``` + + + +```rust +parse("Noisia - Stigma (2015)").year; // Some(2015) +``` + ```` @@ -304,10 +354,17 @@ parse("Noisia - Stigma (2015)").year # 2015 - Write the Python version in Python terms: snake_case functions, options and attributes (`format_track`, `known_artists=`, `full_title`), tuples, `None`/`True`, and results as the dataclass `repr` (`Junk(raw='HD', kind='quality')`). -- Run every example and paste the real output; never write an output by hand. Language-specific +- Write the Rust version in Rust terms: `use trackparse::…;`, the `_with` functions with option + builders (`parse_with(s, &ParseOptions::new().known_artists([…]))`), snake_case fields + (`version_type`, `full_title`), `Option` and `Vec`, and results as their `Debug` output + (`Junk { raw: "HD", kind: Quality }`, `Some(2015)`). +- Run every example and paste the real output; never write an output by hand. For Rust, a scratch + cargo project that depends on the crate by path (`trackparse = { path = "…/rust" }`) is enough. Language-specific notes (typing, `to_dict()`, `TypeError`) go on the page they concern, not on a separate page. - The playground and the landing demo import `js/` directly, so they follow the code automatically; - check them in a browser when the output shape changes. + check them in a browser when the output shape changes. The playground's code panels generate + JS, Python and Rust (`code()` and `listCode()` in `Playground.astro`): when an option or an edit + changes, update all three generators and compile a generated Rust snippet. **READMEs link to the site.** Each README section opens with a `**Docs:**` line that links the matching site pages (`README.md`, `js/README.md`, `python/README.md`, `rust/README.md`, @@ -330,8 +387,8 @@ trigger a release; changes under `js/`, `python/` or `spec/` do, even `docs:` on ## Porting guide (Rust, others) -A port is done when it passes every fixture and every invariant. The Python port is done and is a -good second reference next to JS: its modules map one to one onto `js/src`. Checklist: +A port is done when it passes every fixture and every invariant. The Python and Rust ports are done +and are good second references next to JS: their modules map one to one onto `js/src`. Checklist: 1. **Codegen from `spec/data` and `spec/VERSION`** into a source file (like `js/scripts/gen-data.ts`), with a `--check` mode wired into CI. Expose `SPEC_VERSION`. @@ -348,7 +405,7 @@ good second reference next to JS: its modules map one to one onto `js/src`. Chec file against the fixture schema, each output against `parsed-track.schema.json` (or `tracklist.schema.json` for `fn: "parseTracklist"`; `applyEdits` cases also check `text`), honour `status` (pass / xfail / ambiguous), and keep a port-local skip list that can only shrink. -6. **Property tests** for the SPEC invariants (Hypothesis for Python, proptest for Rust). +6. **Property tests** for the SPEC invariants (Hypothesis for Python; the Rust crate uses a small seeded generator of its own, to stay free of dev dependencies). 7. **API** idiomatic for the language but equivalent: Python `parse`, `parse_artists`, `format_track`, `normalize` (snake_case fields are fine only if the JSON output keeps the spec's keys); Rust with `serde` behind a feature flag and `unicode-normalization` as the only required @@ -372,6 +429,28 @@ Hazards the Python port ran into. Fixtures alone did not catch all of them; comp - **Python 3.9 at runtime.** `X | None` in annotations evaluated at runtime (dataclasses, `get_type_hints`) breaks on 3.9; use `Optional[X]`. Ruff's UP007/UP045 are disabled for this. +Hazards the Rust port ran into. Again the fixtures passed first; compare-ports and random +differential runs against JS (about 500,000 single-track inputs, 290,000 tracklists with edits) +found these: + +- **Letter and uppercase need generated tables.** R0.6 is general category L and Lu. + `char::is_alphabetic()` and `char::is_uppercase()` test the wider `Alphabetic` and `Uppercase` + properties (Nl, some marks, Other_Uppercase). The crate generates range tables + (`unicode_tables.rs`). +- **`str::to_lowercase` follows the compiler's Unicode version**, not Node's. The dedup key (R0.4) + uses a generated lowercase mapping instead, with JS's final-sigma rule. +- **The normalisation crate has its own Unicode version.** `unicode-normalization` ships Unicode 18 + while Node 24 has 17, so 32 new combining marks are ordered differently in NFC. Any port that + takes NFC from a library inherits that library's Unicode version. +- **Keyword option values are arbitrary strings.** JS passes any string given as a version type or + junk kind in `options.keywords` through to the output. Typed enums cannot hold them, so the + pipeline keeps types and kinds as strings (`RawTrack`), `wire` writes that form, and the typed + API maps unknown names to `VersionType::Version` / `JunkKind::Other`. +- **JS number-to-string rules reach the output.** Edit warnings echo the `line` an edit named, so + the JSON writer must format numbers as JS does (`1e+21`, no `.0` on whole values, `-0` as `0`). +- **Lone surrogates.** A Rust `str` cannot hold them; the crate's JSON reader (`json.rs`) turns an + unpaired `\uD800` escape into U+FFFD. + R13 (tracklists) notes for a new port: - **Two passes per text.** First a cheap *probe* per line: the R13.2 time scan, then R1, R2 and R4 @@ -397,7 +476,7 @@ R13 (tracklists) notes for a new port: hazard above does not apply here. - **Time ceilings.** R13.11 asks for linear time; each port's suite picks its own 10,000-line ceilings: `parseTracklist` JS 3 s, Python 15 s; `applyEdits` (shift + sort, 2,000 edits) JS 1 s, - Python 2 s / 5 s. + Python 2 s / 5 s. The Rust ceilings are in `rust/tests/tracklist_properties.rs`. ## Versioning and release @@ -406,16 +485,17 @@ Releases are automated with [release-please](https://github.com/googleapis/relea 1. Feature PRs are **rebase-merged**, so every commit lands on `main` and becomes its own changelog line: each commit message must be a conventional commit, and so must the PR title (`pr-title.yml` enforces the title). Release PRs (`chore: release main`) are squash-merged. Types: `feat`, `fix`, `perf`, `revert`, `docs` (shown in the changelog) and `refactor`, - `test`, `build`, `ci`, `chore` (hidden). Scopes: `js`, `python`, `spec`, `generator`, `fixtures`, `site`, `ci`, `deps`… + `test`, `build`, `ci`, `chore` (hidden). Scopes: `js`, `python`, `rust`, `spec`, `generator`, `fixtures`, `site`, `ci`, `deps`… 2. On every push to `main`, `release.yml` updates a **release PR** (`chore: release main`) that bumps `js/package.json`, `spec/VERSION`, `SPEC_VERSION` in `js/src/data.generated.ts`, the - Python version files (below), and writes `js/CHANGELOG.md` / `spec/CHANGELOG.md` / - `python/CHANGELOG.md`. -3. **Merging the release PR** creates tags `js-vX.Y.Z`, `spec-vX.Y.Z` and `python-vX.Y.Z`, GitHub - Releases with the changelog as notes, then publishes `trackparse` to npm and to PyPI via trusted - publishing (OIDC, no stored token), attaches the tarball / wheel + sdist and appends install - instructions to each release. For a bigger release, add - `.github/release-notes/X.Y.Z.md` beforehand: it is prepended to the notes. + Python and Rust version files (below), and writes `js/CHANGELOG.md` / `spec/CHANGELOG.md` / + `python/CHANGELOG.md` / `rust/CHANGELOG.md`. +3. **Merging the release PR** creates tags `js-vX.Y.Z`, `spec-vX.Y.Z`, `python-vX.Y.Z` and + `rust-vX.Y.Z`, GitHub Releases with the changelog as notes, then publishes `trackparse` to npm + and to PyPI via trusted publishing (OIDC, no stored token), attaches the tarball / wheel + sdist + and appends install instructions to each release. The crates.io job (`publish-crates`) runs + only when the repository variable `CRATES_PUBLISH` is `true` (see below). For a bigger release, + add `.github/release-notes/X.Y.Z.md` beforehand: it is prepended to the notes. Version rules: @@ -428,12 +508,32 @@ Version rules: `python/pyproject.toml`, `__version__` in `python/src/trackparse/__init__.py` and `SPEC_VERSION` in `python/src/trackparse/_data.py`, and writes `python/CHANGELOG.md`. Merging it tags `python-vX.Y.Z` and publishes to PyPI via trusted publishing (environment `pypi`), with the wheel - and sdist attached to the release. `spec.yml` checks that all three versions match. -- A future Rust port (`rs-vX.Y.Z`) will be added the same way. + and sdist attached to the release. `spec.yml` checks that all four versions match. +- `rust` is **linked** as well: a release-please component (`release-type: rust`) in the same + `linked-versions` group. The release PR bumps `rust/Cargo.toml` (the line marked + `x-release-please-version`) and `SPEC_VERSION` in `rust/src/data.rs`, and writes + `rust/CHANGELOG.md`. Merging it tags `rust-vX.Y.Z` and creates the GitHub Release. `Cargo.lock` + is git-ignored, so there is no lock file to bump. +- **crates.io publishing is gated.** The `publish-crates` job in `release.yml` (environment + `crates`: version check, `cargo test --all-features`, `cargo package`, `cargo publish` with a + token from crates.io trusted publishing, the `.crate` file attached to the release) runs only + when the repository variable `CRATES_PUBLISH` is `true`. crates.io can only configure trusted + publishing for a crate that already exists, so the first publish is the maintainer's, by hand: + 1. from the `rust-vX.Y.Z` tag, `cd rust && cargo publish` with a personal crates.io token; + 2. on crates.io, add a trusted publisher for `4matic/trackparse`, workflow `release.yml`, + environment `crates`; + 3. set the repository variable `CRATES_PUBLISH` to `true` + (`gh variable set CRATES_PUBLISH --body true`). + + Until then a release still tags `rust-vX.Y.Z` but skips the crates.io job, and the crate is + installed from git (`cargo add trackparse --git https://github.com/4matic/trackparse`; cargo + finds the package in `rust/` by name). After step 3, drop the "not on crates.io yet" notes from + the READMEs and the site. - **A publish job failed after the tags were created?** Fix the cause on `main` with a hidden commit type (`ci`/`chore`, so no new release), then re-run publishing for the existing tag: `gh workflow run release.yml -f python_tag=python-vX.Y.Z` (PyPI). The npm job always republishes - from a fresh release; a failed npm publish needs the same treatment by hand. + from a fresh release; a failed npm publish needs the same treatment by hand, and so does a failed + crates.io publish (`cargo publish` from the `rust-vX.Y.Z` tag; there is no re-run input for it). - **Agents never merge release PRs, publish, push tags or bump versions on their own initiative.** Merging the release PR is the maintainer's publish decision. @@ -445,8 +545,11 @@ Version rules: - JS: TypeScript strict, Biome formatting (2 spaces, double quotes, 100 columns), no runtime dependencies, ES2020 target, ESM + CJS via tsup. - Python: ruff (100 columns), `mypy --strict`, no runtime dependencies, Python 3.9 syntax. -- Public types in `js/src/types.ts` and `python/src/trackparse/types.py` mirror the schemas; - change them together. +- Rust: rustfmt (100 columns), clippy with `-D warnings`, MSRV 1.74, `unicode-normalization` as + the only required dependency, no `unsafe`. `unwrap`, `expect`, `panic!` and indexing are denied + in `src/` (R0.8): use `get`, iterators and `Option`. +- Public types in `js/src/types.ts`, `python/src/trackparse/types.py` and `rust/src/types.rs` + mirror the schemas; change them together. - No `throw` on any input path. Bad options fall back to defaults. ## Definition of done @@ -458,10 +561,12 @@ Version rules: - [ ] `pnpm gen:check` and `pnpm --filter @trackparse/fixture-gen validate` pass - [ ] Python: `gen_data.py --check`, ruff, `mypy --strict src` and `pytest` pass; conformance is 100%; `python/tests/skip.json` did not grow -- [ ] `node scripts/compare-ports.mjs` reports 0 differences +- [ ] Rust: `gen_data.mjs --check`, `cargo fmt --check`, clippy and `cargo test` pass; the + `TRACKPARSE_REPORT=1` report is 100%; `rust/tests/skip.json` did not grow +- [ ] `node scripts/compare-ports.mjs` reports 0 differences (all three ports) - [ ] `pnpm --filter trackparse size` and `check:package` pass - [ ] R13 changes: `node scripts/corpus-check.mjs` passes when you have the corpus - [ ] Conventional commits and PR title; `feat` if any fixture expectation changed -- [ ] Site pages (`site/src/content/docs`) and READMEs updated in the same PR, examples in both - JavaScript and Python tabs with real output, `**Docs:**` links still pointing at existing +- [ ] Site pages (`site/src/content/docs`) and READMEs updated in the same PR, examples in + JavaScript, Python and Rust tabs with real output, `**Docs:**` links still pointing at existing pages, `pnpm docs:build` passes diff --git a/README.md b/README.md index 7eed57c..1386c23 100644 --- a/README.md +++ b/README.md @@ -99,15 +99,16 @@ Every key is always present. When a guess was involved, `warnings` says which on | Number | What it means | |---|---| -| **13,124** shared fixtures | 1,197 written by hand, 11,927 generated from combinations. 100% pass in JS and Python, nothing skipped. | -| **1,233** of them on tracklists | 297 handwritten, 936 generated. Line splitting, times, bullets and Markdown, warnings, edits | -| **1,346** JS tests | every fixture, a schema check on every output, property-based tests of the spec invariants, API tests | +| **13,130** shared fixtures | 1,203 written by hand, 11,927 generated from combinations. 100% pass in JS, Python and Rust, nothing skipped. | +| **1,239** of them on tracklists | 303 handwritten, 936 generated. Line splitting, times, bullets and Markdown, warnings, edits | +| **1,352** JS tests | every fixture, a schema check on every output, property-based tests of the spec invariants, API tests | | **27** version types | remix, VIP, bootleg, extended, radio, original, live, remaster, sped up, … | | **0** dependencies | ESM + CJS + TypeScript types, about 17 kB gzipped. `trackparse/tracklist` adds about 8.3 KiB, only if you import it | | **Node 18+** | CI runs the full suite on 22 and 24, and every fixture against the built package on 18 and 20 | -| **Python 3.9+** | 1,336 pytest tests on 3.9 to 3.14, plus every fixture against the built wheel. Output is byte-identical to JS | +| **Python 3.9+** | 1,342 pytest tests on 3.9 to 3.14, plus every fixture against the built wheel. Output is byte-identical to JS | +| **Rust 1.74+** | every fixture, the tracklist invariants and the typed API tests on stable and on 1.74. Output is byte-identical to JS on every fixture and on about 790,000 random inputs | | **5,031** real tracklist lines | 117 podcast tracklists the tracklist rules were checked against. Every line round-trips byte for byte | -| **1 spec** | [`spec/SPEC.md`](spec/SPEC.md) defines the behaviour; the Python port passes the same fixtures, and so will Rust | +| **1 spec** | [`spec/SPEC.md`](spec/SPEC.md) defines the behaviour; the Python and Rust ports pass the same fixtures | ## Install @@ -121,7 +122,14 @@ Works in Node 18+ and any runtime with ES2020. pip install trackparse # or: uv add trackparse ``` -Python 3.9+, no dependencies. A Rust port is [on the way](#ports). +Python 3.9+, no dependencies. + +```sh +cargo add trackparse +``` + +Rust 1.74+, one dependency (`unicode-normalization`), `serde` as an optional feature. The crate is not on crates.io yet; until it +is, use `cargo add trackparse --git https://github.com/4matic/trackparse`. See [Ports](#ports). ## Quick start @@ -175,10 +183,45 @@ track.to_dict()["artists"][1] Options are keyword arguments: `parse(s, mode="youtube", known_artists=["Chase & Status"])`. The full Python API is in [`python/README.md`](python/README.md). +### Rust + +The same parser again. Functions are snake_case, results are structs with public fields and enums +for roles, types and kinds, and `to_json()` writes the spec's JSON, identical to the JS output. + +```rust +use trackparse::{format_track_with, parse, parse_artists, FeatPlacement, FormatOptions, JoinerStyle}; + +let track = parse("Noisia feat. Foreign Beggars - Shellshock"); +track.artists; +// [Artist { name: "Noisia", role: Primary, joiner: None, source: Artist }, +// Artist { name: "Foreign Beggars", role: Featured, joiner: Some("feat."), source: Artist }] + +parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)").versions[0]; +// Version { version_type: Live, raw: "Live at Wembley 1986", artists: [], modifiers: [], +// descriptor: Some("at Wembley"), year: Some(1986), unknown_artist: false, delimiter: Paren } + +parse_artists("Sub Focus, Wilkinson & Dimension feat. Kojo") + .iter().map(|a| format!("{}:{}", a.name, a.role)).collect::>(); +// ["Sub Focus:primary", "Wilkinson:primary", "Dimension:primary", "Kojo:featured"] + +let options = FormatOptions::new().feat(FeatPlacement::Title).joiners(JoinerStyle::Canonical); +format_track_with(&parse("Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)"), &options); +// "Wilkinson - Afterglow (feat. Becky Hill) (Sub Focus Remix)" + +track.artists[1].to_json(); +// {"name":"Foreign Beggars","role":"featured","joiner":"feat.","source":"artist"} +``` + +Options are builders passed to the `_with` form of a function: +`parse_with(s, &ParseOptions::new().known_artists(["Chase & Status"]))`. Tracklists are in +`trackparse::tracklist`. Every example on the [documentation site](https://4matic.github.io/trackparse/) +has a Rust tab. + > [!TIP] > `&` is a joiner, so `Chase & Status` comes out as two artists. There's no built-in artist > database. Pass the names you know instead: `parse(s, { knownArtists: ["Chase & Status"] })` in -> JS, `parse(s, known_artists=["Chase & Status"])` in Python. +> JS, `parse(s, known_artists=["Chase & Status"])` in Python, +> `parse_with(s, &ParseOptions::new().known_artists(["Chase & Status"]))` in Rust. ## What it understands @@ -353,14 +396,15 @@ of the list uses spaced dashes. The fixtures in [`spec/fixtures`](spec/fixtures) are the source of truth. The spec says what should happen, the fixtures pin it down, and every port has to pass all of them. The JS and Python -packages both do: **13,124 of 13,124**, with empty skip lists, in CI on every push. +packages and the Rust crate all do: **13,130 of 13,130**, with empty skip lists, in CI on every push. Passing a fixture only checks the fields the case asserts, so -[`scripts/compare-ports.mjs`](scripts/compare-ports.mjs) also runs every fixture input through both -ports and diffs the complete outputs, tracklists and edits included. Result: 0 differences, byte -for byte. +[`scripts/compare-ports.mjs`](scripts/compare-ports.mjs) also runs every fixture input through all +three ports and diffs the complete outputs, tracklists and edits included. Result: 0 differences, +byte for byte. The Rust crate was also compared with JS on about 500,000 random single-track cases +and 290,000 random tracklists with edits: 0 differences. -### Handwritten: 1,197 cases in 27 files +### Handwritten: 1,203 cases in 27 files Each case cites the spec rules it exercises. 62 of them spell out the complete output field by field, so nothing can drift unnoticed. @@ -376,7 +420,7 @@ field, so nothing can drift unnoticed. | Modes | 65 | YouTube pipes, `"Title" by Artist`, uploader fallback, filenames | | Unicode and normalization | 71 | NFC, zero-width characters, fullwidth brackets, Cyrillic, CJK, Turkish İ | | `format`, `parseArtists`, unknown IDs | 94 | Round-trips, canonical joiners, `ID - ID` | -| Tracklist mode | 61 | All 17 real podcast lines that single-line `parse()` gets wrong, the 6 real lines with no separator at all, `parse(s, { mode: "tracklist" })`, Markdown emphasis around names, and names that keep their `*` and `_` | +| Tracklist mode | 67 | All 17 real podcast lines that single-line `parse()` gets wrong, the 6 real lines with no separator at all, `parse(s, { mode: "tracklist" })`, Markdown emphasis around names, and names that keep their `*` and `_` | | Tracklist lines and times | 104 | LF/CRLF/CR, trailing spaces, line kinds, every time form, brackets, gap separators, `=>` arrows, invalid times, list bullets, Markdown around times, `w/` lines | | Tracklist positions | 15 | The real 81-line list numbered `1 ` to `81 ` without dots, and the `2 Unlimited` guard, with a `w/` line in between | | Tracklist warnings | 38 | Each code with its near-miss, and the 10 real out-of-order lists with their suggestions | @@ -452,6 +496,7 @@ pnpm conformance # pass rate per fixture file and per spec rule pnpm --filter trackparse build && node scripts/corpus-check.mjs spec/corpus/.jsonl cd python && uv run pytest # the same fixtures and invariants in Python +cd rust && cargo test # and in Rust ``` ## API @@ -557,7 +602,7 @@ parser.parse("Chase & Status x Camo & Krooked - Track (Alix Perez Rerub)").versi **Docs:** [Tracklist API](https://4matic.github.io/trackparse/reference/tracklist/) · [Warnings](https://4matic.github.io/trackparse/reference/warnings/) -Import from `trackparse/tracklist` (Python: `trackparse.tracklist`). It's a separate entry, so code +Import from `trackparse/tracklist` (Python: `trackparse.tracklist`, Rust: `trackparse::tracklist`). It's a separate entry, so code that only parses single tracks never loads it. #### `parseTracklist(text, options?)` → `Tracklist` @@ -677,9 +722,9 @@ spaced dashes. The checks run last, over the finished entries. | Language | Package | Status | |---|---|---| -| JavaScript / TypeScript | [`trackparse`](https://www.npmjs.com/package/trackparse) on npm | reference implementation, 13,124 / 13,124 fixtures, tracklists as `trackparse/tracklist` | -| Python | [`trackparse`](https://pypi.org/project/trackparse/) on PyPI | 13,124 / 13,124 fixtures, output identical to JS, tracklists as `trackparse.tracklist` | -| Rust | `trackparse` on crates.io | planned, same fixtures | +| JavaScript / TypeScript | [`trackparse`](https://www.npmjs.com/package/trackparse) on npm | reference implementation, 13,130 / 13,130 fixtures, tracklists as `trackparse/tracklist` | +| Python | [`trackparse`](https://pypi.org/project/trackparse/) on PyPI | 13,130 / 13,130 fixtures, output identical to JS, tracklists as `trackparse.tracklist` | +| Rust | `trackparse` on crates.io | passes 13,130 / 13,130, output identical to JS, tracklists as `trackparse::tracklist`; publishing to crates.io pending | Want another language? The porting checklist is in [AGENTS.md](AGENTS.md). @@ -718,7 +763,7 @@ Not there yet: doesn't yet learn names from its other lines. - Warnings for gaps or overlaps between consecutive tracklist times. -Planned next: the Rust port. The browser playground is already live at +Planned next: publishing the Rust crate to crates.io. The browser playground is already live at [4matic.github.io/trackparse/playground](https://4matic.github.io/trackparse/playground/). ## Contributing diff --git a/js/README.md b/js/README.md index 3f63022..69ca8ea 100644 --- a/js/README.md +++ b/js/README.md @@ -11,7 +11,7 @@ Parse music track names into structured metadata: artists, featured artists, rem This is the JavaScript/TypeScript reference implementation of the [trackparse spec](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md). It passes all -13,124 shared fixtures. Zero dependencies, ESM and CommonJS, TypeScript types included, never +13,130 shared fixtures. Zero dependencies, ESM and CommonJS, TypeScript types included, never throws. The principle is **extract, don't delete**: everything recognised lands in a field (artists with diff --git a/python/README.md b/python/README.md index d648579..c0fbb7e 100644 --- a/python/README.md +++ b/python/README.md @@ -21,7 +21,7 @@ doesn't recognise stays in the title, word for word. This is the Python port of [trackparse](https://github.com/4matic/trackparse). Its behaviour is defined by a [shared spec](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md) and pinned -by 13,124 fixtures. It passes all of them, and for every fixture input its output is byte-identical +by 13,130 fixtures. It passes all of them, and for every fixture input its output is byte-identical to the JavaScript package. - Python 3.9 to 3.14 diff --git a/release-please-config.json b/release-please-config.json index f291168..7c4137d 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -4,7 +4,7 @@ "tag-separator": "-", "bump-minor-pre-major": true, "bump-patch-for-minor-pre-major": false, - "pull-request-header": ":robot: Merging this PR tags the release, publishes a GitHub Release with these notes and publishes to npm and PyPI.", + "pull-request-header": ":robot: Merging this PR tags the release, publishes a GitHub Release with these notes and publishes to npm, PyPI and crates.io.", "changelog-sections": [ { "type": "feat", @@ -94,6 +94,19 @@ } ], "initial-version": "0.1.0" + }, + "rust": { + "release-type": "rust", + "component": "rust", + "package-name": "trackparse", + "changelog-path": "CHANGELOG.md", + "extra-files": [ + { + "type": "generic", + "path": "src/data.rs" + } + ], + "initial-version": "0.1.0" } }, "plugins": [ @@ -103,7 +116,8 @@ "components": [ "js", "spec", - "python" + "python", + "rust" ] } ] diff --git a/rust/.gitignore b/rust/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/rust/.gitignore @@ -0,0 +1 @@ +/target diff --git a/rust/Cargo.lock b/rust/Cargo.lock new file mode 100644 index 0000000..2e41b81 --- /dev/null +++ b/rust/Cargo.lock @@ -0,0 +1,123 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + +[[package]] +name = "trackparse" +version = "0.4.0" +dependencies = [ + "serde", + "serde_json", + "unicode-normalization", +] + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-normalization" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75cd3fb03d5288b3ba9a1ee103ac7e9cbb59f0b03d64f8ddfcc04dd42758a85d" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 0000000..d825451 --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "trackparse" +version = "0.4.0" # x-release-please-version +edition = "2021" +rust-version = "1.74" +description = "Turn messy track names into structured data: artists with roles, remixes and versions, junk, and whole tracklists. One spec, same output as the JavaScript and Python packages." +license = "MIT" +repository = "https://github.com/4matic/trackparse" +homepage = "https://4matic.github.io/trackparse/" +documentation = "https://docs.rs/trackparse" +readme = "README.md" +keywords = ["music", "parser", "tracklist", "artist", "remix"] +categories = ["parser-implementations", "multimedia::audio", "text-processing"] +include = ["src/**", "README.md", "LICENSE"] + +[dependencies] +# NFC / NFD follow this crate's Unicode tables (Unicode 18 in 0.1.26). Older releases have older +# tables and normalize some strings differently, so they are not accepted. +unicode-normalization = "0.1.26" +serde = { version = "1", features = ["derive"], optional = true } + +[dev-dependencies] +serde_json = "1" + +[features] +default = [] +# Serialize / Deserialize on the result types, the options and tracklist::Edit. +serde = ["dep:serde"] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints.rust] +unsafe_code = "forbid" + +[lints.clippy] +unwrap_used = "deny" +expect_used = "deny" +panic = "deny" +indexing_slicing = "deny" diff --git a/rust/LICENSE b/rust/LICENSE new file mode 100644 index 0000000..4384c06 --- /dev/null +++ b/rust/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Maksim Maksimov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/rust/README.md b/rust/README.md index bf6f146..fc15a4a 100644 --- a/rust/README.md +++ b/rust/README.md @@ -1,9 +1,660 @@ -# trackparse (Rust) +# trackparse -**Status: planned.** The Rust crate will be published to crates.io as `trackparse`. It will depend -only on `unicode-normalization`, with `serde` behind a feature flag, and it will pass the same shared -fixtures in [`../spec/fixtures`](../spec/fixtures). +[![crates.io](https://img.shields.io/crates/v/trackparse?logo=rust&logoColor=white)](https://crates.io/crates/trackparse) +[![docs.rs](https://img.shields.io/docsrs/trackparse?logo=docsdotrs&logoColor=white)](https://docs.rs/trackparse) +[![rust](https://img.shields.io/github/actions/workflow/status/4matic/trackparse/rust.yml?branch=main&label=tests&logo=github)](https://github.com/4matic/trackparse/actions/workflows/rust.yml) +[![license](https://img.shields.io/badge/license-MIT-blue)](https://github.com/4matic/trackparse/blob/main/LICENSE) -Until then, see the [spec](../spec/SPEC.md) and the [JS package](../js). +**[Documentation](https://4matic.github.io/trackparse/)** · **[Getting started](https://4matic.github.io/trackparse/start/getting-started/)** · **[Playground](https://4matic.github.io/trackparse/playground/)** · **[API on docs.rs](https://docs.rs/trackparse)** -**Docs:** [Ports](https://4matic.github.io/trackparse/project/ports/) · [Adding a language](https://4matic.github.io/trackparse/project/ports/#adding-a-language) +**Turn messy track names into structured data: who made it, who's featured, who remixed it, and +what's just noise.** + +```text +01. Wilkinson ft. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix) [Official Video] +``` + +Most title parsers split that into `"Wilkinson ft. Becky Hill & Tom Cane"` and +`"Afterglow (Sub Focus VIP Remix)"` and stop. Others "clean" it and throw the feat and the remix +away. trackparse keeps all of it. Everything it recognises goes into a field, and anything it +doesn't recognise stays in the title, word for word. + +This is the Rust port of [trackparse](https://github.com/4matic/trackparse). Its behaviour is +defined by a [shared spec](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md) and pinned +by 13,130 fixtures. It passes all of them, and for every fixture input its output is byte-identical +to the JavaScript and Python packages. + +- Rust 1.74 or later +- One dependency (`unicode-normalization`); `serde` is optional +- No `unsafe`, no regular expressions +- Never panics and never returns an error: any `&str` gives a result + +## Install + +```sh +cargo add trackparse +# with Serialize / Deserialize on the types +cargo add trackparse --features serde +``` + +## Quick start + +**Docs:** [Getting started](https://4matic.github.io/trackparse/start/getting-started/) + +```rust +use trackparse::{format_track_with, parse, FormatOptions, JoinerStyle, JunkKind, Mode, VersionType}; + +let track = parse( + "01. Wilkinson ft. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix) [Official Video]", +); + +let credits: Vec = track.artists.iter().map(|a| format!("{} ({})", a.name, a.role)).collect(); +assert_eq!(credits, ["Wilkinson (primary)", "Becky Hill (featured)", "Tom Cane (featured)"]); +assert_eq!(track.title, "Afterglow"); +assert_eq!(track.full_title, "Afterglow (Sub Focus VIP Remix)"); +assert_eq!(track.versions[0].version_type, VersionType::Remix); +assert_eq!(track.versions[0].artists[0].name, "Sub Focus"); +assert_eq!(track.versions[0].modifiers, ["vip"]); +assert_eq!(track.junk[0].raw, "Official Video"); +assert_eq!(track.junk[0].kind, JunkKind::Video); +assert_eq!(track.position.as_ref().map(|p| p.number), Some(1)); +assert_eq!(track.mode, Mode::Youtube); + +let options = FormatOptions::new().joiners(JoinerStyle::Canonical); +assert_eq!( + format_track_with(&track, &options), + "Wilkinson feat. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix)" +); +``` + +`to_json()` returns the spec's JSON form as compact text, with the same camelCase keys the +JavaScript package uses: + +```rust +let track = trackparse::parse("Wilkinson ft. Becky Hill - Afterglow (Sub Focus VIP Remix) [HD]"); +println!("{}", track.to_json()); +``` + +
+Output + +```json +{ + "input": "Wilkinson ft. Becky Hill - Afterglow (Sub Focus VIP Remix) [HD]", + "mode": "youtube", + "position": null, + "timestamp": null, + "artists": [ + { "name": "Wilkinson", "role": "primary", "joiner": null, "source": "artist" }, + { "name": "Becky Hill", "role": "featured", "joiner": "ft.", "source": "artist" } + ], + "title": "Afterglow", + "fullTitle": "Afterglow (Sub Focus VIP Remix)", + "versions": [ + { + "type": "remix", + "raw": "Sub Focus VIP Remix", + "artists": [{ "name": "Sub Focus", "role": "remixer", "joiner": null, "source": "version" }], + "modifiers": ["vip"], + "descriptor": null, + "year": null, + "unknownArtist": false, + "delimiter": "(" + } + ], + "year": null, + "flags": { "explicit": false, "clean": false, "unknownArtist": false, "unknownTitle": false }, + "junk": [{ "raw": "HD", "kind": "quality" }], + "warnings": [] +} +``` + +(Reformatted for width; the keys and values are exactly what `to_json()` returns.) + +
+ +## API + +**Docs:** [Other functions](https://4matic.github.io/trackparse/reference/functions/) + +```text +parse(input: &str) -> ParsedTrack +parse_with(input: &str, options: &ParseOptions) -> ParsedTrack +parse_artists(input: &str) -> Vec +parse_artists_with(input: &str, options: &ParseOptions) -> Vec +format_track(track: &ParsedTrack) -> String +format_track_with(track: &ParsedTrack, options: &FormatOptions) -> String +normalize(input: &str) -> String +all_artists(track: &ParsedTrack) -> Vec +Parser::new(options: &ParseOptions) -> Parser // parser.parse(..), parser.parse_artists(..) +SPEC_VERSION: &str + +tracklist::parse_tracklist(text: &str) -> Tracklist +tracklist::parse_tracklist_with(text: &str, options: &TracklistOptions) -> Tracklist +tracklist::apply_edits(text: &str, edits: &[Edit]) -> EditResult +tracklist::apply_edits_with(text: &str, edits: &[Edit], options: &TracklistOptions) -> EditResult +``` + +Every function has a plain form with the default options and a `_with` form that takes them. + +### `parse` and `ParseOptions` + +**Docs:** [parse and ParsedTrack](https://4matic.github.io/trackparse/reference/parse/) · [Options](https://4matic.github.io/trackparse/reference/options/) + +| Option | Default | | +|---|---|---| +| `mode` | `ModeOption::Auto` | `Clean`, `Youtube`, `Filename`, `Tracklist`, or `Auto` to detect from the string | +| `uploader` | `None` | YouTube channel name, used as the artist when there's no separator (`- Topic` and `VEVO` are dropped) | +| `known_artists` | empty | Names that are never split. There is no built-in list | +| `split_and` | `SplitAnd::Auto` | `Auto` splits on `and` only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole. Also `Always`, `Never` | +| `keywords` | `None` | Extra vocabulary, added to the built-in lists (see below) | + +Options are built with chained setters. The structs are `#[non_exhaustive]`, so start from +`ParseOptions::new()` (or `default()`); the fields are public and can also be assigned. + +```rust +use trackparse::{parse, parse_with, ParseOptions, SplitAnd}; + +let names = |track: &trackparse::ParsedTrack| -> Vec { + track.artists.iter().map(|a| a.name.clone()).collect() +}; + +assert_eq!(names(&parse("Chase & Status - Baddadan")), ["Chase", "Status"]); +let options = ParseOptions::new().known_artists(["Chase & Status"]); +assert_eq!(names(&parse_with("Chase & Status - Baddadan", &options)), ["Chase & Status"]); + +let options = ParseOptions::new().split_and(SplitAnd::Always); +assert_eq!( + names(&parse_with("Simon and Garfunkel - Mrs. Robinson", &options)), + ["Simon", "Garfunkel"] +); +``` + +`KeywordOptions` adds words to the built-in lists: + +| Setter | Field | | +|---|---|---| +| `version_head(word, VersionType)` | `version_heads` | Word that sets a version type (`"rerub"` as `VersionType::Rework`) | +| `descriptor(word)` | `descriptors` | Words kept as a version's `descriptor` | +| `genre(word)` | `genres` | Genre words | +| `junk(phrase, JunkKind)` | `junk` | Phrase to junk kind (`"some label rip"` as `JunkKind::Label`) | +| `feat_marker(marker)` | `feat_markers` | Extra feat markers | + +```rust +use trackparse::{parse, parse_with, JunkKind, KeywordOptions, ParseOptions}; + +assert_eq!(parse("Artist - Song [Some Label Rip]").title, "Song [Some Label Rip]"); + +let keywords = KeywordOptions::new().junk("some label rip", JunkKind::Label); +let track = parse_with("Artist - Song [Some Label Rip]", &ParseOptions::new().keywords(keywords)); +assert_eq!(track.title, "Song"); +assert_eq!(track.junk[0].raw, "Some Label Rip"); +assert_eq!(track.junk[0].kind, JunkKind::Label); +``` + +Parsing is total: any `&str` gives a `ParsedTrack`, including `""`. + +### `ParsedTrack` + +**Docs:** [ParsedTrack fields](https://4matic.github.io/trackparse/reference/parse/#parsedtrack) + +| Field | Type | | +|---|---|---| +| `input` | `String` | The original string, untouched | +| `mode` | `Mode` | Resolved mode: `Clean`, `Youtube`, `Filename` or `Tracklist` | +| `position` | `Option` | Track number: `Position { raw: "01", number: 1 }` | +| `timestamp` | `Option` | Leading cue time: `[12:34]` gives `Timestamp { raw: "12:34", seconds: 754 }` | +| `artists` | `Vec` | Primary, featured and producer credits. Remixers live in `versions` | +| `title` | `String` | Clean title. Brackets it doesn't recognise stay in | +| `full_title` | `String` | `title` with the versions re-attached | +| `versions` | `Vec` | Remixes and other versions, left to right | +| `year` | `Option` | From `(2015)` or `- 2015` | +| `flags` | `Flags` | `explicit`, `clean`, `unknown_artist`, `unknown_title` | +| `junk` | `Vec` | What was taken out, each with a `kind` | +| `warnings` | `Vec` | Heuristics that fired | + +`Artist { name, role, joiner, source }`: + +- `role` is `ArtistRole::Primary`, `Featured`, `Remixer` or `Producer`. +- `joiner` is the text before the name as written (`"&"`, `","`, `"ft."`, `"prod. by"`), or `None` + for the first name in a list. +- `source` is where the credit came from: `ArtistSource::Artist` (left of the dash), `Title` + (right of it) or `Version`. + +`Version { version_type, raw, artists, modifiers, descriptor, year, unknown_artist, delimiter }` +(`version_type` is `type` in JSON): + +```rust +use trackparse::{parse, VersionDelimiter, VersionType}; + +let track = parse("Pendulum - Watercolour (Extended VIP Mix)"); +let version = &track.versions[0]; +assert_eq!(version.version_type, VersionType::Vip); +assert_eq!(version.raw, "Extended VIP Mix"); +assert_eq!(version.modifiers, ["extended"]); +assert_eq!(version.delimiter, VersionDelimiter::Paren); + +let track = parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)"); +let version = &track.versions[0]; +assert_eq!(version.version_type, VersionType::Live); +assert_eq!(version.descriptor.as_deref(), Some("at Wembley")); +assert_eq!(version.year, Some(1986)); +``` + +Version types, junk kinds, warnings, roles and modes are enums (`VersionType`, `JunkKind`, +`Warning`, `ArtistRole`, `ArtistSource`, `Mode`, `ModeOption`, `VersionDelimiter`), listed in the +[API reference](https://4matic.github.io/trackparse/reference/parse/). Each has `as_str()` (the name +used in the spec and in JSON), `from_name()`, `ALL`, `Display` and `FromStr`: + +```rust +use trackparse::VersionType; + +assert_eq!(VersionType::SpedUp.as_str(), "spedUp"); +assert_eq!(VersionType::from_name("remix"), Some(VersionType::Remix)); +assert_eq!("bootleg".parse::(), Ok(VersionType::Bootleg)); +assert_eq!(VersionType::ALL.len(), 27); +``` + +Most of these enums are `#[non_exhaustive]`: a later spec version can add a version type or a +warning, so a `match` on them needs a `_` arm. + +### JSON and serde + +**Docs:** [JSON and Python objects](https://4matic.github.io/trackparse/reference/parse/#json-and-python-objects) + +Every result type has `to_json()`, which writes compact JSON matching +[`parsed-track.schema.json`](https://github.com/4matic/trackparse/blob/main/spec/schema/parsed-track.schema.json) +and +[`tracklist.schema.json`](https://github.com/4matic/trackparse/blob/main/spec/schema/tracklist.schema.json) +(`fullTitle`, `unknownArtist`, ...). The bytes are the same as `JSON.stringify(parse(s))` in +JavaScript. It needs no feature and no dependency. + +With the `serde` feature, the result types, the options and `Edit` implement `Serialize` and +`Deserialize` with the same keys, so `serde_json` writes the same text and reads it back: + +```rust +use trackparse::tracklist::Edit; +use trackparse::{parse, ModeOption, ParseOptions, ParsedTrack}; + +let track = parse("Noisia - Stigma (2015)"); +let json = serde_json::to_string(&track).unwrap(); +assert_eq!(json, track.to_json()); +assert_eq!(serde_json::from_str::(&json).unwrap(), track); + +let options: ParseOptions = + serde_json::from_str(r#"{"mode":"youtube","knownArtists":["Chase & Status"]}"#).unwrap(); +assert_eq!(options, ParseOptions::new().mode(ModeOption::Youtube).known_artists(["Chase & Status"])); + +let edit: Edit = serde_json::from_str(r#"{"op":"set-time","line":3,"seconds":90}"#).unwrap(); +assert_eq!(edit, Edit::set_time(3, 90.0)); +assert_eq!(serde_json::to_string(&edit).unwrap(), r#"{"op":"set-time","line":3,"seconds":90}"#); +``` + +Numbers are written as `to_json()` writes them: whole seconds are integers (`90`, not `90.0`), and +a value of 2^53 and more has the digits JavaScript prints. For every result the parser can produce +the two texts are equal. The edge cases, all in an `Edit` or an option you build yourself: + +- Seconds from 0.000001 up to 0.00001 are written in `serde_json`'s float notation (`1e-6` where + `to_json()` writes `0.000001`), and so are seconds of 1e21 and more by older `serde_json` + releases (`1e21` for `1e+21`). The number is the same and reads back the same. +- Non-finite seconds (NaN, infinity) are written as `null`, as `to_json()` and `JSON.stringify` + do, and `null` reads back as NaN. `apply_edits` reports such an edit as `EditInvalid` either way. +- Line numbers above 2^53 are written as the nearest double, because that is what the edit runs + on (`Edit::delete(usize::MAX)` is `{"op":"delete","line":18446744073709552000}`). +- `KeywordOptions` maps are written as JSON objects without repeated keys: a key added twice + keeps its first place and takes the last value, as in a JavaScript object. + +Reading options is strict: a missing key is the default, an unknown name such as +`"mode":"radio"` is an error. + +### `parse_artists` + +**Docs:** [parseArtists](https://4matic.github.io/trackparse/reference/functions/#parseartistsinput-options) + +Splits a bare artist string. `parse_artists_with` takes the same options as `parse_with`. + +```rust +use trackparse::parse_artists; + +let credits: Vec = parse_artists("Sub Focus, Wilkinson & Dimension feat. Kojo") + .iter() + .map(|a| format!("{}:{}", a.name, a.role)) + .collect(); +assert_eq!(credits, ["Sub Focus:primary", "Wilkinson:primary", "Dimension:primary", "Kojo:featured"]); +``` + +### `format_track` and `FormatOptions` + +**Docs:** [format](https://4matic.github.io/trackparse/reference/functions/#formattrack-options) · [Formatting](https://4matic.github.io/trackparse/guides/formatting/) + +Renders a track back to a string. + +| Option | Default | | +|---|---|---| +| `feat` | `FeatPlacement::Source` | Where featured artists go: `Source` (where they were), `Artist`, `Title` or `Omit` | +| `feat_marker` | `None` | Marker for featured artists, such as `"feat."` | +| `joiners` | `JoinerStyle::Original` | `Original` keeps the joiners as written, `Canonical` uses the standard ones | +| `versions` | `VersionsOption::All` | `All` or `None` | +| `producers` | `true` | Include `(prod. ...)` credits | +| `position` | `false` | Include the track number | + +```rust +use trackparse::{ + format_track, format_track_with, parse, FeatPlacement, FormatOptions, JoinerStyle, VersionsOption, +}; + +let track = parse("01. Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)"); +assert_eq!(format_track(&track), "Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)"); + +let options = FormatOptions::new().feat(FeatPlacement::Title).joiners(JoinerStyle::Canonical); +assert_eq!( + format_track_with(&track, &options), + "Wilkinson - Afterglow (feat. Becky Hill) (Sub Focus Remix)" +); + +let options = FormatOptions::new().feat(FeatPlacement::Omit).versions(VersionsOption::None); +assert_eq!(format_track_with(&track, &options), "Wilkinson - Afterglow"); + +let options = FormatOptions::new().position(true); +assert_eq!( + format_track_with(&track, &options), + "01. Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)" +); +``` + +### `normalize` + +**Docs:** [normalize](https://4matic.github.io/trackparse/reference/functions/#normalizeinput) + +The Unicode cleanup every function runs first: NFC, invisible characters, and dash, bracket and +quote variants. + +```rust +use trackparse::normalize; + +assert_eq!(normalize("Noisia\u{200b} – Stigma (VIP)"), "Noisia - Stigma (VIP)"); +``` + +### `all_artists` + +**Docs:** [allArtists](https://4matic.github.io/trackparse/reference/functions/#allartiststrack) + +Credits plus every remixer, deduplicated. + +```rust +use trackparse::{all_artists, parse}; + +let track = parse("Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)"); +let credits: Vec = + all_artists(&track).iter().map(|a| format!("{}:{}", a.name, a.role)).collect(); +assert_eq!(credits, ["Wilkinson:primary", "Becky Hill:featured", "Sub Focus:remixer"]); +``` + +### `Parser` + +**Docs:** [createParser](https://4matic.github.io/trackparse/reference/functions/#createparseroptions) + +Resolves the options and builds the word tables once, for many calls. It is `Send + Sync`. + +```rust +use trackparse::{KeywordOptions, ParseOptions, Parser, VersionType}; + +let options = ParseOptions::new() + .known_artists(["Chase & Status", "Camo & Krooked"]) + .keywords(KeywordOptions::new().version_head("rerub", VersionType::Rework)); +let parser = Parser::new(&options); + +let track = parser.parse("Chase & Status x Camo & Krooked - Track (Alix Perez Rerub)"); +assert_eq!(track.artists.len(), 2); +assert_eq!(track.versions[0].version_type, VersionType::Rework); +``` + +### `SPEC_VERSION` + +The spec version this build implements. The crate, the npm package, the PyPI package and the spec +are released together and always share one version number. + +## Modes + +**Docs:** [Modes](https://4matic.github.io/trackparse/guides/modes/) + +| Mode | For | Adds | +|---|---|---| +| `Clean` | Store metadata, tags | Only a spaced dash separates artist and title | +| `Youtube` | Video titles, scrobbles | Pipe segments, `"Title" by Artist`, `Artist: "Title"`, unspaced dashes, trailing junk, uploader fallback | +| `Filename` | Files | Strips the extension, `_` becomes a space, `01-Track` numbering | +| `Auto` | Anything | `Filename` for known extensions, `Youtube` when it sees junk, pipes or platform suffixes, `Clean` otherwise | +| `Tracklist` | One line of a tracklist | The first spaced dash always separates; `_-_` too. Never picked by `Auto` | + +```rust +use trackparse::{parse, parse_with, Mode, ModeOption, ParseOptions, Warning}; + +let youtube = ParseOptions::new().mode(ModeOption::Youtube); +let track = parse_with("\"Numb\" by Linkin Park", &youtube); +assert_eq!(track.artists[0].name, "Linkin Park"); +assert_eq!(track.title, "Numb"); +assert_eq!(track.warnings, [Warning::BySplit]); + +let track = parse("07_Burial_-_Archangel.mp3"); +assert_eq!(track.mode, Mode::Filename); +assert_eq!(track.artists[0].name, "Burial"); +assert_eq!(track.title, "Archangel"); +assert_eq!(track.position.as_ref().map(|p| p.number), Some(7)); + +let track = parse_with("Shelter", &youtube.uploader("Porter Robinson")); +assert_eq!(track.artists[0].name, "Porter Robinson"); +``` + +## Tracklists + +**Docs:** [Tracklists](https://4matic.github.io/trackparse/guides/tracklists/) · [Editing tracklists](https://4matic.github.io/trackparse/guides/editing-tracklists/) · [Tracklist API](https://4matic.github.io/trackparse/reference/tracklist/) · [Warnings](https://4matic.github.io/trackparse/reference/warnings/) + +`trackparse::tracklist` parses a whole tracklist, one entry per line, and checks it. Each entry +keeps its line exactly as written plus its own line ending, so joining every `raw` and `eol` is +always the input, CRLF or not. + +```rust +use trackparse::tracklist::{parse_tracklist, EntryKind, Severity, WarningCode}; +use trackparse::VersionType; + +let text = [ + "Hour 2", + "48:20 Noisia - Stigma", + "52:47 Mefjus & Kasra - Bandwagon (Phace Remix)", + "56:05 Black Sun Empire - ID", + "59:31 Alix Perez - Fade Away", + "01:03:10 Interview with Hybris", + "01:07:44 Imanu - Sacrifice", + "00:11:02 Current Value feat. Teddy Killerz - Payload", // typo for 01:11:02 + "01:15:36 Hybris - Spinning Top", +] +.join("\r\n"); + +let list = parse_tracklist(&text); + +let joined: String = list.entries.iter().map(|e| format!("{}{}", e.raw, e.eol)).collect(); +assert_eq!(joined, text); + +use EntryKind::{Header, Marker, Track}; +let kinds: Vec = list.entries.iter().map(|e| e.kind).collect(); +assert_eq!(kinds, [Header, Track, Track, Track, Track, Marker, Track, Track, Track]); + +let entry = &list.entries[2]; +let time = entry.time.as_ref().unwrap(); +assert_eq!((time.raw.as_str(), time.seconds), ("52:47", 3167.0)); +assert_eq!(entry.parts.rest, "Mefjus & Kasra - Bandwagon (Phace Remix)"); +let track = entry.track.as_ref().unwrap(); +assert_eq!(track.artists.len(), 2); +assert_eq!(track.title, "Bandwagon"); +assert_eq!(track.versions[0].version_type, VersionType::Remix); +assert!(list.entries[3].track.as_ref().unwrap().flags.unknown_title); // the ID + +assert_eq!(list.warnings.len(), 2); +assert_eq!(list.warnings[0].code, WarningCode::NoStartAtZero); +assert_eq!(list.warnings[0].severity, Severity::Info); +let warning = &list.warnings[1]; +assert_eq!((warning.code, warning.line), (WarningCode::TimeOutOfOrder, 8)); +let fix = warning.suggestion.as_ref().unwrap(); +assert_eq!((fix.line, fix.raw.as_str(), fix.seconds), (8, "01:11:02", 4262.0)); + +let stats = &list.stats; +assert_eq!((stats.lines, stats.tracks, stats.markers, stats.timed), (9, 7, 1, 8)); +assert_eq!((stats.first_time, stats.last_time), (Some(2900.0), Some(4536.0))); +``` + +The suggestion exists because exactly one time, one digit away from `00:11:02`, fits between its +neighbours. With several candidates or none, `suggestion` is `None`. + +`apply_edits` takes a slice of `Edit` values and only rewrites the lines they name: + +```rust +use trackparse::tracklist::{apply_edits, Edit, EditWarningCode}; + +let text = "48:20 Noisia - Stigma\r\n59:31 Alix Perez - Fade Away\r\n00:03:10 Imanu - Sacrifice\r\n"; + +let edits = [Edit::set_time(3, 3790.0), Edit::shift_from(45.0, 2)]; +let result = apply_edits(text, &edits); + +assert_eq!( + result.text, + "48:20 Noisia - Stigma\r\n01:00:16 Alix Perez - Fade Away\r\n01:03:55 Imanu - Sacrifice\r\n" +); +assert_eq!(result.changed, [2, 3]); +assert_eq!(result.warnings[0].code, EditWarningCode::StyleUpgraded); +assert_eq!((result.warnings[0].edit, result.warnings[0].line), (1, Some(2))); + +let result = apply_edits(text, &[Edit::shift_lines(-3000.0, [1])]); +assert_eq!(result.warnings[0].code, EditWarningCode::TimeClamped); +``` + +A rewritten time keeps its line's style: `48:20` stays `MM:SS`, and a time that crosses the hour +gets hours, with a `style-upgraded` warning. A bad edit changes nothing and warns `edit-invalid`. +Neither function panics. + +`TracklistOptions` has `mode` (default `ModeOption::Tracklist`), `known_artists`, `split_and`, +`keywords`, `audio_seconds` (enables `time-after-audio-end`) and `marker_words`: + +```rust +use trackparse::tracklist::{parse_tracklist_with, TracklistOptions, WarningCode}; + +let options = TracklistOptions::new().audio_seconds(3600.0); +let list = parse_tracklist_with("00:00 A - B\n1:02:03 C - D", &options); +assert_eq!(list.warnings[0].code, WarningCode::TimeAfterAudioEnd); +assert_eq!(list.warnings[0].line, 2); +``` + +| Result | Fields | +|---|---| +| `Tracklist` | `spec_version`, `entries`, `warnings`, `stats` | +| `TracklistEntry` | `line` (1-based), `kind` (`EntryKind`: `Track`, `Marker`, `Header`, `Link`, `Note`, `Blank`), `eol`, `raw`, `parts`, `time`, `track` (`Option`), `layered` (the track text after any time starts with `w/`) | +| `Parts` | `lead`, `time`, `gap`, `rest`, joined they give `raw` | +| `TracklistWarning` | `code` (`WarningCode`), `line`, `severity` (`Info` or `Warning`), `suggestion` | +| `TimeValue` | `raw`, `seconds` (`entry.time`, or `None` on untimed lines) | +| `Suggestion` | `line`, `raw`, `seconds` (`warning.suggestion`, or `None`) | +| `Stats` | `lines`, `tracks`, `markers`, `timed`, `first_time`, `last_time` | +| `EditResult` | `text`, `changed`, `warnings` (`EditWarning { code, edit, line }`) | + +Lists pasted with list bullets or Markdown emphasis (`* 14:21 Artist - Title`, +`**[**14:21**] Artist - Title**`) read like plain lines; the decoration stays in `raw` and `parts`. +A line whose track text (after any time) starts with `w/` is `layered`: a track played over the +previous one +([Markdown](https://4matic.github.io/trackparse/guides/tracklists/#markdown), +[layered tracks](https://4matic.github.io/trackparse/guides/tracklists/#layered-tracks)). + +Warning codes (`WarningCode`): `time-missing`, `time-out-of-order`, `time-duplicate`, +`no-start-at-zero`, `time-after-audio-end` (needs `audio_seconds`), `invalid-time`, `position-gap`, +`position-duplicate`, `line-unparsed`. Edits: `Edit::set_time(line, seconds)`, +`Edit::shift(seconds)` (all timed lines), `Edit::shift_from(seconds, from)`, +`Edit::shift_lines(seconds, lines)`, `Edit::sort_by_time()`, `Edit::set_rest(line, rest)`, +`Edit::insert(after, text)` (`after: 0` inserts at the top), `Edit::delete(line)`. The +[Tracklist API reference](https://4matic.github.io/trackparse/reference/tracklist/) explains each +one. + +Every line is parsed with `ModeOption::Tracklist`, where the first spaced dash always separates +artist and title. `parse_with` accepts it too: + +```rust +use trackparse::{parse, parse_with, JunkKind, ModeOption, ParseOptions}; + +let track = parse("Electrosoul System - Liquid Metal"); +assert_eq!(track.junk[0].raw, "Liquid Metal"); +assert_eq!(track.junk[0].kind, JunkKind::Genre); + +let options = ParseOptions::new().mode(ModeOption::Tracklist); +assert_eq!(parse_with("Electrosoul System - Liquid Metal", &options).title, "Liquid Metal"); +``` + +## How it is tested + +**Docs:** [Testing](https://4matic.github.io/trackparse/project/testing/) · [Ports](https://4matic.github.io/trackparse/project/ports/) + +- `cargo test` runs all 13,130 shared fixtures (1,203 written by hand, the rest generated from + the rules), the spec's invariants for single tracks and for tracklists on generated input (no + panic in any mode, `normalize` idempotent, the format round trip, no word lost, timing), and the + API tests. The skip list is empty. +- `scripts/compare-ports.mjs` in the repository runs every fixture input through the JavaScript + package and this crate and compares the complete JSON output, every field of it, not only the + ones a fixture asserts. The Python package is checked the same way. +- The Unicode facts the rules need (letters, uppercase letters, lowercase mapping) are tables + generated from the reference implementation and compiled into the crate. The output does not + depend on the compiler's Unicode version: Rust 1.74 and current stable give the same bytes. + NFC and NFD are the exception, see [Unicode version](#unicode-version). +- With the `serde` feature, a test asserts that `serde_json::to_string` equals `to_json()` for + every fixture input. +- Clippy denies `unwrap`, `expect`, `panic!` and indexing in the library code, and `unsafe` is + forbidden. + +## Unicode version + +Normalization (NFC in `normalize`, NFD in the key that finds duplicate artists) comes from the +`unicode-normalization` crate and follows its Unicode version. This crate requires 0.1.26 or +later, which has the Unicode 18 tables; older releases have older tables and give other results +for some strings, so Cargo will not select them. + +The JavaScript package normalizes with its runtime's tables, which are Unicode 17 on Node 24. +Unicode 18 added 32 combining marks, so a string that contains one of them can come out with its +marks in another order here than in JavaScript on that runtime. Strings without those marks are +not affected, and every shared fixture gives the same bytes. + +## Performance + +There are no regular expressions and no backtracking: each rule makes a bounded number of passes +over the string. A 10,000-code-point input parses in a few milliseconds in a release build, and +the test suite checks that hostile repetitions (thousands of duplicate credits, bracket groups or +junk phrases) take time roughly in proportion to their length, not to its square. + +## Minimum Rust version + +Rust 1.74. CI runs the test suite on 1.74 and on stable. + +## Development + +From `rust/` in the [repository](https://github.com/4matic/trackparse) (Node 24 is needed for the +codegen script only): + +```sh +node scripts/gen_data.mjs --check # spec/data and Unicode codegen is up to date +cargo fmt --check +cargo clippy --all-targets --all-features -- -D warnings +cargo test # every shared fixture, properties, API +cargo test --all-features # the same with serde, and this README's examples +TRACKPARSE_REPORT=1 cargo test --test fixtures -- --nocapture # pass rate per fixture file and per rule +``` + +Modules mirror the JS reference one to one (`scanner.rs` is `scanner.ts`, and so on) and cite the +same spec rule IDs. Behaviour changes start in the spec, not here: see +[AGENTS.md](https://github.com/4matic/trackparse/blob/main/AGENTS.md). + +## Links + +- [Documentation](https://4matic.github.io/trackparse/), and a + [playground](https://4matic.github.io/trackparse/playground/) that runs the parser in your browser +- [API documentation on docs.rs](https://docs.rs/trackparse) +- [Spec](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md) +- [Project README](https://github.com/4matic/trackparse#readme) +- [GitHub repository](https://github.com/4matic/trackparse) +- [npm package](https://www.npmjs.com/package/trackparse) · [PyPI package](https://pypi.org/project/trackparse/) + +## License + +[MIT](https://github.com/4matic/trackparse/blob/main/LICENSE) diff --git a/rust/examples/dump.rs b/rust/examples/dump.rs new file mode 100644 index 0000000..3a535dd --- /dev/null +++ b/rust/examples/dump.rs @@ -0,0 +1,36 @@ +//! The Rust side of the cross-port diff: JSONL in, JSON out. +//! +//! Each stdin line is an object `{ "fn", "input", "options", "formatOptions", "edits" }` (as in the +//! shared fixtures); each stdout line is the JSON result of `trackparse::wire::call`. A line that +//! is not a JSON object gives `null`. +//! +//! ```sh +//! cargo run --release --example dump < cases.jsonl > results.jsonl +//! ``` + +use std::io::{BufRead, BufWriter, Write}; + +use trackparse::json::Json; +use trackparse::wire; + +fn run(line: &str) -> Json { + let Some(case) = Json::parse(line) else { return Json::Null }; + let func = case.get("fn").and_then(Json::as_str).unwrap_or("parse"); + let input = case.get("input").and_then(Json::as_str).unwrap_or(""); + let empty = Json::Obj(Vec::new()); + let options = case.get("options").unwrap_or(&empty); + let format_options = case.get("formatOptions").unwrap_or(&empty); + let no_edits = Json::Arr(Vec::new()); + let edits = case.get("edits").unwrap_or(&no_edits); + wire::call(func, input, options, format_options, edits) +} + +fn main() -> std::io::Result<()> { + let stdin = std::io::stdin(); + let mut out = BufWriter::new(std::io::stdout().lock()); + for line in stdin.lock().lines() { + let line = line?; + writeln!(out, "{}", run(&line).write())?; + } + out.flush() +} diff --git a/rust/rustfmt.toml b/rust/rustfmt.toml new file mode 100644 index 0000000..c5e6780 --- /dev/null +++ b/rust/rustfmt.toml @@ -0,0 +1,3 @@ +# Same line width as the JS (Biome) and Python (ruff) ports. +max_width = 100 +use_small_heuristics = "Max" diff --git a/rust/scripts/dump_primitives.mjs b/rust/scripts/dump_primitives.mjs new file mode 100644 index 0000000..1ab52f2 --- /dev/null +++ b/rust/scripts/dump_primitives.mjs @@ -0,0 +1,171 @@ +#!/usr/bin/env node +// Expected values for the R0 primitive unit tests (src/words.rs), taken from the JS reference: +// the functions of js/src/words.ts run on tricky code points and strings. +// +// node scripts/dump_primitives.mjs # writes tests/data/primitives.json +// node scripts/dump_primitives.mjs --check # fails if that file is stale +// node scripts/dump_primitives.mjs --all out.json +// every Unicode scalar value and 200,000 random strings around Σ (large; for a one-off +// sweep, not committed): +// TRACKPARSE_PRIMITIVES=out.json cargo test --lib primitives +// +// Needs Node 24+ (it imports the TypeScript source directly). Regenerate when Node's Unicode +// version changes, together with src/unicode_tables.rs (scripts/gen_data.mjs). +import { readFileSync, writeFileSync } from "node:fs"; +import { dirname, join } from "node:path"; +import { fileURLToPath, pathToFileURL } from "node:url"; + +const here = dirname(fileURLToPath(import.meta.url)); +const words = await import(pathToFileURL(join(here, "../../js/src/words.ts")).href); +const args = process.argv.slice(2); +const all = args[0] === "--all"; +const check = args[0] === "--check"; +const outFile = all ? args[1] : join(here, "../tests/data/primitives.json"); + +const isScalar = (cp) => cp < 0xd800 || cp > 0xdfff; + +// --- code points ----------------------------------------------------------------------------- +const cps = new Set(); +if (all) { + for (let cp = 0; cp <= 0x10ffff; cp++) if (isScalar(cp)) cps.add(cp); +} else { + for (let cp = 0; cp < 0x250; cp++) cps.add(cp); + const tricky = [ + 0x2b0, 0x2c6, 0x300, 0x301, 0x345, 0x36f, 0x370, 0x37a, 0x386, 0x3a3, 0x3c2, 0x3c3, 0x3f4, 0x410, 0x430, + 0x5d0, 0x621, 0x640, 0x660, 0x903, 0x904, 0xe01, 0xe31, 0x10a0, 0x10d0, 0x13a0, 0x13f8, 0x1680, 0x167f, + 0x1681, 0x16ee, 0x180e, 0x1c80, 0x1c90, 0x1d2c, 0x1e9e, 0x1f88, 0x1fbc, 0x1ffc, 0x1fff, 0x2000, 0x200a, + 0x200b, 0x200c, 0x200d, 0x2010, 0x2015, 0x2028, 0x2029, 0x202a, 0x202f, 0x2030, 0x205f, 0x2060, 0x2071, + 0x2102, 0x2126, 0x212a, 0x212b, 0x2160, 0x2170, 0x2183, 0x2184, 0x24b6, 0x24d0, 0x2c00, 0x2e2f, 0x3000, + 0x3001, 0x3005, 0x3006, 0x3007, 0x3021, 0x3031, 0x3041, 0x30a1, 0x3400, 0x4e00, 0x9fff, 0xa000, 0xa640, + 0xa78d, 0xa7f2, 0xab70, 0xac00, 0xd7a3, 0xd7ff, 0xe000, 0xf8ff, 0xf900, 0xfb00, 0xfb01, 0xfb13, 0xfe58, + 0xfeff, 0xff08, 0xff21, 0xff41, 0xff70, 0xfffd, 0xffff, 0x10000, 0x10140, 0x10400, 0x10428, 0x104b0, + 0x10570, 0x10c80, 0x118a0, 0x16e40, 0x16fe0, 0x1d400, 0x1d41a, 0x1d6a8, 0x1e900, 0x1e922, 0x1f130, + 0x1f600, 0x1f1eb, 0x20000, 0x2ffff, 0x30000, 0xe0001, 0xe0100, 0x10fffd, 0x10ffff, + ]; + for (const cp of tricky) cps.add(cp); + for (let cp = 0x250; cp <= 0x10ffff; cp += 251) if (isScalar(cp)) cps.add(cp); +} +const cpList = [...cps].sort((a, b) => a - b); +const bits = (test) => cpList.map((cp) => (test(cp) ? "1" : "0")).join(""); +const chr = String.fromCodePoint; +const codePoints = { + // Runs of consecutive code points as [first, count], to keep the file small. + runs: (() => { + const runs = []; + for (const cp of cpList) { + const last = runs[runs.length - 1]; + if (last && last[0] + last[1] === cp) last[1]++; + else runs.push([cp, 1]); + } + return runs; + })(), + whitespace: bits((cp) => words.isWhitespaceCode(cp)), + letter: bits((cp) => words.isLetterAt(chr(cp), 0)), + upper: bits((cp) => words.isUpperAt(chr(cp), 0)), + jsSpace: bits((cp) => chr(cp).trim() === ""), +}; + +// --- strings --------------------------------------------------------------------------------- +const strings = new Set([ + "", " ", "Noisia", " The Upbeats ", "FEAT.", "Feat", "ft.", "Remix,", "remix!!", "a.", ".", "..", "É.", "İ.", + "İstanbul", "ISTANBUL", "ıstanbul", "İ", "STRAẞE", "Straße", "Dž", "dž", "DŽ", "ᾈ", "ᾀ", "ΟΔΥΣΣΕΑΣ", + "Σίσυφος", "ΣΊΣΥΦΟΣ", "Σ", "ΑΣ", "ΑΣ ", "ΑΣΑ", "ΑΣ.", "ΑΣ'", "ΑΣ’Α", "ΑΣ́", "ΆΣ", "Α­Σ", "Σ Σ", + "aΣ", "aΣb", "1Σ", ":Σ", "ΑΣ-Β", "Α.Σ", "Α Σ", "ΑΣ‍", "Beyoncé", "Beyoncé", "BEYONCÉ", "Björk", + "Björk", "Tiësto", "TIËSTO", "Sigur Rós", "Mötley Crüe", "Кино", "КИНО", "Ёлка", "ёлка", "Й", "й", + "한국어", "각", "각", "が", "が", "full", "A", "final", "ʼn", "ǰ", "ΐ", "ᾳ", "ᾼ", "Å", "Å", "Ω", + "Ⅷ", "ⅷ", "Ⓐ", "ⓐ", "𝐀𝐁", "𐐀𐐨", "🎵", "👨‍👩‍👧", "🇫🇮", "à́b", "ậ", "ậ", "a̴", + "a҃", "a᪰", "a⃝", "aͅ", "é́", "ạ̈", "パ", " x ", "\u0085x\u0085", + "x", "᠎x᠎", "​x​", "
x
", " x ", "\tx\n", "\u000bx\u000c", + " x ", " x ", " x", "a   b c", "a\u0085b", "ab", "a​b", + "2015", "2015,", "2015.", "2015..", "1899", "1900", "2099", "2100", "02015", "201", "2015", "2015", "2015a", + "١٩٩٩", "feat.", "w/", "b2b", "P!nk", "A$AP", "AC/DC", "x", "X", "&", "?", "??", "ID?", "Ä:", "Z;", "[Z]", "Ź.", + "ẞ", "ß", "ſ", "K", "Å", "DŽungla", "ΌΣΟΣ", "ὈΔΥΣΣΕΎΣ", "Ꭰ", "ꭰ", "Ა", "ა", "Ⴀ", "Ɥ", "Ꟶ", "𞤀", "𑢠", "Ꙁ", "Ⱥ", + // toLowerCase(): special casing, scripts with late case pairs, and Σ in and out of final position. + "İΣ", "Σİ", "İΣİ", "İİ", "i̇Σ", "ẞΣ", "ΣẞΣ", "STRAẞΣ ẞΣ", "ᎠΣ", "ᎠᎡᎢ", "ΣᏴ", "ꭰΣ", "ᏸΣ", "ᲐᲑΣ", "ΣᲐ", "ႠΣ", "აΣ", + "𞤀Σ", "𞤀𞤁𞤂", "Σ𞤢", "𞤢Σ", "𞥃Σ𞤀", "ΑΣ𞤀", "ΑΣ ᲐΣ", "DžΣ", "ʰΣ", "ΑʰΣ", "ΑΣʰ", "ΑΣʰΑ", "ᾼΣ", "ΑΣͅ", "ΑΣͅΑ", "ⒶΣ", + "ⅧΣ", "ΑΣΣ", "ΣΣ", "ΣΣΣ", "ΑΣΣ.", "ΑΣ·Σ", "ΑΣ·", "ΑΣ:Α", "ΑΣ'Α", "ΑΣ1", "1Σ1", "ΑΣ\u200b", "ΑΣ\u200bΑ", "Α\u00adΣ\u00ad", + "𝐀Σ", "Σ𝐀", "ΑΣ🎵", "🎵Σ", "aΣ a", "AΣ", "ÅΣ", "ΌΣ ΌΣΟ", "Ꟑ", "Ƛ", "Ꟛ", "Ꟗ", "Ꞔ", "Ᲊ", "𐵐", "𖺠", +]); +if (!all) { + // Sigma in context: a small alphabet, fixed seed. + let seed = 7; + const rnd = () => { + seed = (seed * 1103515245 + 12345) & 0x7fffffff; + return seed / 0x7fffffff; + }; + const alphabet = ["Σ", "Α", "α", " ", "'", ".", "́", "­", "a", "1", ":", "-", "‍", "𝐀", "ͅ"]; + // A second, later alphabet (the first one's strings stay as they were). + const wide = [...alphabet, "Σ", "İ", "ẞ", "Ꭰ", "ꭰ", "Ა", "ა", "𞤀", "𞤢", "ʰ", "·", "Dž", "Ⓐ"]; + const draw = (letters) => { + let s = ""; + const n = 1 + Math.floor(rnd() * 6); + for (let k = 0; k < n; k++) s += letters[Math.floor(rnd() * letters.length)]; + return s; + }; + for (let i = 0; i < 160; i++) { + let s = ""; + const n = 1 + Math.floor(rnd() * 6); + for (let k = 0; k < n; k++) s += alphabet[Math.floor(rnd() * alphabet.length)]; + strings.add(s); + } + for (let i = 0; i < 400; i++) strings.add(draw(wide)); +} +if (all) { + // Σ between code points drawn from all cased and case-ignorable ones, and a few others. + let seed = 11; + const rnd = (n) => { + // mulberry32 + seed = (seed + 0x6d2b79f5) | 0; + let t = Math.imul(seed ^ (seed >>> 15), 1 | seed); + t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; + return Math.floor((((t ^ (t >>> 14)) >>> 0) / 4294967296) * n); + }; + const pool = []; + for (const cp of cpList) if (/^[\p{Cased}\p{Case_Ignorable}]$/u.test(chr(cp))) pool.push(chr(cp)); + const plain = ["Σ", "Σ", "Σ", "Α", " ", "1", "-", "İ", "ẞ", "가", "🎵"]; + for (let i = 0; i < 200000; i++) { + let s = ""; + for (let k = 1 + rnd(6); k > 0; k--) s += rnd(2) ? plain[rnd(plain.length)] : pool[rnd(pool.length)]; + strings.add(s); + } +} +const record = (s) => ({ + s, + utf16Len: s.length, + asciiLower: words.asciiLower(s), + lower: s.toLowerCase(), + wordKey: words.wordKey(s), + dedupKey: words.dedupKey(s), + collapse: words.collapseSpaces(s), + words: words.splitWords(s), + jsTrim: s.trim(), + jsTrimEnd: s.trimEnd(), + year: words.yearOf(s), +}); + +const lines = [ + `"unicode": ${JSON.stringify(process.versions.unicode)}`, + `"codePoints": ${JSON.stringify(codePoints)}`, + `"strings": [\n${[...strings].map((s) => JSON.stringify(record(s))).join(",\n")}\n]`, +]; +// Every scalar value whose toLowerCase() is not itself; all others must map to themselves. +const lowerSweep = []; +for (let cp = 0; cp <= 0x10ffff; cp++) { + if (isScalar(cp) && chr(cp).toLowerCase() !== chr(cp)) lowerSweep.push([cp, chr(cp).toLowerCase()]); +} +lines.push(`"lowerSweep": ${JSON.stringify(lowerSweep)}`); +if (all) { + // Every scalar value whose dedup key is not itself; all others must map to themselves. + const sweep = cpList.filter((cp) => words.dedupKey(chr(cp)) !== chr(cp)).map((cp) => [cp, words.dedupKey(chr(cp))]); + lines.push(`"dedupSweep": ${JSON.stringify(sweep)}`); +} +const text = `{\n${lines.join(",\n")}\n}\n`; +if (check) { + if (readFileSync(outFile, "utf8") !== text) { + console.error("tests/data/primitives.json is stale: run `node scripts/dump_primitives.mjs`"); + process.exit(1); + } +} else { + writeFileSync(outFile, text); + console.log(`wrote ${outFile}: ${cpList.length} code points, ${strings.size} strings`); +} diff --git a/rust/scripts/gen_data.mjs b/rust/scripts/gen_data.mjs new file mode 100644 index 0000000..05fda0d --- /dev/null +++ b/rust/scripts/gen_data.mjs @@ -0,0 +1,159 @@ +#!/usr/bin/env node +// Compiles spec/data/*.json and spec/VERSION into src/data.rs, and the Unicode tables into +// src/unicode_tables.rs: the categories L and Lu (SPEC R0.6) and the lowercase mapping of +// `String.prototype.toLowerCase()` with the two properties its final-sigma rule reads (R0.4). +// +// node scripts/gen_data.mjs write the files +// node scripts/gen_data.mjs --check exit 1 if a committed file is stale +import { readdirSync, readFileSync, writeFileSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const here = dirname(fileURLToPath(import.meta.url)); +const specDir = resolve(here, "../../spec"); +const dataDir = join(specDir, "data"); + +/** A Rust string literal. */ +function str(s) { + let out = '"'; + for (const ch of s) { + const cp = ch.codePointAt(0); + if (ch === '"' || ch === "\\") out += `\\${ch}`; + else if (cp >= 0x20 && cp < 0x7f) out += ch; + else out += `\\u{${cp.toString(16)}}`; + } + return `${out}"`; +} + +function value(v, indent) { + const pad = " ".repeat(indent); + if (v === null) return "V::Null"; + if (typeof v === "boolean") return `V::Bool(${v})`; + if (typeof v === "number") return `V::Num(${Number.isInteger(v) ? `${v}.0` : v})`; + if (typeof v === "string") return `V::Str(${str(v)})`; + if (Array.isArray(v)) { + if (v.length === 0) return "V::Arr(&[])"; + return `V::Arr(&[\n${v.map((x) => `${pad} ${value(x, indent + 1)},\n`).join("")}${pad}])`; + } + const entries = Object.entries(v).filter(([k]) => k !== "$comment"); + if (entries.length === 0) return "V::Obj(&[])"; + return `V::Obj(&[\n${entries.map(([k, x]) => `${pad} (${str(k)}, ${value(x, indent + 1)}),\n`).join("")}${pad}])`; +} + +function renderData() { + const version = readFileSync(join(specDir, "VERSION"), "utf8").trim(); + const lines = [ + "// GENERATED from spec/data — do not edit. Run `node scripts/gen_data.mjs` to regenerate.", + "#![allow(clippy::all)]", + "", + "use crate::value::V;", + "", + "/// The version of the spec this crate implements.", + `pub const SPEC_VERSION: &str = ${str(version)}; // x-release-please-version`, + "", + ]; + for (const file of readdirSync(dataDir).filter((f) => f.endsWith(".json")).sort()) { + const name = `${file.slice(0, -5).replace(/-/g, "_").toUpperCase()}_DATA`; + lines.push(`/// spec/data/${file}`); + lines.push(`pub static ${name}: V = ${value(JSON.parse(readFileSync(join(dataDir, file), "utf8")), 0)};`); + lines.push(""); + } + return lines.join("\n"); +} + +/** Inclusive code point ranges matching `re`. */ +function ranges(re) { + const out = []; + let start = -1; + for (let cp = 0; cp <= 0x110000; cp++) { + const hit = cp < 0x110000 && !(cp >= 0xd800 && cp <= 0xdfff) && re.test(String.fromCodePoint(cp)); + if (hit && start < 0) start = cp; + if (!hit && start >= 0) { + out.push([start, cp - 1]); + start = -1; + } + } + return out; +} + +/** + * `toLowerCase()` of every scalar value that does not map to itself, as two tables: runs of code + * points `first, first + step, …, last` that all map to themselves plus `delta`, and the few that + * map to several code points. Runs never overlap. + */ +function lowercase() { + const runs = []; + const multi = []; + let run = null; + for (let cp = 0; cp < 0x110000; cp++) { + if (cp >= 0xd800 && cp <= 0xdfff) continue; + const lower = [...String.fromCodePoint(cp).toLowerCase()].map((c) => c.codePointAt(0)); + if (lower.length === 1 && lower[0] === cp) continue; + if (lower.length !== 1) { + multi.push([cp, lower]); + run = null; // a run must not step over a code point of the other table + continue; + } + const delta = lower[0] - cp; + if (run && run.delta === delta && (run.step === 0 ? cp - run.last <= 2 : cp - run.last === run.step)) { + run.step = cp - run.last; + run.last = cp; + } else { + run = { first: cp, last: cp, step: 0, delta }; + runs.push(run); + } + } + for (const r of runs) if (r.step === 0) r.step = 1; + return { runs, multi }; +} + +const UNICODE_HEADER = `// Unicode ${process.versions.unicode}`; +function renderUnicode() { + const table = (name, doc, rs) => + `/// ${doc}\npub static ${name}: &[(u32, u32)] = &[\n${rs.map(([a, b]) => ` (0x${a.toString(16)}, 0x${b.toString(16)}),\n`).join("")}];\n`; + const hex = (n) => `0x${n.toString(16)}`; + const { runs, multi } = lowercase(); + return [ + "// GENERATED — do not edit. Run `node scripts/gen_data.mjs` to regenerate.", + "// General category tables for SPEC R0.6, taken from the JS reference engine's \\p{L} and \\p{Lu},", + "// and its `toLowerCase()` for the R0.4 dedup key (`str::to_lowercase` follows the compiler's", + "// Unicode version, so it cannot be used).", + UNICODE_HEADER, + "", + table("LETTER", "General category L (Lu, Ll, Lt, Lm, Lo), inclusive ranges.", ranges(/^\p{L}$/u)), + table("UPPERCASE_LETTER", "General category Lu, inclusive ranges.", ranges(/^\p{Lu}$/u)), + table("CASED", "Property Cased (the final-sigma rule), inclusive ranges.", ranges(/^\p{Cased}$/u)), + table("CASE_IGNORABLE", "Property Case_Ignorable (the final-sigma rule), inclusive ranges.", ranges(/^\p{Case_Ignorable}$/u)), + "/// JS `toLowerCase()` of one code point: `(first, last, step, delta)`. Every code point", + "/// `first + k * step <= last` maps to itself plus `delta`. Sorted by `first`, no overlaps.", + `pub static LOWERCASE: &[(u32, u32, u8, i32)] = &[\n${runs.map((r) => ` (${hex(r.first)}, ${hex(r.last)}, ${r.step}, ${r.delta}),\n`).join("")}];`, + "", + "/// Code points whose lowercase is several code points. Sorted.", + `pub static LOWERCASE_MULTI: &[(u32, &[u32])] = &[\n${multi.map(([cp, to]) => ` (${hex(cp)}, &[${to.map(hex).join(", ")}]),\n`).join("")}];`, + "", + ].join("\n"); +} + +const check = process.argv.includes("--check"); +let stale = false; +function emit(file, content, sameHeader) { + const path = resolve(here, "../src", file); + let current = ""; + try { + current = readFileSync(path, "utf8"); + } catch {} + if (check) { + // The Unicode tables depend on the Node version: only compare like with like. + if (sameHeader && !current.includes(sameHeader)) return console.log(`${file}: skipped (${sameHeader.slice(3)} here)`); + if (current !== content) { + console.error(`${file} is stale: run node scripts/gen_data.mjs`); + stale = true; + } + } else if (current !== content) { + writeFileSync(path, content); + console.log(`wrote ${path}`); + } +} +emit("data.rs", renderData()); +emit("unicode_tables.rs", renderUnicode(), UNICODE_HEADER); +if (stale) process.exit(1); diff --git a/rust/src/artists.rs b/rust/src/artists.rs new file mode 100644 index 0000000..c2258e0 --- /dev/null +++ b/rust/src/artists.rs @@ -0,0 +1,127 @@ +//! R7: the artist side. + +use std::collections::HashSet; + +use crate::classify::{classify, Classification, Flag, Site}; +use crate::context::Ctx; +use crate::credits::{split_credits, Credit, ListOptions, PositionedYear}; +use crate::mode::PositionedJunk; +use crate::scanner::{groups_of, remove_groups, slice_from, slice_skel, trim_skel, Skel, PH}; +use crate::types::{ArtistRole, ArtistSource}; +use crate::words::{at, before, span_texts, string, sub, word_spans}; + +#[derive(Debug, Default)] +pub(crate) struct ArtistSideResult { + pub credits: Vec, + pub junk: Vec, + pub years: Vec, + pub unknown_artist: bool, + /// R7.1: artist-side Flag groups. + pub explicit: bool, + pub clean: bool, +} + +pub(crate) struct FeatMarker { + pub start: usize, + pub end: usize, + pub marker: String, +} + +/// R7.2: leftmost unbracketed feat marker with a space (or placeholder) left and a space right. +pub(crate) fn find_feat_marker(s: &Skel, ctx: &Ctx<'_>, from: usize) -> Option { + let spans = word_spans(&s.text); + let words = span_texts(&spans); + for (i, span) in spans.iter().enumerate() { + if span.start < from { + continue; + } + if !matches!(before(&s.text, span.start), Some(' ' | PH)) { + continue; + } + let Some(m) = ctx.t.feat_markers.match_at(&words, i) else { continue }; + let Some(last) = spans.get(i + m.length - 1) else { continue }; + if at(&s.text, last.end) != Some(' ') { + continue; + } + return Some(FeatMarker { + start: span.start, + end: last.end, + marker: string(sub(&s.text, span.start, last.end)), + }); + } + None +} + +/// R7.1–R7.5 over an artist-side skeleton. +pub(crate) fn parse_artist_side(side: &Skel, ctx: &mut Ctx<'_>) -> ArtistSideResult { + let mut result = ArtistSideResult::default(); + let mut removed: HashSet = HashSet::new(); + + // R7.1 + for (_, group) in groups_of(side) { + let site = Site { source: ArtistSource::Artist, delimiter: group.open, pos: group.pos }; + match classify(&group.inner, site, ctx) { + Classification::Feat(c) | Classification::Producer(c) => { + result.credits.extend(c.credits); + result.years.extend(c.years); + if c.unknown { + result.unknown_artist = true; + } + } + Classification::Flag(Flag::Explicit) => result.explicit = true, + Classification::Flag(Flag::Clean) => result.clean = true, + Classification::Year(year) => { + result.years.push(PositionedYear { year, pos: group.pos }) + } + Classification::Junk(kind) => { + result.junk.push(PositionedJunk { raw: group.inner.clone(), kind, pos: group.pos }); + } + Classification::Versions(_) | Classification::Unknown => continue, + } + removed.insert(group.pos); + } + let text = remove_groups(side, &removed); + + // R7.2 + let feat = find_feat_marker(&text, ctx, 0); + let main = match &feat { + Some(f) => trim_skel(&slice_skel(&text, 0, f.start)), + None => trim_skel(&text), + }; + let main_list = split_credits( + &main, + &ListOptions { + role: ArtistRole::Primary, + source: ArtistSource::Artist, + lead: None, + split_with: true, + feat_markers_join: false, + }, + ctx, + ); + result.credits.extend(main_list.credits); + result.years.extend(main_list.years); + if main_list.unknown { + result.unknown_artist = true; + } + if let Some(f) = feat { + let featured = split_credits( + &trim_skel(&slice_from(&text, f.end)), + &ListOptions { + role: ArtistRole::Featured, + source: ArtistSource::Artist, + lead: Some(f.marker), + split_with: false, + feat_markers_join: true, + }, + ctx, + ); + result.credits.extend(featured.credits); + result.years.extend(featured.years); + if featured.unknown { + result.unknown_artist = true; + } + } + result.credits.sort_by_key(|c| c.pos); // stable, like the JS sort + result +} diff --git a/rust/src/assemble.rs b/rust/src/assemble.rs new file mode 100644 index 0000000..49e66bf --- /dev/null +++ b/rust/src/assemble.rs @@ -0,0 +1,234 @@ +//! R9: assembly and dedup. + +use std::collections::{BTreeSet, HashMap}; + +use crate::classify::VersionDraft; +use crate::credits::Credit; +use crate::types::{Artist, ArtistRole, RawVersion, VersionDelimiter}; +use crate::words::dedup_key; + +fn precedence(role: ArtistRole) -> u8 { + match role { + ArtistRole::Primary => 2, + ArtistRole::Featured => 1, + ArtistRole::Producer | ArtistRole::Remixer => 0, + } +} + +pub(crate) fn to_artist(c: Credit) -> Artist { + Artist { name: c.name, role: c.role, joiner: c.joiner, source: c.source } +} + +struct Entry { + a: Artist, + list: usize, + alive: bool, +} + +/// The remaining names of each credit list, as ascending entry indexes, so "the list's first +/// remaining name" and "the next one" are lookups and dedup stays near-linear on inputs with +/// thousands of duplicate credits. +struct Lists(HashMap>); + +impl Lists { + fn new(entries: &[Entry]) -> Lists { + let mut lists: HashMap> = HashMap::new(); + for (i, e) in entries.iter().enumerate() { + lists.entry(e.list).or_default().insert(i); + } + Lists(lists) + } + + fn remove(&mut self, list: usize, e: usize) { + if let Some(members) = self.0.get_mut(&list) { + members.remove(&e); + } + } + + fn insert(&mut self, list: usize, e: usize) { + self.0.entry(list).or_default().insert(e); + } + + /// The entry that follows `e` in `list`, if `e` is the list's first remaining name. + fn heir(&self, list: usize, e: usize) -> Option { + let members = self.0.get(&list)?; + if members.first() != Some(&e) { + return None; + } + members.range(e + 1..).next().copied() + } +} + +/// R7.6: entry `e` leaves its list. If it was the list's first remaining name, the next +/// remaining name of that list takes `joiner`. +fn pass_joiner(entries: &mut [Entry], lists: &Lists, e: usize, joiner: Option) { + let Some(list) = entries.get(e).map(|x| x.list) else { return }; + if let Some(next) = lists.heir(list, e).and_then(|i| entries.get_mut(i)) { + next.a.joiner = joiner; + } +} + +/// R9.2: keep the first occurrence. A later lower/equal-precedence duplicate is removed (R7.6 +/// joiner inheritance); a later higher-precedence duplicate (role upgrade) gives the kept +/// entry its role, joiner and source, and the kept entry moves into that occurrence's list. +pub(crate) fn dedup_artists(credits: Vec) -> Vec { + let mut entries: Vec = credits + .into_iter() + .map(|c| { + let list = c.list; + Entry { a: to_artist(c), list, alive: true } + }) + .collect(); + let mut lists = Lists::new(&entries); + let mut index: HashMap = HashMap::new(); + for i in 0..entries.len() { + let Some(e) = entries.get(i) else { continue }; + // R9.2: producers are a separate credit class, deduped only among themselves. + let class = if e.a.role == ArtistRole::Producer { "p" } else { "c" }; + let key = format!("{class}:{}", dedup_key(&e.a.name)); + let (e_role, e_joiner, e_source, e_list) = + (e.a.role, e.a.joiner.clone(), e.a.source, e.list); + let Some(&k) = index.get(&key) else { + index.insert(key, i); + continue; + }; + let Some((kept_role, kept_joiner, kept_list)) = + entries.get(k).map(|x| (x.a.role, x.a.joiner.clone(), x.list)) + else { + continue; + }; + if precedence(e_role) > precedence(kept_role) { + pass_joiner(&mut entries, &lists, k, kept_joiner); + if let Some(kept) = entries.get_mut(k) { + kept.a.role = e_role; + kept.a.joiner = e_joiner; + kept.a.source = e_source; + kept.list = e_list; + } + lists.remove(kept_list, k); + lists.insert(e_list, k); + } else { + pass_joiner(&mut entries, &lists, i, e_joiner); + } + if let Some(e) = entries.get_mut(i) { + e.alive = false; + } + lists.remove(e_list, i); + } + entries.into_iter().filter(|e| e.alive).map(|e| e.a).collect() +} + +pub(crate) fn to_version(v: VersionDraft) -> RawVersion { + RawVersion { + vtype: v.vtype, + raw: v.raw, + artists: v.artists.into_iter().map(to_artist).collect(), + modifiers: v.modifiers, + descriptor: v.descriptor, + year: v.year, + unknown_artist: v.unknown_artist, + delimiter: v.delimiter, + } +} + +/// R9.4: a version rendered with its delimiter. +pub(crate) fn render_version(raw: &str, delimiter: VersionDelimiter) -> String { + match delimiter { + VersionDelimiter::Paren => format!("({raw})"), + VersionDelimiter::Square => format!("[{raw}]"), + VersionDelimiter::Curly => format!("{{{raw}}}"), + VersionDelimiter::Dash => format!("- {raw}"), + } +} + +pub(crate) fn full_title_of(title: &str, versions: &[RawVersion]) -> String { + std::iter::once(title.to_string()) + .chain(versions.iter().map(|v| render_version(&v.raw, v.delimiter))) + .filter(|s| !s.is_empty()) + .collect::>() + .join(" ") +} + +#[cfg(test)] +#[allow(clippy::unwrap_used, clippy::indexing_slicing)] +mod tests { + use super::*; + use crate::types::ArtistSource; + + /// R9.2 / R7.6 written the plain way: every "first remaining name of the list" is a scan. + /// `dedup_artists` must give exactly this. + fn reference(credits: Vec) -> Vec { + fn pass(entries: &mut [Entry], e: usize, joiner: Option) { + let list = entries[e].list; + let mut members = + entries.iter_mut().enumerate().filter(|(_, x)| x.alive && x.list == list); + if members.next().map(|(i, _)| i) != Some(e) { + return; + } + if let Some((_, next)) = members.next() { + next.a.joiner = joiner; + } + } + let mut entries: Vec = credits + .into_iter() + .map(|c| { + let list = c.list; + Entry { a: to_artist(c), list, alive: true } + }) + .collect(); + let mut index: HashMap = HashMap::new(); + for i in 0..entries.len() { + let e = &entries[i]; + let class = if e.a.role == ArtistRole::Producer { "p" } else { "c" }; + let key = format!("{class}:{}", dedup_key(&e.a.name)); + let (role, joiner, source, list) = (e.a.role, e.a.joiner.clone(), e.a.source, e.list); + let Some(&k) = index.get(&key) else { + index.insert(key, i); + continue; + }; + if precedence(role) > precedence(entries[k].a.role) { + let kept_joiner = entries[k].a.joiner.clone(); + pass(&mut entries, k, kept_joiner); + let kept = &mut entries[k]; + kept.a.role = role; + kept.a.joiner = joiner; + kept.a.source = source; + kept.list = list; + } else { + pass(&mut entries, i, joiner); + } + entries[i].alive = false; + } + entries.into_iter().filter(|e| e.alive).map(|e| e.a).collect() + } + + #[test] + fn dedup_matches_the_plain_algorithm() { + let mut state = 0x2545_f491_u32; + let mut below = |n: u32| { + // xorshift32 + state ^= state << 13; + state ^= state >> 17; + state ^= state << 5; + (state % n) as usize + }; + let roles = + [ArtistRole::Primary, ArtistRole::Featured, ArtistRole::Producer, ArtistRole::Remixer]; + let sources = [ArtistSource::Artist, ArtistSource::Title, ArtistSource::Version]; + let names = ["a", "A", "b", "c", "é", "d"]; + for _ in 0..20_000 { + let lists = 1 + below(4); + let credits: Vec = (0..below(14)) + .map(|i| Credit { + name: names[below(names.len() as u32)].to_string(), + role: roles[below(4)], + joiner: [None, Some("&".to_string()), Some(format!("j{i}"))][below(3)].clone(), + source: sources[below(3)], + pos: i as i64, + list: below(lists as u32), + }) + .collect(); + assert_eq!(dedup_artists(credits.clone()), reference(credits.clone()), "{credits:?}"); + } + } +} diff --git a/rust/src/classify.rs b/rust/src/classify.rs new file mode 100644 index 0000000..c57ba75 --- /dev/null +++ b/rust/src/classify.rs @@ -0,0 +1,461 @@ +//! R5: classification of a group's inner text (also used for dash suffixes and pipe segments). + +use std::collections::HashSet; + +use crate::context::Ctx; +use crate::credits::{split_credits, Credit, ListOptions, ListResult}; +use crate::scanner::scan; +use crate::tables::{is_unknown_token, RunInfo}; +use crate::types::{ArtistRole, ArtistSource, VersionDelimiter}; +use crate::words::{ + ascii_lower, at, before, chars, dedup_key, in_vocab, is_all_digits, js_trim, span_texts, + split_words, string, sub, tail, utf16_off, word_key, word_spans, year_of, WordSpan, +}; + +#[derive(Debug, Clone)] +pub(crate) struct VersionDraft { + /// A version type name; `keywords.versionHeads` values pass through as given. + pub vtype: String, + pub raw: String, + pub artists: Vec, + pub modifiers: Vec, + pub descriptor: Option, + pub year: Option, + pub unknown_artist: bool, + pub delimiter: VersionDelimiter, + pub pos: i64, + /// R5.7.2 ambiguousMixCredit; emitted only when the version is used. + pub ambiguous_mix: bool, + /// Recognised by the R5.7.3 prefix form (R6.2 condition (ii) does not apply). + pub prefix_form: bool, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum Flag { + Explicit, + Clean, +} + +#[derive(Debug, Clone)] +pub(crate) enum Classification { + Junk(String), + Feat(ListResult), + Producer(ListResult), + Flag(Flag), + Year(u32), + Versions(Vec), + Unknown, +} + +/// Where the classified text sits: credits' source, versions' delimiter, absolute offset. +#[derive(Debug, Clone, Copy)] +pub(crate) struct Site { + pub source: ArtistSource, + pub delimiter: VersionDelimiter, + pub pos: i64, +} + +const EXPLICIT_FLAGS: [&str; 4] = ["explicit", "explicit version", "dirty", "dirty version"]; +const CLEAN_FLAGS: [&str; 3] = ["clean", "clean version", "radio clean"]; + +/// R5: classify `inner` (already trimmed and whitespace-collapsed). +pub(crate) fn classify(inner: &str, site: Site, ctx: &mut Ctx<'_>) -> Classification { + let words = split_words(inner); + let Some(first) = words.first() else { return Classification::Unknown }; + if let Some(kind) = junk_kind_of(&words, ctx) { + return Classification::Junk(kind); + } + if let Some(credit) = feat_or_producer(inner, site, ctx) { + return credit; + } + if let Some(flag) = flag_of(&words) { + return Classification::Flag(flag); + } + if words.len() == 1 && is_all_digits(first) { + if let Some(year) = year_of(first) { + return Classification::Year(year); + } + } + match multi_version(inner, site, ctx).or_else(|| single_version(inner, site, ctx)) { + Some(versions) => Classification::Versions(versions), + None => Classification::Unknown, + } +} + +// --------------------------------------------------------------------------- +// R5.1 Junk + +/// R5.1: the junk kind if the whole word list is junk vocabulary, else `None`. +pub(crate) fn junk_kind_of(words: &[String], ctx: &Ctx<'_>) -> Option { + let t = ctx.t; + let mut first_kind: Option<&String> = None; + let mut i = 0; + while let Some(w) = words.get(i) { + if let Some(m) = t.junk_or_genre.match_at(words, i) { + first_kind = first_kind.or(Some(m.value)); + i += m.length; + continue; + } + // R5.1: connectors and year words may sit between junk phrases: `Official Video 2015`. + if t.junk_connectors.contains(w.as_str()) + || t.junk_connectors.contains(word_key(w).as_str()) + || year_of(w).is_some() + { + i += 1; + continue; + } + first_kind = None; + break; + } + // JS truthiness: an empty kind (possible through `keywords.junk`) does not count. + if let Some(kind) = first_kind.filter(|k| !k.is_empty()) { + return Some(kind.clone()); + } + let last = words.last()?; + (words.len() >= 2 && in_vocab(last, &t.label_suffixes)).then(|| "label".to_string()) +} + +// --------------------------------------------------------------------------- +// R5.2 Feat, R5.3 Producer + +fn feat_or_producer(inner: &str, site: Site, ctx: &mut Ctx<'_>) -> Option { + let t = ctx.t; + let text = chars(inner); + let spans = word_spans(&text); + let words = span_texts(&spans); + let feat = t.feat_markers.match_at(&words, 0).map(|m| m.length); + let bracket_only = if feat.is_some() { + None + } else { + t.bracket_only_feat.match_at(&words, 0).map(|m| m.length) + }; + let feat_len = feat.or(bracket_only).unwrap_or(0); + if feat_len > 0 && words.len() > feat_len { + let stop = bracket_only.is_some() + && words.get(feat_len).is_some_and(|next| in_vocab(next, &t.stopwords)); + if !stop { + let r = credits_after(&text, &spans, feat_len, ArtistRole::Featured, site, ctx); + return r.map(Classification::Feat); + } + } + let prod = t.producer_markers.match_at(&words, 0)?; + let mut len = prod.length; + if words.get(len).is_some_and(|w| word_key(w) == "by") { + len += 1; + } + if words.len() > len { + return credits_after(&text, &spans, len, ArtistRole::Producer, site, ctx) + .map(Classification::Producer); + } + None +} + +fn credits_after( + inner: &[char], + spans: &[WordSpan], + marker_words: usize, + role: ArtistRole, + site: Site, + ctx: &mut Ctx<'_>, +) -> Option { + let first = spans.first()?; + let last_marker = spans.get(marker_words.checked_sub(1)?)?; + let first_name = spans.get(marker_words)?; + let lead = string(sub(inner, first.start, last_marker.end)); + // Offsets are UTF-16 units (see scanner.rs). + let base = site.pos + 1 + utf16_off(sub(inner, 0, first_name.start)); + let opts = ListOptions { + role, + source: site.source, + lead: Some(lead), + split_with: false, + feat_markers_join: role == ArtistRole::Featured, + }; + Some(list_from_text(tail(inner, first_name.start), base, ctx, &opts)) +} + +/// Split a plain string (nested brackets protected by a fresh scan) as a credit list. +pub(crate) fn list_from_text( + text: &[char], + base: i64, + ctx: &mut Ctx<'_>, + opts: &ListOptions, +) -> ListResult { + split_credits(&scan(text, base).0, opts, ctx) +} + +// --------------------------------------------------------------------------- +// R5.4 Flag + +fn flag_of(words: &[String]) -> Option { + let key = words.iter().map(|w| word_key(w)).collect::>().join(" "); + if EXPLICIT_FLAGS.contains(&key.as_str()) { + Some(Flag::Explicit) + } else if CLEAN_FLAGS.contains(&key.as_str()) { + Some(Flag::Clean) + } else { + None + } +} + +// --------------------------------------------------------------------------- +// R5.6 Multi-version + +/// Split at top-level ` / ` or `; ` (outside nested brackets). +fn split_multi_parts(inner: &[char]) -> Vec { + let mut parts: Vec<&[char]> = Vec::new(); + let mut depth = 0usize; + let mut start = 0usize; + for (i, &ch) in inner.iter().enumerate() { + if matches!(ch, '(' | '[' | '{') { + depth += 1; + } else if matches!(ch, ')' | ']' | '}') && depth > 0 { + depth -= 1; + } else if depth == 0 + && ch == '/' + && before(inner, i) == Some(' ') + && at(inner, i + 1) == Some(' ') + { + parts.push(sub(inner, start, i - 1)); + start = i + 2; + } else if depth == 0 && ch == ';' && at(inner, i + 1) == Some(' ') { + parts.push(sub(inner, start, i)); + start = i + 2; + } + } + parts.push(tail(inner, start)); + parts.into_iter().map(|p| js_trim(&string(p)).to_string()).collect() +} + +fn multi_version(inner: &str, site: Site, ctx: &mut Ctx<'_>) -> Option> { + let parts = split_multi_parts(&chars(inner)); + if parts.len() < 2 { + return None; + } + let mut out = Vec::new(); + for part in &parts { + if part.is_empty() { + return None; + } + out.extend(single_version(part, site, ctx)?); + } + Some(out) +} + +// --------------------------------------------------------------------------- +// R5.7 Version + +fn single_version(raw: &str, site: Site, ctx: &mut Ctx<'_>) -> Option> { + let text = chars(raw); + let spans = word_spans(&text); + let words = span_texts(&spans); + if let Some(v) = head_by(raw, &text, &spans, &words, site, ctx) { + return Some(vec![v]); + } + if let Some(v) = head_scan(raw, &words, site, ctx) { + return Some(vec![v]); + } + prefix_form(raw, &words, site, ctx).map(|v| vec![v]) +} + +fn base_version(raw: &str, vtype: &str, site: Site) -> VersionDraft { + VersionDraft { + vtype: vtype.to_string(), + raw: raw.to_string(), + artists: Vec::new(), + modifiers: Vec::new(), + descriptor: None, + year: None, + unknown_artist: false, + delimiter: site.delimiter, + pos: site.pos, + ambiguous_mix: false, + prefix_form: false, + } +} + +fn remixer_opts() -> ListOptions { + ListOptions { + role: ArtistRole::Remixer, + source: ArtistSource::Version, + lead: None, + split_with: false, + feat_markers_join: false, + } +} + +/// R9.2: remixers are deduped within their own version only. +fn dedup_remixers(credits: Vec) -> Vec { + let mut seen: HashSet = HashSet::new(); + credits.into_iter().filter(|c| seen.insert(dedup_key(&c.name))).collect() +} + +fn set_credits(v: &mut VersionDraft, text: &[char], site: Site, ctx: &mut Ctx<'_>) { + let r = list_from_text(text, site.pos, ctx, &remixer_opts()); + v.artists = dedup_remixers(r.credits); + if r.unknown { + v.unknown_artist = true; + } + // R7.5: a dropped year-only name sets the version's year if it is still null. + if let Some(dropped) = r.years.first() { + v.year = v.year.or(Some(dropped.year)); + } +} + +/// R5.7.1: `Remix by Skrillex`. +fn head_by( + raw: &str, + text: &[char], + spans: &[WordSpan], + words: &[String], + site: Site, + ctx: &mut Ctx<'_>, +) -> Option { + let t = ctx.t; + let head = t.heads.match_at(words, 0)?; + let by = words.get(head.length)?; + let rest = spans.get(head.length + 1)?; + if word_key(by) != "by" { + return None; + } + let mut v = base_version(raw, head.value, site); + set_credits(&mut v, tail(text, rest.start), site, ctx); + Some(v) +} + +struct RunItem { + start: usize, + end: usize, + info: RunInfo, + year: Option, +} + +/// Walk left from `end` collecting the modifier run (R5.7.2). +fn collect_run(words: &[String], end: usize, ctx: &Ctx<'_>) -> Vec { + let mut items: Vec = Vec::new(); + let mut j = end; + while j > 0 { + if let Some(m) = ctx.t.run_words.match_ending(words, j) { + items.push(RunItem { start: j - m.length, end: j, info: m.value.clone(), year: None }); + j -= m.length; + continue; + } + let Some(year) = words.get(j - 1).and_then(|w| year_of(w)) else { break }; + items.push(RunItem { start: j - 1, end: j, info: RunInfo::default(), year: Some(year) }); + j -= 1; + } + items.reverse(); + items +} + +/// R5.7.2: `Extended VIP Mix`, `Skrillex Remix`, `Taylor's Version`. +fn head_scan(raw: &str, words: &[String], site: Site, ctx: &mut Ctx<'_>) -> Option { + let t = ctx.t; + let head = t.heads.match_ending(words, words.len())?; + let head_type: &str = head.value; + let head_start = words.len() - head.length; + let run = collect_run(words, head_start, ctx); + let credit_end = run.first().map_or(head_start, |r| r.start); + let credit_words = words.get(..credit_end).unwrap_or(&[]); + let left = run.len().checked_sub(1); + + // R5.7.2 type resolution. Generic = canonical type mix/edit/version, any spelling. + let generic = t.generic_head_types.contains(head_type); + let mut vtype: String = head_type.to_string(); + let mut type_item: Option = None; + let mut via_mix = false; + let nearest_head = if generic { nearest_non_generic_head(&run, ctx) } else { None }; + // JS truthiness: an empty type name does not count. + let truthy = |s: Option<&String>| s.filter(|s| !s.is_empty()).cloned(); + let left_capable = + left.and_then(|i| run.get(i)).and_then(|r| truthy(r.info.type_capable.as_ref())); + let nearest_type = + nearest_head.and_then(|i| run.get(i)).and_then(|r| truthy(r.info.head.as_ref())); + if let (true, Some(capable)) = (generic, left_capable) { + vtype = capable; + type_item = left; + } else if let Some(head) = nearest_type { + // `2011 Remastered Version` → remaster + vtype = head; + type_item = nearest_head; + } else if head_type == "mix" && !credit_words.is_empty() { + vtype = "remix".to_string(); + via_mix = true; + } + let mut v = base_version(raw, &vtype, site); + + let mut descriptors: Vec = Vec::new(); + for (i, item) in run.iter().enumerate() { + if let Some(year) = item.year { + v.year = v.year.or(Some(year)); + continue; + } + let modifier = item.info.type_capable.as_ref().or(item.info.descriptor.as_ref()); + if let Some(modifier) = modifier { + if Some(i) != type_item && !v.modifiers.contains(modifier) { + v.modifiers.push(modifier.clone()); + } + } else if item.info.genre { + descriptors.push(words.get(item.start..item.end).unwrap_or(&[]).join(" ")); + } + } + + if let Some(last_credit_word) = credit_words.last() { + let credit = credit_words.join(" "); + let last_word = ascii_lower(last_credit_word); + if is_unknown_token(&credit, t) { + v.unknown_artist = true; + } else if vtype == "version" || vtype == "cover" || is_all_junk_phrases(credit_words, ctx) { + // R5.7.2: `Japanese Version`, `Taylor's Version`, `Adele Cover`, `Video Edit`. + descriptors.insert(0, credit); + } else { + let mut name = chars(&credit); + if last_word.ends_with("'s") { + name.truncate(name.len().saturating_sub(2)); + } + set_credits(&mut v, &name, site, ctx); + if via_mix && v.artists.last().is_some_and(|a| split_words(&a.name).len() >= 3) { + v.ambiguous_mix = true; + } + } + } + v.descriptor = if descriptors.is_empty() { None } else { Some(descriptors.join(" ")) }; + Some(v) +} + +/// R5.7.2 type rule 2: the non-generic head in the run nearest the (generic) head. +fn nearest_non_generic_head(run: &[RunItem], ctx: &Ctx<'_>) -> Option { + (0..run.len()).rev().find(|&i| { + run.get(i) + .and_then(|r| r.info.head.as_ref()) + .is_some_and(|head| !ctx.t.generic_head_types.contains(head.as_str())) + }) +} + +/// R5.7.2: the credit span is made entirely of junk phrases (`Video` in `Video Edit`). +fn is_all_junk_phrases(words: &[String], ctx: &Ctx<'_>) -> bool { + let mut i = 0; + while i < words.len() { + match ctx.t.junk_phrases.match_at(words, i) { + Some(m) => i += m.length, + None => return false, + } + } + !words.is_empty() +} + +/// R5.7.3: `Live at Wembley 1986`, `Remastered 2015`, `Sped Up`. +fn prefix_form(raw: &str, words: &[String], site: Site, ctx: &Ctx<'_>) -> Option { + let m = ctx.t.prefix_forms.match_at(words, 0)?; + let mut v = base_version(raw, m.value, site); + v.prefix_form = true; + let mut rest: Vec<&str> = Vec::new(); + for w in words.get(m.length..).unwrap_or(&[]) { + match if v.year.is_none() { year_of(w) } else { None } { + Some(year) => v.year = Some(year), + None => rest.push(w), + } + } + v.descriptor = if rest.is_empty() { None } else { Some(rest.join(" ")) }; + Some(v) +} diff --git a/rust/src/context.rs b/rust/src/context.rs new file mode 100644 index 0000000..665eba6 --- /dev/null +++ b/rust/src/context.rs @@ -0,0 +1,77 @@ +//! Per-call parse context: resolved options + vocabulary tables. + +use std::collections::HashSet; + +use crate::options::SplitAndMode; +use crate::tables::Tables; +use crate::types::Warning; +use crate::words::{at, dedup_key, is_whitespace, string, sub}; + +pub(crate) struct Ctx<'a> { + pub t: &'a Tables, + pub known_keys: &'a HashSet, + /// Longest knownArtists entry, in UTF-16 units (bounds the R7.3a search). + pub known_max_len: usize, + pub split_and: SplitAndMode, + pub warnings: Vec, + /// Counter giving every split credit list an id (R7.6 joiner inheritance across R9.2). + pub list_seq: usize, +} + +/// The `knownArtists` part of a context, computed once per parser. +pub(crate) fn known_keys(known: &[String]) -> (HashSet, usize) { + let keys = known.iter().map(|k| dedup_key(k)).filter(|k| !k.is_empty()).collect(); + let max_len = known.iter().map(|k| k.encode_utf16().count()).max().unwrap_or(0); + (keys, max_len) +} + +pub(crate) fn warn(ctx: &mut Ctx<'_>, w: Warning) { + if !ctx.warnings.contains(&w) { + ctx.warnings.push(w); + } +} + +/// R7.3a: length of the longest knownArtists entry matching `text` at `start` (dedup-key +/// comparison), followed by end, whitespace, `,` or `;` (or `extra_boundary`: R4.2 also accepts +/// `-`, so `3 Doors Down-Kryptonite` is protected). 0 when none matches. +/// +/// The search window is `2 * longest + 8` UTF-16 units, exactly as in the JS reference. +pub(crate) fn match_known_at( + text: &[char], + start: usize, + ctx: &Ctx<'_>, + extra_boundary: Option, +) -> usize { + if ctx.known_keys.is_empty() { + return 0; + } + let budget = ctx.known_max_len.saturating_mul(2).saturating_add(8); + let mut limit = start; + let mut used = 0usize; + while let Some(ch) = at(text, limit) { + let w = ch.len_utf16(); + if used + w > budget { + break; + } + used += w; + limit += 1; + } + let mut end = limit; + while end > start { + let next = at(text, end); + let boundary = end == text.len() + || next == Some(',') + || next == Some(';') + || is_whitespace(next) + || (extra_boundary.is_some() && next == extra_boundary); + if boundary && ctx.known_keys.contains(&dedup_key(&string(sub(text, start, end)))) { + return end - start; + } + end -= 1; + } + 0 +} + +pub(crate) fn is_known_artist(text: &str, ctx: &Ctx<'_>) -> bool { + !ctx.known_keys.is_empty() && ctx.known_keys.contains(&dedup_key(text)) +} diff --git a/rust/src/credits.rs b/rust/src/credits.rs new file mode 100644 index 0000000..2e74952 --- /dev/null +++ b/rust/src/credits.rs @@ -0,0 +1,260 @@ +//! R7.3–R7.5: splitting a credit list into names. + +use crate::context::{match_known_at, Ctx}; +use crate::options::SplitAndMode; +use crate::scanner::{render_skel, slice_skel, trim_skel, Skel}; +use crate::tables::is_unknown_token; +use crate::types::{ArtistRole, ArtistSource}; +use crate::words::{ + at, before, chars, collapse_chars, collapse_spaces, in_vocab, is_all_digits, is_digit, + is_whitespace, js_trim_end, string, sub, tail, word_key, word_matches, year_of, +}; + +/// An artist credit plus its absolute offset, used for ordering (R9.1). +#[derive(Debug, Clone)] +pub(crate) struct Credit { + pub name: String, + pub role: ArtistRole, + pub joiner: Option, + pub source: ArtistSource, + pub pos: i64, + /// Id of the credit list it came from (R7.6 joiner inheritance in R9.2). + pub list: usize, +} + +/// A year with its absolute offset (R9.6: the track year is the first in text order). +#[derive(Debug, Clone, Copy)] +pub(crate) struct PositionedYear { + pub year: u32, + pub pos: i64, +} + +#[derive(Debug, Clone)] +pub(crate) struct ListOptions { + pub role: ArtistRole, + pub source: ArtistSource, + /// Joiner of the first name: `None`, or the feat / producer marker as written. + pub lead: Option, + /// R7.3: `with` splits only in the main list of the artist side. + pub split_with: bool, + /// R7.2: later feat markers act as joiners inside a featured list. + pub feat_markers_join: bool, +} + +#[derive(Debug, Clone, Default)] +pub(crate) struct ListResult { + pub credits: Vec, + /// R7.5: an unknown token was dropped. + pub unknown: bool, + /// R7.5: dropped year-only names. + pub years: Vec, +} + +struct JoinerHit { + start: usize, + end: usize, + raw: String, +} + +const AND_LIKE: [&str; 3] = ["&", "and", "+"]; + +fn word_at(text: &[char], start: usize) -> usize { + let mut end = start; + while end < text.len() && !is_whitespace(at(text, end)) { + end += 1; + } + end +} + +/// The word after a joiner; a tight joiner (`,` `;`) ends it, since the name ends there. +fn next_word(text: &[char], from: usize) -> String { + let mut a = from; + while a < text.len() && is_whitespace(at(text, a)) { + a += 1; + } + let mut b = a; + while b < text.len() && !is_whitespace(at(text, b)) && !matches!(at(text, b), Some(',' | ';')) { + b += 1; + } + string(sub(text, a, b)) +} + +/// R7.3b: the leftmost joiner occurrence at or after `from`, honouring the guards. +fn find_joiner( + text: &[char], + from: usize, + split_at_comma: bool, + opts: &ListOptions, + ctx: &Ctx<'_>, +) -> Option { + let mut p = from; + while let Some(ch) = at(text, p) { + if ch == ',' || ch == ';' { + if ch == ',' && is_digit(before(text, p)) && is_digit(at(text, p + 1)) { + p += 1; + continue; // `1,000` + } + return Some(JoinerHit { start: p, end: p + 1, raw: ch.to_string() }); + } + if p == 0 || before(text, p) != Some(' ') || is_whitespace(Some(ch)) { + p += 1; + continue; + } + let end = word_at(text, p); + if end >= text.len() || at(text, end) != Some(' ') { + p += 1; + continue; // spaced joiners need a space after + } + let word = string(sub(text, p, end)); + if spaced_joiner(&word, text, end, split_at_comma, opts, ctx) { + return Some(JoinerHit { start: p, end, raw: word }); + } + p += 1; + } + None +} + +fn spaced_joiner( + word: &str, + text: &[char], + end: usize, + split_at_comma: bool, + opts: &ListOptions, + ctx: &Ctx<'_>, +) -> bool { + if opts.feat_markers_join && ctx.t.feat_markers.match_at(&[word], 0).is_some() { + return true; + } + for j in &ctx.t.spaced_joiners { + let matches = if j.case_sensitive { word == j.raw } else { word_matches(word, j.raw) }; + if !matches { + continue; + } + if j.raw == "with" && !opts.split_with { + return false; + } + if j.is_and { + if ctx.split_and == SplitAndMode::Never { + return false; + } + if ctx.split_and == SplitAndMode::Auto && !split_at_comma { + return false; + } + } + if AND_LIKE.contains(&j.raw) && in_vocab(&next_word(text, end), &ctx.t.no_split_before) { + return false; + } + return true; + } + false +} + +/// R7.4: clean one raw name. +pub(crate) fn clean_name(raw: &str) -> String { + let mut name = chars(&collapse_spaces(raw)); + if let (Some(&first), Some(&last)) = (name.first(), name.last()) { + if name.len() >= 2 && (first == '"' || first == '\'') && last == first { + name = chars(&collapse_chars(sub(&name, 1, name.len() - 1))); + } + } + let mut name: String = string(&name); + while name.ends_with(',') || name.ends_with(';') { + name.pop(); + name.truncate(js_trim_end(&name).len()); + } + if let Some(space) = name.find(' ') { + let head = name.get(..space).unwrap_or(""); + if space > 0 && word_key(head) == "by" { + name = name.get(space + 1..).unwrap_or("").to_string(); + } + } + collapse_spaces(&name) +} + +struct RawName { + name: String, + joiner: Option, + pos: i64, +} + +/// R7.4: strip one pair of wrapping quotes from the whole list (no other such quote inside). +fn unwrap_list(list: &Skel) -> Skel { + let t = trim_skel(list); + let n = t.text.len(); + let Some(q) = at(&t.text, 0) else { return t }; + if n < 2 || (q != '"' && q != '\'') || at(&t.text, n - 1) != Some(q) { + return t; + } + // `indexOf(q, 1)`: the next such quote must be the last character. + let next = tail(&t.text, 1).iter().position(|&c| c == q).map(|i| i + 1); + if next != Some(n - 1) { + return t; + } + trim_skel(&slice_skel(&t, 1, n - 1)) +} + +/// R7.3: split `input` into credits. +pub(crate) fn split_credits(input: &Skel, opts: &ListOptions, ctx: &mut Ctx<'_>) -> ListResult { + let list = unwrap_list(input); // R7.4: `"Camo & Krooked"` + let text = &list.text; + let mut raw: Vec = Vec::new(); + let mut joiner: Option = opts.lead.clone(); + let mut split_at_comma = false; + let mut start = 0usize; + while start <= text.len() { + while start < text.len() && is_whitespace(at(text, start)) { + start += 1; + } + let known = match_known_at(text, start, ctx, Some('-')); // R7.3a + let hit = find_joiner(text, start + known, split_at_comma, opts, ctx); + let end = hit.as_ref().map_or(text.len(), |h| h.start); + raw.push(RawName { + name: clean_name(&render_skel(&slice_skel(&list, start, end))), + joiner: joiner.take(), + pos: list.pos.get(start).or(list.pos.last()).copied().unwrap_or(0), + }); + let Some(hit) = hit else { break }; + if hit.raw == "," || hit.raw == ";" { + split_at_comma = true; // R7.3: `and` after a tight joiner + } + start = hit.end; + joiner = Some(hit.raw); + } + finish_names(raw, opts, ctx) +} + +/// R7.4 empty drops, R7.5 year/unknown drops. R7.6: the first survivor takes the lead joiner +/// (`None`, or the feat/producer marker). +fn finish_names(raw: Vec, opts: &ListOptions, ctx: &mut Ctx<'_>) -> ListResult { + let named: Vec = raw.into_iter().filter(|r| !r.name.is_empty()).collect(); + let count = named.len(); + let mut unknown = false; + let mut years: Vec = Vec::new(); + let mut kept: Vec = Vec::new(); + for r in named { + if is_unknown_token(&r.name, ctx.t) { + unknown = true; + continue; + } + let year = if is_all_digits(&r.name) { year_of(&r.name) } else { None }; + match year { + Some(year) if count > 1 => years.push(PositionedYear { year, pos: r.pos }), + _ => kept.push(r), + } + } + let list = ctx.list_seq; + ctx.list_seq += 1; + let credits = kept + .into_iter() + .enumerate() + .map(|(i, r)| Credit { + name: r.name, + role: opts.role, + joiner: if i == 0 { opts.lead.clone() } else { r.joiner }, + source: opts.source, + pos: r.pos, + list, + }) + .collect(); + ListResult { credits, unknown, years } +} diff --git a/rust/src/data.rs b/rust/src/data.rs new file mode 100644 index 0000000..274fadf --- /dev/null +++ b/rust/src/data.rs @@ -0,0 +1,563 @@ +// GENERATED from spec/data — do not edit. Run `node scripts/gen_data.mjs` to regenerate. +#![allow(clippy::all)] + +use crate::value::V; + +/// The version of the spec this crate implements. +pub const SPEC_VERSION: &str = "0.4.0"; // x-release-please-version + +/// spec/data/descriptors.json +pub static DESCRIPTORS_DATA: V = V::Obj(&[ + ("descriptors", V::Arr(&[ + V::Str("radio"), + V::Str("extended"), + V::Str("club"), + V::Str("original"), + V::Str("instrumental"), + V::Str("dub"), + V::Str("vip"), + V::Str("acoustic"), + V::Str("live"), + V::Str("demo"), + V::Str("vocal"), + V::Str("clean"), + V::Str("dirty"), + V::Str("explicit"), + V::Str("short"), + V::Str("long"), + V::Str("full"), + V::Str("album"), + V::Str("single"), + V::Str("alternate"), + V::Str("alt"), + V::Str("alternative"), + V::Str("main"), + V::Str("special"), + V::Str("bonus"), + V::Str("deluxe"), + V::Str("mono"), + V::Str("stereo"), + V::Str("new"), + V::Str("official"), + V::Str("orchestral"), + V::Str("piano"), + V::Str("unplugged"), + V::Str("12\""), + V::Str("7\""), + V::Str("12''"), + V::Str("7''"), + V::Str("12 inch"), + V::Str("7 inch"), + V::Str("re"), + V::Str("final"), + V::Str("second"), + V::Str("2nd"), + V::Str("3rd"), + ])), +]); + +/// spec/data/extensions.json +pub static EXTENSIONS_DATA: V = V::Obj(&[ + ("extensions", V::Arr(&[ + V::Str("mp3"), + V::Str("flac"), + V::Str("wav"), + V::Str("m4a"), + V::Str("ogg"), + V::Str("opus"), + V::Str("aac"), + V::Str("aiff"), + V::Str("aif"), + V::Str("wma"), + V::Str("alac"), + V::Str("mp4"), + V::Str("webm"), + V::Str("mkv"), + ])), +]); + +/// spec/data/feat-markers.json +pub static FEAT_MARKERS_DATA: V = V::Obj(&[ + ("markers", V::Arr(&[ + V::Str("feat."), + V::Str("feat"), + V::Str("ft."), + V::Str("ft"), + V::Str("featuring"), + V::Str("feat:"), + V::Str("ft:"), + ])), + ("bracketOnly", V::Arr(&[ + V::Str("with"), + V::Str("w/"), + ])), + ("producer", V::Arr(&[ + V::Str("prod."), + V::Str("prod"), + V::Str("produced"), + V::Str("prod.by"), + V::Str("prod:"), + ])), + ("titleMarkers", V::Arr(&[ + V::Str("feat."), + V::Str("ft."), + V::Str("featuring"), + ])), + ("titleProducer", V::Arr(&[ + V::Str("prod."), + V::Str("prod. by"), + V::Str("produced by"), + V::Str("prod.by"), + ])), + ("producerBy", V::Str("by")), +]); + +/// spec/data/genres.json +pub static GENRES_DATA: V = V::Obj(&[ + ("genres", V::Arr(&[ + V::Str("d'n'b"), + V::Str("dnb"), + V::Str("d&b"), + V::Str("d & b"), + V::Str("drum & bass"), + V::Str("drum&bass"), + V::Str("drum and bass"), + V::Str("drum n bass"), + V::Str("drum 'n' bass"), + V::Str("drum'n'bass"), + V::Str("neurofunk"), + V::Str("neuro"), + V::Str("liquid"), + V::Str("liquid funk"), + V::Str("jump up"), + V::Str("jump-up"), + V::Str("jungle"), + V::Str("halftime"), + V::Str("dancefloor"), + V::Str("dubstep"), + V::Str("riddim"), + V::Str("brostep"), + V::Str("trap"), + V::Str("future bass"), + V::Str("house"), + V::Str("deep house"), + V::Str("tech house"), + V::Str("progressive house"), + V::Str("electro house"), + V::Str("techno"), + V::Str("trance"), + V::Str("psytrance"), + V::Str("psy"), + V::Str("hardstyle"), + V::Str("hardcore"), + V::Str("breaks"), + V::Str("breakbeat"), + V::Str("garage"), + V::Str("uk garage"), + V::Str("ukg"), + V::Str("2step"), + V::Str("2-step"), + V::Str("grime"), + V::Str("bass"), + V::Str("bass house"), + V::Str("edm"), + V::Str("electronic"), + V::Str("idm"), + V::Str("synthwave"), + V::Str("phonk"), + V::Str("hip hop"), + V::Str("hip-hop"), + V::Str("rap"), + V::Str("pop"), + V::Str("rock"), + V::Str("metal"), + V::Str("ambient"), + V::Str("chillout"), + V::Str("lofi"), + V::Str("lo-fi"), + ])), +]); + +/// spec/data/header-words.json +pub static HEADER_WORDS_DATA: V = V::Obj(&[ + ("words", V::Arr(&[ + V::Str("tracklist"), + V::Str("setlist"), + V::Str("playlist"), + V::Str("part"), + V::Str("hour"), + V::Str("cd"), + V::Str("disc"), + V::Str("side"), + V::Str("chapter"), + V::Str("segment"), + V::Str("set"), + ])), +]); + +/// spec/data/joiners.json +pub static JOINERS_DATA: V = V::Obj(&[ + ("spaced", V::Arr(&[ + V::Obj(&[ + ("raw", V::Str("&")), + ("canonical", V::Str("&")), + ]), + V::Obj(&[ + ("raw", V::Str("and")), + ("canonical", V::Str("&")), + ("kind", V::Str("and")), + ]), + V::Obj(&[ + ("raw", V::Str("x")), + ("canonical", V::Str("x")), + ("caseSensitive", V::Bool(true)), + ]), + V::Obj(&[ + ("raw", V::Str("\u{d7}")), + ("canonical", V::Str("x")), + ]), + V::Obj(&[ + ("raw", V::Str("vs.")), + ("canonical", V::Str("vs.")), + ]), + V::Obj(&[ + ("raw", V::Str("vs")), + ("canonical", V::Str("vs.")), + ]), + V::Obj(&[ + ("raw", V::Str("versus")), + ("canonical", V::Str("vs.")), + ]), + V::Obj(&[ + ("raw", V::Str("/")), + ("canonical", V::Str("/")), + ]), + V::Obj(&[ + ("raw", V::Str("+")), + ("canonical", V::Str("+")), + ]), + V::Obj(&[ + ("raw", V::Str("with")), + ("canonical", V::Str("with")), + ]), + V::Obj(&[ + ("raw", V::Str("meets")), + ("canonical", V::Str("meets")), + ]), + V::Obj(&[ + ("raw", V::Str("pres.")), + ("canonical", V::Str("pres.")), + ]), + V::Obj(&[ + ("raw", V::Str("presents")), + ("canonical", V::Str("pres.")), + ]), + V::Obj(&[ + ("raw", V::Str("b2b")), + ("canonical", V::Str("b2b")), + ]), + ])), + ("tight", V::Arr(&[ + V::Obj(&[ + ("raw", V::Str(",")), + ("canonical", V::Str(",")), + ]), + V::Obj(&[ + ("raw", V::Str(";")), + ("canonical", V::Str(",")), + ]), + ])), + ("featCanonical", V::Str("feat.")), +]); + +/// spec/data/junk.json +pub static JUNK_DATA: V = V::Obj(&[ + ("phrases", V::Obj(&[ + ("official video", V::Str("video")), + ("official music video", V::Str("video")), + ("music video", V::Str("video")), + ("official video clip", V::Str("video")), + ("video clip", V::Str("video")), + ("official clip", V::Str("video")), + ("clip officiel", V::Str("video")), + ("official hd video", V::Str("video")), + ("official 4k video", V::Str("video")), + ("official mv", V::Str("video")), + ("mv", V::Str("video")), + ("m/v", V::Str("video")), + ("video", V::Str("video")), + ("official visualizer", V::Str("video")), + ("official visualiser", V::Str("video")), + ("visualizer", V::Str("video")), + ("visualiser", V::Str("video")), + ("audio visualizer", V::Str("video")), + ("official animated video", V::Str("video")), + ("animated video", V::Str("video")), + ("live video", V::Str("video")), + ("official live video", V::Str("video")), + ("performance video", V::Str("video")), + ("official performance video", V::Str("video")), + ("official audio", V::Str("audio")), + ("audio", V::Str("audio")), + ("audio only", V::Str("audio")), + ("full audio", V::Str("audio")), + ("official lyric video", V::Str("lyrics")), + ("official lyrics video", V::Str("lyrics")), + ("lyric video", V::Str("lyrics")), + ("lyrics video", V::Str("lyrics")), + ("lyrics", V::Str("lyrics")), + ("lyric", V::Str("lyrics")), + ("with lyrics", V::Str("lyrics")), + ("lyrics on screen", V::Str("lyrics")), + ("letra", V::Str("lyrics")), + ("hd", V::Str("quality")), + ("hq", V::Str("quality")), + ("uhd", V::Str("quality")), + ("4k", V::Str("quality")), + ("8k", V::Str("quality")), + ("1080p", V::Str("quality")), + ("720p", V::Str("quality")), + ("480p", V::Str("quality")), + ("high quality", V::Str("quality")), + ("full hd", V::Str("quality")), + ("free download", V::Str("promo")), + ("free dl", V::Str("promo")), + ("out now", V::Str("promo")), + ("premiere", V::Str("promo")), + ("exclusive", V::Str("promo")), + ("preview", V::Str("promo")), + ("teaser", V::Str("promo")), + ("snippet", V::Str("promo")), + ("new song", V::Str("promo")), + ("available now", V::Str("promo")), + ("ncs release", V::Str("label")), + ("monstercat release", V::Str("label")), + ("official", V::Str("other")), + ])), + ("connectors", V::Arr(&[ + V::Str("-"), + V::Str("|"), + V::Str("/"), + V::Str("&"), + V::Str("+"), + V::Str(","), + ])), + ("labelSuffixes", V::Arr(&[ + V::Str("release"), + V::Str("records"), + V::Str("recordings"), + ])), +]); + +/// spec/data/layered-words.json +pub static LAYERED_WORDS_DATA: V = V::Obj(&[ + ("words", V::Arr(&[ + V::Str("w/"), + ])), +]); + +/// spec/data/marker-words.json +pub static MARKER_WORDS_DATA: V = V::Obj(&[ + ("words", V::Arr(&[ + V::Str("intro"), + V::Str("outro"), + V::Str("break"), + V::Str("interlude"), + V::Str("intermission"), + V::Str("jingle"), + V::Str("ad"), + V::Str("advert"), + V::Str("advertisement"), + V::Str("talk"), + V::Str("interview"), + V::Str("speech"), + V::Str("announcement"), + V::Str("shoutout"), + V::Str("shout-out"), + V::Str("pause"), + V::Str("start"), + V::Str("end"), + V::Str("silence"), + V::Str("applause"), + V::Str("skit"), + ])), +]); + +/// spec/data/no-split-before.json +pub static NO_SPLIT_BEFORE_DATA: V = V::Obj(&[ + ("words", V::Arr(&[ + V::Str("sons"), + V::Str("daughters"), + V::Str("friends"), + V::Str("co"), + V::Str("co."), + V::Str("company"), + V::Str("his"), + V::Str("her"), + V::Str("their"), + V::Str("orchestra"), + ])), +]); + +/// spec/data/platform-suffixes.json +pub static PLATFORM_SUFFIXES_DATA: V = V::Obj(&[ + ("suffixes", V::Arr(&[ + V::Str(" - YouTube Music"), + V::Str(" - YouTube"), + V::Str(" | Free Listening on SoundCloud"), + V::Str(" - SoundCloud"), + V::Str(" | SoundCloud"), + V::Str(" - Topic"), + V::Str(" | Bandcamp"), + V::Str(" - Bandcamp"), + ])), +]); + +/// spec/data/stopwords.json +pub static STOPWORDS_DATA: V = V::Obj(&[ + ("words", V::Arr(&[ + V::Str("you"), + V::Str("me"), + V::Str("him"), + V::Str("her"), + V::Str("us"), + V::Str("them"), + V::Str("it"), + V::Str("i"), + V::Str("love"), + V::Str("my"), + V::Str("your"), + V::Str("our"), + V::Str("the"), + V::Str("a"), + V::Str("an"), + V::Str("this"), + V::Str("that"), + V::Str("myself"), + V::Str("yourself"), + V::Str("everyone"), + V::Str("everybody"), + V::Str("somebody"), + V::Str("someone"), + V::Str("nobody"), + V::Str("nothing"), + V::Str("all"), + V::Str("night"), + V::Str("side"), + V::Str("day"), + ])), +]); + +/// spec/data/unknown-tokens.json +pub static UNKNOWN_TOKENS_DATA: V = V::Obj(&[ + ("caseSensitive", V::Arr(&[ + V::Str("ID"), + V::Str("IDs"), + V::Str("ID?"), + ])), + ("caseInsensitive", V::Arr(&[ + V::Str("unknown"), + V::Str("unknown artist"), + V::Str("unknown title"), + V::Str("untitled"), + V::Str("?"), + V::Str("??"), + V::Str("???"), + ])), +]); + +/// spec/data/version-keywords.json +pub static VERSION_KEYWORDS_DATA: V = V::Obj(&[ + ("heads", V::Obj(&[ + ("remix", V::Str("remix")), + ("rmx", V::Str("remix")), + ("mix", V::Str("mix")), + ("bootleg", V::Str("bootleg")), + ("vip", V::Str("vip")), + ("edit", V::Str("edit")), + ("re-edit", V::Str("edit")), + ("reedit", V::Str("edit")), + ("flip", V::Str("flip")), + ("refix", V::Str("refix")), + ("rework", V::Str("rework")), + ("re-work", V::Str("rework")), + ("mashup", V::Str("mashup")), + ("mash-up", V::Str("mashup")), + ("mash up", V::Str("mashup")), + ("blend", V::Str("blend")), + ("dub", V::Str("dub")), + ("version", V::Str("version")), + ("ver", V::Str("version")), + ("remaster", V::Str("remaster")), + ("remastered", V::Str("remaster")), + ("cover", V::Str("cover")), + ("reprise", V::Str("reprise")), + ])), + ("genericHeads", V::Arr(&[ + V::Str("mix"), + V::Str("edit"), + V::Str("version"), + ])), + ("typeCapableModifiers", V::Obj(&[ + ("radio", V::Str("radio")), + ("extended", V::Str("extended")), + ("club", V::Str("club")), + ("original", V::Str("original")), + ("instrumental", V::Str("instrumental")), + ("dub", V::Str("dub")), + ("vip", V::Str("vip")), + ("acoustic", V::Str("acoustic")), + ("live", V::Str("live")), + ("acapella", V::Str("acapella")), + ("a cappella", V::Str("acapella")), + ("a capella", V::Str("acapella")), + ("acappella", V::Str("acapella")), + ("demo", V::Str("demo")), + ])), + ("prefixForms", V::Obj(&[ + ("live", V::Str("live")), + ("remastered", V::Str("remaster")), + ("remaster", V::Str("remaster")), + ("acoustic", V::Str("acoustic")), + ("instrumental", V::Str("instrumental")), + ("acapella", V::Str("acapella")), + ("a cappella", V::Str("acapella")), + ("demo", V::Str("demo")), + ("sped up", V::Str("spedUp")), + ("speed up", V::Str("spedUp")), + ("slowed + reverb", V::Str("slowed")), + ("slowed & reverb", V::Str("slowed")), + ("slowed and reverb", V::Str("slowed")), + ("slowed", V::Str("slowed")), + ("nightcore", V::Str("nightcore")), + ])), + ("types", V::Arr(&[ + V::Str("remix"), + V::Str("bootleg"), + V::Str("vip"), + V::Str("edit"), + V::Str("flip"), + V::Str("refix"), + V::Str("rework"), + V::Str("mashup"), + V::Str("blend"), + V::Str("dub"), + V::Str("mix"), + V::Str("extended"), + V::Str("radio"), + V::Str("club"), + V::Str("original"), + V::Str("instrumental"), + V::Str("acapella"), + V::Str("live"), + V::Str("acoustic"), + V::Str("remaster"), + V::Str("demo"), + V::Str("reprise"), + V::Str("cover"), + V::Str("version"), + V::Str("spedUp"), + V::Str("slowed"), + V::Str("nightcore"), + ])), +]); diff --git a/rust/src/digits.rs b/rust/src/digits.rs new file mode 100644 index 0000000..64fe871 --- /dev/null +++ b/rust/src/digits.rs @@ -0,0 +1,26 @@ +//! ASCII digit scanning shared by R4.1 (prefix.rs) and the tracklist time scanner (R13.2). + +use crate::words::{at, is_digit, sub}; + +/// Length of the run of ASCII digits starting at `from`. +pub(crate) fn digit_run(s: &[char], from: usize) -> usize { + let mut i = from; + while is_digit(at(s, i)) { + i += 1; + } + i - from +} + +/// The value of a short run of ASCII digits (saturating; callers pass at most a few digits). +pub(crate) fn digits_value(s: &[char]) -> u32 { + s.iter().fold(0u32, |n, c| n.saturating_mul(10).saturating_add(c.to_digit(10).unwrap_or(0))) +} + +/// Exactly two digits (not followed by a third) with a value of at most 59, else `None`. +pub(crate) fn two_digits_up_to_59(s: &[char], at_: usize) -> Option { + if !is_digit(at(s, at_)) || !is_digit(at(s, at_ + 1)) || is_digit(at(s, at_ + 2)) { + return None; + } + let n = digits_value(sub(s, at_, at_ + 2)); + (n <= 59).then_some(n) +} diff --git a/rust/src/format.rs b/rust/src/format.rs new file mode 100644 index 0000000..ab95d2d --- /dev/null +++ b/rust/src/format.rs @@ -0,0 +1,148 @@ +//! R11: render a parsed track back to a string. + +use std::collections::HashSet; + +use crate::assemble::render_version; +use crate::options::{FeatMode, ResolvedFormat}; +use crate::tables::{default_tables, Tables}; +use crate::types::{Artist, ArtistRole, ArtistSource, VersionDelimiter}; +use crate::words::{dedup_key, word_matches}; + +/// The parts of a track R11 reads. +pub(crate) struct FormatInput<'a> { + pub artists: &'a [Artist], + pub title: &'a str, + pub versions: Vec<(&'a str, VersionDelimiter)>, + pub position_raw: Option<&'a str>, +} + +fn is_feat_marker(raw: &str, t: &Tables) -> bool { + t.feat_markers.match_at(&[raw], 0).is_some() + || t.bracket_only_feat.match_at(&[raw], 0).is_some() +} + +/// R11.5: map a raw joiner to its canonical form through data/joiners.json; feat markers become +/// `featCanonical`. A featured list's lead marker is always a feat marker (`with` → `feat.`), +/// while between names the joiner table wins (`Sigala with Ella Eyre` keeps `with`). +fn canonical_joiner(raw: &str, t: &Tables, feat_lead: bool) -> String { + if feat_lead && is_feat_marker(raw, t) { + return t.feat_canonical.to_string(); + } + if let Some(tight) = t.tight_joiners.get(raw) { + return (*tight).to_string(); + } + for j in &t.spaced_joiners { + if if j.case_sensitive { raw == j.raw } else { word_matches(raw, j.raw) } { + return j.canonical.to_string(); + } + } + if is_feat_marker(raw, t) { + t.feat_canonical.to_string() + } else { + raw.to_string() + } +} + +/// R11.1: `" " + joiner + " "`; tight joiners as the raw char + `" "`; a missing joiner as `&`. +fn join_sep(joiner: Option<&str>, o: &ResolvedFormat, t: &Tables) -> String { + let j = match joiner { + None => "&".to_string(), + Some(j) if o.canonical => canonical_joiner(j, t, false), + Some(j) => j.to_string(), + }; + if t.tight_joiners.contains_key(j.as_str()) { + format!("{j} ") + } else { + format!(" {j} ") + } +} + +/// Names of one credit list joined by their own joiners (the first joiner is not rendered). +fn join_names(list: &[&Artist], o: &ResolvedFormat, t: &Tables) -> String { + let mut out = String::new(); + for (i, a) in list.iter().enumerate() { + if i > 0 { + out.push_str(&join_sep(a.joiner.as_deref(), o, t)); + } + out.push_str(&a.name); + } + out +} + +/// The marker in front of a featured list. +fn lead_marker(first: &Artist, o: &ResolvedFormat, t: &Tables, fallback: &str) -> String { + if let Some(marker) = &o.feat_marker { + return marker.clone(); + } + let raw = first.joiner.as_deref().unwrap_or(fallback); + if o.canonical { + canonical_joiner(raw, t, true) + } else { + raw.to_string() + } +} + +pub(crate) fn format(track: &FormatInput<'_>, o: &ResolvedFormat) -> String { + let tables = default_tables(); + let t: &Tables = &tables; + let with_role = |role: ArtistRole| { + track.artists.iter().filter(|a| a.role == role).collect::>() + }; + let primaries = with_role(ArtistRole::Primary); + let featured = with_role(ArtistRole::Featured); + let producers = with_role(ArtistRole::Producer); + + let (artist_feat, title_feat): (Vec<&Artist>, Vec<&Artist>) = match o.feat { + FeatMode::Source => { + featured.iter().copied().partition(|a| a.source == ArtistSource::Artist) + } + FeatMode::Artist => (featured, Vec::new()), + FeatMode::Title => (Vec::new(), featured), + FeatMode::Omit => (Vec::new(), Vec::new()), + }; + + // R11.1 / R11.2 + let mut artist_part = join_names(&primaries, o, t); + if let Some(first) = artist_feat.first() { + let lead = lead_marker(first, o, t, t.feat_canonical); + let names = join_names(&artist_feat, o, t); + artist_part = if artist_part.is_empty() { + format!("{lead} {names}") + } else { + format!("{artist_part} {lead} {names}") + }; + } + + // R11.3 + let mut pieces: Vec = Vec::new(); + if !track.title.is_empty() { + pieces.push(track.title.to_string()); + } + if let Some(first) = title_feat.first() { + let lead = lead_marker(first, o, t, t.feat_canonical); + pieces.push(format!("({lead} {})", join_names(&title_feat, o, t))); + } + if o.versions { + pieces + .extend(track.versions.iter().map(|(raw, delimiter)| render_version(raw, *delimiter))); + } + if let (true, Some(first)) = (o.producers, producers.first()) { + let marker = first.joiner.as_deref().unwrap_or("prod."); + pieces.push(format!("({marker} {})", join_names(&producers, o, t))); + } + let title_part = pieces.join(" "); + + // R11.4 + let mut result = + if artist_part.is_empty() { title_part } else { format!("{artist_part} - {title_part}") }; + if let (true, Some(raw)) = (o.position, track.position_raw) { + result = format!("{raw}. {result}"); + } + result +} + +/// All credited names: track artists plus every version's remixers, deduped by R0.4 key. +pub(crate) fn all_artists<'a>(all: impl Iterator) -> Vec { + let mut seen: HashSet = HashSet::new(); + all.filter(|a| seen.insert(dedup_key(&a.name))).cloned().collect() +} diff --git a/rust/src/json.rs b/rust/src/json.rs new file mode 100644 index 0000000..6853fcd --- /dev/null +++ b/rust/src/json.rs @@ -0,0 +1,374 @@ +//! A small JSON value with a reader and a writer. The crate has no JSON dependency: this is what +//! `to_json()` writes with, and what the fixtures and the cross-port diff read. + +/// An owned JSON value. Objects keep insertion order (like JS objects with string keys). +/// +/// ``` +/// use trackparse::json::Json; +/// +/// let value = Json::parse(r#"{"title":"Stigma","year":2015,"tags":["dnb",null]}"#).unwrap(); +/// assert_eq!(value.get("title").and_then(Json::as_str), Some("Stigma")); +/// assert_eq!(value.get("year"), Some(&Json::Num(2015.0))); +/// assert_eq!(value.get("tags").and_then(Json::as_array).map(|t| t.len()), Some(2)); +/// assert_eq!(value.write(), r#"{"title":"Stigma","year":2015,"tags":["dnb",null]}"#); +/// assert_eq!(Json::parse("{oops"), None); +/// ``` +/// +/// The enum is `#[non_exhaustive]`: a `match` on it outside this crate needs a `_` arm. +#[derive(Debug, Clone, PartialEq)] +#[non_exhaustive] +pub enum Json { + /// `null`. + Null, + /// `true` or `false`. + Bool(bool), + /// A number. Written as JS writes it: `3167`, `7.5`; a non-finite value is `null`. + Num(f64), + /// A string. + Str(String), + /// An array. + Arr(Vec), + /// An object: its members in order. + Obj(Vec<(String, Json)>), +} + +impl std::fmt::Display for Json { + /// The compact JSON text of [`Json::write`]. + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(&self.write()) + } +} + +impl Json { + /// A string value. + pub fn str(s: &str) -> Json { + Json::Str(s.to_string()) + } + + /// A string value, or `null` for `None`. + pub fn opt_str(s: Option<&str>) -> Json { + s.map_or(Json::Null, Json::str) + } + + /// The member `key` of an object. + pub fn get(&self, key: &str) -> Option<&Json> { + match self { + Json::Obj(entries) => entries.iter().find(|(k, _)| k == key).map(|(_, v)| v), + _ => None, + } + } + + /// The string, if the value is one. + pub fn as_str(&self) -> Option<&str> { + match self { + Json::Str(s) => Some(s), + _ => None, + } + } + + /// The items, if the value is an array. + pub fn as_array(&self) -> Option<&[Json]> { + match self { + Json::Arr(items) => Some(items), + _ => None, + } + } + + /// The members in order, if the value is an object. + pub fn as_object(&self) -> Option<&[(String, Json)]> { + match self { + Json::Obj(entries) => Some(entries), + _ => None, + } + } + + /// Compact JSON text, written the way `JSON.stringify` writes it. + pub fn write(&self) -> String { + let mut out = String::new(); + self.write_into(&mut out); + out + } + + fn write_into(&self, out: &mut String) { + match self { + Json::Null => out.push_str("null"), + Json::Bool(b) => out.push_str(if *b { "true" } else { "false" }), + Json::Num(n) => write_number(*n, out), + Json::Str(s) => write_string(s, out), + Json::Arr(items) => { + out.push('['); + for (i, item) in items.iter().enumerate() { + if i > 0 { + out.push(','); + } + item.write_into(out); + } + out.push(']'); + } + Json::Obj(entries) => { + out.push('{'); + for (i, (k, v)) in entries.iter().enumerate() { + if i > 0 { + out.push(','); + } + write_string(k, out); + out.push(':'); + v.write_into(out); + } + out.push('}'); + } + } + } + + /// Parse JSON text. `None` on malformed input (never panics). `1e999` reads as infinity, as + /// in JS, so fixtures can carry non-finite numbers. + pub fn parse(text: &str) -> Option { + let chars: Vec = text.chars().collect(); + let mut p = Reader { chars: &chars, at: 0, depth: 0 }; + p.ws(); + let v = p.value()?; + p.ws(); + if p.at == chars.len() { + Some(v) + } else { + None + } + } +} + +/// JS `Number::toString` (what `JSON.stringify` writes): the shortest digits that round-trip, +/// laid out without an exponent from 1e-6 up to 1e21 and as `1e+21` / `1.5e-7` outside it. +/// Non-finite values are `null`; `-0` is `0`. +#[cfg(feature = "serde")] +pub(crate) fn number_text(n: f64) -> String { + let mut out = String::new(); + write_number(n, &mut out); + out +} + +fn write_number(n: f64, out: &mut String) { + if !n.is_finite() { + out.push_str("null"); + return; + } + if n == 0.0 { + out.push('0'); + return; + } + if n < 0.0 { + out.push('-'); + } + // `{:e}` gives the shortest round-trip digits as `d[.ddd]e`. + let sci = format!("{:e}", n.abs()); + let (mantissa, exp) = sci.split_once('e').unwrap_or((&sci, "0")); + let digits: String = mantissa.chars().filter(char::is_ascii_digit).collect(); + let k = digits.len() as i32; + // The value is 0.digits × 10^point. + let point = exp.parse::().unwrap_or(0) + 1; + if k <= point && point <= 21 { + out.push_str(&digits); + out.extend(std::iter::repeat('0').take((point - k) as usize)); + } else if 0 < point && point <= 21 { + let (int, frac) = digits.split_at(point as usize); + out.push_str(int); + out.push('.'); + out.push_str(frac); + } else if -6 < point && point <= 0 { + out.push_str("0."); + out.extend(std::iter::repeat('0').take((-point) as usize)); + out.push_str(&digits); + } else { + let (first, rest) = digits.split_at(1.min(digits.len())); + out.push_str(first); + if !rest.is_empty() { + out.push('.'); + out.push_str(rest); + } + out.push('e'); + out.push(if point > 0 { '+' } else { '-' }); + out.push_str(&(point - 1).abs().to_string()); + } +} + +fn write_string(s: &str, out: &mut String) { + out.push('"'); + for ch in s.chars() { + match ch { + '"' => out.push_str("\\\""), + '\\' => out.push_str("\\\\"), + '\n' => out.push_str("\\n"), + '\r' => out.push_str("\\r"), + '\t' => out.push_str("\\t"), + '\u{8}' => out.push_str("\\b"), + '\u{c}' => out.push_str("\\f"), + c if (c as u32) < 0x20 => out.push_str(&format!("\\u{:04x}", c as u32)), + c => out.push(c), + } + } + out.push('"'); +} + +struct Reader<'a> { + chars: &'a [char], + at: usize, + depth: usize, +} + +impl Reader<'_> { + fn peek(&self) -> Option { + self.chars.get(self.at).copied() + } + + fn ws(&mut self) { + while matches!(self.peek(), Some(' ' | '\t' | '\n' | '\r')) { + self.at += 1; + } + } + + fn eat(&mut self, word: &str) -> bool { + let n = word.chars().count(); + let ok = self + .chars + .get(self.at..self.at + n) + .is_some_and(|s| s.iter().copied().eq(word.chars())); + if ok { + self.at += n; + } + ok + } + + fn value(&mut self) -> Option { + if self.depth > 200 { + return None; + } + match self.peek()? { + 'n' => self.eat("null").then_some(Json::Null), + 't' => self.eat("true").then_some(Json::Bool(true)), + 'f' => self.eat("false").then_some(Json::Bool(false)), + '"' => self.string().map(Json::Str), + '[' => { + self.at += 1; + self.depth += 1; + let mut items = Vec::new(); + self.ws(); + if self.peek() == Some(']') { + self.at += 1; + } else { + loop { + self.ws(); + items.push(self.value()?); + self.ws(); + match self.peek()? { + ',' => self.at += 1, + ']' => { + self.at += 1; + break; + } + _ => return None, + } + } + } + self.depth -= 1; + Some(Json::Arr(items)) + } + '{' => { + self.at += 1; + self.depth += 1; + let mut entries: Vec<(String, Json)> = Vec::new(); + self.ws(); + if self.peek() == Some('}') { + self.at += 1; + } else { + loop { + self.ws(); + let key = self.string()?; + self.ws(); + if self.peek()? != ':' { + return None; + } + self.at += 1; + self.ws(); + let v = self.value()?; + // A repeated key keeps its first position and takes the last value (JS). + match entries.iter_mut().find(|(k, _)| *k == key) { + Some(slot) => slot.1 = v, + None => entries.push((key, v)), + } + self.ws(); + match self.peek()? { + ',' => self.at += 1, + '}' => { + self.at += 1; + break; + } + _ => return None, + } + } + } + self.depth -= 1; + Some(Json::Obj(entries)) + } + _ => self.number(), + } + } + + fn number(&mut self) -> Option { + let start = self.at; + while matches!(self.peek(), Some('0'..='9' | '-' | '+' | '.' | 'e' | 'E')) { + self.at += 1; + } + let text: String = self.chars.get(start..self.at)?.iter().collect(); + text.parse::().ok().map(Json::Num) + } + + fn hex4(&mut self) -> Option { + let s: String = self.chars.get(self.at..self.at + 4)?.iter().collect(); + self.at += 4; + u32::from_str_radix(&s, 16).ok() + } + + fn string(&mut self) -> Option { + if self.peek()? != '"' { + return None; + } + self.at += 1; + let mut out = String::new(); + loop { + let ch = self.peek()?; + self.at += 1; + match ch { + '"' => return Some(out), + '\\' => { + let e = self.peek()?; + self.at += 1; + match e { + 'n' => out.push('\n'), + 'r' => out.push('\r'), + 't' => out.push('\t'), + 'b' => out.push('\u{8}'), + 'f' => out.push('\u{c}'), + 'u' => { + let hi = self.hex4()?; + let cp = if (0xd800..0xdc00).contains(&hi) && self.eat("\\u") { + let lo = self.hex4()?; + if (0xdc00..0xe000).contains(&lo) { + 0x10000 + ((hi - 0xd800) << 10) + (lo - 0xdc00) + } else { + // Two units that do not pair: both become U+FFFD. + out.push('\u{fffd}'); + lo + } + } else { + hi + }; + // A lone surrogate cannot live in a Rust string. + out.push(char::from_u32(cp).unwrap_or('\u{fffd}')); + } + other => out.push(other), + } + } + c => out.push(c), + } + } + } +} diff --git a/rust/src/lib.rs b/rust/src/lib.rs new file mode 100644 index 0000000..73ebe92 --- /dev/null +++ b/rust/src/lib.rs @@ -0,0 +1,326 @@ +//! Turn messy track names into structured data: artists with roles, remixes and versions, +//! junk, and whole tracklists. +//! +//! trackparse is driven by a written spec. Behaviour is defined by [`SPEC.md`] and its shared +//! fixtures. This crate passes every shared fixture, and for every fixture input its output is +//! byte-identical to the JavaScript (npm `trackparse`) and Python (PyPI `trackparse`) packages. +//! Rule IDs such as `R6.2` in these docs refer to the spec. +//! +//! - User documentation: +//! - The spec: +//! +//! [`SPEC.md`]: https://github.com/4matic/trackparse/blob/main/spec/SPEC.md +//! +//! # Single tracks +//! +//! [`parse`] takes any string and returns a [`ParsedTrack`]. It never panics and never returns +//! an error: what it recognises goes into a field, what it does not stays in the title. +//! +//! ``` +//! use trackparse::{parse, ArtistRole, JunkKind, VersionType}; +//! +//! let track = parse("Noisia feat. Foreign Beggars - Shellshock (Rockwell Remix) [Official Video]"); +//! +//! assert_eq!(track.artists[0].name, "Noisia"); +//! assert_eq!(track.artists[1].name, "Foreign Beggars"); +//! assert_eq!(track.artists[1].role, ArtistRole::Featured); +//! assert_eq!(track.title, "Shellshock"); +//! assert_eq!(track.full_title, "Shellshock (Rockwell Remix)"); +//! assert_eq!(track.versions[0].version_type, VersionType::Remix); +//! assert_eq!(track.versions[0].artists[0].name, "Rockwell"); +//! assert_eq!(track.junk[0].kind, JunkKind::Video); +//! ``` +//! +//! [`parse_with`] takes [`ParseOptions`]; a [`Parser`] keeps resolved options for many calls. +//! [`parse_artists`] splits a credit string, [`format_track`] writes a track back as a string, +//! [`normalize()`] cleans a string without parsing it, and [`all_artists`] lists every credited +//! name, remixers included. +//! +//! ``` +//! use trackparse::{format_track_with, parse_with, FeatPlacement, FormatOptions, ParseOptions}; +//! +//! let options = ParseOptions::new().known_artists(["Chase & Status"]); +//! let track = parse_with("Chase & Status - Blind Faith ft. Liam Bailey", &options); +//! assert_eq!(track.artists.len(), 2); +//! +//! let format = FormatOptions::new().feat(FeatPlacement::Artist); +//! assert_eq!(format_track_with(&track, &format), "Chase & Status ft. Liam Bailey - Blind Faith"); +//! ``` +//! +//! # Tracklists +//! +//! The [`tracklist`] module reads a whole pasted tracklist: one entry per line, with its time, +//! its kind and the parsed track, plus warnings about the times. [`tracklist::apply_edits`] +//! rewrites times and lines without touching anything else. +//! +//! ``` +//! use trackparse::tracklist::{apply_edits, parse_tracklist, Edit, WarningCode}; +//! +//! let text = "00:00 Noisia - Stigma\n03:45 Phace & Misanthrop - Desert Orgy\n02:10 Mefjus - Suicide Bassline"; +//! let list = parse_tracklist(text); +//! assert_eq!(list.stats.tracks, 3); +//! assert_eq!(list.entries[1].time.as_ref().unwrap().seconds, 225.0); +//! assert_eq!(list.entries[1].track.as_ref().unwrap().title, "Desert Orgy"); +//! assert_eq!(list.warnings[0].code, WarningCode::TimeOutOfOrder); +//! +//! let fixed = apply_edits(text, &[Edit::sort_by_time()]); +//! assert_eq!( +//! fixed.text, +//! "00:00 Noisia - Stigma\n02:10 Mefjus - Suicide Bassline\n03:45 Phace & Misanthrop - Desert Orgy" +//! ); +//! ``` +//! +//! # JSON +//! +//! Fields are snake_case in Rust. `to_json()` on every output type writes the spec's JSON form: +//! camelCase keys (`fullTitle`, `unknownArtist`), every key present, in the schema's order. It is +//! the same text the JavaScript and Python packages produce, and needs no dependency. +//! +//! ``` +//! let artists = trackparse::parse_artists("Noisia & Phace"); +//! assert_eq!( +//! artists[1].to_json(), +//! r#"{"name":"Phace","role":"primary","joiner":"&","source":"artist"}"# +//! ); +//! ``` +//! +//! With the `serde` feature the output types implement `Serialize` and `Deserialize` with the +//! same keys, so `serde_json::to_string(&track)` gives the text of `track.to_json()`. The +//! options and [`tracklist::Edit`] implement both traits too. Numbers are written as +//! `to_json()` writes them. The exceptions are numbers no parse result contains: seconds from +//! 0.000001 up to 0.00001 (and, with older `serde_json` releases, of 1e21 and more) in an +//! `Edit` or an option built by hand, which `serde_json` writes in its own float notation +//! (`1e-6` for `0.000001`). Non-finite seconds are written as `null`, as by `to_json()`, and +//! `null` reads back as NaN. Keyword maps are written without repeated keys (the last value +//! wins, as in a JS object). +//! +//! # Guarantees +//! +//! - Total: any `&str` gives a result. No panics, no `Result` (R0.8). +//! - No regular expressions and no backtracking: the scanners make a bounded number of passes +//! over the input. A 10,000-code-point string parses in a few milliseconds, and the test suite +//! checks that repeated hostile fragments scale far below quadratic. +//! - No `unsafe`. One dependency (`unicode-normalization`); `serde` only with the feature. +//! - The Unicode tables the rules depend on (letters, uppercase letters, lowercase mapping) are +//! compiled in, so the output does not change with the compiler version. +//! - NFC and NFD (R1, R0.4) come from `unicode-normalization` and follow that crate's Unicode +//! version: 0.1.26, the minimum this crate accepts, has the Unicode 18 tables. The JavaScript +//! reference normalizes with its runtime's tables (Unicode 17 on Node 24), so a string with +//! one of the 32 combining marks added in Unicode 18 can come out in another mark order than +//! it does there. Text without those marks is not affected. + +#![warn(missing_docs)] +#![cfg_attr(docsrs, feature(doc_cfg))] + +pub mod json; +pub mod tracklist; +#[doc(hidden)] +pub mod wire; + +mod artists; +mod assemble; +mod classify; +mod context; +mod credits; +#[rustfmt::skip] +mod data; +mod digits; +mod format; +mod mode; +mod normalize; +mod options; +mod parser; +mod prefix; +mod scanner; +mod separator; +#[cfg(feature = "serde")] +mod serde_support; +mod tables; +mod title; +mod types; +#[rustfmt::skip] +mod unicode_tables; +mod value; +mod words; + +pub use data::SPEC_VERSION; +pub use options::{ + FeatPlacement, FormatOptions, JoinerStyle, KeywordOptions, ModeOption, ParseOptions, SplitAnd, + VersionsOption, +}; +pub use types::{ + Artist, ArtistRole, ArtistSource, Flags, Junk, JunkKind, Mode, ParsedTrack, Position, + Timestamp, ToJson, UnknownName, Version, VersionDelimiter, VersionType, Warning, +}; + +use options::{Resolved, ResolvedFormat}; +use parser::Engine; + +/// The examples of the README, run as doc tests (they use the `serde` feature). +#[cfg(all(doctest, feature = "serde"))] +#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] +#[doc = include_str!("../README.md")] +pub struct ReadmeDoctests; + +/// Parse one track string with the default options (mode `auto`). +/// +/// Never panics: any string gives a [`ParsedTrack`] (SPEC R0.8). +/// +/// ``` +/// let track = trackparse::parse("Sub Focus - Out the Blue ft. Alice Gold (2015)"); +/// assert_eq!(track.title, "Out the Blue"); +/// assert_eq!(track.year, Some(2015)); +/// assert_eq!(track.artists.len(), 2); +/// ``` +pub fn parse(input: &str) -> ParsedTrack { + Engine::shared().run(input, false).into_track() +} + +/// Parse one track string with options (R12). +/// +/// To parse many strings with the same options, build a [`Parser`] once instead. +/// +/// ``` +/// use trackparse::{parse_with, Mode, ModeOption, ParseOptions}; +/// +/// let options = ParseOptions::new().mode(ModeOption::Youtube); +/// let track = parse_with("Noisia - Stigma (Official Video)", &options); +/// assert_eq!(track.mode, Mode::Youtube); +/// assert_eq!(track.title, "Stigma"); +/// assert_eq!(track.junk[0].raw, "Official Video"); +/// ``` +pub fn parse_with(input: &str, options: &ParseOptions) -> ParsedTrack { + Parser::new(options).parse(input) +} + +/// Split a credit string into artists (R10). +/// +/// ``` +/// let artists = trackparse::parse_artists("Noisia & The Upbeats feat. Foreign Beggars"); +/// let names: Vec<&str> = artists.iter().map(|a| a.name.as_str()).collect(); +/// assert_eq!(names, ["Noisia", "The Upbeats", "Foreign Beggars"]); +/// ``` +pub fn parse_artists(input: &str) -> Vec { + Engine::shared().run_artists(input) +} + +/// [`parse_artists`] with options (`known_artists`, `split_and`, `keywords`). +/// +/// ``` +/// use trackparse::{parse_artists_with, ParseOptions}; +/// +/// let options = ParseOptions::new().known_artists(["Above & Beyond"]); +/// let artists = parse_artists_with("Above & Beyond & Zoë Johnston", &options); +/// let names: Vec<&str> = artists.iter().map(|a| a.name.as_str()).collect(); +/// assert_eq!(names, ["Above & Beyond", "Zoë Johnston"]); +/// ``` +pub fn parse_artists_with(input: &str, options: &ParseOptions) -> Vec { + Parser::new(options).parse_artists(input) +} + +/// Render a parsed track back to a string (R11) with the default format options. +/// +/// ``` +/// use trackparse::{format_track, parse}; +/// +/// let track = parse("Sub Focus - Out the Blue ft. Alice Gold"); +/// assert_eq!(format_track(&track), "Sub Focus - Out the Blue (ft. Alice Gold)"); +/// ``` +pub fn format_track(track: &ParsedTrack) -> String { + format_track_with(track, &FormatOptions::default()) +} + +/// Render a parsed track back to a string (R11). +/// +/// ``` +/// use trackparse::{format_track_with, parse, FeatPlacement, FormatOptions}; +/// +/// let track = parse("Sub Focus - Out the Blue ft. Alice Gold"); +/// let options = FormatOptions::new().feat(FeatPlacement::Artist); +/// assert_eq!(format_track_with(&track, &options), "Sub Focus ft. Alice Gold - Out the Blue"); +/// ``` +pub fn format_track_with(track: &ParsedTrack, options: &FormatOptions) -> String { + let input = format::FormatInput { + artists: &track.artists, + title: &track.title, + versions: track.versions.iter().map(|v| (v.raw.as_str(), v.delimiter)).collect(), + position_raw: track.position.as_ref().map(|p| p.raw.as_str()), + }; + format::format(&input, &ResolvedFormat::from_typed(options)) +} + +/// Normalize a track string (R1): NFC, ASCII brackets, quotes and dashes, invisible characters +/// removed, whitespace collapsed. Idempotent. +/// +/// ``` +/// assert_eq!(trackparse::normalize(" Noisia – Stigma\u{200b} "), "Noisia - Stigma"); +/// ``` +pub fn normalize(input: &str) -> String { + normalize::normalize(input) +} + +/// All credited names: the track's artists plus every version's remixers, deduped (R0.4 key). +/// +/// ``` +/// let track = trackparse::parse("Fox Stevenson - Bruises (Magnetude Remix)"); +/// let names: Vec = trackparse::all_artists(&track).into_iter().map(|a| a.name).collect(); +/// assert_eq!(names, ["Fox Stevenson", "Magnetude"]); +/// ``` +pub fn all_artists(track: &ParsedTrack) -> Vec { + format::all_artists( + track.artists.iter().chain(track.versions.iter().flat_map(|v| v.artists.iter())), + ) +} + +/// A parser with its options resolved and its vocabulary tables built once (`createParser` in +/// JavaScript, `create_parser` in Python). Use it to parse many strings with the same options. +/// It is `Send + Sync`, and cloning it is cheap (the tables are shared). +/// +/// ``` +/// use trackparse::{ParseOptions, Parser}; +/// +/// let parser = Parser::new(&ParseOptions::new().known_artists(["Chase & Status"])); +/// let track = parser.parse("Chase & Status - Blind Faith"); +/// assert_eq!(track.artists.len(), 1); +/// assert_eq!(track.artists[0].name, "Chase & Status"); +/// ``` +#[derive(Clone)] +pub struct Parser { + engine: Engine, +} + +impl Parser { + /// Resolve `options` and build the vocabulary tables. + pub fn new(options: &ParseOptions) -> Parser { + Parser { engine: Engine::new(Resolved::from_typed(options)) } + } + + /// [`parse`] with this parser's options. + pub fn parse(&self, input: &str) -> ParsedTrack { + self.engine.run(input, false).into_track() + } + + /// [`parse_artists`] with this parser's options. + /// + /// ``` + /// use trackparse::{ParseOptions, Parser, SplitAnd}; + /// + /// let parser = Parser::new(&ParseOptions::new().split_and(SplitAnd::Always)); + /// assert_eq!(parser.parse_artists("Above and Beyond").len(), 2); + /// ``` + pub fn parse_artists(&self, input: &str) -> Vec { + self.engine.run_artists(input) + } +} + +impl Default for Parser { + fn default() -> Self { + Parser::new(&ParseOptions::default()) + } +} + +impl std::fmt::Debug for Parser { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Parser").finish_non_exhaustive() + } +} diff --git a/rust/src/mode.rs b/rust/src/mode.rs new file mode 100644 index 0000000..7760405 --- /dev/null +++ b/rust/src/mode.rs @@ -0,0 +1,245 @@ +//! R2: mode resolution, platform suffixes, filename handling and youtube pipes. + +use crate::classify::junk_kind_of; +use crate::context::{warn, Ctx}; +use crate::options::Requested; +use crate::scanner::{ + groups_of, has_spaced_dash, render_skel, scan, slice_skel, start_pos, Segment, Skel, +}; +use crate::types::{Mode, Warning}; +use crate::words::{ + ascii_lower, at, before, chars, collapse_spaces, js_trim_chars, span_texts, split_words, + string, sub, tail, utf16_off, word_spans, +}; + +#[derive(Debug, Clone)] +pub(crate) struct PositionedJunk { + pub raw: String, + /// A junk kind name; `keywords.junk` values pass through as given. + pub kind: String, + pub pos: i64, +} + +/// A contiguous piece of the normalized string and its absolute offset. +#[derive(Debug, Clone)] +pub(crate) struct Piece { + pub text: Vec, + pub base: i64, +} + +pub(crate) struct Prelude { + pub mode: Mode, + /// The working string (R2.4 step 2/4), or the artist piece in the `artist | title` case. + pub working: Piece, + /// R2.4 step 3: the title piece when two dash-less pipe segments remain. + pub pipe_title: Option, + pub junk: Vec, +} + +fn ascii_lower_chars(t: &[char]) -> Vec { + t.iter().map(|c| c.to_ascii_lowercase()).collect() +} + +/// R2.2: strip trailing platform suffixes (longest first, repeatedly). +fn strip_platform_suffixes(s: &[char], ctx: &Ctx<'_>, junk: &mut Vec) -> Vec { + let mut text = s.to_vec(); + let mut stripped = true; + while stripped { + stripped = false; + let lower = ascii_lower_chars(&text); + for suffix in &ctx.t.platform_suffixes { + let suffix_lower = chars(&ascii_lower(suffix)); + if !lower.ends_with(&suffix_lower) { + continue; + } + let start = text.len() - suffix_lower.len().min(text.len()); + junk.push(PositionedJunk { + raw: string(tail(&text, start + 3)), + kind: "platform".to_string(), + pos: utf16_off(sub(&text, 0, start)) + 3, + }); + text.truncate(start); + stripped = true; + break; + } + } + text +} + +fn last_dot(s: &[char]) -> Option { + s.iter().rposition(|&c| c == '.') +} + +fn has_extension(s: &[char], ctx: &Ctx<'_>) -> bool { + last_dot(s).is_some_and(|dot| { + let ext = ascii_lower(&string(tail(s, dot + 1))); + ctx.t.extensions.contains(ext.as_str()) + }) +} + +/// Top-level ` | ` / ` || ` separators on a skeleton → trimmed segment ranges. +pub(crate) fn split_pipes(skel: &Skel) -> Vec { + let t = &skel.text; + let mut cuts: Vec<(usize, usize)> = Vec::new(); + let mut i = 1; + while i < t.len() { + if before(t, i) == Some(' ') && at(t, i) == Some('|') { + let bars = if at(t, i + 1) == Some('|') { 2 } else { 1 }; + if at(t, i + bars) == Some(' ') { + cuts.push((i - 1, i + bars + 1)); + i += bars; + } + } + i += 1; + } + cuts.push((t.len(), t.len())); + let mut segments = Vec::with_capacity(cuts.len()); + let mut start = 0usize; + for (a, b) in cuts { + let mut s = start; + let mut e = a; + while s < e && at(t, s) == Some(' ') { + s += 1; + } + while e > s && before(t, e) == Some(' ') { + e -= 1; + } + segments.push(Segment { skel: slice_skel(skel, s, e), start: s, end: e }); + start = b; + } + segments +} + +/// R8.4 test: the skeleton ends with an unbracketed junk phrase (genres excluded). Returns the +/// code-point index where the phrase starts, and its kind. +pub(crate) fn trailing_junk_phrase(text: &[char], ctx: &Ctx<'_>) -> Option<(usize, String)> { + let spans = word_spans(text); + let words = span_texts(&spans); + let m = ctx.t.junk_phrases.match_ending(&words, spans.len())?; + let first = spans.get(spans.len().checked_sub(m.length)?)?; + Some((first.start, m.value.clone())) +} + +fn junk_text_kind(text: &str, ctx: &Ctx<'_>) -> Option { + let words = split_words(text); + if words.is_empty() { + None + } else { + junk_kind_of(&words, ctx) + } +} + +/// R2.1 youtube signals (besides platform suffixes). +fn looks_like_youtube(skel: &Skel, ctx: &Ctx<'_>) -> bool { + if split_pipes(skel).len() > 1 { + return true; + } + for (_, group) in groups_of(skel) { + if junk_text_kind(&group.inner, ctx).is_some_and(|kind| kind != "genre") { + return true; + } + } + trailing_junk_phrase(&skel.text, ctx).is_some() +} + +pub(crate) fn prelude(normalized: &str, requested: Requested, ctx: &mut Ctx<'_>) -> Prelude { + let mut junk: Vec = Vec::new(); + let mut text = strip_platform_suffixes(&chars(normalized), ctx, &mut junk); + let had_platform = !junk.is_empty(); + + let mut mode = match requested { + Requested::Mode(m) => m, // R13.6: tracklist is explicit only; R2.3/R2.4 do not run. + _ if has_extension(&text, ctx) => Mode::Filename, + _ => Mode::Clean, + }; + + if mode == Mode::Filename { + // R2.3: strip the extension, trim, then `_` → space when there is no space. + if has_extension(&text, ctx) { + text.truncate(last_dot(&text).unwrap_or(text.len())); + } + text = js_trim_chars(&text).to_vec(); + if !text.contains(&' ') && text.contains(&'_') { + let spaced: Vec = text.iter().map(|&c| if c == '_' { ' ' } else { c }).collect(); + text = js_trim_chars(&spaced).to_vec(); + } + } + + let (skel, unbalanced) = scan(&text, 0); + if unbalanced { + warn(ctx, Warning::UnbalancedBrackets); + } + if requested == Requested::Auto + && mode == Mode::Clean + && (had_platform || looks_like_youtube(&skel, ctx)) + { + mode = Mode::Youtube; + } + + if mode != Mode::Youtube { + return Prelude { mode, working: Piece { text, base: 0 }, pipe_title: None, junk }; + } + let (working, pipe_title) = split_youtube_pipes(&skel, ctx, &mut junk); + Prelude { mode, working, pipe_title, junk } +} + +fn piece_of(seg: &Segment) -> Piece { + Piece { text: chars(&render_skel(&seg.skel)), base: start_pos(&seg.skel, 0) } +} + +/// R2.4 +fn split_youtube_pipes( + skel: &Skel, + ctx: &mut Ctx<'_>, + junk: &mut Vec, +) -> (Piece, Option) { + let segments = split_pipes(skel); + if segments.len() <= 1 { + return (Piece { text: chars(&render_skel(skel)), base: 0 }, None); + } + + let mut remaining: Vec<&Segment> = Vec::new(); + for seg in &segments { + let text = collapse_spaces(&render_skel(&seg.skel)); + // R2.4 step 1: a segment with a spaced dash is an artist/title candidate, never junk. + let kind = if has_spaced_dash(&seg.skel.text) { None } else { junk_text_kind(&text, ctx) }; + match kind { + Some(kind) if !kind.is_empty() => { + junk.push(PositionedJunk { raw: text, kind, pos: start_pos(&seg.skel, 0) }); + } + _ if !text.is_empty() => remaining.push(seg), + _ => {} + } + } + let push_other = |keep: usize, junk: &mut Vec| { + for (i, seg) in remaining.iter().enumerate() { + if i == keep { + continue; + } + junk.push(PositionedJunk { + raw: collapse_spaces(&render_skel(&seg.skel)), + kind: "other".to_string(), + pos: start_pos(&seg.skel, 0), + }); + } + }; + + if let Some(i) = remaining.iter().position(|seg| has_spaced_dash(&seg.skel.text)) { + push_other(i, junk); + return (remaining.get(i).map_or_else(empty_piece, |s| piece_of(s)), None); + } + if let [first, second] = remaining.as_slice() { + warn(ctx, Warning::AmbiguousSeparator); + return (piece_of(first), Some(piece_of(second))); + } + if let Some(first) = remaining.first() { + push_other(0, junk); + return (piece_of(first), None); + } + // Every segment was junk: nothing left to parse. + (empty_piece(), None) +} + +fn empty_piece() -> Piece { + Piece { text: Vec::new(), base: 0 } +} diff --git a/rust/src/normalize.rs b/rust/src/normalize.rs new file mode 100644 index 0000000..8bfe9fb --- /dev/null +++ b/rust/src/normalize.rs @@ -0,0 +1,75 @@ +//! R1: normalization. + +use unicode_normalization::UnicodeNormalization; + +use crate::words::{at, before, is_ws}; + +/// R1.2 invisible characters removed outright. ZWNJ/ZWJ (U+200C/U+200D) are kept (ZWJ emoji). +/// U+E000 is reserved as the R3.4 group placeholder, so it can never occur in input. +fn is_removed(cp: u32) -> bool { + matches!(cp, 0x200b | 0x2060 | 0xfeff | 0x00ad | 0xe000) +} + +/// R1.3 brackets, R1.4 quotes, R1.5 dashes → ASCII. `None` for a removed character. +fn map_char(ch: char) -> Option { + let cp = ch as u32; + if is_removed(cp) { + return None; + } + if (0x2010..=0x2015).contains(&cp) { + return Some('-'); // R1.5 + } + Some(match cp { + 0xff08 => '(', + 0xff09 => ')', + 0xff3b | 0x3010 | 0x3014 => '[', + 0xff3d | 0x3011 | 0x3015 => ']', + 0xff5b => '{', + 0xff5d => '}', + 0x201c | 0x201d | 0x201e | 0x00ab | 0x00bb | 0x300c | 0x300d | 0x300e | 0x300f | 0xff02 => { + '"' + } + 0x2018 | 0x2019 | 0x201a | 0x0060 | 0x00b4 => '\'', + 0x2212 | 0xfe58 | 0xfe63 | 0xff0d => '-', + _ => ch, + }) +} + +/// R1.5 (second half): a run of 2+ `-` with whitespace on both sides becomes one `-`. +fn collapse_spaced_dash_runs(chars: &[char]) -> Vec { + let mut out = Vec::with_capacity(chars.len()); + let mut i = 0; + while let Some(ch) = at(chars, i) { + if ch != '-' { + out.push(ch); + i += 1; + continue; + } + let mut j = i; + while at(chars, j) == Some('-') { + j += 1; + } + let spaced = + j - i >= 2 && before(chars, i).is_some_and(is_ws) && at(chars, j).is_some_and(is_ws); + if spaced { + out.push('-'); + } else { + out.extend(std::iter::repeat('-').take(j - i)); + } + i = j; + } + out +} + +/// R1.6: every whitespace code point → one space, runs collapsed, trimmed. +fn collapse_whitespace(chars: &[char]) -> String { + crate::words::collapse_chars(chars) +} + +/// R1: normalize a track string. Idempotent. +pub(crate) fn normalize(input: &str) -> String { + let chars: Vec = input.nfc().filter_map(map_char).collect(); + // R1.8: removing invisibles can leave a decomposed sequence behind; re-compose so that + // normalize() stays idempotent. + collapse_whitespace(&collapse_spaced_dash_runs(&chars)).nfc().collect() +} diff --git a/rust/src/options.rs b/rust/src/options.rs new file mode 100644 index 0000000..a36b201 --- /dev/null +++ b/rust/src/options.rs @@ -0,0 +1,660 @@ +//! R12 options: the typed public options and the resolved form the pipeline reads. +//! +//! Two doors lead to the resolved form: the typed structs below, and loose JSON (`wire`), which +//! is resolved with exactly the fallbacks of the JS reference (a bad value means the default, +//! R0.8). + +use crate::json::Json; +use crate::types::{string_enum, JunkKind, Mode, VersionType}; + +string_enum! { + /// The mode to parse in (R2). `Auto` picks clean, youtube or filename from the string + /// itself, never tracklist. + /// + /// ``` + /// use trackparse::{parse_with, Mode, ModeOption, ParseOptions}; + /// + /// let input = "Noisia - Stigma (Official Video)"; + /// assert_eq!(parse_with(input, &ParseOptions::new()).mode, Mode::Youtube); + /// let clean = ParseOptions::new().mode(ModeOption::Clean); + /// assert_eq!(parse_with(input, &clean).mode, Mode::Clean); + /// assert_eq!(ModeOption::default(), ModeOption::Auto); + /// ``` + #[non_exhaustive] + ModeOption { + Auto => "auto", Clean => "clean", Youtube => "youtube", Filename => "filename", + Tracklist => "tracklist", + } +} + +string_enum! { + /// When the word `and` splits a credit list (R7.3). `&` and the other joiners always split. + /// + /// ``` + /// use trackparse::{parse_artists_with, ParseOptions, SplitAnd}; + /// + /// let count = |split_and| { + /// let options = ParseOptions::new().split_and(split_and); + /// parse_artists_with("Above and Beyond", &options).len() + /// }; + /// assert_eq!(count(SplitAnd::Auto), 1); + /// assert_eq!(count(SplitAnd::Always), 2); + /// assert_eq!(count(SplitAnd::Never), 1); + /// ``` + #[non_exhaustive] + SplitAnd { Auto => "auto", Always => "always", Never => "never" } +} + +string_enum! { + /// Where [`format_track_with`](crate::format_track_with) writes featured artists (R11.2). + /// + /// ``` + /// use trackparse::{format_track_with, parse, FeatPlacement, FormatOptions}; + /// + /// let track = parse("Sub Focus - Out the Blue ft. Alice Gold"); + /// let with = |feat| format_track_with(&track, &FormatOptions::new().feat(feat)); + /// assert_eq!(with(FeatPlacement::Source), "Sub Focus - Out the Blue (ft. Alice Gold)"); + /// assert_eq!(with(FeatPlacement::Artist), "Sub Focus ft. Alice Gold - Out the Blue"); + /// assert_eq!(with(FeatPlacement::Title), "Sub Focus - Out the Blue (ft. Alice Gold)"); + /// assert_eq!(with(FeatPlacement::Omit), "Sub Focus - Out the Blue"); + /// ``` + #[non_exhaustive] + FeatPlacement { Source => "source", Artist => "artist", Title => "title", Omit => "omit" } +} + +string_enum! { + /// Joiners as written, or mapped to their canonical form (R11.5). + /// + /// ``` + /// use trackparse::{format_track_with, parse, FormatOptions, JoinerStyle}; + /// + /// let track = parse("Noisia & The Upbeats ft Tasha Baxter - Dead Limit"); +/// assert_eq!(format_track_with(&track, &FormatOptions::new()), track.input); + /// let options = FormatOptions::new().joiners(JoinerStyle::Canonical); + /// assert_eq!( + /// format_track_with(&track, &options), + /// "Noisia & The Upbeats feat. Tasha Baxter - Dead Limit" + /// ); + /// ``` + #[non_exhaustive] + JoinerStyle { Original => "original", Canonical => "canonical" } +} + +string_enum! { + /// Whether [`format_track_with`](crate::format_track_with) writes the versions (R11.3). + /// + /// ``` + /// use trackparse::{format_track_with, parse, FormatOptions, VersionsOption}; + /// + /// let track = parse("Fox Stevenson - Bruises (Magnetude Remix)"); + /// let options = FormatOptions::new().versions(VersionsOption::None); + /// assert_eq!(format_track_with(&track, &options), "Fox Stevenson - Bruises"); + /// ``` + #[non_exhaustive] + VersionsOption { All => "all", None => "none" } +} + +#[allow(clippy::derivable_impls)] // the enum comes from a macro +impl Default for ModeOption { + fn default() -> Self { + ModeOption::Auto + } +} + +#[allow(clippy::derivable_impls)] // the enum comes from a macro +impl Default for SplitAnd { + fn default() -> Self { + SplitAnd::Auto + } +} + +#[allow(clippy::derivable_impls)] // the enum comes from a macro +impl Default for FeatPlacement { + fn default() -> Self { + FeatPlacement::Source + } +} + +#[allow(clippy::derivable_impls)] // the enum comes from a macro +impl Default for JoinerStyle { + fn default() -> Self { + JoinerStyle::Original + } +} + +#[allow(clippy::derivable_impls)] // the enum comes from a macro +impl Default for VersionsOption { + fn default() -> Self { + VersionsOption::All + } +} + +/// Extra vocabulary, added to the built-in word lists (R12). Keys are matched with ASCII +/// lowercasing. +/// +/// ``` +/// use trackparse::{parse_with, JunkKind, KeywordOptions, ParseOptions, VersionType}; +/// +/// let keywords = KeywordOptions::new() +/// .version_head("rerub", VersionType::Remix) +/// .junk("out now", JunkKind::Promo); +/// let options = ParseOptions::new().keywords(keywords); +/// let track = parse_with("Noisia - Stigma (Phace Rerub) [Out Now]", &options); +/// assert_eq!(track.versions[0].version_type, VersionType::Remix); +/// assert_eq!(track.versions[0].artists[0].name, "Phace"); +/// assert_eq!(track.junk[0].kind, JunkKind::Promo); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(default, rename_all = "camelCase"))] +#[non_exhaustive] +pub struct KeywordOptions { + /// Extra version heads: word and the version type it means. A JSON object (`versionHeads`). + #[cfg_attr(feature = "serde", serde(with = "crate::serde_support::pairs"))] + pub version_heads: Vec<(String, VersionType)>, + /// Extra descriptor words (`Extended`, `Deluxe`). + pub descriptors: Vec, + /// Extra genre names. + pub genres: Vec, + /// Extra junk phrases: phrase and its kind. A JSON object. + #[cfg_attr(feature = "serde", serde(with = "crate::serde_support::pairs"))] + pub junk: Vec<(String, JunkKind)>, + /// Extra markers that introduce featured artists (`featMarkers` in JSON). + pub feat_markers: Vec, +} + +impl KeywordOptions { + /// No extra words. + pub fn new() -> Self { + Self::default() + } + + /// Add a version head (`"rerub"` means [`VersionType::Remix`]). + pub fn version_head(mut self, key: impl Into, version_type: VersionType) -> Self { + self.version_heads.push((key.into(), version_type)); + self + } + + /// Add a descriptor word. + pub fn descriptor(mut self, word: impl Into) -> Self { + self.descriptors.push(word.into()); + self + } + + /// Add a genre name. + pub fn genre(mut self, word: impl Into) -> Self { + self.genres.push(word.into()); + self + } + + /// Add a junk phrase (`"free download"` is [`JunkKind::Promo`]). + pub fn junk(mut self, phrase: impl Into, kind: JunkKind) -> Self { + self.junk.push((phrase.into(), kind)); + self + } + + /// Add a marker that introduces featured artists. + pub fn feat_marker(mut self, marker: impl Into) -> Self { + self.feat_markers.push(marker.into()); + self + } +} + +/// Options of [`parse_with`](crate::parse_with), [`parse_artists_with`](crate::parse_artists_with) +/// and [`Parser`](crate::Parser) (R12). The default is what [`parse`](crate::parse) uses. +/// +/// Build one with the chained setters, or set the public fields on a default value. +/// +/// ``` +/// use trackparse::{parse_with, ModeOption, ParseOptions, SplitAnd}; +/// +/// let options = ParseOptions::new() +/// .mode(ModeOption::Youtube) +/// .uploader("Noisia") +/// .known_artists(["Chase & Status"]) +/// .split_and(SplitAnd::Never); +/// let track = parse_with("Stigma (Official Video)", &options); +/// assert_eq!(track.artists[0].name, "Noisia"); +/// assert_eq!(track.title, "Stigma"); +/// +/// let mut same = ParseOptions::default(); +/// same.mode = ModeOption::Youtube; +/// same.uploader = Some("Noisia".into()); +/// same.known_artists = vec!["Chase & Status".into()]; +/// same.split_and = SplitAnd::Never; +/// assert_eq!(same, options); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(default, rename_all = "camelCase"))] +#[non_exhaustive] +pub struct ParseOptions { + /// The mode; default [`ModeOption::Auto`]. + pub mode: ModeOption, + /// youtube mode: the channel name, used as the artist when the title has no separator + /// (R6.8). + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] + pub uploader: Option, + /// Names that must never be split (R7.3a): `Chase & Status`, `Above & Beyond`. + pub known_artists: Vec, + /// When `and` splits a credit list; default [`SplitAnd::Auto`]. + pub split_and: SplitAnd, + /// Extra vocabulary. + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] + pub keywords: Option, +} + +impl ParseOptions { + /// The default options. + pub fn new() -> Self { + Self::default() + } + + /// Set the mode. + pub fn mode(mut self, mode: ModeOption) -> Self { + self.mode = mode; + self + } + + /// Set the uploader (the channel name, for youtube mode). + pub fn uploader(mut self, uploader: impl Into) -> Self { + self.uploader = Some(uploader.into()); + self + } + + /// Set the names that must never be split. + pub fn known_artists(mut self, names: I) -> Self + where + I: IntoIterator, + S: Into, + { + self.known_artists = names.into_iter().map(Into::into).collect(); + self + } + + /// Set when `and` splits a credit list. + pub fn split_and(mut self, split_and: SplitAnd) -> Self { + self.split_and = split_and; + self + } + + /// Set the extra vocabulary. + pub fn keywords(mut self, keywords: KeywordOptions) -> Self { + self.keywords = Some(keywords); + self + } +} + +/// Options of [`format_track_with`](crate::format_track_with) (R11). +/// +/// ``` +/// use trackparse::{format_track_with, parse, FeatPlacement, FormatOptions}; +/// +/// let track = parse("03. Sub Focus - Out the Blue ft. Alice Gold (Wilkinson Remix)"); +/// let options = FormatOptions::new() +/// .feat(FeatPlacement::Artist) +/// .feat_marker("feat.") +/// .position(true); +/// assert_eq!( +/// format_track_with(&track, &options), +/// "03. Sub Focus feat. Alice Gold - Out the Blue (Wilkinson Remix)" +/// ); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(default, rename_all = "camelCase"))] +#[non_exhaustive] +pub struct FormatOptions { + /// Where featured artists go; default [`FeatPlacement::Source`] (where they were found). + pub feat: FeatPlacement, + /// Marker written in front of featured lists instead of the one in the input. + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] + pub feat_marker: Option, + /// Joiners as written or canonical; default [`JoinerStyle::Original`]. + pub joiners: JoinerStyle, + /// Write the versions or not; default [`VersionsOption::All`]. + pub versions: VersionsOption, + /// Write `prod.` credits; default `true`. + pub producers: bool, + /// Write the position in front; default `false`. + pub position: bool, +} + +impl Default for FormatOptions { + fn default() -> Self { + FormatOptions { + feat: FeatPlacement::Source, + feat_marker: None, + joiners: JoinerStyle::Original, + versions: VersionsOption::All, + producers: true, + position: false, + } + } +} + +impl FormatOptions { + /// The default options. + pub fn new() -> Self { + Self::default() + } + + /// Set where featured artists go. + pub fn feat(mut self, feat: FeatPlacement) -> Self { + self.feat = feat; + self + } + + /// Set the marker written in front of featured lists. + pub fn feat_marker(mut self, marker: impl Into) -> Self { + self.feat_marker = Some(marker.into()); + self + } + + /// Set the joiner style. + pub fn joiners(mut self, joiners: JoinerStyle) -> Self { + self.joiners = joiners; + self + } + + /// Set whether versions are written. + pub fn versions(mut self, versions: VersionsOption) -> Self { + self.versions = versions; + self + } + + /// Set whether `prod.` credits are written. + pub fn producers(mut self, producers: bool) -> Self { + self.producers = producers; + self + } + + /// Set whether the position is written in front. + pub fn position(mut self, position: bool) -> Self { + self.position = position; + self + } +} + +// --------------------------------------------------------------------------- +// Resolved forms + +/// `options.mode` as the pipeline sees it. `Other` is any value that is neither missing nor one +/// of the five names: JS then skips the R2.1 youtube detection but still detects filenames. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum Requested { + Auto, + Mode(Mode), + Other, +} + +/// `options.splitAnd`: anything but `auto` / `never` (or missing) behaves as `always` in JS. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum SplitAndMode { + Auto, + Always, + Never, +} + +/// `options.keywords` with the maps in JS `Object.entries` order. Types and kinds stay strings: +/// JS passes any string value through to the output. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub(crate) struct Keywords { + pub version_heads: Vec<(String, String)>, + pub descriptors: Vec, + pub genres: Vec, + pub junk: Vec<(String, String)>, + pub feat_markers: Vec, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) struct Resolved { + pub mode: Requested, + pub uploader: Option, + pub known_artists: Vec, + pub split_and: SplitAndMode, + /// `None`: the default tables. + pub keywords: Option, +} + +impl Default for Resolved { + fn default() -> Self { + Resolved { + mode: Requested::Auto, + uploader: None, + known_artists: Vec::new(), + split_and: SplitAndMode::Auto, + keywords: None, + } + } +} + +/// A canonical array index (`"0"`, `"17"`; not `"01"`): JS lists such keys first, ascending. +fn array_index(key: &str) -> Option { + if key.is_empty() || key.len() > 10 || !key.bytes().all(|b| b.is_ascii_digit()) { + return None; + } + if key.len() > 1 && key.starts_with('0') { + return None; + } + key.parse::().ok().filter(|n| *n <= 0xffff_fffe) +} + +/// `Object.entries` order of an object built from `pairs`: a repeated key keeps its first place +/// and takes the last value; integer-like keys come first in ascending order, then the others in +/// insertion order. +pub(crate) fn js_entries(pairs: &[(String, V)]) -> Vec<(String, V)> { + let mut unique: Vec<(String, V)> = Vec::with_capacity(pairs.len()); + let mut index: std::collections::HashMap<&str, usize> = std::collections::HashMap::new(); + for (k, v) in pairs { + match index.get(k.as_str()).and_then(|&i| unique.get_mut(i)) { + Some(slot) => slot.1 = v.clone(), + None => { + index.insert(k.as_str(), unique.len()); + unique.push((k.clone(), v.clone())); + } + } + } + let mut ints: Vec<(u64, (String, V))> = Vec::new(); + let mut rest: Vec<(String, V)> = Vec::new(); + for pair in unique { + match array_index(&pair.0) { + Some(n) => ints.push((n, pair)), + None => rest.push(pair), + } + } + ints.sort_by_key(|(n, _)| *n); + ints.into_iter().map(|(_, p)| p).chain(rest).collect() +} + +/// R0.8: option lists may be anything at runtime; only arrays of strings count. +pub(crate) fn string_list(value: Option<&Json>) -> Vec { + match value { + Some(Json::Arr(items)) => { + items.iter().filter_map(|v| v.as_str().map(str::to_string)).collect() + } + _ => Vec::new(), + } +} + +/// R0.8: option maps may be anything at runtime; only plain objects' string values count. +pub(crate) fn string_entries(value: Option<&Json>) -> Vec<(String, String)> { + match value { + Some(Json::Obj(entries)) => js_entries(entries) + .into_iter() + .filter_map(|(k, v)| v.as_str().map(|s| (k, s.to_string()))) + .collect(), + _ => Vec::new(), + } +} + +impl Keywords { + fn from_json(value: &Json) -> Keywords { + Keywords { + version_heads: string_entries(value.get("versionHeads")), + descriptors: string_list(value.get("descriptors")), + genres: string_list(value.get("genres")), + junk: string_entries(value.get("junk")), + feat_markers: string_list(value.get("featMarkers")), + } + } + + fn from_typed(k: &KeywordOptions) -> Keywords { + let heads: Vec<(String, String)> = + k.version_heads.iter().map(|(key, t)| (key.clone(), t.as_str().to_string())).collect(); + let junk: Vec<(String, String)> = + k.junk.iter().map(|(key, kind)| (key.clone(), kind.as_str().to_string())).collect(); + Keywords { + version_heads: js_entries(&heads), + descriptors: k.descriptors.clone(), + genres: k.genres.clone(), + junk: js_entries(&junk), + feat_markers: k.feat_markers.clone(), + } + } +} + +impl Resolved { + /// Loose JSON options, with the JS fallbacks. + pub(crate) fn from_json(options: &Json) -> Resolved { + if options.as_object().is_none() { + return Resolved::default(); // safeOptions: not an object + } + let mode = match options.get("mode") { + None | Some(Json::Null) => Requested::Auto, // `options.mode ?? "auto"` + Some(Json::Str(s)) if s == "auto" => Requested::Auto, + Some(Json::Str(s)) => Mode::from_name(s).map_or(Requested::Other, Requested::Mode), + Some(_) => Requested::Other, + }; + let split_and = match options.get("splitAnd") { + None | Some(Json::Null) => SplitAndMode::Auto, // `options?.splitAnd ?? "auto"` + Some(Json::Str(s)) if s == "auto" => SplitAndMode::Auto, + Some(Json::Str(s)) if s == "never" => SplitAndMode::Never, + Some(_) => SplitAndMode::Always, + }; + // `options?.keywords ? … : baseTables`, then `isRecord`: only a plain object adds words. + let keywords = match options.get("keywords") { + Some(k @ Json::Obj(_)) => Some(Keywords::from_json(k)), + _ => None, + }; + Resolved { + mode, + uploader: options.get("uploader").and_then(Json::as_str).map(str::to_string), + known_artists: string_list(options.get("knownArtists")), + split_and, + keywords, + } + } + + pub(crate) fn from_typed(options: &ParseOptions) -> Resolved { + Resolved { + mode: match options.mode { + ModeOption::Auto => Requested::Auto, + ModeOption::Clean => Requested::Mode(Mode::Clean), + ModeOption::Youtube => Requested::Mode(Mode::Youtube), + ModeOption::Filename => Requested::Mode(Mode::Filename), + ModeOption::Tracklist => Requested::Mode(Mode::Tracklist), + }, + uploader: options.uploader.clone(), + known_artists: options.known_artists.clone(), + split_and: match options.split_and { + SplitAnd::Auto => SplitAndMode::Auto, + SplitAnd::Always => SplitAndMode::Always, + SplitAnd::Never => SplitAndMode::Never, + }, + keywords: options.keywords.as_ref().map(Keywords::from_typed), + } + } +} + +/// `options.feat` as R11 reads it: an unknown value places featured artists nowhere. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum FeatMode { + Source, + Artist, + Title, + Omit, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) struct ResolvedFormat { + pub feat: FeatMode, + pub feat_marker: Option, + pub canonical: bool, + pub versions: bool, + pub producers: bool, + pub position: bool, +} + +/// JS truthiness of a JSON value. +fn truthy(v: &Json) -> bool { + match v { + Json::Null => false, + Json::Bool(b) => *b, + Json::Num(n) => *n != 0.0 && !n.is_nan(), + Json::Str(s) => !s.is_empty(), + Json::Arr(_) | Json::Obj(_) => true, + } +} + +/// JS `String(value)` (what a template literal does with a non-string `featMarker`). +fn js_string(v: &Json) -> String { + match v { + Json::Null => "null".to_string(), + Json::Bool(b) => b.to_string(), + Json::Num(n) if n.is_nan() => "NaN".to_string(), + Json::Num(n) if n.is_infinite() => { + (if *n > 0.0 { "Infinity" } else { "-Infinity" }).to_string() + } + Json::Num(_) => v.write(), + Json::Str(s) => s.clone(), + // Array.prototype.join: null elements are empty. + Json::Arr(items) => items + .iter() + .map(|i| if matches!(i, Json::Null) { String::new() } else { js_string(i) }) + .collect::>() + .join(","), + Json::Obj(_) => "[object Object]".to_string(), + } +} + +impl ResolvedFormat { + /// Loose JSON format options, with the JS fallbacks (`??` for missing and `null`). + pub(crate) fn from_json(o: &Json) -> ResolvedFormat { + let get = |key: &str| match o.get(key) { + Some(Json::Null) | None => None, + Some(v) => Some(v), + }; + ResolvedFormat { + feat: match get("feat") { + None => FeatMode::Source, + Some(Json::Str(s)) if s == "source" => FeatMode::Source, + Some(Json::Str(s)) if s == "artist" => FeatMode::Artist, + Some(Json::Str(s)) if s == "title" => FeatMode::Title, + Some(_) => FeatMode::Omit, + }, + // `o.featMarker !== undefined`: an explicit null is rendered as "null". + feat_marker: o.get("featMarker").map(js_string), + canonical: get("joiners").and_then(Json::as_str) == Some("canonical"), + versions: get("versions").map_or(true, |v| v.as_str() == Some("all")), + producers: get("producers").map_or(true, truthy), + position: get("position").is_some_and(truthy), + } + } + + pub(crate) fn from_typed(o: &FormatOptions) -> ResolvedFormat { + ResolvedFormat { + feat: match o.feat { + FeatPlacement::Source => FeatMode::Source, + FeatPlacement::Artist => FeatMode::Artist, + FeatPlacement::Title => FeatMode::Title, + FeatPlacement::Omit => FeatMode::Omit, + }, + feat_marker: o.feat_marker.clone(), + canonical: o.joiners == JoinerStyle::Canonical, + versions: o.versions == VersionsOption::All, + producers: o.producers, + position: o.position, + } + } +} diff --git a/rust/src/parser.rs b/rust/src/parser.rs new file mode 100644 index 0000000..9761a9e --- /dev/null +++ b/rust/src/parser.rs @@ -0,0 +1,243 @@ +//! Pipeline: R1 → R2 → R4 → R3/R6 → R7 → R8 → R9, plus R10 parse_artists. + +use std::collections::HashSet; +use std::sync::{Arc, OnceLock}; + +use crate::artists::parse_artist_side; +use crate::assemble::{dedup_artists, full_title_of, to_version}; +use crate::context::{known_keys, warn, Ctx}; +use crate::mode::{prelude, Piece, Prelude}; +use crate::normalize::normalize; +use crate::options::Resolved; +use crate::prefix::strip_prefixes; +use crate::scanner::{scan, split_at_spaced_dashes, trim_skel, Skel}; +use crate::separator::{find_separator, SeparatorInput}; +use crate::tables::{tables_for, Tables}; +use crate::title::{add_peeled, parse_title_side, Extracted}; +use crate::types::{Artist, ArtistSource, Flags, Mode, RawJunk, RawTrack, Warning}; +use crate::words::{chars, js_trim_end}; + +/// Offset used for uploader text so it sorts before everything from the input. +const UPLOADER_BASE: i64 = -1_000_000_000; + +fn skel_of(piece: &Piece, ctx: &mut Ctx<'_>) -> Skel { + let (skel, unbalanced) = scan(&piece.text, piece.base); + if unbalanced { + warn(ctx, Warning::UnbalancedBrackets); + } + trim_skel(&skel) +} + +/// R6.8: uploader minus a trailing ` - Topic` and `VEVO`. +fn uploader_skel(uploader: Option<&str>) -> Option { + let mut u = normalize(uploader?); + if let Some(rest) = u.strip_suffix(" - Topic") { + u = rest.to_string(); + } + if let Some(rest) = u.strip_suffix("VEVO") { + u = js_trim_end(rest).to_string(); + } + if u.is_empty() { + return None; + } + Some(scan(&chars(&u), UPLOADER_BASE).0) +} + +/// Resolved options with the tables built once (JS `createParser` / `createListParser`). +#[derive(Clone)] +pub(crate) struct Engine { + options: Resolved, + tables: Arc, + known_keys: HashSet, + known_max_len: usize, +} + +/// The R1, R2 and R4 stage of `run`, kept so the tracklist probe's work is not redone. +struct Staged<'a> { + engine: &'a Engine, + ctx: Ctx<'a>, + pre: Prelude, + track: RawTrack, + /// The skeleton after R4; `None` when the input is empty after R1 (R9.5: `track` is final). + working: Option, +} + +fn by_pos(mut items: Vec, pos: impl Fn(&T) -> i64) -> Vec { + items.sort_by_key(|item| pos(item)); // stable, like the JS sort + items +} + +impl Engine { + pub(crate) fn new(options: Resolved) -> Engine { + let tables = tables_for(options.keywords.as_ref()); + let (known_keys, known_max_len) = known_keys(&options.known_artists); + Engine { options, tables, known_keys, known_max_len } + } + + /// The engine behind `parse` / `parse_artists` without options. + pub(crate) fn shared() -> &'static Engine { + static DEFAULT: OnceLock = OnceLock::new(); + DEFAULT.get_or_init(|| Engine::new(Resolved::default())) + } + + fn ctx(&self) -> Ctx<'_> { + Ctx { + t: &self.tables, + known_keys: &self.known_keys, + known_max_len: self.known_max_len, + split_and: self.options.split_and, + warnings: Vec::new(), + list_seq: 0, + } + } + + fn stage(&self, input: &str) -> Staged<'_> { + let mut ctx = self.ctx(); + let norm = normalize(input); + let pre = prelude(&norm, self.options.mode, &mut ctx); + let mut track = RawTrack::empty(input, pre.mode); + if norm.is_empty() { + return Staged { engine: self, ctx, pre, track, working: None }; // R9.5 + } + + // R4 + let prefix = strip_prefixes(&pre.working.text, pre.working.base, pre.mode, &ctx); + track.timestamp = prefix.timestamp; + track.position = prefix.position; + let working = skel_of(&Piece { text: prefix.rest, base: prefix.base }, &mut ctx); + Staged { engine: self, ctx, pre, track, working: Some(working) } + } + + pub(crate) fn run(&self, input: &str, list_context: bool) -> RawTrack { + finish(self.stage(input), list_context) + } + + /// R10 + pub(crate) fn run_artists(&self, input: &str) -> Vec { + let mut ctx = self.ctx(); + let norm = normalize(input); + if norm.is_empty() { + return Vec::new(); + } + let side = parse_artist_side(&scan(&chars(&norm), 0).0, &mut ctx); + let mut artists = dedup_artists(side.credits); + for a in &mut artists { + a.source = ArtistSource::Artist; + } + artists + } + + /// R1, R2 and R4 only, as `run` does them: no artist/title parsing. `finish` completes the + /// parse from the same stage, so a probed line is not normalized twice. + pub(crate) fn probe(&self, input: &str) -> LineProbe<'_> { + let staged = self.stage(input); + LineProbe { + position: staged.track.position.is_some(), + spaced_dash: staged.pre.pipe_title.is_none() + && staged + .working + .as_ref() + .is_some_and(|w| split_at_spaced_dashes(w, true).len() >= 2), + empty: staged.working.is_none(), + staged, + } + } +} + +/// R6–R9 on a staged input. +fn finish(st: Staged<'_>, list_context: bool) -> RawTrack { + let Staged { engine, mut ctx, pre, mut track, working } = st; + let Some(working) = working else { return track }; + + let mut out = Extracted::default(); + let artist_skel: Option; + let title_skel: Skel; + let relaxed: bool; + if let Some(pipe_title) = &pre.pipe_title { + // R2.4 step 3: `artist | title`, R6 skipped. + title_skel = skel_of(pipe_title, &mut ctx); + artist_skel = (!working.is_empty()).then_some(working); + relaxed = artist_skel.is_some(); + } else { + let sep = find_separator( + SeparatorInput { + skel: &working, + mode: pre.mode, + uploader: uploader_skel(engine.options.uploader.as_deref()), + list_context, + }, + &mut ctx, + ); + add_peeled(&mut out, sep.peeled); + artist_skel = sep.artist; + title_skel = sep.title; + relaxed = sep.split; + } + + let artist_side = + artist_skel.as_ref().map(|s| parse_artist_side(s, &mut ctx)).unwrap_or_default(); + let title_side = + parse_title_side(&title_skel, relaxed, pre.mode == Mode::Youtube, &mut out, &mut ctx); + + // R9 + let versions = by_pos(out.versions, |v| v.pos); + if versions.iter().any(|v| v.ambiguous_mix) { + warn(&mut ctx, Warning::AmbiguousMixCredit); + } + let mut credits = artist_side.credits; + credits.extend(by_pos(out.credits, |c| c.pos)); + track.artists = dedup_artists(credits); + track.title = title_side.title; + track.versions = versions.into_iter().map(to_version).collect(); + track.full_title = full_title_of(&track.title, &track.versions); + // R9.6: the first year in text order. + let mut years = artist_side.years; + years.extend(out.years); + track.year = by_pos(years, |y| y.pos).first().map(|y| y.year); + track.flags = Flags { + explicit: out.explicit || artist_side.explicit, + clean: out.clean || artist_side.clean, + unknown_artist: artist_side.unknown_artist || out.unknown_artist, + unknown_title: title_side.unknown_title, + }; + let mut junk = pre.junk; + junk.extend(artist_side.junk); + junk.extend(out.junk); + track.junk = + by_pos(junk, |j| j.pos).into_iter().map(|j| RawJunk { raw: j.raw, kind: j.kind }).collect(); + track.warnings = ctx.warnings; + track +} + +/// Facts about a line's prefix and separator search, for the tracklist module (R13.4.2, R13.5). +pub(crate) struct LineProbe<'a> { + /// R4.2 took a position. + pub position: bool, + /// The skeleton R6 searches (after R2 and R4) has a spaced dash (R6.1). + pub spaced_dash: bool, + /// The input is empty after R1. + pub empty: bool, + staged: Staged<'a>, +} + +impl LineProbe<'_> { + /// The parse of the probed input (R6–R9 only). + pub(crate) fn finish(self, list_context: bool) -> RawTrack { + finish(self.staged, list_context) + } +} + +/// Internal: parsing hooks for the tracklist module, with the options compiled once. +pub(crate) struct ListParser { + engine: Engine, +} + +impl ListParser { + pub(crate) fn new(options: Resolved) -> ListParser { + ListParser { engine: Engine::new(options) } + } + + pub(crate) fn probe(&self, input: &str) -> LineProbe<'_> { + self.engine.probe(input) + } +} diff --git a/rust/src/prefix.rs b/rust/src/prefix.rs new file mode 100644 index 0000000..db8e608 --- /dev/null +++ b/rust/src/prefix.rs @@ -0,0 +1,146 @@ +//! R4: leading timestamp and track-position prefixes. + +use crate::context::{match_known_at, Ctx}; +use crate::digits::{digit_run, digits_value, two_digits_up_to_59}; +use crate::scanner::{has_spaced_dash, scan}; +use crate::types::{Mode, Position, Timestamp}; +use crate::words::{at, string, sub, tail, utf16_off}; + +pub(crate) struct PrefixResult { + pub rest: Vec, + /// Absolute offset of `rest`. + pub base: i64, + pub timestamp: Option, + pub position: Option, +} + +struct TimeMatch { + raw: String, + seconds: u64, + end: usize, +} + +/// `H:MM:SS`, `HH:MM:SS`, `M:SS`, `MM:SS` starting at `at_`. +fn match_time(s: &[char], at_: usize) -> Option { + let lead = digit_run(s, at_); + if !(1..=2).contains(&lead) || at(s, at_ + lead) != Some(':') { + return None; + } + let first = u64::from(digits_value(sub(s, at_, at_ + lead))); + let mid = u64::from(two_digits_up_to_59(s, at_ + lead + 1)?); + let after_mid = at_ + lead + 3; + if at(s, after_mid) == Some(':') { + if let Some(sec) = two_digits_up_to_59(s, after_mid + 1) { + let end = after_mid + 3; + return Some(TimeMatch { + raw: string(sub(s, at_, end)), + seconds: first * 3600 + mid * 60 + u64::from(sec), + end, + }); + } + } + if lead == 2 && first > 59 { + return None; // MM is 00–59 + } + Some(TimeMatch { + raw: string(sub(s, at_, after_mid)), + seconds: first * 60 + mid, + end: after_mid, + }) +} + +/// After a prefix: skip one space, then an optional `- ` (spaced dash). +fn skip_space_and_dash(s: &[char], at_: usize) -> usize { + let mut i = at_; + if at(s, i) == Some(' ') { + i += 1; + } + if at(s, i) == Some('-') && at(s, i + 1) == Some(' ') { + i += 2; + } + i +} + +/// R4.1 +fn match_timestamp(s: &[char]) -> Option<(Timestamp, usize)> { + let bracket = match at(s, 0) { + Some('[') => Some(']'), + Some('(') => Some(')'), + _ => None, + }; + let t = match_time(s, usize::from(bracket.is_some()))?; + let mut end = t.end; + if bracket.is_some() { + if at(s, end) != bracket { + return None; + } + end += 1; + } + if end < s.len() && at(s, end) != Some(' ') { + return None; + } + Some((Timestamp { raw: t.raw, seconds: t.seconds }, skip_space_and_dash(s, end))) +} + +fn contains_spaced_dash(s: &[char]) -> bool { + has_spaced_dash(&scan(s, 0).0.text) +} + +/// R4.2: end offset of the position prefix, or `None`. Forms are tried (a), (b), (c), (d)/(e). +fn match_position(s: &[char], mode: Mode) -> Option { + let n = digit_run(s, 0); + if !(1..=3).contains(&n) { + return None; + } + let c = at(s, n); + let zero_padded = at(s, 0) == Some('0') && n >= 2; + // (a) `01. `, `1) ` + if (c == Some('.') || c == Some(')')) && (at(s, n + 1) == Some(' ') || n + 1 == s.len()) { + return Some(skip_space_and_dash(s, n + 1)); + } + // (b) `01 `: a position in every mode. + if zero_padded && c == Some(' ') { + return Some(skip_space_and_dash(s, n)); + } + // (c) `3 - Artist - Title`; in filename mode `N - ` is always a position (`311 - Amber.mp3`). + if c == Some(' ') && at(s, n + 1) == Some('-') && at(s, n + 2) == Some(' ') { + if mode == Mode::Filename || contains_spaced_dash(tail(s, n + 3)) { + return Some(n + 3); + } + return None; + } + if mode == Mode::Filename { + // (e) `01-Track`, `03_name`, `01.Track` + if matches!(c, Some('-' | '_' | '.')) && at(s, n + 1).is_some_and(|ch| ch != ' ') { + return Some(n + 1); + } + // (e) `3 My Song.mp3`: only when the remainder has no spaced dash. + if c == Some(' ') && !contains_spaced_dash(tail(s, n + 1)) { + return Some(skip_space_and_dash(s, n)); + } + } + // (d) `2 Unlimited`, `50 Cent`: never a position outside filename mode. + None +} + +pub(crate) fn strip_prefixes(text: &[char], base: i64, mode: Mode, ctx: &Ctx<'_>) -> PrefixResult { + let mut rest: &[char] = text; + let mut offset = base; + let mut timestamp = None; + let mut position = None; + + if let Some((ts, end)) = match_timestamp(rest) { + timestamp = Some(ts); + offset += utf16_off(sub(rest, 0, end)); + rest = tail(rest, end); + } + if match_known_at(rest, 0, ctx, Some('-')) == 0 { + if let Some(end) = match_position(rest, mode).filter(|&end| end < rest.len()) { + let digits = sub(rest, 0, digit_run(rest, 0)); + position = Some(Position { raw: string(digits), number: digits_value(digits) }); + offset += utf16_off(sub(rest, 0, end)); + rest = tail(rest, end); + } + } + PrefixResult { rest: rest.to_vec(), base: offset, timestamp, position } +} diff --git a/rust/src/scanner.rs b/rust/src/scanner.rs new file mode 100644 index 0000000..5a83873 --- /dev/null +++ b/rust/src/scanner.rs @@ -0,0 +1,274 @@ +//! R3: top-level group scanner and skeleton. +//! +//! A `Skel` is a skeleton (code points) plus, for every code point, its absolute offset in the +//! normalized input. Offsets are in UTF-16 units, as in the JS reference, so that every +//! "order of appearance" comparison gives the same answer. Groups are looked up by the offset of +//! their placeholder, so any slice of a skeleton still knows which groups it contains. + +use std::collections::{HashMap, HashSet}; +use std::rc::Rc; + +use crate::types::VersionDelimiter; +use crate::words::{at, before, collapse_chars, is_whitespace, string, sub}; + +/// R3.4 placeholder code point. +pub(crate) const PH: char = '\u{e000}'; + +#[derive(Debug, Clone)] +pub(crate) struct Group { + pub open: VersionDelimiter, + /// R3.5: inner text, trimmed and whitespace-collapsed. + pub inner: String, + /// The group exactly as written, brackets included. + pub raw: String, + /// Absolute offset of the opener. + pub pos: i64, +} + +pub(crate) type Groups = Rc>; + +#[derive(Debug, Clone)] +pub(crate) struct Skel { + pub text: Vec, + pub pos: Vec, + pub groups: Groups, +} + +fn closer_of(ch: char) -> Option { + match ch { + '(' => Some(')'), + '[' => Some(']'), + '{' => Some('}'), + _ => None, + } +} + +fn delimiter_of(ch: Option) -> VersionDelimiter { + match ch { + Some('[') => VersionDelimiter::Square, + Some('{') => VersionDelimiter::Curly, + _ => VersionDelimiter::Paren, + } +} + +/// R3.1–R3.5: scan `s` (whose first unit sits at absolute offset `base`). The second value is +/// "unbalanced" (R3.3). +pub(crate) fn scan(s: &[char], base: i64) -> (Skel, bool) { + // Absolute offset of every code point, plus one entry for the end of the string. + let mut offsets: Vec = Vec::with_capacity(s.len() + 1); + let mut off = base; + for ch in s { + offsets.push(off); + off += ch.len_utf16() as i64; + } + offsets.push(off); + let offset_at = |i: usize| offsets.get(i).copied().unwrap_or(off); + + let mut text: Vec = Vec::with_capacity(s.len()); + let mut pos: Vec = Vec::with_capacity(s.len()); + let mut groups: HashMap = HashMap::new(); + let mut stack: Vec = Vec::new(); + let mut group_start = 0usize; + for (i, &ch) in s.iter().enumerate() { + if stack.is_empty() { + if let Some(closer) = closer_of(ch) { + stack.push(closer); + group_start = i; + } else { + text.push(ch); + pos.push(offset_at(i)); + } + continue; + } + if let Some(closer) = closer_of(ch) { + stack.push(closer); + } else if stack.last() == Some(&ch) { + stack.pop(); + if stack.is_empty() { + add_group(s, group_start, i + 1, true, &offset_at, &mut groups); + text.push(PH); + pos.push(offset_at(group_start)); + } + } + // R3.2: a non-matching closer is literal text inside the group. + } + let unbalanced = !stack.is_empty(); + if unbalanced { + // R3.3: the group runs to the end of the string. + add_group(s, group_start, s.len(), false, &offset_at, &mut groups); + text.push(PH); + pos.push(offset_at(group_start)); + } + (Skel { text, pos, groups: Rc::new(groups) }, unbalanced) +} + +fn add_group( + s: &[char], + start: usize, + end: usize, + closed: bool, + offset_at: &dyn Fn(usize) -> i64, + groups: &mut HashMap, +) { + let inner = sub(s, start + 1, if closed { end.saturating_sub(1) } else { end }); + let pos = offset_at(start); + groups.insert( + pos, + Group { + open: delimiter_of(at(s, start)), + inner: collapse_chars(inner), + raw: string(sub(s, start, end)), + pos, + }, + ); +} + +// --------------------------------------------------------------------------- +// Skeleton operations + +impl Skel { + pub fn len(&self) -> usize { + self.text.len() + } + + pub fn is_empty(&self) -> bool { + self.text.is_empty() + } +} + +pub(crate) fn slice_skel(s: &Skel, start: usize, end: usize) -> Skel { + let a = start.min(s.text.len()); + let b = end.min(s.text.len()).max(a); + Skel { + text: sub(&s.text, a, b).to_vec(), + pos: s.pos.get(a..b.min(s.pos.len())).unwrap_or(&[]).to_vec(), + groups: Rc::clone(&s.groups), + } +} + +/// `slice_skel(s, start)` to the end. +pub(crate) fn slice_from(s: &Skel, start: usize) -> Skel { + slice_skel(s, start, s.text.len()) +} + +pub(crate) fn trim_skel(s: &Skel) -> Skel { + let mut a = 0; + let mut b = s.text.len(); + while a < b && is_whitespace(at(&s.text, a)) { + a += 1; + } + while b > a && is_whitespace(before(&s.text, b)) { + b -= 1; + } + slice_skel(s, a, b) +} + +pub(crate) fn concat_skel(a: &Skel, b: &Skel) -> Skel { + let mut text = a.text.clone(); + text.extend_from_slice(&b.text); + let mut pos = a.pos.clone(); + pos.extend_from_slice(&b.pos); + Skel { text, pos, groups: Rc::clone(&a.groups) } +} + +/// The group behind the placeholder at `index`, if it is one. +pub(crate) fn group_at(s: &Skel, index: usize) -> Option<&Group> { + if at(&s.text, index) != Some(PH) { + return None; + } + s.groups.get(s.pos.get(index)?) +} + +/// Groups in the skeleton, left to right, with their unit index. +pub(crate) fn groups_of(s: &Skel) -> Vec<(usize, &Group)> { + (0..s.text.len()).filter_map(|i| group_at(s, i).map(|g| (i, g))).collect() +} + +pub(crate) fn has_group(s: &Skel) -> bool { + s.text.contains(&PH) +} + +/// Substitute groups back (R3.4 reassembly). Whitespace is not touched. +pub(crate) fn render_skel(s: &Skel) -> String { + let mut out = String::new(); + for (i, &ch) in s.text.iter().enumerate() { + match group_at(s, i) { + Some(g) => out.push_str(&g.raw), + None => out.push(ch), + } + } + out +} + +/// Absolute offset of the first unit (or `fallback` for an empty skeleton). +pub(crate) fn start_pos(s: &Skel, fallback: i64) -> i64 { + s.pos.first().copied().unwrap_or(fallback) +} + +/// Remove the placeholders of the given groups. +pub(crate) fn remove_groups(s: &Skel, remove: &HashSet) -> Skel { + if remove.is_empty() { + return s.clone(); + } + let mut text = Vec::with_capacity(s.text.len()); + let mut pos = Vec::with_capacity(s.pos.len()); + for (&ch, &p) in s.text.iter().zip(s.pos.iter()) { + if ch == PH && remove.contains(&p) { + continue; + } + text.push(ch); + pos.push(p); + } + Skel { text, pos, groups: Rc::clone(&s.groups) } +} + +/// R6.1: `-` with a space immediately on both sides. +pub(crate) fn is_spaced_dash_at(text: &[char], i: usize) -> bool { + at(text, i) == Some('-') && before(text, i) == Some(' ') && at(text, i + 1) == Some(' ') +} + +pub(crate) fn has_spaced_dash(text: &[char]) -> bool { + (1..text.len().saturating_sub(1)).any(|i| is_spaced_dash_at(text, i)) +} + +#[derive(Debug, Clone)] +pub(crate) struct Segment { + pub skel: Skel, + /// Trimmed range inside the parent skeleton. + pub start: usize, + pub end: usize, +} + +fn trimmed_segment(s: &Skel, start: usize, end: usize) -> Segment { + let mut a = start; + let mut b = start.max(end); + while a < b && is_whitespace(at(&s.text, a)) { + a += 1; + } + while b > a && is_whitespace(before(&s.text, b)) { + b -= 1; + } + Segment { skel: slice_skel(s, a, b), start: a, end: b } +} + +/// R6.1 / R8.2: split a skeleton at every spaced dash into trimmed segments. With +/// `allow_leading`, a string starting with `- ` yields an empty first segment (R6.3). +pub(crate) fn split_at_spaced_dashes(s: &Skel, allow_leading: bool) -> Vec { + let mut segments = Vec::new(); + let t = &s.text; + let mut start = 0usize; + if allow_leading && at(t, 0) == Some('-') && at(t, 1) == Some(' ') { + segments.push(Segment { skel: slice_skel(s, 0, 0), start: 0, end: 0 }); + start = 2; + } + let mut i = start.max(1); + while i + 1 < t.len() { + if is_spaced_dash_at(t, i) { + segments.push(trimmed_segment(s, start, i - 1)); + start = i + 2; + } + i += 1; + } + segments.push(trimmed_segment(s, start, t.len())); + segments +} diff --git a/rust/src/separator.rs b/rust/src/separator.rs new file mode 100644 index 0000000..c6125f3 --- /dev/null +++ b/rust/src/separator.rs @@ -0,0 +1,289 @@ +//! R6: artist/title separator, including R6.2 suffix peeling (shared with R8.2). + +use crate::classify::{classify, Classification, Flag, Site, VersionDraft}; +use crate::context::{is_known_artist, warn, Ctx}; +use crate::scanner::{ + concat_skel, has_group, render_skel, slice_from, slice_skel, split_at_spaced_dashes, start_pos, + trim_skel, Segment, Skel, PH, +}; +use crate::types::{ArtistSource, Mode, VersionDelimiter, Warning}; +use crate::words::{ + at, before, collapse_chars, in_vocab, is_letter_at, is_letter_before, is_upper_at, + is_whitespace, split_words_chars, tail, year_of, +}; + +/// The classifications R6.2 / R8.2 can peel. +#[derive(Debug, Clone)] +pub(crate) enum Peelable { + Junk(String), + Flag(Flag), + Year(u32), + Versions(Vec), +} + +#[derive(Debug, Clone)] +pub(crate) struct Peeled { + pub cls: Peelable, + pub raw: String, + pub pos: i64, +} + +/// R6.2 classification of a bare dash segment: placeholders make it Unknown. +fn classify_segment(seg: &Skel, ctx: &mut Ctx<'_>) -> Classification { + if has_group(seg) { + return Classification::Unknown; + } + let text = collapse_chars(&seg.text); + let site = Site { + source: ArtistSource::Title, + delimiter: VersionDelimiter::Dash, + pos: start_pos(seg, 0), + }; + classify(&text, site, ctx) +} + +fn peelable(c: Classification) -> Option { + match c { + Classification::Junk(kind) => Some(Peelable::Junk(kind)), + Classification::Flag(flag) => Some(Peelable::Flag(flag)), + Classification::Year(year) => Some(Peelable::Year(year)), + Classification::Versions(versions) => Some(Peelable::Versions(versions)), + Classification::Feat(_) | Classification::Producer(_) | Classification::Unknown => None, + } +} + +/// R6.2 / R8.2: peel classifiable suffixes off the right end. `relaxed` drops conditions +/// (i)–(iv) (R8.2 with an artist side). Returns the remaining segments and the peeled +/// suffixes, left to right. +pub(crate) fn peel_suffixes( + segments: Vec, + relaxed: bool, + ctx: &mut Ctx<'_>, +) -> (Vec, Vec) { + let mut remaining = segments; + let mut peeled: Vec = Vec::new(); + while remaining.len() >= 2 { + let Some(last) = remaining.last() else { break }; + let Some(cls) = peelable(classify_segment(&last.skel, ctx)) else { break }; + let words = split_words_chars(&last.skel.text); + // (ii) does not apply to prefix-form versions (`Andy C b2b Hedex - Live at Printworks`). + let prefix_form = + matches!(&cls, Peelable::Versions(vs) if vs.iter().all(|v| v.prefix_form)); + let ok = relaxed + || remaining.len() > 2 + || (words.len() >= 2 && !prefix_form) + || words.iter().any(|w| year_of(w).is_some()) + || matches!(cls, Peelable::Junk(_)); + if !ok { + break; + } + peeled.push(Peeled { + cls, + raw: collapse_chars(&last.skel.text), + pos: start_pos(&last.skel, 0), + }); + remaining.pop(); + } + peeled.reverse(); + (remaining, peeled) +} + +pub(crate) struct SeparatorResult { + pub artist: Option, + pub title: Skel, + /// A separator split the string (R6.3–R6.7): R8.2 peels without conditions. + pub split: bool, + pub peeled: Vec, +} + +pub(crate) struct SeparatorInput<'a> { + pub skel: &'a Skel, + pub mode: Mode, + pub uploader: Option, + /// R13.4.2 list context (internal, set only by the tracklist module): enables the R6.10 + /// tight `letter-Uppercase` dash in tracklist mode. + pub list_context: bool, +} + +fn non_empty(s: &Skel) -> Option { + let t = trim_skel(s); + (!t.is_empty()).then_some(t) +} + +fn split_at(s: &Skel, cut_start: usize, cut_end: usize) -> (Option, Skel) { + (non_empty(&slice_skel(s, 0, cut_start)), trim_skel(&slice_from(s, cut_end))) +} + +fn result(parts: (Option, Skel), peeled: Vec) -> SeparatorResult { + let split = parts.0.is_some(); + SeparatorResult { artist: parts.0, title: parts.1, split, peeled } +} + +/// R6.3: the first segment is the artist side, the rest (up to the last kept one) the title. +fn first_dash_split(skel: &Skel, segments: &[Segment]) -> Option<(Option, Skel)> { + let [first, second, ..] = segments else { return None }; + let last = segments.last()?; + let artist = (!first.skel.is_empty()).then(|| first.skel.clone()); + Some((artist, slice_skel(skel, second.start, last.end))) +} + +pub(crate) fn find_separator(input: SeparatorInput<'_>, ctx: &mut Ctx<'_>) -> SeparatorResult { + let skel = input.skel; + let mode = input.mode; + let segments = split_at_spaced_dashes(skel, true); + if mode == Mode::Tracklist { + return tracklist_separator(skel, &segments, input.list_context, ctx); + } + let (remaining, peeled) = peel_suffixes(segments, false, ctx); + + // R6.3 + if let Some(parts) = first_dash_split(skel, &remaining) { + return result(parts, peeled); + } + + let rest = remaining.first().map_or_else(|| slice_skel(skel, 0, 0), |s| s.skel.clone()); + if let Some(other) = split_without_spaced_dash(&rest, mode, ctx) { + return result(other, peeled); + } + + // R6.8: the uploader fallback does not warn noSeparator. + let artist = if mode == Mode::Youtube { input.uploader } else { None }; + if !rest.is_empty() && artist.is_none() { + warn(ctx, Warning::NoSeparator); + } + SeparatorResult { artist, title: rest, split: false, peeled } +} + +/// R6.10: tracklist mode. The first spaced dash always separates (no R6.2 peeling; R8.2 still +/// peels later suffixes on the title side). Without one: R6.4, then the first `_-_`, then (list +/// context only) the last tight `letter-Uppercase` dash; both of these warn `unspacedDashSplit`. +fn tracklist_separator( + skel: &Skel, + segments: &[Segment], + list_context: bool, + ctx: &mut Ctx<'_>, +) -> SeparatorResult { + if let Some(parts) = first_dash_split(skel, segments) { + return result(parts, Vec::new()); + } + let rest = segments.first().map_or_else(|| slice_skel(skel, 0, 0), |s| s.skel.clone()); + if let Some(asym) = asymmetric_dash(&rest.text) { + warn(ctx, Warning::AsymmetricDashSplit); + return result(split_at(&rest, asym, asym + 1), Vec::new()); + } + if let Some(underscore) = rest.text.windows(3).position(|w| w == ['_', '-', '_']) { + warn(ctx, Warning::UnspacedDashSplit); + return result(split_at(&rest, underscore, underscore + 3), Vec::new()); + } + if list_context { + if let Some(tight) = tight_upper_dash(&rest.text) { + warn(ctx, Warning::UnspacedDashSplit); + return result(split_at(&rest, tight, tight + 1), Vec::new()); + } + } + if !rest.is_empty() { + warn(ctx, Warning::NoSeparator); + } + SeparatorResult { artist: None, title: rest, split: false, peeled: Vec::new() } +} + +/// R6.10: the last `-` with a letter (R0.6) on its left and an uppercase letter (Lu) on its +/// right, as in R6.7 (`Jay-Z-Numb` → `Jay-Z` / `Numb`). +fn tight_upper_dash(t: &[char]) -> Option { + (1..t.len().saturating_sub(1)) + .rev() + .find(|&i| at(t, i) == Some('-') && is_letter_before(t, i) && is_upper_at(t, i + 1)) +} + +fn split_without_spaced_dash( + s: &Skel, + mode: Mode, + ctx: &mut Ctx<'_>, +) -> Option<(Option, Skel)> { + if let Some(asym) = asymmetric_dash(&s.text) { + warn(ctx, Warning::AsymmetricDashSplit); + return Some(split_at(s, asym, asym + 1)); + } + if mode == Mode::Youtube { + if let Some(quoted) = quoted_title(s) { + warn(ctx, Warning::QuotedTitleSplit); + return Some(quoted); + } + if let Some(by) = by_split(s, ctx) { + warn(ctx, Warning::BySplit); + let (left, right) = split_at(s, by, by + 4); + let artist = (!right.is_empty()).then_some(right); + return Some((artist, left.unwrap_or_else(|| s.clone()))); + } + } + if mode == Mode::Youtube || mode == Mode::Filename { + if let Some(dash) = unspaced_dash(s, ctx) { + warn(ctx, Warning::UnspacedDashSplit); + return Some(split_at(s, dash, dash + 1)); + } + } + None +} + +/// R6.4: the first `-` with a space on exactly one side. +fn asymmetric_dash(t: &[char]) -> Option { + (1..t.len().saturating_sub(1)).find(|&i| { + at(t, i) == Some('-') && is_whitespace(before(t, i)) != is_whitespace(at(t, i + 1)) + }) +} + +/// R6.5: `Artist "Title" (extra)`. +fn quoted_title(s: &Skel) -> Option<(Option, Skel)> { + let t = &s.text; + let open = t.iter().position(|&c| c == '"').filter(|&i| i > 0)?; + let close = tail(t, open + 1).iter().position(|&c| c == '"')? + open + 1; + let mut artist = trim_skel(&slice_skel(s, 0, open)); + if matches!(artist.text.last(), Some(':' | '-')) { + artist = trim_skel(&slice_skel(&artist, 0, artist.len() - 1)); + } + let title = trim_skel(&concat_skel(&slice_skel(s, open + 1, close), &slice_from(s, close + 1))); + Some(((!artist.is_empty()).then_some(artist), title)) +} + +/// R6.6: index of the space before the last usable ` by `. The right side must be non-empty and +/// not a single stopword (`Stand by Me`). +fn by_split(s: &Skel, ctx: &Ctx<'_>) -> Option { + let t = &s.text; + // Candidates right to left; index 0 is never one (`i > 0` in the JS loop). + let mut i = t.len().checked_sub(4)?; + while i > 0 { + if t.get(i..i + 4) == Some(&[' ', 'b', 'y', ' ']) { + // Placeholder-only words (groups such as `(Official Video)`) don't count here. + let right: Vec = split_words_chars(tail(t, i + 4)) + .into_iter() + .filter(|w| !(w.chars().count() == 1 && w.starts_with(PH))) + .collect(); + let single_stopword = + right.len() == 1 && right.first().is_some_and(|w| in_vocab(w, &ctx.t.stopwords)); + if !right.is_empty() && !single_stopword { + return Some(i); + } + } + i -= 1; + } + None +} + +/// R6.7: `Jay-Z-Numb` → the chosen unspaced dash index. +fn unspaced_dash(s: &Skel, ctx: &Ctx<'_>) -> Option { + let t = &s.text; + let mut last_candidate = None; + for i in 1..t.len().saturating_sub(1) { + if at(t, i) != Some('-') || is_whitespace(before(t, i)) || is_whitespace(at(t, i + 1)) { + continue; + } + if !(at(t, i + 1) == Some('"') || is_letter_at(t, i + 1)) { + continue; + } + if !ctx.known_keys.is_empty() && is_known_artist(&render_skel(&slice_skel(s, 0, i)), ctx) { + return Some(i); + } + last_candidate = Some(i); + } + last_candidate +} diff --git a/rust/src/serde_support.rs b/rust/src/serde_support.rs new file mode 100644 index 0000000..0bf9b99 --- /dev/null +++ b/rust/src/serde_support.rs @@ -0,0 +1,255 @@ +//! Helpers for the `serde` feature, so `serde_json::to_string(&x)` is the text of `x.to_json()`. +//! +//! Numbers share the writer of `to_json()` ([`number_text`]): a whole value is handed to the +//! serializer as the integer with the digits JavaScript prints (`3167`, not `3167.0`; +//! `1152921504606847000` for 2^60), so `serde_json` writes the same text. +//! +//! What is true for `serde_json`: +//! +//! - Every finite number is written as `to_json()` writes it, except where `serde_json`'s own +//! float notation differs from JavaScript's: `1e-6 <= |x| < 1e-5` (`1e-6` for `0.000001`) and, +//! in `serde_json` releases that write floats with ryu, `|x| >= 1e21` (`1e21` for `1e+21`). +//! It is the same number and reads back the same. No time the parser produces is in those +//! ranges; only an `Edit` or `audio_seconds` built by hand is. Whole values from 2^63 on are +//! handed over as `u64` / `i128`, which `serde_json` writes; a format without 128-bit integers +//! reports an error for whole seconds of 2^64 and more. +//! - Non-finite seconds are written as `null`, as `to_json()` does, and `null` reads back as NaN +//! (in an `Option`, as `None`). `apply_edits` treats every non-finite value as `edit-invalid`. +//! - Line numbers above 2^53 are written as JavaScript writes the nearest double, and read back +//! as that double saturated to `usize`. +//! - Keyword maps are written as JSON objects without repeated keys: a repeated key keeps its +//! first place and takes the last value, like a JS object. Reading does the same. +//! +//! Formats that are not human-readable get plain `f64` / `u64` values. + +use serde::de::{Error as DeError, MapAccess, Visitor}; +use serde::ser::SerializeMap; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +use crate::json::number_text; + +/// 2^53: up to here every whole double is its own decimal text. +const EXACT: f64 = 9_007_199_254_740_992.0; + +/// A double as JS writes numbers, for a human-readable format. +fn js_number(value: f64, serializer: S) -> Result { + if !value.is_finite() { + return serializer.serialize_unit(); // `null`, like `JSON.stringify` + } + if value.fract() != 0.0 || value.abs() >= 1e21 { + return serializer.serialize_f64(value); + } + if value.abs() <= EXACT { + return serializer.serialize_i64(value as i64); + } + // A whole value JS prints without an exponent: the shortest digits that round-trip, then + // zeros. Those digits are an integer the serializer can write as they are. + let text = number_text(value); + if let Ok(n) = text.parse::() { + serializer.serialize_i64(n) + } else if let Ok(n) = text.parse::() { + serializer.serialize_u64(n) + } else if let Ok(n) = text.parse::() { + serializer.serialize_i128(n) + } else { + serializer.serialize_f64(value) + } +} + +/// Seconds: a whole value is an integer, a non-finite one is `null` (read back as NaN). +pub(crate) mod seconds { + use super::*; + + pub(crate) fn serialize(value: &f64, serializer: S) -> Result { + if serializer.is_human_readable() { + js_number(*value, serializer) + } else { + serializer.serialize_f64(*value) + } + } + + pub(crate) fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result { + if deserializer.is_human_readable() { + Ok(Option::::deserialize(deserializer)?.unwrap_or(f64::NAN)) + } else { + f64::deserialize(deserializer) + } + } +} + +pub(crate) fn opt_seconds( + value: &Option, + serializer: S, +) -> Result { + struct Seconds(f64); + impl Serialize for Seconds { + fn serialize(&self, serializer: S) -> Result { + seconds::serialize(&self.0, serializer) + } + } + value.map(Seconds).serialize(serializer) +} + +/// A line number of an edit. `to_json()` writes it as a JS number, so above 2^53 it is the +/// nearest double; this writes the same digits and reads them back (saturating at `usize::MAX`). +struct Line(usize); + +impl Serialize for Line { + fn serialize(&self, serializer: S) -> Result { + if serializer.is_human_readable() && self.0 as u64 > (1 << 53) { + js_number(self.0 as f64, serializer) + } else { + serializer.serialize_u64(self.0 as u64) + } + } +} + +impl<'de> Deserialize<'de> for Line { + fn deserialize>(deserializer: D) -> Result { + struct LineVisitor; + impl Visitor<'_> for LineVisitor { + type Value = Line; + + fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str("a line number (a non-negative whole number)") + } + + fn visit_u64(self, v: u64) -> Result { + Ok(Line(usize::try_from(v).unwrap_or(usize::MAX))) + } + + fn visit_i64(self, v: i64) -> Result { + u64::try_from(v) + .map_err(|_| E::custom(format_args!("a line number cannot be negative: {v}"))) + .and_then(|v| self.visit_u64(v)) + } + + fn visit_f64(self, v: f64) -> Result { + if v.is_finite() && v.fract() == 0.0 && v >= 0.0 { + Ok(Line(v as usize)) // saturates + } else { + Err(E::custom(format_args!("a line number must be a whole number: {v}"))) + } + } + } + // A self-describing format may hold the number as a double (`18446744073709552000`), and + // an `Edit` is read through serde's buffer for tagged enums, which only hands a double + // to `deserialize_any`. + if deserializer.is_human_readable() { + deserializer.deserialize_any(LineVisitor) + } else { + deserializer.deserialize_u64(LineVisitor) + } + } +} + +pub(crate) mod line { + use super::*; + + pub(crate) fn serialize(v: &usize, serializer: S) -> Result { + Line(*v).serialize(serializer) + } + + pub(crate) fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { + Line::deserialize(d).map(|l| l.0) + } +} + +pub(crate) mod opt_line { + use super::*; + + pub(crate) fn serialize( + v: &Option, + serializer: S, + ) -> Result { + v.map(Line).serialize(serializer) + } + + pub(crate) fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result, D::Error> { + Ok(Option::::deserialize(d)?.map(|l| l.0)) + } +} + +pub(crate) mod opt_lines { + use super::*; + + pub(crate) fn serialize( + v: &Option>, + serializer: S, + ) -> Result { + v.as_ref() + .map(|lines| lines.iter().map(|l| Line(*l)).collect::>()) + .serialize(serializer) + } + + pub(crate) fn deserialize<'de, D: Deserializer<'de>>( + d: D, + ) -> Result>, D::Error> { + Ok(Option::>::deserialize(d)? + .map(|lines| lines.into_iter().map(|l| l.0).collect())) + } +} + +/// Ordered `(key, value)` pairs as a map (`keywords.versionHeads`, `keywords.junk`). A repeated +/// key keeps its first place and takes the last value, as in a JS object, so the JSON never has +/// a key twice. +pub(crate) mod pairs { + use super::*; + use std::collections::HashMap; + + fn unique<'a, T>(pairs: impl Iterator) -> Vec<(&'a String, T)> { + let mut out: Vec<(&String, T)> = Vec::new(); + let mut index: HashMap<&str, usize> = HashMap::new(); + for (key, value) in pairs { + match index.get(key.as_str()).and_then(|&i| out.get_mut(i)) { + Some(slot) => slot.1 = value, + None => { + index.insert(key.as_str(), out.len()); + out.push((key, value)); + } + } + } + out + } + + pub(crate) fn serialize( + pairs: &[(String, T)], + serializer: S, + ) -> Result { + let pairs = unique(pairs.iter().map(|(k, v)| (k, v))); + let mut map = serializer.serialize_map(Some(pairs.len()))?; + for (key, value) in pairs { + map.serialize_entry(key, value)?; + } + map.end() + } + + pub(crate) fn deserialize<'de, D: Deserializer<'de>, T: Deserialize<'de>>( + deserializer: D, + ) -> Result, D::Error> { + struct Pairs(std::marker::PhantomData); + impl<'de, T: Deserialize<'de>> Visitor<'de> for Pairs { + type Value = Vec<(String, T)>; + + fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str("a map of keyword to name") + } + + fn visit_map>(self, mut map: A) -> Result { + let mut out: Vec<(String, T)> = Vec::new(); + let mut index: HashMap = HashMap::new(); + while let Some((key, value)) = map.next_entry::()? { + match index.get(&key).and_then(|&i| out.get_mut(i)) { + Some(slot) => slot.1 = value, + None => { + index.insert(key.clone(), out.len()); + out.push((key, value)); + } + } + } + Ok(out) + } + } + deserializer.deserialize_map(Pairs(std::marker::PhantomData)) + } +} diff --git a/rust/src/tables.rs b/rust/src/tables.rs new file mode 100644 index 0000000..b4263c2 --- /dev/null +++ b/rust/src/tables.rs @@ -0,0 +1,202 @@ +//! Vocabulary tables compiled from spec/data, optionally extended by `options.keywords` (R12). + +use std::collections::{HashMap, HashSet}; +use std::sync::{Arc, OnceLock}; + +use crate::data::{ + DESCRIPTORS_DATA, EXTENSIONS_DATA, FEAT_MARKERS_DATA, GENRES_DATA, JOINERS_DATA, JUNK_DATA, + NO_SPLIT_BEFORE_DATA, PLATFORM_SUFFIXES_DATA, STOPWORDS_DATA, UNKNOWN_TOKENS_DATA, + VERSION_KEYWORDS_DATA, +}; +use crate::options::{js_entries, Keywords}; +use crate::value::V; +use crate::words::{ascii_lower, js_trim, PhraseTable}; + +#[derive(Debug, Clone)] +pub(crate) struct SpacedJoiner { + pub raw: &'static str, + pub canonical: &'static str, + pub is_and: bool, + pub case_sensitive: bool, +} + +/// Category of a word in the modifier run left of a version head (R5.7.2). Version types are +/// strings: `keywords.versionHeads` values pass through to the output as given. +#[derive(Debug, Clone, Default)] +pub(crate) struct RunInfo { + pub type_capable: Option, + pub descriptor: Option, + pub genre: bool, + pub head: Option, +} + +#[derive(Debug)] +pub(crate) struct Tables { + pub feat_markers: PhraseTable<()>, + pub bracket_only_feat: PhraseTable<()>, + pub producer_markers: PhraseTable<()>, + /// R8.3: the only unbracketed feat markers on the title side (+ keywords.featMarkers). + pub title_feat_markers: PhraseTable<()>, + /// R8.3: the only unbracketed producer markers on the title side. + pub title_producer_markers: PhraseTable<()>, + /// Junk phrases plus genres (kind `genre`): the R5.1 tokenizer vocabulary. + pub junk_or_genre: PhraseTable, + /// Junk phrases only (R8.4). + pub junk_phrases: PhraseTable, + pub junk_connectors: HashSet<&'static str>, + pub label_suffixes: HashSet<&'static str>, + pub heads: PhraseTable, + pub generic_head_types: HashSet<&'static str>, + /// Everything allowed in the R5.7.2 modifier run, keyed by phrase. + pub run_words: PhraseTable, + pub prefix_forms: PhraseTable, + pub spaced_joiners: Vec, + pub tight_joiners: HashMap<&'static str, &'static str>, + pub feat_canonical: &'static str, + pub no_split_before: HashSet<&'static str>, + pub stopwords: HashSet<&'static str>, + pub unknown_case_sensitive: HashSet<&'static str>, + pub unknown_case_insensitive: HashSet<&'static str>, + pub extensions: HashSet<&'static str>, + pub platform_suffixes: Vec<&'static str>, +} + +fn lower_keys(list: &[String]) -> Vec { + list.iter().map(|s| js_trim(&ascii_lower(s)).to_string()).filter(|s| !s.is_empty()).collect() +} + +/// The string-valued entries of a data object, in `Object.entries` order. +fn data_entries(obj: V) -> Vec<(String, String)> { + let pairs: Vec<(String, String)> = obj + .entries() + .iter() + .filter_map(|(k, v)| v.as_str().map(|s| ((*k).to_string(), s.to_string()))) + .collect(); + js_entries(&pairs) +} + +fn marker_table(base: V, extra: &[String]) -> PhraseTable<()> { + PhraseTable::new( + base.strings().map(str::to_string).chain(extra.iter().cloned()).map(|m| (m, ())), + ) +} + +fn word_set(list: V) -> HashSet<&'static str> { + list.strings().collect() +} + +pub(crate) fn build_tables(keywords: Option<&Keywords>) -> Tables { + let none = Keywords::default(); + let kw = keywords.unwrap_or(&none); + let extra_feat = lower_keys(&kw.feat_markers); + + let mut junk_entries = data_entries(JUNK_DATA.get("phrases")); + junk_entries.extend(kw.junk.iter().cloned()); + let mut genres: Vec = GENRES_DATA.get("genres").strings().map(str::to_string).collect(); + genres.extend(lower_keys(&kw.genres)); + let junk_phrases = PhraseTable::new(junk_entries.iter().cloned()); + // Junk phrases are added first, so they win over an identical genre key. + let junk_or_genre = PhraseTable::new( + junk_entries.iter().cloned().chain(genres.iter().map(|g| (g.clone(), "genre".to_string()))), + ); + + let mut head_entries = data_entries(VERSION_KEYWORDS_DATA.get("heads")); + head_entries.extend(kw.version_heads.iter().cloned()); + let heads = PhraseTable::new(head_entries.iter().cloned()); + + // A Map in JS: the first note of a key fixes its place, later notes merge into it. + let mut run_info: Vec<(String, RunInfo)> = Vec::new(); + let mut run_index: HashMap = HashMap::new(); + let mut note = |key: &str, patch: &dyn Fn(&mut RunInfo)| { + let k = js_trim(&ascii_lower(key)).to_string(); + let i = *run_index.entry(k.clone()).or_insert_with(|| { + run_info.push((k, RunInfo::default())); + run_info.len() - 1 + }); + if let Some(slot) = run_info.get_mut(i) { + patch(&mut slot.1); + } + }; + for (k, t) in data_entries(VERSION_KEYWORDS_DATA.get("typeCapableModifiers")) { + note(&k, &|info| info.type_capable = Some(t.clone())); + } + let descriptors = DESCRIPTORS_DATA.get("descriptors"); + for d in descriptors.strings().map(str::to_string).chain(lower_keys(&kw.descriptors)) { + let value = js_trim(&ascii_lower(&d)).to_string(); + note(&d, &|info| info.descriptor = Some(value.clone())); + } + for g in &genres { + note(g, &|info| info.genre = true); + } + for (k, t) in &head_entries { + note(k, &|info| info.head = Some(t.clone())); + } + + let spaced_joiners = JOINERS_DATA + .get("spaced") + .items() + .iter() + .filter_map(|j| { + Some(SpacedJoiner { + raw: j.get("raw").as_str()?, + canonical: j.get("canonical").as_str()?, + is_and: j.get("kind").as_str() == Some("and"), + case_sensitive: j.get("caseSensitive") == V::Bool(true), + }) + }) + .collect(); + let tight_joiners = JOINERS_DATA + .get("tight") + .items() + .iter() + .filter_map(|j| Some((j.get("raw").as_str()?, j.get("canonical").as_str()?))) + .collect(); + let mut platform_suffixes: Vec<&'static str> = + PLATFORM_SUFFIXES_DATA.get("suffixes").strings().collect(); + // JS sorts by UTF-16 length, longest first (stable). + platform_suffixes.sort_by_key(|s| std::cmp::Reverse(s.encode_utf16().count())); + + Tables { + feat_markers: marker_table(FEAT_MARKERS_DATA.get("markers"), &extra_feat), + bracket_only_feat: marker_table(FEAT_MARKERS_DATA.get("bracketOnly"), &[]), + producer_markers: marker_table(FEAT_MARKERS_DATA.get("producer"), &[]), + title_feat_markers: marker_table(FEAT_MARKERS_DATA.get("titleMarkers"), &extra_feat), + title_producer_markers: marker_table(FEAT_MARKERS_DATA.get("titleProducer"), &[]), + junk_or_genre, + junk_phrases, + junk_connectors: word_set(JUNK_DATA.get("connectors")), + label_suffixes: word_set(JUNK_DATA.get("labelSuffixes")), + heads, + generic_head_types: word_set(VERSION_KEYWORDS_DATA.get("genericHeads")), + run_words: PhraseTable::new(run_info), + prefix_forms: PhraseTable::new(data_entries(VERSION_KEYWORDS_DATA.get("prefixForms"))), + spaced_joiners, + tight_joiners, + feat_canonical: JOINERS_DATA.get("featCanonical").as_str().unwrap_or("feat."), + no_split_before: word_set(NO_SPLIT_BEFORE_DATA.get("words")), + stopwords: word_set(STOPWORDS_DATA.get("words")), + unknown_case_sensitive: word_set(UNKNOWN_TOKENS_DATA.get("caseSensitive")), + unknown_case_insensitive: word_set(UNKNOWN_TOKENS_DATA.get("caseInsensitive")), + extensions: word_set(EXTENSIONS_DATA.get("extensions")), + platform_suffixes, + } +} + +static DEFAULT_TABLES: OnceLock> = OnceLock::new(); + +pub(crate) fn default_tables() -> Arc { + Arc::clone(DEFAULT_TABLES.get_or_init(|| Arc::new(build_tables(None)))) +} + +pub(crate) fn tables_for(keywords: Option<&Keywords>) -> Arc { + match keywords { + Some(k) => Arc::new(build_tables(Some(k))), + None => default_tables(), + } +} + +/// R7.5 / R8.6: an unknown placeholder name (`ID`, `???`, `Untitled`…). +pub(crate) fn is_unknown_token(text: &str, t: &Tables) -> bool { + t.unknown_case_sensitive.contains(text) + || t.unknown_case_insensitive.contains(ascii_lower(text).as_str()) +} diff --git a/rust/src/title.rs b/rust/src/title.rs new file mode 100644 index 0000000..9518172 --- /dev/null +++ b/rust/src/title.rs @@ -0,0 +1,290 @@ +//! R8: the title side. + +use std::collections::HashSet; + +use crate::classify::{classify, Classification, Flag, Site, VersionDraft}; +use crate::context::Ctx; +use crate::credits::{split_credits, Credit, ListOptions, PositionedYear}; +use crate::mode::PositionedJunk; +use crate::scanner::{ + groups_of, remove_groups, render_skel, slice_skel, split_at_spaced_dashes, trim_skel, Skel, PH, +}; +use crate::separator::{peel_suffixes, Peelable, Peeled}; +use crate::tables::is_unknown_token; +use crate::types::{ArtistRole, ArtistSource}; +use crate::words::{ + at, before, chars, collapse_chars, collapse_spaces, span_texts, string, sub, word_spans, +}; + +/// Everything the title side (and R6.2 peeling) can extract. +#[derive(Debug, Default)] +pub(crate) struct Extracted { + pub credits: Vec, + pub versions: Vec, + pub junk: Vec, + pub years: Vec, + pub explicit: bool, + pub clean: bool, + pub unknown_artist: bool, +} + +impl Extracted { + fn set_flag(&mut self, flag: Flag) { + match flag { + Flag::Explicit => self.explicit = true, + Flag::Clean => self.clean = true, + } + } +} + +/// Record R6.2 / R8.2 peeled dash suffixes. +pub(crate) fn add_peeled(out: &mut Extracted, peeled: Vec) { + for p in peeled { + match p.cls { + Peelable::Versions(versions) => out.versions.extend(versions), + Peelable::Junk(kind) => out.junk.push(PositionedJunk { raw: p.raw, kind, pos: p.pos }), + Peelable::Flag(flag) => out.set_flag(flag), + Peelable::Year(year) => out.years.push(PositionedYear { year, pos: p.pos }), + } + } +} + +pub(crate) struct TitleSideResult { + pub title: String, + pub unknown_title: bool, +} + +/// `relaxed`: an artist side was split off (R8.2 peels without conditions). +pub(crate) fn parse_title_side( + input: &Skel, + relaxed: bool, + youtube: bool, + out: &mut Extracted, + ctx: &mut Ctx<'_>, +) -> TitleSideResult { + let removed = extract_groups(input, out, ctx); // R8.1 + + // R8.2 + let segments = split_at_spaced_dashes(input, false); + let (remaining, peeled) = peel_suffixes(segments, relaxed, ctx); + add_peeled(out, peeled); + let last_kept_end = remaining.last().map_or(0, |s| s.end); + let mut skel = slice_skel(input, 0, last_kept_end); + + skel = extract_unbracketed_credits(&skel, out, ctx); // R8.3 + skel = remove_groups(&skel, &removed); + if youtube { + skel = strip_trailing_junk(&skel, out, ctx); // R8.4 + } + + let title = cleanup_title(&render_skel(&skel)); // R8.5 + let unknown_title = !title.is_empty() && is_unknown_token(&title, ctx.t); // R8.6 + TitleSideResult { title, unknown_title } +} + +/// R8.1: classify every group; returns the positions of the groups to remove. +fn extract_groups(skel: &Skel, out: &mut Extracted, ctx: &mut Ctx<'_>) -> HashSet { + let mut removed = HashSet::new(); + for (_, group) in groups_of(skel) { + let site = Site { source: ArtistSource::Title, delimiter: group.open, pos: group.pos }; + match classify(&group.inner, site, ctx) { + Classification::Versions(versions) => out.versions.extend(versions), + Classification::Junk(kind) => { + out.junk.push(PositionedJunk { raw: group.inner.clone(), kind, pos: group.pos }); + } + Classification::Flag(flag) => out.set_flag(flag), + Classification::Year(year) => out.years.push(PositionedYear { year, pos: group.pos }), + Classification::Feat(c) | Classification::Producer(c) => { + out.credits.extend(c.credits); + out.years.extend(c.years); + if c.unknown { + out.unknown_artist = true; + } + } + Classification::Unknown => continue, + } + removed.insert(group.pos); + } + removed +} + +struct MarkerHit { + start: usize, + end: usize, + marker: String, + role: ArtistRole, +} + +/// R8.3 markers, left to right, each with a space on both sides: feat markers from +/// `#titleMarkers` (`feat.`, `ft.`, `featuring`; undotted `feat`/`ft` stay text) and +/// producer markers from `#titleProducer` (`prod.`, `prod. by`, `produced by`, `prod.by`). +fn title_markers(s: &Skel, ctx: &Ctx<'_>) -> Vec { + let spans = word_spans(&s.text); + let words = span_texts(&spans); + let mut hits = Vec::new(); + let mut i = 0; + while let Some(span) = spans.get(i) { + let step = i + 1; + if before(&s.text, span.start) != Some(' ') { + i = step; + continue; + } + let (role, last_index) = if let Some(feat) = ctx.t.title_feat_markers.match_at(&words, i) { + (ArtistRole::Featured, i + feat.length - 1) + } else if let Some(prod) = ctx.t.title_producer_markers.match_at(&words, i) { + (ArtistRole::Producer, i + prod.length - 1) + } else { + i = step; + continue; + }; + let Some(last) = spans.get(last_index) else { + i = step; + continue; + }; + if at(&s.text, last.end) != Some(' ') { + i = step; + continue; + } + hits.push(MarkerHit { + start: span.start, + end: last.end, + marker: string(sub(&s.text, span.start, last.end)), + role, + }); + i = last_index + 1; + } + hits +} + +/// R8.3: `Title feat. X`, `Title prod. by Y` → credits, removed from the title. A list runs to +/// the next placeholder, the next marker of the other kind, or the end; later feat markers +/// inside a featured list are joiners (R7.2). +fn extract_unbracketed_credits(input: &Skel, out: &mut Extracted, ctx: &mut Ctx<'_>) -> Skel { + let markers = title_markers(input, ctx); + if markers.is_empty() { + return input.clone(); + } + // `indexOf(PH, from)` for every `from`, computed once so many markers stay linear (R0.8). + let len = input.text.len(); + let mut next_group = vec![len; len + 1]; + for k in (0..len).rev() { + let next = if at(&input.text, k) == Some(PH) { + k + } else { + next_group.get(k + 1).copied().unwrap_or(len) + }; + if let Some(slot) = next_group.get_mut(k) { + *slot = next; + } + } + let mut cuts: Vec<(usize, usize)> = Vec::new(); + let mut i = 0; + while let Some(hit) = markers.get(i) { + let mut list_end = next_group.get(hit.end).copied().unwrap_or(len); + let other = markers.iter().skip(i + 1).find(|m| m.role != hit.role && m.start >= hit.end); + if let Some(other) = other { + if other.start < list_end { + list_end = other.start; + } + } + let list = trim_skel(&slice_skel(input, hit.end, list_end)); + if !list.is_empty() { + let r = split_credits( + &list, + &ListOptions { + role: hit.role, + source: ArtistSource::Title, + lead: Some(hit.marker.clone()), + split_with: false, + feat_markers_join: hit.role == ArtistRole::Featured, + }, + ctx, + ); + out.credits.extend(r.credits); + out.years.extend(r.years); + if r.unknown { + out.unknown_artist = true; + } + cuts.push((hit.start, list_end)); + } else { + list_end = hit.end; + } + while markers.get(i).is_some_and(|m| m.start < list_end) { + i += 1; + } + } + // The cuts are disjoint and ascending: remove them in one pass. + let mut text: Vec = Vec::with_capacity(len); + let mut pos: Vec = Vec::with_capacity(len); + let mut from = 0usize; + for &(start, end) in &cuts { + let start = start.min(len).max(from); + text.extend_from_slice(sub(&input.text, from, start)); + pos.extend_from_slice(input.pos.get(from..start).unwrap_or(&[])); + from = end.min(len).max(from); + } + text.extend_from_slice(sub(&input.text, from, len)); + pos.extend_from_slice(input.pos.get(from..).unwrap_or(&[])); + Skel { text, pos, groups: std::rc::Rc::clone(&input.groups) } +} + +/// R8.4: strip trailing unbracketed junk phrases (optionally after a lone `-` / `|`). Word spans +/// are computed once and walked backwards, so repeated junk stays linear (R0.8). +fn strip_trailing_junk(input: &Skel, out: &mut Extracted, ctx: &Ctx<'_>) -> Skel { + let skel = trim_skel(input); + let spans = word_spans(&skel.text); + let words = span_texts(&spans); + let mut end = spans.len(); // words still in the title + while let Some(m) = ctx.t.junk_phrases.match_ending(&words, end) { + let first = end - m.length.min(end); + let mut keep = first; + if keep > 0 && words.get(keep - 1).is_some_and(|w| is_lone_edge(w)) { + keep -= 1; + } + if keep == 0 { + break; // never strip the whole title + } + let from = spans.get(first).map_or(0, |s| s.start); + let to = end.checked_sub(1).and_then(|k| spans.get(k)).map_or(skel.text.len(), |s| s.end); + out.junk.push(PositionedJunk { + raw: collapse_chars(sub(&skel.text, from, to)), + kind: m.value.clone(), + pos: skel.pos.get(from).copied().unwrap_or(0), + }); + end = keep; + } + if end == spans.len() { + return skel; + } + let cut = end.checked_sub(1).and_then(|k| spans.get(k)).map_or(0, |s| s.end); + trim_skel(&slice_skel(&skel, 0, cut)) +} + +fn is_lone_edge(word: &str) -> bool { + word == "-" || word == "|" +} + +fn strip_lone_edges(s: &str) -> String { + let words: Vec<&str> = s.split(' ').collect(); + let mut a = 0; + let mut b = words.len(); + while a < b && words.get(a).is_some_and(|w| is_lone_edge(w)) { + a += 1; + } + while b > a && words.get(b - 1).is_some_and(|w| is_lone_edge(w)) { + b -= 1; + } + words.get(a..b).unwrap_or(&[]).join(" ") +} + +/// R8.5 +pub(crate) fn cleanup_title(raw: &str) -> String { + let title = strip_lone_edges(&collapse_spaces(raw)); + let t = chars(&title); + if let (Some(&q), Some(&last)) = (t.first(), t.last()) { + if t.len() >= 2 && (q == '"' || q == '\'') && last == q { + return strip_lone_edges(&collapse_chars(sub(&t, 1, t.len() - 1))); + } + } + title +} diff --git a/rust/src/tracklist/edits.rs b/rust/src/tracklist/edits.rs new file mode 100644 index 0000000..41d9e51 --- /dev/null +++ b/rust/src/tracklist/edits.rs @@ -0,0 +1,459 @@ +//! R13.9: apply_edits. Edits apply in order, each to the result of the previous one. +//! +//! Edits are read as loose JSON objects with the number rules of the JS reference (a bool is not +//! a number; `null`, NaN and infinities are invalid). Typed [`Edit`](super::Edit) values are +//! written to that form first, so both doors share one code path. + +use std::collections::BTreeSet; + +use crate::json::Json; +use crate::words::is_ws; + +use super::options::js_number; +use super::split::{has_line_break, split_lines}; +use super::times::{format_time, scan_time, TimeScan}; +use super::types::{num, EditResult, EditWarning, EditWarningCode, Eol}; +use crate::types::obj; + +struct WorkLine { + raw: String, + eol: Eol, + /// Written by an edit (R13.9.1). + changed: bool, + /// `scan_time(raw)`, kept in step with `raw` (each line is scanned once per write). + scan: TimeScan, +} + +/// R13.9.6: the edit cannot be applied. +struct InvalidEdit; + +type Checked = Result; + +/// A warning with the line as the JS reference holds it: any integer-valued number an invalid +/// edit carried, not only a real line number. +pub(crate) struct RawEditWarning { + code: EditWarningCode, + edit: usize, + line: Option, +} + +/// The result of `apply_edits` before it is typed or written as JSON. +pub(crate) struct RawEditResult { + text: String, + changed: Vec, + warnings: Vec, +} + +impl RawEditResult { + pub(crate) fn into_result(self) -> EditResult { + EditResult { + text: self.text, + changed: self.changed, + warnings: self + .warnings + .into_iter() + // Typed edits carry `usize` lines, written as JS numbers: the value is a whole + // number from 0 to 2^64 and the cast saturates at `usize::MAX`. Negative and + // larger lines only exist behind the JSON door, which writes `to_json_value`. + .map(|w| EditWarning { + code: w.code, + edit: w.edit, + line: w.line.map(|l| l as usize), + }) + .collect(), + } + } + + pub(crate) fn to_json_value(&self) -> Json { + let warnings = self + .warnings + .iter() + .map(|w| { + obj(vec![ + ("code", Json::str(w.code.as_str())), + ("edit", num(w.edit)), + ("line", w.line.map_or(Json::Null, Json::Num)), + ]) + }) + .collect(); + obj(vec![ + ("text", Json::str(&self.text)), + ("changed", Json::Arr(self.changed.iter().map(|l| num(*l)).collect())), + ("warnings", Json::Arr(warnings)), + ]) + } +} + +/// Edit state. Every edit validates its input before it mutates anything, so an invalid edit +/// (R13.9.6) only has to drop the warnings it added: no snapshot of the lines is needed. +struct EditCtx { + /// Boxed, so an insert or delete moves pointers, not lines. + #[allow(clippy::vec_box)] + lines: Vec>, + index: usize, + warnings: Vec, + /// R13.9.2: times with one-digit hours and with wider hours, over all lines. + one_digit: i64, + wide_hours: i64, + /// R13.9.5: how many lines end with LF, CRLF and CR. + eols: [i64; 3], +} + +fn work_line(raw: String, eol: Eol, changed: bool) -> Box { + let scan = scan_time(&raw); + Box::new(WorkLine { raw, eol, changed, scan }) +} + +fn eol_slot(eol: Eol) -> Option { + match eol { + Eol::Lf => Some(0), + Eol::CrLf => Some(1), + Eol::Cr => Some(2), + Eol::None => None, + } +} + +impl EditCtx { + /// Add (`by` = 1) or remove (`by` = -1) a line's time from the hour-width counts (R13.9.2). + fn count_hours(&mut self, scan: &TimeScan, by: i64) { + match &scan.style { + Some(style) if style.hours => { + if style.hour_width == 1 { + self.one_digit += by; + } else { + self.wide_hours += by; + } + } + _ => {} + } + } + + fn count_eol(&mut self, eol: Eol, by: i64) { + if let Some(n) = eol_slot(eol).and_then(|slot| self.eols.get_mut(slot)) { + *n += by; + } + } + + /// A line enters (`by` = 1) or leaves (`by` = -1) the text. + fn count_line(&mut self, line: &WorkLine, by: i64) { + self.count_hours(&line.scan, by); + self.count_eol(line.eol, by); + } + + fn set_eol(&mut self, index: usize, eol: Eol) { + let Some(line) = self.lines.get_mut(index) else { return }; + let old = line.eol; + line.eol = eol; + line.changed = true; + self.count_eol(old, -1); + self.count_eol(eol, 1); + } + + fn set_raw(&mut self, index: usize, raw: String) { + let scan = scan_time(&raw); + let Some(line) = self.lines.get_mut(index) else { return }; + let old = std::mem::replace(&mut line.scan, scan.clone()); + line.raw = raw; + line.changed = true; + self.count_hours(&old, -1); + self.count_hours(&scan, 1); + } + + fn warn(&mut self, code: EditWarningCode, line: Option) { + self.warnings.push(RawEditWarning { code, edit: self.index, line }); + } + + /// 0-based index of an existing 1-based line number, else `InvalidEdit`. + fn line_index(&self, value: Option<&Json>) -> Checked { + let n = integer(value)?; + if n < 1.0 || n > self.lines.len() as f64 { + return Err(InvalidEdit); + } + Ok(n as usize - 1) + } + + /// R13.9.2: do the text's times with hours use one-digit hours? (All of them, at least one.) + fn one_digit_hours(&self) -> bool { + self.one_digit > 0 && self.wide_hours == 0 + } +} + +/// A JS number that `Number.isInteger` accepts. +fn integer(value: Option<&Json>) -> Checked { + js_number(value).filter(|n| n.is_finite() && n.fract() == 0.0).ok_or(InvalidEdit) +} + +fn finite(value: Option<&Json>) -> Checked { + js_number(value).filter(|n| n.is_finite()).ok_or(InvalidEdit) +} + +fn single_line(value: Option<&Json>) -> Checked<&str> { + value.and_then(Json::as_str).filter(|s| !has_line_break(s)).ok_or(InvalidEdit) +} + +struct Retime { + index: usize, + raw: String, + clamped: bool, + upgraded: bool, +} + +/// R13.9.2 / R13.9.3: the rewritten line for a new value, or `InvalidEdit`. +fn retime(ctx: &EditCtx, index: usize, value: f64, one_digit: bool) -> Checked { + let scan = &ctx.lines.get(index).ok_or(InvalidEdit)?.scan; + let (Some(style), Some(_)) = (&scan.style, &scan.time) else { return Err(InvalidEdit) }; + let clamped = value < 0.0; + let f = format_time(if clamped { 0.0 } else { value }, style, one_digit).ok_or(InvalidEdit)?; + let p = &scan.parts; + Ok(Retime { + index, + raw: format!("{}{}{}{}", p.lead, f.raw, p.gap, p.rest), + clamped, + upgraded: f.upgraded, + }) +} + +fn commit(ctx: &mut EditCtx, changes: Vec) { + for c in changes { + ctx.set_raw(c.index, c.raw); + let line = Some((c.index + 1) as f64); + if c.clamped { + ctx.warn(EditWarningCode::TimeClamped, line); + } + if c.upgraded { + ctx.warn(EditWarningCode::StyleUpgraded, line); + } + } +} + +/// Lines whose neighbourhood `canonical` must check after an edit; `None` = every line. +type Touched = Option>; + +fn set_time(ctx: &mut EditCtx, edit: &Json) -> Checked { + let index = ctx.line_index(edit.get("line"))?; + let value = finite(edit.get("seconds"))?; + let change = retime(ctx, index, value, ctx.one_digit_hours())?; + commit(ctx, vec![change]); + Ok(Some(Vec::new())) // a timed line is never empty and keeps its eol +} + +fn shift(ctx: &mut EditCtx, edit: &Json) -> Checked { + let delta = finite(edit.get("seconds"))?; + let targets: Vec = if let Some(list) = edit.get("lines") { + let list = list.as_array().ok_or(InvalidEdit)?; + let set: BTreeSet = + list.iter().map(|v| ctx.line_index(Some(v))).collect::>()?; + set.into_iter().collect() + } else { + let from = match edit.get("from") { + Some(v) => ctx.line_index(Some(v))?, + None => 0, + }; + (from..ctx.lines.len()).collect() + }; + let one_digit = ctx.one_digit_hours(); + let mut changes = Vec::new(); + for i in targets { + let seconds = ctx.lines.get(i).and_then(|l| l.scan.time.as_ref()).map(|t| t.seconds); + if let Some(seconds) = seconds { + changes.push(retime(ctx, i, seconds + delta, one_digit)?); + } + } + commit(ctx, changes); + Ok(Some(Vec::new())) +} + +struct Block { + seconds: f64, + from: usize, + to: usize, +} + +/// R13.9.4: stable sort of blocks (a timed line plus the untimed lines after it). +fn sort_by_time(ctx: &mut EditCtx) -> Touched { + let Some(first) = ctx.lines.iter().position(|l| l.scan.time.is_some()) else { + return Some(Vec::new()); + }; + let mut blocks: Vec = Vec::new(); + for (i, line) in ctx.lines.iter().enumerate().skip(first) { + match (&line.scan.time, blocks.last_mut()) { + (Some(t), _) => blocks.push(Block { seconds: t.seconds, from: i, to: i + 1 }), + (None, Some(block)) => block.to = i + 1, + (None, None) => {} + } + } + // Stable: equal times keep their order. + blocks.sort_by(|x, y| x.seconds.partial_cmp(&y.seconds).unwrap_or(std::cmp::Ordering::Equal)); + let order: Vec = (0..first).chain(blocks.iter().flat_map(|b| b.from..b.to)).collect(); + let eols: Vec = ctx.lines.iter().map(|l| l.eol).collect(); + let mut old: Vec>> = + std::mem::take(&mut ctx.lines).into_iter().map(Some).collect(); + for (slot, src) in order.into_iter().enumerate() { + let Some(mut line) = old.get_mut(src).and_then(Option::take) else { continue }; + line.eol = eols.get(slot).copied().unwrap_or(line.eol); // eol values stay in their slots + line.changed = line.changed || src != slot; + ctx.lines.push(line); + } + None +} + +fn set_rest(ctx: &mut EditCtx, edit: &Json) -> Checked { + let index = ctx.line_index(edit.get("line"))?; + let rest = single_line(edit.get("rest"))?; + let p = &ctx.lines.get(index).ok_or(InvalidEdit)?.scan.parts; + // R13.9 set-rest: a non-empty rest after a time is preceded by whitespace; a gap that does + // not end with R0.2 whitespace (`""`, `]`, `)`) gets one space. + let spaced = p.gap.chars().next_back().is_some_and(is_ws); + let space = if !p.time.is_empty() && !spaced && !rest.is_empty() { " " } else { "" }; + let raw = format!("{}{}{}{space}{rest}", p.lead, p.time, p.gap); + ctx.set_raw(index, raw); + Ok(Some(vec![index])) +} + +/// R13.9.5: the most common non-empty eol (ties: the one seen first in line order), `"\n"` if +/// none. Counts are kept up to date; only a tie needs a look at the lines. +fn common_eol(ctx: &EditCtx) -> Eol { + let best = ctx.eols.iter().copied().max().unwrap_or(0); + if best <= 0 { + return Eol::Lf; + } + let is_top = |eol: Eol| eol_slot(eol).and_then(|s| ctx.eols.get(s)).is_some_and(|n| *n == best); + let top: Vec = [Eol::Lf, Eol::CrLf, Eol::Cr].into_iter().filter(|e| is_top(*e)).collect(); + match top.as_slice() { + [only] => *only, + _ => ctx.lines.iter().map(|l| l.eol).find(|e| is_top(*e)).unwrap_or(Eol::Lf), + } +} + +fn insert(ctx: &mut EditCtx, edit: &Json) -> Checked { + let after = integer(edit.get("after"))?; + if after < 0.0 || after > ctx.lines.len() as f64 { + return Err(InvalidEdit); + } + let after = after as usize; + let text = single_line(edit.get("text"))?; + let eol = common_eol(ctx); + let count = ctx.lines.len(); + // R13.9.5: inserting into an empty text keeps it without a trailing newline. + let mut line = work_line(text.to_string(), if count == 0 { Eol::None } else { eol }, true); + if after == count && ctx.lines.last().is_some_and(|last| last.eol == Eol::None) { + ctx.set_eol(count - 1, eol); + line.eol = Eol::None; + } + ctx.count_line(&line, 1); + ctx.lines.insert(after, line); + Ok(Some(vec![after])) +} + +fn remove(ctx: &mut EditCtx, edit: &Json) -> Checked { + let index = ctx.line_index(edit.get("line"))?; + let gone = ctx.lines.remove(index); + ctx.count_line(&gone, -1); + let count = ctx.lines.len(); + if index == count && ctx.lines.last().is_some_and(|last| last.eol != gone.eol) { + ctx.set_eol(count - 1, gone.eol); // R13.9.5: the deleted last line's eol moves up + } + Ok(Some(vec![index])) +} + +/// A `"\r"` line followed by an empty `"\n"` line reads back as one CRLF line. +fn merge_at(ctx: &mut EditCtx, k: usize) { + let (Some(prev), Some(next)) = (ctx.lines.get(k), ctx.lines.get(k + 1)) else { return }; + if prev.eol != Eol::Cr || !next.raw.is_empty() || next.eol != Eol::Lf { + return; + } + ctx.set_eol(k, Eol::CrLf); + let next = ctx.lines.remove(k + 1); + ctx.count_line(&next, -1); +} + +/// R13.9.5: keep the work lines equal to what `split_lines(join(lines))` would give: a `"\r"` +/// followed by an empty `"\n"` line reads back as one CRLF, and an empty last line without eol is +/// not a line. The lines are canonical before each edit, so only the neighbourhood of the lines +/// the edit touched (and the end) is checked; `None` checks every line (sort-by-time). +fn canonical(ctx: &mut EditCtx, touched: Touched) { + let count = ctx.lines.len(); + // Descending, so a merge at k never moves a pair still to be checked. + let starts: Vec = match touched { + None => (0..count.saturating_sub(1)).rev().collect(), + Some(touched) => { + let mut set: BTreeSet = BTreeSet::new(); + set.extend(count.checked_sub(2)); + for t in touched { + set.extend(t.checked_sub(1)); + set.insert(t); + } + set.into_iter().rev().collect() + } + }; + for k in starts { + merge_at(ctx, k); + } + if ctx.lines.last().is_some_and(|last| last.raw.is_empty() && last.eol == Eol::None) { + if let Some(last) = ctx.lines.pop() { + ctx.count_line(&last, -1); + } + } +} + +fn apply_one(ctx: &mut EditCtx, edit: &Json) -> Checked { + if edit.as_object().is_none() { + return Err(InvalidEdit); + } + match edit.get("op").and_then(Json::as_str) { + Some("set-time") => set_time(ctx, edit), + Some("shift") => shift(ctx, edit), + Some("sort-by-time") => Ok(sort_by_time(ctx)), + Some("set-rest") => set_rest(ctx, edit), + Some("insert") => insert(ctx, edit), + Some("delete") => remove(ctx, edit), + _ => Err(InvalidEdit), + } +} + +/// R13.9.6: an `edit-invalid` warning's line is the edit's integer `line`, else `after`, else +/// none. +fn invalid_line(edit: &Json) -> Option { + ["line", "after"].into_iter().find_map(|key| integer(edit.get(key)).ok()) +} + +/// R13.9: apply `edits` (loose JSON objects) to `text`. Never fails (R13.9.6): an invalid edit +/// changes nothing and warns `edit-invalid`. +pub(crate) fn apply_edits(text: &str, edits: &[Json]) -> RawEditResult { + if edits.is_empty() { + return RawEditResult { text: text.to_string(), changed: Vec::new(), warnings: Vec::new() }; + } + let mut ctx = EditCtx { + lines: Vec::new(), + index: 0, + warnings: Vec::new(), + one_digit: 0, + wide_hours: 0, + eols: [0; 3], + }; + for l in split_lines(text) { + let line = work_line(l.raw, l.eol, false); + ctx.count_line(&line, 1); + ctx.lines.push(line); + } + for (i, edit) in edits.iter().enumerate() { + ctx.index = i; + let warnings_before = ctx.warnings.len(); + // Validation fails before any mutation, so the lines need no rollback (R13.9.6). + match apply_one(&mut ctx, edit) { + Ok(touched) => canonical(&mut ctx, touched), + Err(InvalidEdit) => { + ctx.warnings.truncate(warnings_before); + ctx.warn(EditWarningCode::EditInvalid, invalid_line(edit)); + } + } + } + let changed = + ctx.lines.iter().enumerate().filter(|(_, l)| l.changed).map(|(i, _)| i + 1).collect(); + let mut text = String::new(); + for l in &ctx.lines { + text.push_str(&l.raw); + text.push_str(l.eol.as_str()); + } + RawEditResult { text, changed, warnings: ctx.warnings } +} diff --git a/rust/src/tracklist/emphasis.rs b/rust/src/tracklist/emphasis.rs new file mode 100644 index 0000000..c1702b7 --- /dev/null +++ b/rust/src/tracklist/emphasis.rs @@ -0,0 +1,114 @@ +//! R13.12 Markdown emphasis markers in a tracklist line. + +use crate::words::{at, before, is_ws}; + +/// Length of the maximal run of `*` or `_` at `from` (0 when there is none). +fn run_length(s: &[char], from: usize) -> usize { + match at(s, from) { + Some(ch @ ('*' | '_')) => { + let mut j = from; + while at(s, j) == Some(ch) { + j += 1; + } + j - from + } + _ => 0, + } +} + +/// R13.2.1 / R13.2.3: the length of an emphasis run at `from` (a maximal run of 1 or 2 `*` or +/// `_`), else 0. Used next to the time, where runs are read by position rather than by pairing. +pub(crate) fn emphasis_run(s: &[char], from: usize) -> usize { + let n = run_length(s, from); + if n <= 2 { + n + } else { + 0 + } +} + +/// R13.12.2 outer side: line edge, R0.2 whitespace, a bracket, or a `*` / `_` of another run. +fn is_outer(ch: Option) -> bool { + ch.map_or(true, |c| is_ws(c) || matches!(c, '[' | ']' | '(' | ')' | '*' | '_')) +} + +/// R13.12.2 inner side: a character that is not R0.2 whitespace. +fn is_inner(ch: Option) -> bool { + ch.is_some_and(|c| !is_ws(c)) +} + +/// The stack of a run: one per `*`, `**`, `_`, `__`; longer runs and other characters have none. +fn stack_of(ch: Option, len: usize) -> Option { + match (ch, len) { + (Some('*'), 1) => Some(0), + (Some('*'), 2) => Some(1), + (Some('_'), 1) => Some(2), + (Some('_'), 2) => Some(3), + _ => None, + } +} + +fn mark(marked: &mut [bool], from: usize, len: usize) { + for slot in marked.iter_mut().skip(from).take(len) { + *slot = true; + } +} + +/// R13.12: `raw[from..]` (the line's `rest`) without its emphasis markers. A run of 1 or 2 `*` +/// or `_` closes when the character before it is an inner side and the one after it an outer +/// side, and opens the other way round. A closer pairs with the nearest opener of the same +/// characters; that opener and every opener after it leave the stack. One stack per run (`*`, +/// `**`, `_`, `__`) keeps this linear. Runs before `from` (lead and gap) never pair, except that +/// `open`, a lead run the gap left open (R13.12.4), pairs with a closing run of the same +/// character at the end of the line. +pub(crate) fn without_markers(raw: &[char], from: usize, open: Option) -> String { + let mut marked = vec![false; raw.len()]; + let mut stacks: [Vec; 4] = [Vec::new(), Vec::new(), Vec::new(), Vec::new()]; + let mut i = from; + while i < raw.len() { + let len = run_length(raw, i).max(1); + let own = stack_of(at(raw, i), len); + let prev = before(raw, i); + let next = at(raw, i + len); + let opener = match own { + Some(o) if is_inner(prev) && is_outer(next) => stacks.get_mut(o).and_then(Vec::pop), + _ => None, + }; + if let Some(a) = opener { + mark(&mut marked, a, len); + mark(&mut marked, i, len); + for st in stacks.iter_mut() { + while st.last().is_some_and(|&top| top > a) { + st.pop(); + } + } + } else if let Some(o) = own { + if is_outer(prev) && is_inner(next) { + if let Some(st) = stacks.get_mut(o) { + st.push(i); + } + } + } + i += len; + } + // R13.12.4: the last run of the line, after which there is only R0.2 whitespace. + if let Some(open) = open { + let mut end = raw.len(); + while end > from && before(raw, end).is_some_and(is_ws) { + end -= 1; + } + let mut start = end; + while start > from && before(raw, start) == Some(open) { + start -= 1; + } + if end - start <= 2 && start > from && is_inner(before(raw, start)) { + for slot in marked.iter_mut().take(end).skip(start) { + if *slot { + break; + } + *slot = true; + } + } + } + raw.iter().zip(&marked).skip(from).filter(|(_, m)| !**m).map(|(c, _)| *c).collect() +} diff --git a/rust/src/tracklist/kinds.rs b/rust/src/tracklist/kinds.rs new file mode 100644 index 0000000..81601e9 --- /dev/null +++ b/rust/src/tracklist/kinds.rs @@ -0,0 +1,118 @@ +//! R13.3 line kinds and R13.4.2 candidate lines. + +use std::collections::HashSet; +use std::sync::{Arc, OnceLock}; + +use crate::data::{HEADER_WORDS_DATA, LAYERED_WORDS_DATA, MARKER_WORDS_DATA}; +use crate::types::{ArtistRole, RawTrack, Warning}; +use crate::words::{ + ascii_lower, at, chars, in_vocab, is_whitespace, is_ws, split_words_chars, string, sub, + PhraseTable, +}; + +fn header_words() -> &'static HashSet<&'static str> { + static WORDS: OnceLock> = OnceLock::new(); + WORDS.get_or_init(|| HEADER_WORDS_DATA.get("words").strings().collect()) +} + +fn layered_words() -> &'static HashSet<&'static str> { + static WORDS: OnceLock> = OnceLock::new(); + WORDS.get_or_init(|| LAYERED_WORDS_DATA.get("words").strings().collect()) +} + +/// `data/marker-words.json` plus `options.markerWords` (R13.10). Entries are split into words the +/// same way as the track part (R13.3), so `shout-out` matches the words `shout`, `out`. +pub(crate) fn marker_table(extra: &[String]) -> Arc> { + static DEFAULT: OnceLock>> = OnceLock::new(); + let entry = |w: &str| (marker_words(w).join(" "), ()); + let base = MARKER_WORDS_DATA.get("words").strings().map(entry); + if extra.is_empty() { + return DEFAULT.get_or_init(|| Arc::new(PhraseTable::new(base))).clone(); + } + Arc::new(PhraseTable::new(base.chain(extra.iter().map(|w| entry(w))))) +} + +fn is_marker_break(ch: char) -> bool { + ch == '/' || ch == '-' || is_ws(ch) +} + +fn is_bracket(ch: char) -> bool { + matches!(ch, '(' | ')' | '[' | ']' | '{' | '}') +} + +/// R13.3 marker words: split on R0.2 whitespace, `/` and `-`, then strip leading and trailing +/// `()[]{}` from each piece; empty pieces are dropped. Word keys (R0.3) are applied on matching. +pub(crate) fn marker_words(text: &str) -> Vec { + text.split(is_marker_break) + .map(|piece| piece.trim_matches(is_bracket)) + .filter(|piece| !piece.is_empty()) + .map(str::to_string) + .collect() +} + +/// R13.13: the length of a layered prefix at the start of the line text: R0.2 whitespace, a word +/// of `data/layered-words.json` (word key, R0.3), then R0.2 whitespace, with more text after it. +/// 0 when there is none. +pub(crate) fn layered_prefix(text: &[char]) -> usize { + let mut i = 0; + while is_whitespace(at(text, i)) { + i += 1; + } + let mut j = i; + while j < text.len() && !is_whitespace(at(text, j)) { + j += 1; + } + if j == i || j == text.len() || !in_vocab(&string(sub(text, i, j)), layered_words()) { + return 0; + } + while is_whitespace(at(text, j)) { + j += 1; + } + if j < text.len() { + j + } else { + 0 + } +} + +/// R13.3.1 +pub(crate) fn is_blank(raw: &str) -> bool { + raw.chars().all(is_ws) +} + +fn trim_ws(s: &str) -> &str { + s.trim_matches(is_ws) +} + +/// R13.3.3 link: `http://`, `https://` or `www.` (ASCII case-insensitive). +pub(crate) fn is_link(rest: &str) -> bool { + let head: String = trim_ws(rest).chars().take(8).collect(); + let t = ascii_lower(&head); + t.starts_with("http://") || t.starts_with("https://") || t.starts_with("www.") +} + +/// R13.3.3 header: ends with `:`, or a header word followed by at most one more word. +pub(crate) fn is_header(rest: &str) -> bool { + let t = trim_ws(rest); + if t.ends_with(':') { + return true; + } + let words = split_words_chars(&chars(t)); + words.len() <= 2 && words.first().is_some_and(|first| in_vocab(first, header_words())) +} + +/// R13.3: any marker word (or multi-word entry) among the track part's marker words. +pub(crate) fn has_marker_word(track_part: &str, markers: &PhraseTable<()>) -> bool { + let words = marker_words(track_part); + (0..words.len()).any(|i| markers.match_at(&words, i).is_some()) +} + +/// R13.3: the track part has a separator: it is not empty after R1 (`empty`), its parse did not +/// warn `noSeparator`, and the artist side is not empty (at least one primary artist, or +/// `flags.unknownArtist`). +pub(crate) fn has_separator(track: &RawTrack, empty: bool) -> bool { + if empty || track.warnings.contains(&Warning::NoSeparator) { + return false; + } + track.flags.unknown_artist || track.artists.iter().any(|a| a.role == ArtistRole::Primary) +} diff --git a/rust/src/tracklist/mod.rs b/rust/src/tracklist/mod.rs new file mode 100644 index 0000000..c040ec7 --- /dev/null +++ b/rust/src/tracklist/mod.rs @@ -0,0 +1,126 @@ +//! Multi-line tracklists (SPEC R13): [`parse_tracklist`] and [`apply_edits`]. +//! +//! A tracklist is the text people paste under a mix: one track per line, usually with a cue +//! time, sometimes with headers, links and notes in between. [`parse_tracklist`] gives one +//! [`TracklistEntry`] per line and never changes or drops a line; [`apply_edits`] rewrites the +//! text (set a time, shift, sort, insert, delete) and leaves every other byte alone. +//! +//! Guides: and +//! . +//! +//! ``` +//! use trackparse::tracklist::{parse_tracklist, EntryKind}; +//! +//! let list = parse_tracklist("Tracklist:\n\n00:00 Intro\n01:30 Noisia - Stigma\n"); +//! let kinds: Vec = list.entries.iter().map(|e| e.kind).collect(); +//! assert_eq!(kinds, [EntryKind::Header, EntryKind::Blank, EntryKind::Marker, EntryKind::Track]); +//! assert_eq!(list.stats.timed, 2); +//! assert!(list.warnings.is_empty()); +//! ``` +//! +//! Rule IDs (`R13.2`…) refer to the spec. The output is byte-identical to `trackparse/tracklist` +//! in the JavaScript package and `trackparse.tracklist` in Python. + +mod edits; +mod emphasis; +mod kinds; +mod options; +mod parse; +mod positions; +mod split; +mod times; +mod types; +mod warnings; + +pub use options::TracklistOptions; +pub use types::{ + Edit, EditResult, EditWarning, EditWarningCode, EntryKind, Eol, Parts, Severity, Stats, + Suggestion, TimeValue, Tracklist, TracklistEntry, TracklistWarning, WarningCode, +}; + +use crate::json::Json; +use crate::types::ToJson; + +/// Parse a multi-line tracklist with the default options (R13). +/// +/// The text is split at LF, CRLF and CR only; every line becomes one entry, and the entries' +/// `raw + eol`, joined, are the text again (R13.1.2). Never panics. +/// +/// ``` +/// use trackparse::tracklist::{parse_tracklist, EntryKind}; +/// +/// let list = parse_tracklist("00:00 Noisia - Stigma\n[03:45] Phace & Misanthrop - Desert Orgy\n"); +/// assert_eq!(list.stats.tracks, 2); +/// let second = &list.entries[1]; +/// assert_eq!(second.kind, EntryKind::Track); +/// assert_eq!(second.time.as_ref().map(|t| t.seconds), Some(225.0)); +/// let track = second.track.as_ref().unwrap(); +/// assert_eq!(track.artists.len(), 2); +/// assert_eq!(track.title, "Desert Orgy"); +/// ``` +pub fn parse_tracklist(text: &str) -> Tracklist { + parse_tracklist_with(text, &TracklistOptions::default()) +} + +/// [`parse_tracklist`] with options (R13.10). +/// +/// ``` +/// use trackparse::tracklist::{parse_tracklist_with, TracklistOptions, WarningCode}; +/// +/// let options = TracklistOptions::new().audio_seconds(3600.0); +/// let list = parse_tracklist_with("00:00 A - B\n1:02:03 C - D", &options); +/// assert_eq!(list.warnings[0].code, WarningCode::TimeAfterAudioEnd); +/// assert_eq!(list.warnings[0].line, 2); +/// ``` +pub fn parse_tracklist_with(text: &str, options: &TracklistOptions) -> Tracklist { + parse::parse_tracklist(text, &options::resolve_typed(options)).into_tracklist() +} + +/// Apply edits to a tracklist text (R13.9), in order, each to the result of the previous one. +/// +/// Lines no edit wrote stay byte-identical. Never panics: an edit that cannot be applied changes +/// nothing and is reported as [`EditWarningCode::EditInvalid`]. +/// +/// ``` +/// use trackparse::tracklist::{apply_edits, Edit}; +/// +/// let text = "00:00 Noisia - Stigma\n03:45 Phace - Cold Champagne\n"; +/// let edits = [ +/// Edit::shift_from(30.0, 2), +/// Edit::set_rest(1, "Noisia - Stigma (Neosignal Remix)"), +/// ]; +/// let result = apply_edits(text, &edits); +/// assert_eq!(result.text, "00:00 Noisia - Stigma (Neosignal Remix)\n04:15 Phace - Cold Champagne\n"); +/// assert_eq!(result.changed, [1, 2]); +/// assert!(result.warnings.is_empty()); +/// ``` +pub fn apply_edits(text: &str, edits: &[Edit]) -> EditResult { + let edits: Vec = edits.iter().map(ToJson::to_json_value).collect(); + edits::apply_edits(text, &edits).into_result() +} + +/// [`apply_edits`] with options. The options are accepted for symmetry with the other ports +/// (R13.10); edits do not depend on them today. +/// +/// ``` +/// use trackparse::tracklist::{apply_edits, apply_edits_with, Edit, TracklistOptions}; +/// +/// let (text, edits) = ("00:00 A - B\n01:00 C - D", [Edit::shift(5.0)]); +/// let result = apply_edits_with(text, &edits, &TracklistOptions::new()); +/// assert_eq!(result.text, "00:05 A - B\n01:05 C - D"); +/// assert_eq!(result, apply_edits(text, &edits)); +/// ``` +pub fn apply_edits_with(text: &str, edits: &[Edit], options: &TracklistOptions) -> EditResult { + let _ = options; + apply_edits(text, edits) +} + +/// `parseTracklist` for the JSON door (`wire`): loose options, the pipeline's own tracks. +pub(crate) fn wire_parse(text: &str, options: &Json) -> Json { + parse::parse_tracklist(text, &options::resolve_json(options)).to_json_value() +} + +/// `applyEdits` for the JSON door (`wire`): `edits` is anything; only an array has edits. +pub(crate) fn wire_edits(text: &str, edits: &Json) -> Json { + edits::apply_edits(text, edits.as_array().unwrap_or(&[])).to_json_value() +} diff --git a/rust/src/tracklist/options.rs b/rust/src/tracklist/options.rs new file mode 100644 index 0000000..61a5dce --- /dev/null +++ b/rust/src/tracklist/options.rs @@ -0,0 +1,172 @@ +//! R13.10: tracklist options, sanitised so bad values are ignored (R0.8). + +use crate::json::Json; +use crate::options::{ + string_list, KeywordOptions, ModeOption, ParseOptions, Requested, Resolved, SplitAnd, + SplitAndMode, +}; +use crate::types::Mode; + +/// Options of [`parse_tracklist_with`](super::parse_tracklist_with) (R13.10). +/// +/// ``` +/// use trackparse::tracklist::{parse_tracklist_with, TracklistOptions, WarningCode}; +/// +/// let options = TracklistOptions::new() +/// .audio_seconds(3600.0) +/// .marker_words(["Outro Speech"]) +/// .known_artists(["Chase & Status"]); +/// let list = parse_tracklist_with("00:00 Chase & Status - Blind Faith\n1:00:05 A - B", &options); +/// assert_eq!(list.entries[0].track.as_ref().unwrap().artists.len(), 1); +/// assert_eq!(list.warnings[0].code, WarningCode::TimeAfterAudioEnd); +/// ``` +#[derive(Debug, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(default, rename_all = "camelCase"))] +#[non_exhaustive] +pub struct TracklistOptions { + /// Per-line parse mode; default [`ModeOption::Tracklist`]. + pub mode: ModeOption, + /// Names that must never be split (R7.3a). + pub known_artists: Vec, + /// When `and` splits a credit list; default [`SplitAnd::Auto`]. + pub split_and: SplitAnd, + /// Extra vocabulary for the per-line parse. + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] + pub keywords: Option, + /// Length of the audio in seconds; enables `time-after-audio-end`. A negative or non-finite + /// value is ignored. + #[cfg_attr( + feature = "serde", + serde( + skip_serializing_if = "Option::is_none", + serialize_with = "crate::serde_support::opt_seconds" + ) + )] + pub audio_seconds: Option, + /// Extra marker words (R13.3): a line that is only such a word is a `Marker`. + pub marker_words: Vec, +} + +impl Default for TracklistOptions { + fn default() -> Self { + TracklistOptions { + mode: ModeOption::Tracklist, + known_artists: Vec::new(), + split_and: SplitAnd::Auto, + keywords: None, + audio_seconds: None, + marker_words: Vec::new(), + } + } +} + +impl TracklistOptions { + /// The default options. + pub fn new() -> Self { + Self::default() + } + + /// Set the per-line parse mode. + pub fn mode(mut self, mode: ModeOption) -> Self { + self.mode = mode; + self + } + + /// Set the names that must never be split. + pub fn known_artists(mut self, names: I) -> Self + where + I: IntoIterator, + S: Into, + { + self.known_artists = names.into_iter().map(Into::into).collect(); + self + } + + /// Set when `and` splits a credit list. + pub fn split_and(mut self, split_and: SplitAnd) -> Self { + self.split_and = split_and; + self + } + + /// Set the extra vocabulary. + pub fn keywords(mut self, keywords: KeywordOptions) -> Self { + self.keywords = Some(keywords); + self + } + + /// Set the length of the audio in seconds. + pub fn audio_seconds(mut self, seconds: f64) -> Self { + self.audio_seconds = Some(seconds); + self + } + + /// Set the extra marker words. + pub fn marker_words(mut self, words: I) -> Self + where + I: IntoIterator, + S: Into, + { + self.marker_words = words.into_iter().map(Into::into).collect(); + self + } +} + +pub(crate) struct ResolvedOptions { + /// Options for the per-line parse. + pub parse: Resolved, + pub audio_seconds: Option, + pub marker_words: Vec, +} + +/// A JS `number` view of a JSON value: `None` unless it is a number (a bool is not one). +pub(crate) fn js_number(value: Option<&Json>) -> Option { + match value { + Some(Json::Num(n)) => Some(*n), + _ => None, + } +} + +fn audio(seconds: Option) -> Option { + seconds.filter(|a| a.is_finite() && *a >= 0.0) +} + +/// Loose JSON options, with the fallbacks of the JS reference. +pub(crate) fn resolve_json(options: &Json) -> ResolvedOptions { + // `mode`, `splitAnd`, `knownArtists` and `keywords` are passed on only when well-formed; + // `uploader` is not a tracklist option. + let mut parse = Resolved::from_json(options); + parse.uploader = None; + parse.mode = match options.get("mode").and_then(Json::as_str) { + Some("auto") => Requested::Auto, + Some(name) => { + Mode::from_name(name).map_or(Requested::Mode(Mode::Tracklist), Requested::Mode) + } + None => Requested::Mode(Mode::Tracklist), + }; + parse.split_and = match options.get("splitAnd").and_then(Json::as_str) { + Some("always") => SplitAndMode::Always, + Some("never") => SplitAndMode::Never, + _ => SplitAndMode::Auto, + }; + ResolvedOptions { + parse, + audio_seconds: audio(js_number(options.get("audioSeconds"))), + marker_words: string_list(options.get("markerWords")), + } +} + +pub(crate) fn resolve_typed(options: &TracklistOptions) -> ResolvedOptions { + let parse = ParseOptions { + mode: options.mode, + uploader: None, + known_artists: options.known_artists.clone(), + split_and: options.split_and, + keywords: options.keywords.clone(), + }; + ResolvedOptions { + parse: Resolved::from_typed(&parse), + audio_seconds: audio(options.audio_seconds), + marker_words: options.marker_words.clone(), + } +} diff --git a/rust/src/tracklist/parse.rs b/rust/src/tracklist/parse.rs new file mode 100644 index 0000000..8dfd9ac --- /dev/null +++ b/rust/src/tracklist/parse.rs @@ -0,0 +1,215 @@ +//! R13.1–R13.8: parse_tracklist. + +use crate::data::SPEC_VERSION; +use crate::json::Json; +use crate::parser::{LineProbe, ListParser}; +use crate::types::{Position, RawTrack}; +use crate::words::{chars, string, tail}; + +use super::kinds::{ + has_marker_word, has_separator, is_blank, is_header, is_link, layered_prefix, marker_table, +}; +use super::options::ResolvedOptions; +use super::positions::{bare_candidate, confirm_positions, BareCandidate}; +use super::split::{split_lines, Line}; +use super::times::{scan_time, TimeScan}; +use super::types::{tracklist_json, EntryKind, Stats, Tracklist, TracklistEntry, TracklistWarning}; +use super::warnings::{tracklist_warnings, WarningInput}; + +struct Row<'a> { + line: Line, + scan: TimeScan, + /// R13.4.1 line text: rest without emphasis markers (R13.12) and a layered prefix (R13.13). + text: String, + /// R13.13 + layered: bool, + blank: bool, + /// R13.4.2 + candidate: bool, + dash: bool, + probe: Option>, + bare: Option, + track: Option, + /// R13.3: the track part has a separator. + separated: bool, + /// R13.3: the track part has a marker word. + marker: bool, +} + +/// A parsed tracklist with the pipeline's own tracks (see `RawTrack`): `entries[i].track` is +/// empty and `tracks[i]` holds it. The wire writes this form; the typed API converts it. +pub(crate) struct RawTracklist { + entries: Vec, + tracks: Vec>, + warnings: Vec, + stats: Stats, +} + +impl RawTracklist { + pub(crate) fn into_tracklist(self) -> Tracklist { + let mut entries = self.entries; + for (entry, track) in entries.iter_mut().zip(self.tracks) { + entry.track = track.map(RawTrack::into_track); + } + Tracklist { + spec_version: SPEC_VERSION.to_string(), + entries, + warnings: self.warnings, + stats: self.stats, + } + } + + /// The spec's JSON form, written exactly as the JS reference would. + pub(crate) fn to_json_value(&self) -> Json { + let entries = self + .entries + .iter() + .zip(&self.tracks) + .map(|(e, t)| e.json_with(t.as_ref().map_or(Json::Null, RawTrack::to_json_value))) + .collect(); + tracklist_json(SPEC_VERSION, entries, &self.warnings, &self.stats) + } +} + +pub(crate) fn parse_tracklist(text: &str, opts: &ResolvedOptions) -> RawTracklist { + let markers = marker_table(&opts.marker_words); + let lp = ListParser::new(opts.parse.clone()); + + // R13.2 time scan. R13.4.2: a candidate line has a time or a spaced dash in the skeleton R6 + // searches (after R2/R4); the probe runs R1/R2/R4 once and is finished below (R13.4.1). + let mut rows: Vec> = split_lines(text) + .into_iter() + .map(|line| { + let scan = scan_time(&line.raw); + let blank = is_blank(&line.raw); + let scanned = chars(&scan.text); + let layered = if blank { 0 } else { layered_prefix(&scanned) }; + let mut row = Row { + line, + scan, + text: string(tail(&scanned, layered)), + layered: layered > 0, + blank, + candidate: false, + dash: false, + probe: None, + bare: None, + track: None, + separated: false, + marker: false, + }; + if blank { + return row; + } + let probe = lp.probe(&row.text); // R13.4.1 + row.dash = probe.spaced_dash; + row.candidate = row.scan.time.is_some() || row.dash; + // R13.5 / R13.13.3: a layered line never has a bare position. + row.bare = if row.layered { None } else { bare_candidate(&row.text, probe.position) }; + row.probe = Some(probe); + row + }) + .collect(); + let candidates = rows.iter().filter(|r| r.candidate).count(); + let dashes = rows.iter().filter(|r| r.candidate && r.dash).count(); + let list_context = candidates > 0 && 2 * dashes >= candidates; + + // R13.5: confirmed bare positions are removed before parsing. R13.4.1: one parse per line. + // R13.13.3: layered lines are not neighbours for the R13.5 search. + let confirmed = confirm_positions( + &rows.iter().map(|r| r.bare.as_ref().map(|b| b.number)).collect::>(), + &rows.iter().map(|r| r.candidate && !r.layered).collect::>(), + ); + for (r, is_position) in rows.iter_mut().zip(confirmed) { + let Some(own_probe) = r.probe.take() else { continue }; + let bare = if is_position { r.bare.as_ref() } else { None }; + let probe = match bare { + Some(b) => lp.probe(&b.stripped), + None => own_probe, + }; + r.marker = has_marker_word(bare.map_or(&r.text, |b| &b.stripped), &markers); + let empty = probe.empty; + // R13.4.2: the R6.10 tight dash only on timed lines without a marker word. + let mut track = probe.finish(list_context && r.scan.time.is_some() && !r.marker); + if let Some(b) = bare { + track.position = Some(Position { raw: b.raw.clone(), number: b.number }); + } + r.separated = has_separator(&track, empty); + r.track = Some(track); + } + + // R13.3 + let mut entries = Vec::with_capacity(rows.len()); + let mut tracks = Vec::with_capacity(rows.len()); + let mut positions = Vec::with_capacity(rows.len()); + let mut invalid = Vec::with_capacity(rows.len()); + let mut unparsed = Vec::with_capacity(rows.len()); + for (i, r) in rows.into_iter().enumerate() { + let kind = kind_of(&r); + let keep = kind == EntryKind::Track || kind == EntryKind::Marker; + let track = if keep { r.track } else { None }; + positions.push(track.as_ref().and_then(|t| t.position.as_ref()).map(|p| p.number)); + invalid.push(r.scan.invalid); + // R13.7 line-unparsed: a track entry whose track part has no separator (R13.3). + unparsed.push(kind == EntryKind::Track && !r.separated); + entries.push(TracklistEntry { + line: i + 1, + kind, + eol: r.line.eol, + raw: r.line.raw, + parts: r.scan.parts, + time: r.scan.time, + track: None, + layered: r.layered, + }); + tracks.push(track); + } + + let warnings = tracklist_warnings(&WarningInput { + entries: &entries, + positions: &positions, + invalid: &invalid, + unparsed: &unparsed, + audio_seconds: opts.audio_seconds, + }); + let stats = stats_of(&entries); + RawTracklist { entries, tracks, warnings, stats } +} + +fn kind_of(r: &Row<'_>) -> EntryKind { + if r.blank || r.track.is_none() { + return EntryKind::Blank; + } + let marker = !r.separated && r.marker; + if r.scan.time.is_some() { + return if marker { EntryKind::Marker } else { EntryKind::Track }; + } + if is_link(&r.text) { + EntryKind::Link + } else if is_header(&r.text) { + EntryKind::Header + } else if marker { + EntryKind::Marker + } else if r.separated { + EntryKind::Track + } else { + EntryKind::Note + } +} + +fn stats_of(entries: &[TracklistEntry]) -> Stats { + let mut stats = Stats { lines: entries.len(), ..Stats::default() }; + for e in entries { + match e.kind { + EntryKind::Track => stats.tracks += 1, + EntryKind::Marker => stats.markers += 1, + _ => {} + } + if let Some(t) = &e.time { + stats.timed += 1; + stats.first_time.get_or_insert(t.seconds); + stats.last_time = Some(t.seconds); + } + } + stats +} diff --git a/rust/src/tracklist/positions.rs b/rust/src/tracklist/positions.rs new file mode 100644 index 0000000..6c399de --- /dev/null +++ b/rust/src/tracklist/positions.rs @@ -0,0 +1,62 @@ +//! R13.5 bare positions. + +use crate::digits::{digit_run, digits_value}; +use crate::words::{at, chars, is_ws, string, sub, tail}; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) struct BareCandidate { + pub raw: String, + pub number: u32, + /// The track part with the digits and the following space removed. + pub stripped: String, +} + +/// R13.5: a track part starting with 1–3 ASCII digits and a space (U+0020 only), where R4.2 took +/// no position (`position_taken`), is a bare candidate. The remainder must be non-empty. +pub(crate) fn bare_candidate(rest: &str, position_taken: bool) -> Option { + if position_taken { + return None; + } + let rest = &chars(rest); + let n = digit_run(rest, 0); + if !(1..=3).contains(&n) || at(rest, n) != Some(' ') { + return None; + } + let stripped = tail(rest, n + 1); + if stripped.iter().all(|c| is_ws(*c)) { + return None; + } + let raw = sub(rest, 0, n); + Some(BareCandidate { raw: string(raw), number: digits_value(raw), stripped: string(stripped) }) +} + +/// R13.5: candidate `i` is a position when the nearest preceding or the nearest following +/// candidate line (R13.4.2) also has a bare candidate equal to `N - 1` or `N + 1`. `bare` holds +/// each line's bare number. Linear time. +pub(crate) fn confirm_positions(bare: &[Option], candidate_line: &[bool]) -> Vec { + let n = bare.len(); + let is_candidate = |i: usize| candidate_line.get(i).copied().unwrap_or(false); + let mut prev: Vec> = vec![None; n]; + let mut next: Vec> = vec![None; n]; + let mut last = None; + for (i, slot) in prev.iter_mut().enumerate() { + *slot = last; + if is_candidate(i) { + last = Some(i); + } + } + last = None; + for (i, slot) in next.iter_mut().enumerate().rev() { + *slot = last; + if is_candidate(i) { + last = Some(i); + } + } + let adjacent = |b: u32, j: Option| { + j.and_then(|j| bare.get(j).copied().flatten()).is_some_and(|o| o + 1 == b || o == b + 1) + }; + bare.iter() + .zip(prev.iter().zip(&next)) + .map(|(b, (p, nx))| b.is_some_and(|b| adjacent(b, *p) || adjacent(b, *nx))) + .collect() +} diff --git a/rust/src/tracklist/split.rs b/rust/src/tracklist/split.rs new file mode 100644 index 0000000..5a132aa --- /dev/null +++ b/rust/src/tracklist/split.rs @@ -0,0 +1,45 @@ +//! R13.1: line split (LF, CRLF, CR only) with the lossless guarantee. + +use super::types::Eol; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) struct Line { + pub raw: String, + pub eol: Eol, +} + +/// R13.1.1: split at LF, CRLF and CR. U+2028/U+2029, U+0085 and other R0.2 characters are not +/// line breaks. A trailing empty segment after the final terminator is not a line; `""` has no +/// lines. R13.1.2: the lines' `raw + eol`, joined, are the text. +pub(crate) fn split_lines(text: &str) -> Vec { + let bytes = text.as_bytes(); + let mut lines = Vec::new(); + let mut start = 0; + let mut i = 0; + // LF and CR are ASCII, so every cut is at a character boundary. + let piece = |a: usize, b: usize| text.get(a..b).unwrap_or("").to_string(); + while let Some(&c) = bytes.get(i) { + if c == 0x0a { + lines.push(Line { raw: piece(start, i), eol: Eol::Lf }); + start = i + 1; + } else if c == 0x0d { + if bytes.get(i + 1) == Some(&0x0a) { + lines.push(Line { raw: piece(start, i), eol: Eol::CrLf }); + i += 1; + } else { + lines.push(Line { raw: piece(start, i), eol: Eol::Cr }); + } + start = i + 1; + } + i += 1; + } + if start < bytes.len() { + lines.push(Line { raw: piece(start, bytes.len()), eol: Eol::None }); + } + lines +} + +/// A line break inside a single-line value (R13.9.5, R13.9.6). +pub(crate) fn has_line_break(s: &str) -> bool { + s.bytes().any(|c| c == 0x0a || c == 0x0d) +} diff --git a/rust/src/tracklist/times.rs b/rust/src/tracklist/times.rs new file mode 100644 index 0000000..8e28cd8 --- /dev/null +++ b/rust/src/tracklist/times.rs @@ -0,0 +1,360 @@ +//! R13.2: the tracklist time scanner (separate from R4.1) and R13.9.2 time formatting. + +use crate::digits::{digit_run, digits_value}; +use crate::words::{at, chars, is_digit, is_whitespace, string, sub, tail}; + +use super::emphasis::{emphasis_run, without_markers}; +use super::types::{Parts, TimeValue}; + +/// JS `Number.MAX_SAFE_INTEGER`. +const MAX_SAFE_INTEGER: f64 = 9_007_199_254_740_991.0; + +/// The written shape of a time, kept by edits (R13.9.2). +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) struct TimeStyle { + pub hours: bool, + /// Digits written for the hours (minimum width), 0 without hours. + pub hour_width: usize, + /// Digits written for the minutes (minimum width). + pub minute_width: usize, + /// R13.9.2: two-part time already at 60 minutes or more; it stays two-part when it grows. + pub long_minutes: bool, + /// `.` or `,` when the time has a fraction. + pub frac_sep: Option, + pub frac_digits: usize, +} + +#[derive(Debug, Clone, PartialEq)] +pub(crate) struct TimeScan { + pub parts: Parts, + pub time: Option, + pub style: Option, + /// R13.2.4: a `digits:digits` shape after lead that fails R13.2.2. + pub invalid: bool, + /// R13.12: `rest` without its paired emphasis markers (the line text, before R13.13 / R13.5). + pub text: String, +} + +/// R13.2.3 separators after the time. +fn is_gap_separator(ch: Option) -> bool { + matches!(ch, Some('-' | '–' | '—' | '|' | '.' | ':')) +} + +fn skip_whitespace(s: &[char], from: usize) -> usize { + let mut i = from; + while is_whitespace(at(s, i)) { + i += 1; + } + i +} + +/// R13.2.1 bullets (before a time, or alone on a line without one). +fn is_bullet(ch: Option) -> bool { + matches!(ch, Some('-' | '–' | '—' | '*' | '•')) +} + +/// R13.1.3 / R13.2.1: a line without a time. `lead` holds an optional bullet: R0.2 whitespace, +/// one of `-` `–` `—` `*` `•`, then at least one R0.2 whitespace (all of it); `rest` is the +/// remainder. +fn untimed(raw: &[char], invalid: bool) -> TimeScan { + let start = skip_whitespace(raw, 0); + let mut lead = 0; + if is_bullet(at(raw, start)) && is_whitespace(at(raw, start + 1)) { + lead = skip_whitespace(raw, start + 1); + } + TimeScan { + parts: Parts { + lead: string(sub(raw, 0, lead)), + time: String::new(), + gap: String::new(), + rest: string(tail(raw, lead)), + }, + time: None, + style: None, + invalid, + text: without_markers(raw, lead, None), + } +} + +/// R13.2.3: past a closing run for an opening run of `open` (same character, 1 or 2 long). +fn closing_run(raw: &[char], from: usize, open: Option) -> usize { + if open.is_some() && at(raw, from) == open { + from + emphasis_run(raw, from) + } else { + from + } +} + +/// `int.frac` parsed as one decimal literal, so every port gets the same double. +pub(crate) fn seconds_of(whole: u32, frac: &str) -> f64 { + if frac.is_empty() { + f64::from(whole) + } else { + format!("{whole}.{frac}").parse().unwrap_or(f64::from(whole)) + } +} + +struct Shape<'a> { + /// The digit runs between the colons (2 or more). + parts: Vec<&'a [char]>, + end: usize, +} + +/// R13.2.4: the maximal `digits(:digits)+` run at `from`, or `None`. +fn shape_at(s: &[char], from: usize) -> Option> { + let na = digit_run(s, from); + if na == 0 || at(s, from + na) != Some(':') || !is_digit(at(s, from + na + 1)) { + return None; + } + let mut parts = vec![sub(s, from, from + na)]; + let mut end = from + na; + while at(s, end) == Some(':') && is_digit(at(s, end + 1)) { + let n = digit_run(s, end + 1); + parts.push(sub(s, end + 1, end + 1 + n)); + end += 1 + n; + } + Some(Shape { parts, end }) +} + +/// R13.2.2 validity: whole seconds of `A:B` / `A:B:C` (no other part count), or `None`. +pub(crate) fn shape_seconds(parts: &[&[char]]) -> Option { + match parts { + [a, b, c] => { + if a.is_empty() || a.len() > 2 || b.len() != 2 || c.len() != 2 { + return None; + } + let (m, sec) = (digits_value(b), digits_value(c)); + if m > 59 || sec > 59 { + return None; + } + Some(digits_value(a) * 3600 + m * 60 + sec) + } + [a, b] => { + if a.is_empty() || a.len() > 3 || b.len() != 2 { + return None; + } + let sec = digits_value(b); + if sec > 59 { + return None; + } + Some(digits_value(a) * 60 + sec) + } + _ => None, + } +} + +fn starts_with(s: &[char], from: usize, word: &str) -> bool { + let n = word.chars().count(); + sub(s, from, from + n).iter().copied().eq(word.chars()) +} + +/// R13.2: lead, time and gap at the start of `raw`; the rest is everything after. +pub(crate) fn scan_time(raw: &str) -> TimeScan { + let raw = &chars(raw); + // R13.2.1 lead: whitespace, an optional bullet, an optional emphasis run, an optional `[` / + // `(`, then (after a bracket) another optional emphasis run. A run counts only when the next + // character is a bracket (first run) or a digit. + let mut i = skip_whitespace(raw, 0); + if is_bullet(at(raw, i)) && is_whitespace(at(raw, i + 1)) { + i = skip_whitespace(raw, i + 1); + } + let mut outer_open: Option = None; + let mut n = emphasis_run(raw, i); + if n > 0 && (matches!(at(raw, i + n), Some('[' | '(')) || is_digit(at(raw, i + n))) { + outer_open = at(raw, i); + i += n; + } + let closer = match at(raw, i) { + Some('[') => Some(']'), + Some('(') => Some(')'), + _ => None, + }; + let mut inner_open: Option = None; + if closer.is_some() { + i += 1; + n = emphasis_run(raw, i); + if n > 0 && is_digit(at(raw, i + n)) { + inner_open = at(raw, i); + i += n; + } + } + let lead_end = i; + + // R13.2.2 time + let Some(shape) = shape_at(raw, i) else { return untimed(raw, false) }; + let Some(whole) = shape_seconds(&shape.parts) else { return untimed(raw, true) }; // R13.2.4 + let mut j = shape.end; + let mut frac_sep: Option = None; + let mut frac = String::new(); + if let Some(sep @ ('.' | ',')) = at(raw, j) { + let n = digit_run(raw, j + 1); + if (1..=3).contains(&n) { + frac_sep = Some(sep); + frac = string(sub(raw, j + 1, j + 1 + n)); + j += 1 + n; + } + } + let time_end = j; + + // R13.2.3 gap: closing runs for the lead's runs (same character), around the closing bracket. + let follows_time = + |k: usize| k >= raw.len() || is_whitespace(at(raw, k)) || is_gap_separator(at(raw, k)); + // R13.12.4: a lead run the gap leaves open may pair with a run at the end of the line. + let mut open: Option = None; + if let Some(closer) = closer { + let mut k = closing_run(raw, j, inner_open); + if k == j { + open = inner_open; + } + j = k; + if at(raw, j) != Some(closer) { + return untimed(raw, false); + } + j += 1; + k = closing_run(raw, j, outer_open); + if k > j && follows_time(k) { + j = k; + } else { + open = outer_open.or(open); + } + } else { + let k = closing_run(raw, j, outer_open); + if k == j { + open = outer_open; + } + j = k; + if !follows_time(j) { + return untimed(raw, false); + } + } + j = skip_whitespace(raw, j); + if is_gap_separator(at(raw, j)) { + j = skip_whitespace(raw, j + 1); + } + if starts_with(raw, j, "==>") { + j = skip_whitespace(raw, j + 3); + } else if starts_with(raw, j, "=>") { + j = skip_whitespace(raw, j + 2); + } + + let time_raw = string(sub(raw, lead_end, time_end)); + let hours = shape.parts.len() == 3; + let first = shape.parts.first().copied().unwrap_or(&[]); + let second = shape.parts.get(1).copied().unwrap_or(&[]); + // R13.9.2 long-minute style: two parts with 60 minutes or more. + let long_minutes = !hours && digits_value(first) >= 60; + TimeScan { + parts: Parts { + lead: string(sub(raw, 0, lead_end)), + time: time_raw.clone(), + gap: string(sub(raw, time_end, j)), + rest: string(tail(raw, j)), + }, + time: Some(TimeValue { raw: time_raw, seconds: seconds_of(whole, &frac) }), + style: Some(TimeStyle { + hours, + hour_width: if hours { first.len() } else { 0 }, + // R13.9.2: a long-minute time's minimum minute width is min(width, 2), so it never + // keeps 3 minute digits once it is short again (`125:30` − 7000 s → `08:50`). + minute_width: if hours { + second.len() + } else if long_minutes { + first.len().min(2) + } else { + first.len() + }, + long_minutes, + frac_sep, + frac_digits: frac.chars().count(), + }), + invalid: false, + text: without_markers(raw, j, open), + } +} + +fn pad(n: u64, width: usize) -> String { + format!("{n:0width$}") +} + +pub(crate) struct FormattedTime { + pub raw: String, + pub upgraded: bool, +} + +/// R13.9.2: write `seconds` (finite, ≥ 0) in `style`. Values are rounded half up to the fraction +/// precision (`floor(v·10^d + 0.5)`). A value of an hour or more without hours is upgraded to +/// `HH:MM:SS` (`H:MM:SS` when `one_digit_hours`), except in long-minute style. Returns `None` +/// when the value cannot be written as a valid R13.2.2 time (100 hours or more, more than 999 +/// long-style minutes, R13.9.2). +pub(crate) fn format_time( + seconds: f64, + style: &TimeStyle, + one_digit_hours: bool, +) -> Option { + let scale: f64 = match style.frac_digits { + 0 => 1.0, + 1 => 10.0, + 2 => 100.0, + _ => 1000.0, + }; + // The same double arithmetic as the JS reference; integers only after the range check. + let units = (seconds * scale + 0.5).floor(); + if !units.is_finite() || units.abs() > MAX_SAFE_INTEGER || units < 0.0 { + return None; + } + let whole_f = (units / scale).floor(); + let frac_units = (units - whole_f * scale) as u64; + // The written time must stay valid under R13.2.2 (hours are 1–2 digits). + if whole_f >= 100.0 * 3600.0 { + return None; + } + let whole = whole_f as u64; + let frac = match style.frac_sep { + Some(sep) if style.frac_digits > 0 => { + format!("{sep}{}", pad(frac_units, style.frac_digits)) + } + _ => String::new(), + }; + let sec = whole % 60; + if style.hours { + let h = whole / 3600; + let m = (whole % 3600) / 60; + return Some(FormattedTime { + raw: format!( + "{}:{}:{}{frac}", + pad(h, style.hour_width), + pad(m, style.minute_width), + pad(sec, 2) + ), + upgraded: false, + }); + } + if style.long_minutes { + let m = whole / 60; + if m > 999 { + return None; // R13.2.2: two-part minutes are 1–3 digits + } + return Some(FormattedTime { + raw: format!("{}:{}{frac}", pad(m, style.minute_width), pad(sec, 2)), + upgraded: false, + }); + } + if whole >= 3600 { + let h = whole / 3600; + let m = (whole % 3600) / 60; + return Some(FormattedTime { + raw: format!( + "{}:{}:{}{frac}", + pad(h, if one_digit_hours { 1 } else { 2 }), + pad(m, 2), + pad(sec, 2) + ), + upgraded: true, + }); + } + let m = whole / 60; + Some(FormattedTime { + raw: format!("{}:{}{frac}", pad(m, style.minute_width), pad(sec, 2)), + upgraded: false, + }) +} diff --git a/rust/src/tracklist/types.rs b/rust/src/tracklist/types.rs new file mode 100644 index 0000000..73b964f --- /dev/null +++ b/rust/src/tracklist/types.rs @@ -0,0 +1,646 @@ +//! Public tracklist types. They mirror `spec/schema/tracklist.schema.json`; field names are +//! snake_case in Rust and the spec's camelCase in JSON (`to_json()`, and `serde` with that +//! feature). + +use crate::json::Json; +use crate::types::{json_methods, list, obj, opt, string_enum, ParsedTrack, ToJson}; + +string_enum! { + /// What a line of a tracklist is (R13.3). + /// + /// ``` + /// use trackparse::tracklist::{parse_tracklist, EntryKind}; + /// + /// let text = "Tracklist:\n00:00 Intro\n02:10 Noisia - Stigma\n\nhttps://example.com/mix"; + /// let kinds: Vec = parse_tracklist(text).entries.iter().map(|e| e.kind).collect(); + /// assert_eq!( + /// kinds, + /// [EntryKind::Header, EntryKind::Marker, EntryKind::Track, EntryKind::Blank, EntryKind::Link] + /// ); + /// ``` + #[non_exhaustive] + EntryKind { + Track => "track", Marker => "marker", Header => "header", Link => "link", Note => "note", + Blank => "blank", + } +} + +string_enum! { + /// The line terminator that followed a line (R13.1.1); `None` when the text ended without + /// one. + /// + /// ``` + /// use trackparse::tracklist::{parse_tracklist, Eol}; + /// + /// let list = parse_tracklist("A - B\r\nC - D"); + /// assert_eq!(list.entries[0].eol, Eol::CrLf); + /// assert_eq!(list.entries[1].eol, Eol::None); + /// assert_eq!(Eol::CrLf.as_str(), "\r\n"); + /// ``` + Eol { Lf => "\n", CrLf => "\r\n", Cr => "\r", None => "" } +} + +/// A line cut into four pieces that join back to it: `lead + time + gap + rest == raw` +/// (R13.1.3). +/// +/// ``` +/// use trackparse::tracklist::parse_tracklist; +/// +/// let list = parse_tracklist("- [03:45] Phace - Cold Champagne"); +/// let parts = &list.entries[0].parts; +/// assert_eq!(parts.lead, "- ["); +/// assert_eq!(parts.time, "03:45"); +/// assert_eq!(parts.gap, "] "); +/// assert_eq!(parts.rest, "Phace - Cold Champagne"); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Parts { + /// What stands before the time: indentation, a bullet, an opening bracket. + pub lead: String, + /// The time as written, without brackets; empty when the line has none. + pub time: String, + /// What stands between the time and the rest: a closing bracket, whitespace, a separator. + pub gap: String, + /// Everything after that. + pub rest: String, +} + +/// The time of a line (R13.2.5). +/// +/// ``` +/// use trackparse::tracklist::parse_tracklist; +/// +/// let list = parse_tracklist("[1:02:03] A - B\n1:02:03.5 C - D"); +/// let first = list.entries[0].time.as_ref().unwrap(); +/// assert_eq!((first.raw.as_str(), first.seconds), ("1:02:03", 3723.0)); +/// let second = list.entries[1].time.as_ref().unwrap(); +/// assert_eq!((second.raw.as_str(), second.seconds), ("1:02:03.5", 3723.5)); +/// assert_eq!(first.to_json(), r#"{"raw":"1:02:03","seconds":3723}"#); +/// ``` +#[derive(Debug, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct TimeValue { + /// As written, without brackets. + pub raw: String, + /// The time in seconds; it may carry a fraction. A whole value is an integer in JSON. + #[cfg_attr(feature = "serde", serde(with = "crate::serde_support::seconds"))] + pub seconds: f64, +} + +/// One line of a tracklist. +/// +/// ``` +/// use trackparse::tracklist::{parse_tracklist, EntryKind, Eol}; +/// +/// let list = parse_tracklist("00:00 Noisia - Stigma\nw/ Phace - Cold Champagne\n"); +/// let entry = &list.entries[1]; +/// assert_eq!(entry.line, 2); +/// assert_eq!(entry.kind, EntryKind::Track); +/// assert_eq!(entry.eol, Eol::Lf); +/// assert_eq!(entry.raw, "w/ Phace - Cold Champagne"); +/// assert!(entry.time.is_none()); +/// assert!(entry.layered); +/// assert_eq!(entry.track.as_ref().unwrap().title, "Cold Champagne"); +/// ``` +#[derive(Debug, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct TracklistEntry { + /// 1-based line number. + pub line: usize, + /// What the line is. + pub kind: EntryKind, + /// The line terminator that followed it. + pub eol: Eol, + /// The line as written, without its terminator. Never normalized. + pub raw: String, + /// `raw` cut into lead, time, gap and rest. + pub parts: Parts, + /// The line's time, if it has a valid one. + pub time: Option, + /// The parse of the line text, for `Track` and `Marker` entries. + pub track: Option, + /// The line starts with `w/`: played over the previous track (R13.13). + pub layered: bool, +} + +string_enum! { + /// The code of a tracklist warning (R13.7), in the table order of the spec. + /// + /// ``` + /// use trackparse::tracklist::{parse_tracklist, WarningCode}; + /// + /// let list = parse_tracklist("05:00 A - B\n03:00 C - D\nE - F"); + /// let codes: Vec = list.warnings.iter().map(|w| w.code).collect(); + /// assert_eq!( + /// codes, + /// [WarningCode::NoStartAtZero, WarningCode::TimeOutOfOrder, WarningCode::TimeMissing] + /// ); + /// assert_eq!(WarningCode::TimeOutOfOrder.as_str(), "time-out-of-order"); + /// ``` + #[non_exhaustive] + WarningCode { + TimeMissing => "time-missing", TimeOutOfOrder => "time-out-of-order", + TimeDuplicate => "time-duplicate", NoStartAtZero => "no-start-at-zero", + TimeAfterAudioEnd => "time-after-audio-end", InvalidTime => "invalid-time", + PositionGap => "position-gap", PositionDuplicate => "position-duplicate", + LineUnparsed => "line-unparsed", + } +} + +string_enum! { + /// How serious a tracklist warning is. + /// + /// ``` + /// use trackparse::tracklist::{parse_tracklist, Severity}; + /// + /// let list = parse_tracklist("05:00 A - B\n03:00 C - D"); + /// let severities: Vec = list.warnings.iter().map(|w| w.severity).collect(); + /// assert_eq!(severities, [Severity::Info, Severity::Warning]); + /// ``` + #[non_exhaustive] + Severity { Info => "info", Warning => "warning" } +} + +/// A fix for a `time-out-of-order` warning that changes one or two digits (R13.7). +/// +/// ``` +/// use trackparse::tracklist::parse_tracklist; +/// +/// let text = "00:00 A - B\n01:02:00 C - D\n01:22:21 E - F\n01:06:40 G - H\n01:10:00 I - J"; +/// let list = parse_tracklist(text); +/// assert_eq!(list.warnings[0].line, 4); +/// let suggestion = list.warnings[0].suggestion.as_ref().unwrap(); +/// assert_eq!(suggestion.line, 3); +/// assert_eq!(suggestion.raw, "01:02:21"); +/// assert_eq!(suggestion.seconds, 3741.0); +/// ``` +#[derive(Debug, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Suggestion { + /// The line to change. + pub line: usize, + /// The time to write there. + pub raw: String, + /// That time in seconds. + #[cfg_attr(feature = "serde", serde(with = "crate::serde_support::seconds"))] + pub seconds: f64, +} + +/// A warning about a tracklist (R13.7). +/// +/// ``` +/// use trackparse::tracklist::{parse_tracklist, Severity, WarningCode}; +/// +/// let list = parse_tracklist("00:00 A - B\n00:00 C - D"); +/// let warning = &list.warnings[0]; +/// assert_eq!(warning.code, WarningCode::TimeDuplicate); +/// assert_eq!(warning.line, 2); +/// assert_eq!(warning.severity, Severity::Warning); +/// assert!(warning.suggestion.is_none()); +/// ``` +#[derive(Debug, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct TracklistWarning { + /// What is wrong. + pub code: WarningCode, + /// The 1-based line it is about. + pub line: usize, + /// How serious it is. + pub severity: Severity, + /// A fix, for `time-out-of-order` when exactly one small change repairs the order. + pub suggestion: Option, +} + +/// Counts over a tracklist. +/// +/// ``` +/// use trackparse::tracklist::parse_tracklist; +/// +/// let stats = parse_tracklist("Tracklist:\n00:00 Intro\n02:10 Noisia - Stigma\nA - B").stats; +/// assert_eq!((stats.lines, stats.tracks, stats.markers, stats.timed), (4, 2, 1, 2)); +/// assert_eq!(stats.first_time, Some(0.0)); +/// assert_eq!(stats.last_time, Some(130.0)); +/// ``` +#[derive(Debug, Clone, PartialEq, Default)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +pub struct Stats { + /// Number of lines (entries). + pub lines: usize, + /// Number of `Track` entries. + pub tracks: usize, + /// Number of `Marker` entries. + pub markers: usize, + /// Number of entries with a time. + pub timed: usize, + /// The time of the first timed entry, in seconds. + #[cfg_attr(feature = "serde", serde(serialize_with = "crate::serde_support::opt_seconds"))] + pub first_time: Option, + /// The time of the last timed entry, in seconds. + #[cfg_attr(feature = "serde", serde(serialize_with = "crate::serde_support::opt_seconds"))] + pub last_time: Option, +} + +/// The result of [`parse_tracklist`](super::parse_tracklist): one entry per line, the warnings +/// and the counts. +/// +/// The entries' `raw` and `eol`, joined, are the text again (R13.1.2). +/// +/// ``` +/// use trackparse::tracklist::parse_tracklist; +/// +/// let text = "00:00 Noisia - Stigma\r\n03:45 Phace - Cold Champagne"; +/// let list = parse_tracklist(text); +/// assert_eq!(list.spec_version, trackparse::SPEC_VERSION); +/// assert_eq!(list.entries.len(), 2); +/// let joined: String = list.entries.iter().map(|e| format!("{}{}", e.raw, e.eol)).collect(); +/// assert_eq!(joined, text); +/// assert!(list.to_json().starts_with(r#"{"specVersion":""#)); +/// ``` +#[derive(Debug, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +pub struct Tracklist { + /// The version of the spec the result follows (`specVersion` in JSON). + pub spec_version: String, + /// One entry per line, in order. + pub entries: Vec, + /// Warnings, ordered by line. + pub warnings: Vec, + /// Counts. + pub stats: Stats, +} + +/// One edit of a tracklist text (R13.9). Line numbers are 1-based and refer to the text as the +/// previous edit left it. +/// +/// The JSON form is the spec's (`{"op":"set-time","line":3,"seconds":90}`). +/// +/// ``` +/// use trackparse::tracklist::{apply_edits, Edit}; +/// +/// let text = "00:00 A - B\n01:00 C - D\n"; +/// let edits = [Edit::set_time(2, 90.0), Edit::insert(2, "02:00 E - F"), Edit::delete(1)]; +/// assert_eq!(apply_edits(text, &edits).text, "01:30 C - D\n02:00 E - F\n"); +/// assert_eq!(edits[0].to_json(), r#"{"op":"set-time","line":2,"seconds":90}"#); +/// assert_eq!(edits[0], Edit::SetTime { line: 2, seconds: 90.0 }); +/// ``` +#[derive(Debug, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "op", rename_all = "kebab-case"))] +#[non_exhaustive] +pub enum Edit { + /// Rewrite the time of `line`, keeping its written style (R13.9.2). + SetTime { + /// The line to change. + #[cfg_attr(feature = "serde", serde(with = "crate::serde_support::line"))] + line: usize, + /// The new time in seconds. + #[cfg_attr(feature = "serde", serde(with = "crate::serde_support::seconds"))] + seconds: f64, + }, + /// Add `seconds` to every timed line of `lines`, else from line `from` on, else of the + /// whole text. + Shift { + /// Seconds to add; negative moves the times back. + #[cfg_attr(feature = "serde", serde(with = "crate::serde_support::seconds"))] + seconds: f64, + /// Only these lines. + #[cfg_attr( + feature = "serde", + serde( + default, + skip_serializing_if = "Option::is_none", + with = "crate::serde_support::opt_lines" + ) + )] + lines: Option>, + /// Only this line and the ones after it. + #[cfg_attr( + feature = "serde", + serde( + default, + skip_serializing_if = "Option::is_none", + with = "crate::serde_support::opt_line" + ) + )] + from: Option, + }, + /// Stable sort of the timed lines, each with the untimed lines after it (R13.9.4). + SortByTime, + /// Replace everything after the time and gap of `line`. + SetRest { + /// The line to change. + #[cfg_attr(feature = "serde", serde(with = "crate::serde_support::line"))] + line: usize, + /// The new text after the time. + rest: String, + }, + /// Insert `text` as a new line after line `after` (0: at the start). + Insert { + /// The line to insert after. + #[cfg_attr(feature = "serde", serde(with = "crate::serde_support::line"))] + after: usize, + /// The new line, without a terminator. + text: String, + }, + /// Remove `line`. + Delete { + /// The line to remove. + #[cfg_attr(feature = "serde", serde(with = "crate::serde_support::line"))] + line: usize, + }, +} + +impl Edit { + /// [`Edit::SetTime`]: rewrite the time of `line`. + pub fn set_time(line: usize, seconds: f64) -> Edit { + Edit::SetTime { line, seconds } + } + + /// [`Edit::Shift`] over every timed line of the text. + /// + /// ``` + /// use trackparse::tracklist::{apply_edits, Edit}; + /// + /// let result = apply_edits("00:10 A - B\n01:00 C - D", &[Edit::shift(-10.0)]); + /// assert_eq!(result.text, "00:00 A - B\n00:50 C - D"); + /// ``` + pub fn shift(seconds: f64) -> Edit { + Edit::Shift { seconds, lines: None, from: None } + } + + /// [`Edit::Shift`] over line `from` and the lines after it. + pub fn shift_from(seconds: f64, from: usize) -> Edit { + Edit::Shift { seconds, lines: None, from: Some(from) } + } + + /// [`Edit::Shift`] over the given lines only. + pub fn shift_lines(seconds: f64, lines: impl IntoIterator) -> Edit { + Edit::Shift { seconds, lines: Some(lines.into_iter().collect()), from: None } + } + + /// [`Edit::SortByTime`]. + pub fn sort_by_time() -> Edit { + Edit::SortByTime + } + + /// [`Edit::SetRest`]: replace what follows the time of `line`. + pub fn set_rest(line: usize, rest: impl Into) -> Edit { + Edit::SetRest { line, rest: rest.into() } + } + + /// [`Edit::Insert`]: a new line after line `after` (0: at the start). + pub fn insert(after: usize, text: impl Into) -> Edit { + Edit::Insert { after, text: text.into() } + } + + /// [`Edit::Delete`]: remove `line`. + pub fn delete(line: usize) -> Edit { + Edit::Delete { line } + } +} + +string_enum! { + /// The code of an edit warning (R13.9). + /// + /// ``` + /// use trackparse::tracklist::{apply_edits, Edit, EditWarningCode}; + /// + /// let result = apply_edits("00:10 A - B", &[Edit::shift(-60.0), Edit::delete(9)]); + /// let codes: Vec = result.warnings.iter().map(|w| w.code).collect(); + /// assert_eq!(codes, [EditWarningCode::TimeClamped, EditWarningCode::EditInvalid]); + /// ``` + #[non_exhaustive] + EditWarningCode { + EditInvalid => "edit-invalid", TimeClamped => "time-clamped", + StyleUpgraded => "style-upgraded", + } +} + +/// A warning about one edit. +/// +/// ``` +/// use trackparse::tracklist::{apply_edits, Edit, EditWarningCode}; +/// +/// let result = apply_edits("59:30 A - B", &[Edit::shift(60.0)]); +/// assert_eq!(result.text, "01:00:30 A - B"); +/// let warning = &result.warnings[0]; +/// assert_eq!(warning.code, EditWarningCode::StyleUpgraded); +/// assert_eq!(warning.edit, 0); +/// assert_eq!(warning.line, Some(1)); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct EditWarning { + /// What happened. + pub code: EditWarningCode, + /// Index of the edit in the `edits` slice. + pub edit: usize, + /// The line concerned; for `EditInvalid` the edit's own `line` (or `after`), which may not + /// exist in the text. + /// + /// The edits run on JS numbers (R13.9), so a line number above 2^53 comes back as the + /// nearest double, saturated to `usize`: `Edit::delete(usize::MAX)` warns with + /// `Some(usize::MAX)`, and `to_json()` writes `18446744073709552000` as JavaScript does. + #[cfg_attr(feature = "serde", serde(default, with = "crate::serde_support::opt_line"))] + pub line: Option, +} + +/// The result of [`apply_edits`](super::apply_edits). +/// +/// ``` +/// use trackparse::tracklist::{apply_edits, Edit}; +/// +/// let result = apply_edits("00:00 A - B\n01:00 C - D", &[Edit::set_rest(2, "E - F")]); +/// assert_eq!(result.text, "00:00 A - B\n01:00 E - F"); +/// assert_eq!(result.changed, [2]); +/// assert!(result.warnings.is_empty()); +/// assert_eq!( +/// result.to_json(), +/// r#"{"text":"00:00 A - B\n01:00 E - F","changed":[2],"warnings":[]}"# +/// ); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct EditResult { + /// The edited text. + pub text: String, + /// Line numbers (in the final text) of lines an edit wrote; sorted, unique. + pub changed: Vec, + /// One warning per edit that could not be applied as asked. + pub warnings: Vec, +} + +json_methods!( + Parts, + TimeValue, + TracklistEntry, + Suggestion, + TracklistWarning, + Stats, + Tracklist, + Edit, + EditWarning, + EditResult +); + +pub(crate) fn num(n: usize) -> Json { + Json::Num(n as f64) +} + +fn num_opt(v: Option) -> Json { + v.map_or(Json::Null, Json::Num) +} + +impl ToJson for Parts { + fn to_json_value(&self) -> Json { + obj(vec![ + ("lead", Json::str(&self.lead)), + ("time", Json::str(&self.time)), + ("gap", Json::str(&self.gap)), + ("rest", Json::str(&self.rest)), + ]) + } +} + +impl ToJson for TimeValue { + fn to_json_value(&self) -> Json { + obj(vec![("raw", Json::str(&self.raw)), ("seconds", Json::Num(self.seconds))]) + } +} + +impl TracklistEntry { + /// The entry's JSON with `track` given: the wire writes the pipeline's own track there. + pub(crate) fn json_with(&self, track: Json) -> Json { + obj(vec![ + ("line", num(self.line)), + ("kind", Json::str(self.kind.as_str())), + ("eol", Json::str(self.eol.as_str())), + ("raw", Json::str(&self.raw)), + ("parts", self.parts.to_json_value()), + ("time", opt(&self.time)), + ("track", track), + ("layered", Json::Bool(self.layered)), + ]) + } +} + +impl ToJson for TracklistEntry { + fn to_json_value(&self) -> Json { + self.json_with(opt(&self.track)) + } +} + +impl ToJson for Suggestion { + fn to_json_value(&self) -> Json { + obj(vec![ + ("line", num(self.line)), + ("raw", Json::str(&self.raw)), + ("seconds", Json::Num(self.seconds)), + ]) + } +} + +impl ToJson for TracklistWarning { + fn to_json_value(&self) -> Json { + obj(vec![ + ("code", Json::str(self.code.as_str())), + ("line", num(self.line)), + ("severity", Json::str(self.severity.as_str())), + ("suggestion", opt(&self.suggestion)), + ]) + } +} + +impl ToJson for Stats { + fn to_json_value(&self) -> Json { + obj(vec![ + ("lines", num(self.lines)), + ("tracks", num(self.tracks)), + ("markers", num(self.markers)), + ("timed", num(self.timed)), + ("firstTime", num_opt(self.first_time)), + ("lastTime", num_opt(self.last_time)), + ]) + } +} + +/// The JSON of a tracklist whose entries are already written. +pub(crate) fn tracklist_json( + spec_version: &str, + entries: Vec, + warnings: &[TracklistWarning], + stats: &Stats, +) -> Json { + obj(vec![ + ("specVersion", Json::str(spec_version)), + ("entries", Json::Arr(entries)), + ("warnings", list(warnings)), + ("stats", stats.to_json_value()), + ]) +} + +impl ToJson for Tracklist { + fn to_json_value(&self) -> Json { + let entries = self.entries.iter().map(ToJson::to_json_value).collect(); + tracklist_json(&self.spec_version, entries, &self.warnings, &self.stats) + } +} + +impl ToJson for Edit { + /// The edit as the spec writes it (`{"op":"set-time","line":3,"seconds":90}`). + fn to_json_value(&self) -> Json { + match self { + Edit::SetTime { line, seconds } => obj(vec![ + ("op", Json::str("set-time")), + ("line", num(*line)), + ("seconds", Json::Num(*seconds)), + ]), + Edit::Shift { seconds, lines, from } => { + let mut entries = + vec![("op", Json::str("shift")), ("seconds", Json::Num(*seconds))]; + if let Some(lines) = lines { + entries.push(("lines", Json::Arr(lines.iter().map(|l| num(*l)).collect()))); + } + if let Some(from) = from { + entries.push(("from", num(*from))); + } + obj(entries) + } + Edit::SortByTime => obj(vec![("op", Json::str("sort-by-time"))]), + Edit::SetRest { line, rest } => obj(vec![ + ("op", Json::str("set-rest")), + ("line", num(*line)), + ("rest", Json::str(rest)), + ]), + Edit::Insert { after, text } => obj(vec![ + ("op", Json::str("insert")), + ("after", num(*after)), + ("text", Json::str(text)), + ]), + Edit::Delete { line } => obj(vec![("op", Json::str("delete")), ("line", num(*line))]), + } + } +} + +impl ToJson for EditWarning { + fn to_json_value(&self) -> Json { + obj(vec![ + ("code", Json::str(self.code.as_str())), + ("edit", num(self.edit)), + ("line", self.line.map_or(Json::Null, |l| Json::Num(l as f64))), + ]) + } +} + +impl ToJson for EditResult { + fn to_json_value(&self) -> Json { + obj(vec![ + ("text", Json::str(&self.text)), + ("changed", Json::Arr(self.changed.iter().map(|l| num(*l)).collect())), + ("warnings", list(&self.warnings)), + ]) + } +} diff --git a/rust/src/tracklist/warnings.rs b/rust/src/tracklist/warnings.rs new file mode 100644 index 0000000..d5783be --- /dev/null +++ b/rust/src/tracklist/warnings.rs @@ -0,0 +1,261 @@ +//! R13.7 tracklist warnings and the `time-out-of-order` suggestion search. + +use super::times::seconds_of; +use super::types::{ + EntryKind, Severity, Suggestion, TimeValue, TracklistEntry, TracklistWarning, WarningCode, +}; + +pub(crate) struct WarningInput<'a> { + pub entries: &'a [TracklistEntry], + /// R4.2 / R13.5 position number of each entry's track, if it has one. + pub positions: &'a [Option], + /// R13.2.4 per entry. + pub invalid: &'a [bool], + /// R13.7 line-unparsed per entry: a `track` entry whose track part has no separator (R13.3). + pub unparsed: &'a [bool], + pub audio_seconds: Option, +} + +#[derive(Debug, Clone, Copy)] +struct Slot { + /// Index of the digit in `raw`. + at: usize, + field: usize, + place: i64, + digit: i64, +} + +/// Outcome of one line's digit search: no candidate, exactly one, or several. +pub(crate) enum Search { + None, + One(TimeValue), + Many, +} + +/// One digit change: the slot and its new digit. +type Change = (Slot, i64); + +struct Digits<'a> { + raw: &'a [char], + frac: String, + values: Vec, + lo: Option, + hi: Option, +} + +impl Digits<'_> { + /// The value with `changes` applied, when it is a valid time inside the bounds. + fn value_with(&self, changes: &[Change]) -> Option { + let mut v = self.values.clone(); + for (slot, d) in changes { + if let Some(field) = v.get_mut(slot.field) { + *field += (d - slot.digit) * slot.place; + } + } + let mult: &[i64] = if v.len() == 3 { &[3600, 60, 1] } else { &[60, 1] }; + let mut whole: i64 = 0; + for (f, value) in v.iter().enumerate() { + if f > 0 && *value > 59 { + return None; + } + whole += value * mult.get(f).copied().unwrap_or(0); + } + let t = seconds_of(u32::try_from(whole).ok()?, &self.frac); + (self.lo.map_or(true, |lo| lo < t) && self.hi.map_or(true, |hi| t < hi)).then_some(t) + } + + fn render(&self, changes: &[Change]) -> String { + let mut out = self.raw.to_vec(); + for (slot, d) in changes { + if let (Some(ch), Some(digit)) = + (out.get_mut(slot.at), u32::try_from(*d).ok().and_then(|d| char::from_digit(d, 10))) + { + *ch = digit; + } + } + out.into_iter().collect() + } +} + +/// R13.7 suggestion search on one raw time: change 1, then 2 digits (fraction digits excluded); +/// keep candidates that are valid times (R13.2.2: fields after the first at most 59) with +/// `lo < t` (when `lo` exists) and `t < hi` (when `hi` exists). Only the smallest number of +/// changes with any candidate counts. Bounded and arithmetic: at most 7 digits, 9·7 + 81·21 +/// candidates. +pub(crate) fn search_time(raw: &str, lo: Option, hi: Option) -> Search { + let raw: Vec = raw.chars().collect(); + let frac_start = raw.iter().position(|c| *c == '.' || *c == ',').unwrap_or(raw.len()); + let frac: String = raw.iter().skip(frac_start + 1).collect(); + let mut values: Vec = vec![0]; + let mut slots: Vec = Vec::new(); + for (i, ch) in raw.iter().enumerate().take(frac_start) { + if *ch == ':' { + values.push(0); + } else if let Some(d) = ch.to_digit(10).filter(|_| ch.is_ascii_digit()) { + let f = values.len() - 1; + if let Some(v) = values.last_mut() { + *v = *v * 10 + i64::from(d); + } + slots.push(Slot { at: i, field: f, place: 0, digit: i64::from(d) }); + } + } + // Place value of each digit inside its field. + let mut place = 1; + let mut field = usize::MAX; + for slot in slots.iter_mut().rev() { + if slot.field != field { + field = slot.field; + place = 1; + } + slot.place = place; + place *= 10; + } + let digits = Digits { raw: &raw, frac, values, lo, hi }; + + let mut found: Option> = None; + let mut count = 0; + for slot in &slots { + for d in (0..=9).filter(|d| *d != slot.digit) { + let change = vec![(*slot, d)]; + if digits.value_with(&change).is_some() { + count += 1; + found = Some(change); + } + } + } + if count == 0 { + 'pairs: for (x, a) in slots.iter().enumerate() { + for b in slots.iter().skip(x + 1) { + for da in (0..=9).filter(|d| *d != a.digit) { + for db in (0..=9).filter(|d| *d != b.digit) { + let change = vec![(*a, da), (*b, db)]; + if digits.value_with(&change).is_some() { + count += 1; + found = Some(change); + if count >= 2 { + break 'pairs; + } + } + } + } + } + } + } + match found { + Some(change) if count == 1 => match digits.value_with(&change) { + Some(seconds) => Search::One(TimeValue { raw: digits.render(&change), seconds }), + None => Search::None, + }, + Some(_) if count > 1 => Search::Many, + _ => Search::None, + } +} + +/// A timed entry: its line number and time. +type Timed<'a> = (usize, &'a TimeValue); + +/// R13.7 suggestion for the out-of-order timed entry `k` (index into `times`): search its own +/// time between its neighbours first; only when that finds no candidate at all, search the +/// previous timed entry's time between the one before it and entry `k`. +pub(crate) fn suggest_fix(times: &[Timed<'_>], k: usize) -> Option { + let (cur_line, cur) = *times.get(k)?; + let (prev_line, prev) = *times.get(k.checked_sub(1)?)?; + let next = times.get(k + 1).map(|(_, t)| t.seconds); + match search_time(&cur.raw, Some(prev.seconds), next) { + Search::One(t) => { + return Some(Suggestion { line: cur_line, raw: t.raw, seconds: t.seconds }) + } + Search::Many => return None, + Search::None => {} + } + let before = k.checked_sub(2).and_then(|i| times.get(i)).map(|(_, t)| t.seconds); + match search_time(&prev.raw, before, Some(cur.seconds)) { + Search::One(t) => Some(Suggestion { line: prev_line, raw: t.raw, seconds: t.seconds }), + _ => None, + } +} + +/// Table order of R13.7; warnings of one line are emitted in this order. +fn rank(code: WarningCode) -> usize { + WarningCode::ALL.iter().position(|c| *c == code).unwrap_or(usize::MAX) +} + +pub(crate) fn tracklist_warnings(input: &WarningInput<'_>) -> Vec { + let entries = input.entries; + let mut per_line: Vec> = entries.iter().map(|_| Vec::new()).collect(); + let mut add = |i: usize, code: WarningCode, suggestion: Option| { + let (Some(e), Some(list)) = (entries.get(i), per_line.get_mut(i)) else { return }; + let severity = + if code == WarningCode::NoStartAtZero { Severity::Info } else { Severity::Warning }; + list.push(TracklistWarning { code, line: e.line, severity, suggestion }); + }; + + let timed: Vec<(usize, Timed<'_>)> = entries + .iter() + .enumerate() + .filter_map(|(i, e)| e.time.as_ref().map(|t| (i, (e.line, t)))) + .collect(); + let flag = |list: &[bool], i: usize| list.get(i).copied().unwrap_or(false); + + for (i, e) in entries.iter().enumerate() { + // R13.13.3: an untimed layered line plays over the previous track, at its time. + if e.kind == EntryKind::Track && e.time.is_none() && !e.layered && !timed.is_empty() { + add(i, WarningCode::TimeMissing, None); + } + if flag(input.invalid, i) { + add(i, WarningCode::InvalidTime, None); + } + if flag(input.unparsed, i) { + add(i, WarningCode::LineUnparsed, None); + } + } + + let times: Vec> = timed.iter().map(|(_, t)| *t).collect(); + let mut prev: Option = None; + for (k, (i, (_, t))) in timed.iter().enumerate() { + match prev { + None => { + if t.seconds != 0.0 { + add(*i, WarningCode::NoStartAtZero, None); + } + } + Some(p) => { + if t.seconds < p { + add(*i, WarningCode::TimeOutOfOrder, suggest_fix(×, k)); + } else if t.seconds == p { + add(*i, WarningCode::TimeDuplicate, None); + } + } + } + if input.audio_seconds.is_some_and(|audio| t.seconds > audio) { + add(*i, WarningCode::TimeAfterAudioEnd, None); + } + prev = Some(t.seconds); + } + + let mut prev_pos: Option = None; + for (i, e) in entries.iter().enumerate() { + let pos = if e.kind == EntryKind::Track { + input.positions.get(i).copied().flatten() + } else { + None + }; + let Some(pos) = pos else { continue }; + if let Some(p) = prev_pos { + if pos == p { + add(i, WarningCode::PositionDuplicate, None); + } else if p.checked_add(1) != Some(pos) { + add(i, WarningCode::PositionGap, None); + } + } + prev_pos = Some(pos); + } + + per_line + .into_iter() + .flat_map(|mut ws| { + ws.sort_by_key(|w| rank(w.code)); // stable + ws + }) + .collect() +} diff --git a/rust/src/types.rs b/rust/src/types.rs new file mode 100644 index 0000000..df98df2 --- /dev/null +++ b/rust/src/types.rs @@ -0,0 +1,693 @@ +//! Public types. They mirror `spec/schema/parsed-track.schema.json`; field names are snake_case +//! in Rust and the spec's camelCase in JSON (`to_json()`, and `serde` with that feature). + +use crate::json::Json; + +// Decision: output structs stay constructible (not `#[non_exhaustive]`): tests build them. + +/// The error of `FromStr` on the crate's enums: the string is not one of the spec's names. +/// +/// ``` +/// use trackparse::{ArtistRole, UnknownName}; +/// +/// let err: UnknownName = "singer".parse::().unwrap_err(); +/// assert_eq!(err.to_string(), "unknown ArtistRole name: \"singer\""); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct UnknownName { + pub(crate) kind: &'static str, + pub(crate) name: String, +} + +impl UnknownName { + /// The string that was not recognised. + pub fn name(&self) -> &str { + &self.name + } +} + +impl std::fmt::Display for UnknownName { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "unknown {} name: {:?}", self.kind, self.name) + } +} + +impl std::error::Error for UnknownName {} + +/// Declares a string-valued enum: `as_str()`, `from_name()`, `ALL`, `Display`, `FromStr`, and +/// with the `serde` feature `Serialize` / `Deserialize` as the spec name. +macro_rules! string_enum { + ($(#[$meta:meta])* $name:ident { $($variant:ident => $text:literal),+ $(,)? }) => { + $(#[$meta])* + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] + pub enum $name { + $( + #[doc = concat!("`", stringify!($text), "` in the spec and in JSON.")] + $variant + ),+ + } + + impl $name { + /// Every value, in the spec's order. + pub const ALL: &'static [$name] = &[$($name::$variant),+]; + + /// Every name, in the order of `ALL`. + pub const NAMES: &'static [&'static str] = &[$($text),+]; + + /// The name used in the spec and in JSON. + pub fn as_str(self) -> &'static str { + match self { $($name::$variant => $text),+ } + } + + /// The value with that spec name (exact match), or `None`. + pub fn from_name(name: &str) -> Option<$name> { + match name { $($text => Some($name::$variant),)+ _ => None } + } + } + + impl std::fmt::Display for $name { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(self.as_str()) + } + } + + impl std::str::FromStr for $name { + type Err = $crate::types::UnknownName; + + fn from_str(name: &str) -> Result<$name, Self::Err> { + $name::from_name(name).ok_or_else(|| $crate::types::UnknownName { + kind: stringify!($name), + name: name.to_string(), + }) + } + } + + #[cfg(feature = "serde")] + #[cfg_attr(docsrs, doc(cfg(feature = "serde")))] + impl serde::Serialize for $name { + fn serialize(&self, serializer: S) -> Result { + serializer.serialize_str(self.as_str()) + } + } + + #[cfg(feature = "serde")] + #[cfg_attr(docsrs, doc(cfg(feature = "serde")))] + impl<'de> serde::Deserialize<'de> for $name { + fn deserialize>(deserializer: D) -> Result<$name, D::Error> { + let name = ::deserialize(deserializer)?; + $name::from_name(&name) + .ok_or_else(|| serde::de::Error::unknown_variant(&name, $name::NAMES)) + } + } + }; +} +pub(crate) use string_enum; + +/// Adds the inherent `to_json()` to types that implement [`ToJson`], so no import is needed, and +/// marks them as the crate's own (`ToJson` is sealed). +macro_rules! json_methods { + ($($name:ty),+ $(,)?) => { + $( + impl $crate::types::sealed::Sealed for $name {} + + impl $name { + /// The spec's JSON form as compact text: camelCase keys, every key present, in + /// the schema's order. The same text the JavaScript and Python packages give. + pub fn to_json(&self) -> String { + $crate::types::ToJson::to_json_value(self).write() + } + } + )+ + }; +} +pub(crate) use json_methods; + +string_enum! { + /// The mode a string was parsed in (R2). `Tracklist` is only used when asked for (R13.6); + /// `auto` never resolves to it. + /// + /// ``` + /// use trackparse::{parse, Mode}; + /// + /// assert_eq!(parse("Noisia - Stigma").mode, Mode::Clean); + /// assert_eq!(parse("Noisia - Stigma (Official Video)").mode, Mode::Youtube); + /// assert_eq!(parse("01_noisia_-_stigma.mp3").mode, Mode::Filename); + /// assert_eq!(Mode::Youtube.as_str(), "youtube"); + /// assert_eq!("filename".parse::(), Ok(Mode::Filename)); + /// ``` + #[non_exhaustive] + Mode { Clean => "clean", Youtube => "youtube", Filename => "filename", Tracklist => "tracklist" } +} + +string_enum! { + /// What an artist did on the track (R7). + /// + /// ``` + /// use trackparse::{parse, ArtistRole}; + /// + /// let track = parse("Noisia feat. Foreign Beggars - Shellshock (prod. by Phace)"); + /// let roles: Vec = track.artists.iter().map(|a| a.role).collect(); + /// assert_eq!(roles, [ArtistRole::Primary, ArtistRole::Featured, ArtistRole::Producer]); + /// assert_eq!(ArtistRole::Featured.to_string(), "featured"); + /// ``` + #[non_exhaustive] + ArtistRole { Primary => "primary", Featured => "featured", Remixer => "remixer", Producer => "producer" } +} + +string_enum! { + /// Where in the string an artist was found: the artist side, the title side, or a version + /// group. + /// + /// ``` + /// use trackparse::{parse, ArtistSource}; + /// + /// let track = parse("Sub Focus - Out the Blue ft. Alice Gold"); + /// assert_eq!(track.artists[0].source, ArtistSource::Artist); + /// assert_eq!(track.artists[1].source, ArtistSource::Title); + /// ``` + #[non_exhaustive] + ArtistSource { Artist => "artist", Title => "title", Version => "version" } +} + +string_enum! { + /// The type of a version (R5): remix, edit, live, remaster and so on. + /// + /// ``` + /// use trackparse::{parse, VersionType}; + /// + /// let track = parse("Fox Stevenson - Bruises (Magnetude Remix) [Extended Mix]"); + /// let types: Vec = track.versions.iter().map(|v| v.version_type).collect(); + /// assert_eq!(types, [VersionType::Remix, VersionType::Extended]); + /// assert_eq!(VersionType::SpedUp.as_str(), "spedUp"); + /// ``` + #[non_exhaustive] + VersionType { + Remix => "remix", Bootleg => "bootleg", Vip => "vip", Edit => "edit", Flip => "flip", + Refix => "refix", Rework => "rework", Mashup => "mashup", Blend => "blend", Dub => "dub", + Mix => "mix", Extended => "extended", Radio => "radio", Club => "club", + Original => "original", Instrumental => "instrumental", Acapella => "acapella", + Live => "live", Acoustic => "acoustic", Remaster => "remaster", Demo => "demo", + Reprise => "reprise", Cover => "cover", Version => "version", SpedUp => "spedUp", + Slowed => "slowed", Nightcore => "nightcore", + } +} + +string_enum! { + /// How a version was written: in a bracket group, or after a dash. + /// + /// ``` + /// use trackparse::{parse, VersionDelimiter}; + /// + /// let track = parse("Noisia - Stigma [VIP] - Extended Mix"); + /// assert_eq!(track.versions[0].delimiter, VersionDelimiter::Square); + /// assert_eq!(track.versions[1].delimiter, VersionDelimiter::Dash); + /// ``` + VersionDelimiter { Paren => "(", Square => "[", Curly => "{", Dash => "-" } +} + +string_enum! { + /// What kind of noise a junk fragment is (R5). + /// + /// ``` + /// use trackparse::{parse, JunkKind}; + /// + /// let track = parse("Noisia - Stigma [Official Video] [HD] [Free Download]"); + /// let kinds: Vec = track.junk.iter().map(|j| j.kind).collect(); + /// assert_eq!(kinds, [JunkKind::Video, JunkKind::Quality, JunkKind::Promo]); + /// ``` + #[non_exhaustive] + JunkKind { + Video => "video", Audio => "audio", Lyrics => "lyrics", Quality => "quality", + Promo => "promo", Platform => "platform", Label => "label", Genre => "genre", + Other => "other", + } +} + +string_enum! { + /// A warning of the single-track parser: the result is a guess the caller may want to check. + /// + /// ``` + /// use trackparse::{parse, Warning}; + /// + /// assert_eq!(parse("Just A Title").warnings, [Warning::NoSeparator]); + /// assert_eq!(parse("Noisia - Stigma (Unbalanced").warnings, [Warning::UnbalancedBrackets]); + /// assert_eq!(Warning::NoSeparator.as_str(), "noSeparator"); + /// ``` + #[non_exhaustive] + Warning { + NoSeparator => "noSeparator", AmbiguousSeparator => "ambiguousSeparator", + UnspacedDashSplit => "unspacedDashSplit", AsymmetricDashSplit => "asymmetricDashSplit", + BySplit => "bySplit", QuotedTitleSplit => "quotedTitleSplit", + AmbiguousMixCredit => "ambiguousMixCredit", UnbalancedBrackets => "unbalancedBrackets", + } +} + +/// One credited artist. +/// +/// ``` +/// use trackparse::{parse, ArtistRole, ArtistSource}; +/// +/// let track = parse("Noisia & The Upbeats - Dead Limit"); +/// let second = &track.artists[1]; +/// assert_eq!(second.name, "The Upbeats"); +/// assert_eq!(second.role, ArtistRole::Primary); +/// assert_eq!(second.joiner.as_deref(), Some("&")); +/// assert_eq!(second.source, ArtistSource::Artist); +/// assert_eq!( +/// second.to_json(), +/// r#"{"name":"The Upbeats","role":"primary","joiner":"&","source":"artist"}"# +/// ); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Artist { + /// The name as written, trimmed. + pub name: String, + /// What the artist did on the track. + pub role: ArtistRole, + /// Raw joiner / marker text that preceded the name in its credit list; `None` for the first. + pub joiner: Option, + /// Where in the string the artist was found. + pub source: ArtistSource, +} + +/// One version of the track: a remix, an edit, a live take, a remaster (R5, R8). +/// +/// ``` +/// use trackparse::{parse, VersionDelimiter, VersionType}; +/// +/// let track = parse("Fox Stevenson - Bruises (Magnetude Extended Remix) [Live at Lowlands 2016]"); +/// let remix = &track.versions[0]; +/// assert_eq!(remix.version_type, VersionType::Remix); +/// assert_eq!(remix.raw, "Magnetude Extended Remix"); +/// assert_eq!(remix.artists[0].name, "Magnetude"); +/// assert_eq!(remix.modifiers, ["extended"]); +/// assert_eq!(remix.delimiter, VersionDelimiter::Paren); +/// let live = &track.versions[1]; +/// assert_eq!(live.version_type, VersionType::Live); +/// assert_eq!(live.descriptor.as_deref(), Some("at Lowlands")); +/// assert_eq!(live.year, Some(2016)); +/// assert_eq!(live.delimiter, VersionDelimiter::Square); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +pub struct Version { + /// The type; `type` in JSON. + #[cfg_attr(feature = "serde", serde(rename = "type"))] + pub version_type: VersionType, + /// The version text as written, without its brackets. + pub raw: String, + /// Who made it (role `Remixer`); empty for versions without a credit. + pub artists: Vec, + /// Other version words in the same group, as lowercase keys (`extended` in `Extended Remix`). + pub modifiers: Vec, + /// Free text of the version that is neither a credit nor a keyword. + pub descriptor: Option, + /// A year written inside the version. + pub year: Option, + /// The credit is a placeholder such as `ID` or `Unknown`. + pub unknown_artist: bool, + /// How the version was written. + pub delimiter: VersionDelimiter, +} + +/// A fragment that says nothing about the track: `Official Video`, `HD`, `Free Download`. +/// It is taken out of the title and kept here (the parser extracts, it does not delete). +/// +/// ``` +/// use trackparse::{parse, JunkKind}; +/// +/// let track = parse("Noisia - Stigma [Official Video]"); +/// assert_eq!(track.junk[0].raw, "Official Video"); +/// assert_eq!(track.junk[0].kind, JunkKind::Video); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Junk { + /// The fragment as written, without its brackets. + pub raw: String, + /// What kind of noise it is. + pub kind: JunkKind, +} + +/// Yes/no facts about the track. +/// +/// ``` +/// let track = trackparse::parse("ID - ID (Explicit)"); +/// assert!(track.flags.explicit); +/// assert!(track.flags.unknown_artist && track.flags.unknown_title); +/// assert!(!track.flags.clean); +/// ``` +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +pub struct Flags { + /// Marked `Explicit` / `Dirty`. + pub explicit: bool, + /// Marked `Clean`. + pub clean: bool, + /// The artist is a placeholder (`ID`, `Unknown Artist`). + pub unknown_artist: bool, + /// The title is a placeholder (`ID`, `Untitled`). + pub unknown_title: bool, +} + +/// A track number in front of the string (R4.2). +/// +/// ``` +/// let track = trackparse::parse("01. Camo & Krooked - Climax"); +/// let position = track.position.unwrap(); +/// assert_eq!(position.raw, "01"); +/// assert_eq!(position.number, 1); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Position { + /// As written, without the separator after it. + pub raw: String, + /// The number in it. + pub number: u32, +} + +/// A cue time in front of a single track string (R4.1), in whole seconds. +/// +/// ``` +/// let track = trackparse::parse("[01:23:45] Sub Focus - Out the Blue"); +/// let timestamp = track.timestamp.unwrap(); +/// assert_eq!(timestamp.raw, "01:23:45"); +/// assert_eq!(timestamp.seconds, 5025); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Timestamp { + /// As written, without brackets. + pub raw: String, + /// The time in seconds. + pub seconds: u64, +} + +/// The result of [`parse`](crate::parse): everything recognised in one track string. +/// +/// Anything recognised is in a field; anything not recognised stays in `title` verbatim. +/// +/// ``` +/// let track = trackparse::parse("Noisia - Stigma (2015)"); +/// assert_eq!( +/// track.to_json(), +/// concat!( +/// r#"{"input":"Noisia - Stigma (2015)","mode":"clean","position":null,"#, +/// r#""timestamp":null,"artists":[{"name":"Noisia","role":"primary","joiner":null,"#, +/// r#""source":"artist"}],"title":"Stigma","fullTitle":"Stigma","versions":[],"#, +/// r#""year":2015,"flags":{"explicit":false,"clean":false,"unknownArtist":false,"#, +/// r#""unknownTitle":false},"junk":[],"warnings":[]}"# +/// ) +/// ); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +pub struct ParsedTrack { + /// The string that was parsed, unchanged. + pub input: String, + /// The mode it was parsed in. + pub mode: Mode, + /// A leading track number. + pub position: Option, + /// A leading cue time. + pub timestamp: Option, + /// Primary, featured and producer credits, in the order written. Remixers are in + /// `versions`; [`all_artists`](crate::all_artists) gives both. + pub artists: Vec, + /// The title without versions, featured credits and junk. + pub title: String, + /// The title with its versions, as written (`fullTitle` in JSON). + pub full_title: String, + /// Remixes, edits and other versions, in the order written. + pub versions: Vec, + /// A release year found outside the versions. + pub year: Option, + /// Yes/no facts. + pub flags: Flags, + /// Fragments that say nothing about the track. + pub junk: Vec, + /// Guesses the caller may want to check. + pub warnings: Vec, +} + +json_methods!(Artist, Version, Junk, Flags, Position, Timestamp, ParsedTrack); + +/// Conversion to the spec's JSON form (camelCase keys, every key present, schema order). +/// +/// Every output type also has `to_json()` as an inherent method; the trait is for generic code. +/// It is sealed: only the types of this crate implement it. +/// +/// ``` +/// use trackparse::json::Json; +/// use trackparse::ToJson; +/// +/// let track = trackparse::parse("Noisia - Stigma"); +/// let value: Json = track.to_json_value(); +/// assert_eq!(value.get("title").and_then(Json::as_str), Some("Stigma")); +/// ``` +pub trait ToJson: sealed::Sealed { + /// The value as a JSON tree. + fn to_json_value(&self) -> Json; + + /// Compact JSON text. + fn to_json(&self) -> String { + self.to_json_value().write() + } +} + +pub(crate) mod sealed { + /// Keeps [`ToJson`](super::ToJson) closed to this crate's types. + pub trait Sealed {} +} + +pub(crate) fn obj(entries: Vec<(&str, Json)>) -> Json { + Json::Obj(entries.into_iter().map(|(k, v)| (k.to_string(), v)).collect()) +} + +pub(crate) fn list(items: &[T]) -> Json { + Json::Arr(items.iter().map(ToJson::to_json_value).collect()) +} + +pub(crate) fn opt(v: &Option) -> Json { + v.as_ref().map_or(Json::Null, ToJson::to_json_value) +} + +fn num_opt(v: Option) -> Json { + v.map_or(Json::Null, |n| Json::Num(f64::from(n))) +} + +impl ToJson for Artist { + fn to_json_value(&self) -> Json { + obj(vec![ + ("name", Json::str(&self.name)), + ("role", Json::str(self.role.as_str())), + ("joiner", Json::opt_str(self.joiner.as_deref())), + ("source", Json::str(self.source.as_str())), + ]) + } +} + +impl ToJson for Version { + fn to_json_value(&self) -> Json { + obj(vec![ + ("type", Json::str(self.version_type.as_str())), + ("raw", Json::str(&self.raw)), + ("artists", list(&self.artists)), + ("modifiers", Json::Arr(self.modifiers.iter().map(|m| Json::str(m)).collect())), + ("descriptor", Json::opt_str(self.descriptor.as_deref())), + ("year", num_opt(self.year)), + ("unknownArtist", Json::Bool(self.unknown_artist)), + ("delimiter", Json::str(self.delimiter.as_str())), + ]) + } +} + +impl ToJson for Junk { + fn to_json_value(&self) -> Json { + obj(vec![("raw", Json::str(&self.raw)), ("kind", Json::str(self.kind.as_str()))]) + } +} + +impl ToJson for Flags { + fn to_json_value(&self) -> Json { + obj(vec![ + ("explicit", Json::Bool(self.explicit)), + ("clean", Json::Bool(self.clean)), + ("unknownArtist", Json::Bool(self.unknown_artist)), + ("unknownTitle", Json::Bool(self.unknown_title)), + ]) + } +} + +impl ToJson for Position { + fn to_json_value(&self) -> Json { + obj(vec![("raw", Json::str(&self.raw)), ("number", Json::Num(f64::from(self.number)))]) + } +} + +impl ToJson for Timestamp { + fn to_json_value(&self) -> Json { + obj(vec![("raw", Json::str(&self.raw)), ("seconds", Json::Num(self.seconds as f64))]) + } +} + +impl ToJson for ParsedTrack { + fn to_json_value(&self) -> Json { + obj(vec![ + ("input", Json::str(&self.input)), + ("mode", Json::str(self.mode.as_str())), + ("position", opt(&self.position)), + ("timestamp", opt(&self.timestamp)), + ("artists", list(&self.artists)), + ("title", Json::str(&self.title)), + ("fullTitle", Json::str(&self.full_title)), + ("versions", list(&self.versions)), + ("year", num_opt(self.year)), + ("flags", self.flags.to_json_value()), + ("junk", list(&self.junk)), + ("warnings", Json::Arr(self.warnings.iter().map(|w| Json::str(w.as_str())).collect())), + ]) + } +} + +// --------------------------------------------------------------------------- +// The pipeline's own track. Version types and junk kinds are strings here: through loose JSON +// options (`keywords.versionHeads`, `keywords.junk`) the JS reference passes any string value on +// to the output, which the typed enums above cannot hold. `wire` writes this form; the typed API +// converts it (the typed options can only name real types and kinds). + +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) struct RawVersion { + pub vtype: String, + pub raw: String, + pub artists: Vec, + pub modifiers: Vec, + pub descriptor: Option, + pub year: Option, + pub unknown_artist: bool, + pub delimiter: VersionDelimiter, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) struct RawJunk { + pub raw: String, + pub kind: String, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) struct RawTrack { + pub input: String, + pub mode: Mode, + pub position: Option, + pub timestamp: Option, + pub artists: Vec, + pub title: String, + pub full_title: String, + pub versions: Vec, + pub year: Option, + pub flags: Flags, + pub junk: Vec, + pub warnings: Vec, +} + +impl RawTrack { + pub(crate) fn empty(input: &str, mode: Mode) -> RawTrack { + RawTrack { + input: input.to_string(), + mode, + position: None, + timestamp: None, + artists: Vec::new(), + title: String::new(), + full_title: String::new(), + versions: Vec::new(), + year: None, + flags: Flags::default(), + junk: Vec::new(), + warnings: Vec::new(), + } + } + + /// The typed track. A type or kind name the enums do not have (only reachable through loose + /// JSON options) becomes `VersionType::Version` / `JunkKind::Other`. + pub(crate) fn into_track(self) -> ParsedTrack { + ParsedTrack { + input: self.input, + mode: self.mode, + position: self.position, + timestamp: self.timestamp, + artists: self.artists, + title: self.title, + full_title: self.full_title, + versions: self + .versions + .into_iter() + .map(|v| Version { + version_type: VersionType::from_name(&v.vtype).unwrap_or(VersionType::Version), + raw: v.raw, + artists: v.artists, + modifiers: v.modifiers, + descriptor: v.descriptor, + year: v.year, + unknown_artist: v.unknown_artist, + delimiter: v.delimiter, + }) + .collect(), + year: self.year, + flags: self.flags, + junk: self + .junk + .into_iter() + .map(|j| Junk { + raw: j.raw, + kind: JunkKind::from_name(&j.kind).unwrap_or(JunkKind::Other), + }) + .collect(), + warnings: self.warnings, + } + } + + /// The spec's JSON form, written exactly as the JS reference would. + pub(crate) fn to_json_value(&self) -> Json { + let versions = self + .versions + .iter() + .map(|v| { + obj(vec![ + ("type", Json::str(&v.vtype)), + ("raw", Json::str(&v.raw)), + ("artists", list(&v.artists)), + ("modifiers", Json::Arr(v.modifiers.iter().map(|m| Json::str(m)).collect())), + ("descriptor", Json::opt_str(v.descriptor.as_deref())), + ("year", num_opt(v.year)), + ("unknownArtist", Json::Bool(v.unknown_artist)), + ("delimiter", Json::str(v.delimiter.as_str())), + ]) + }) + .collect(); + let junk = self + .junk + .iter() + .map(|j| obj(vec![("raw", Json::str(&j.raw)), ("kind", Json::str(&j.kind))])) + .collect(); + obj(vec![ + ("input", Json::str(&self.input)), + ("mode", Json::str(self.mode.as_str())), + ("position", opt(&self.position)), + ("timestamp", opt(&self.timestamp)), + ("artists", list(&self.artists)), + ("title", Json::str(&self.title)), + ("fullTitle", Json::str(&self.full_title)), + ("versions", Json::Arr(versions)), + ("year", num_opt(self.year)), + ("flags", self.flags.to_json_value()), + ("junk", Json::Arr(junk)), + ("warnings", Json::Arr(self.warnings.iter().map(|w| Json::str(w.as_str())).collect())), + ]) + } +} diff --git a/rust/src/unicode_tables.rs b/rust/src/unicode_tables.rs new file mode 100644 index 0000000..3fcccb8 --- /dev/null +++ b/rust/src/unicode_tables.rs @@ -0,0 +1,2177 @@ +// GENERATED — do not edit. Run `node scripts/gen_data.mjs` to regenerate. +// General category tables for SPEC R0.6, taken from the JS reference engine's \p{L} and \p{Lu}, +// and its `toLowerCase()` for the R0.4 dedup key (`str::to_lowercase` follows the compiler's +// Unicode version, so it cannot be used). +// Unicode 17.0 + +/// General category L (Lu, Ll, Lt, Lm, Lo), inclusive ranges. +pub static LETTER: &[(u32, u32)] = &[ + (0x41, 0x5a), + (0x61, 0x7a), + (0xaa, 0xaa), + (0xb5, 0xb5), + (0xba, 0xba), + (0xc0, 0xd6), + (0xd8, 0xf6), + (0xf8, 0x2c1), + (0x2c6, 0x2d1), + (0x2e0, 0x2e4), + (0x2ec, 0x2ec), + (0x2ee, 0x2ee), + (0x370, 0x374), + (0x376, 0x377), + (0x37a, 0x37d), + (0x37f, 0x37f), + (0x386, 0x386), + (0x388, 0x38a), + (0x38c, 0x38c), + (0x38e, 0x3a1), + (0x3a3, 0x3f5), + (0x3f7, 0x481), + (0x48a, 0x52f), + (0x531, 0x556), + (0x559, 0x559), + (0x560, 0x588), + (0x5d0, 0x5ea), + (0x5ef, 0x5f2), + (0x620, 0x64a), + (0x66e, 0x66f), + (0x671, 0x6d3), + (0x6d5, 0x6d5), + (0x6e5, 0x6e6), + (0x6ee, 0x6ef), + (0x6fa, 0x6fc), + (0x6ff, 0x6ff), + (0x710, 0x710), + (0x712, 0x72f), + (0x74d, 0x7a5), + (0x7b1, 0x7b1), + (0x7ca, 0x7ea), + (0x7f4, 0x7f5), + (0x7fa, 0x7fa), + (0x800, 0x815), + (0x81a, 0x81a), + (0x824, 0x824), + (0x828, 0x828), + (0x840, 0x858), + (0x860, 0x86a), + (0x870, 0x887), + (0x889, 0x88f), + (0x8a0, 0x8c9), + (0x904, 0x939), + (0x93d, 0x93d), + (0x950, 0x950), + (0x958, 0x961), + (0x971, 0x980), + (0x985, 0x98c), + (0x98f, 0x990), + (0x993, 0x9a8), + (0x9aa, 0x9b0), + (0x9b2, 0x9b2), + (0x9b6, 0x9b9), + (0x9bd, 0x9bd), + (0x9ce, 0x9ce), + (0x9dc, 0x9dd), + (0x9df, 0x9e1), + (0x9f0, 0x9f1), + (0x9fc, 0x9fc), + (0xa05, 0xa0a), + (0xa0f, 0xa10), + (0xa13, 0xa28), + (0xa2a, 0xa30), + (0xa32, 0xa33), + (0xa35, 0xa36), + (0xa38, 0xa39), + (0xa59, 0xa5c), + (0xa5e, 0xa5e), + (0xa72, 0xa74), + (0xa85, 0xa8d), + (0xa8f, 0xa91), + (0xa93, 0xaa8), + (0xaaa, 0xab0), + (0xab2, 0xab3), + (0xab5, 0xab9), + (0xabd, 0xabd), + (0xad0, 0xad0), + (0xae0, 0xae1), + (0xaf9, 0xaf9), + (0xb05, 0xb0c), + (0xb0f, 0xb10), + (0xb13, 0xb28), + (0xb2a, 0xb30), + (0xb32, 0xb33), + (0xb35, 0xb39), + (0xb3d, 0xb3d), + (0xb5c, 0xb5d), + (0xb5f, 0xb61), + (0xb71, 0xb71), + (0xb83, 0xb83), + (0xb85, 0xb8a), + (0xb8e, 0xb90), + (0xb92, 0xb95), + (0xb99, 0xb9a), + (0xb9c, 0xb9c), + (0xb9e, 0xb9f), + (0xba3, 0xba4), + (0xba8, 0xbaa), + (0xbae, 0xbb9), + (0xbd0, 0xbd0), + (0xc05, 0xc0c), + (0xc0e, 0xc10), + (0xc12, 0xc28), + (0xc2a, 0xc39), + (0xc3d, 0xc3d), + (0xc58, 0xc5a), + (0xc5c, 0xc5d), + (0xc60, 0xc61), + (0xc80, 0xc80), + (0xc85, 0xc8c), + (0xc8e, 0xc90), + (0xc92, 0xca8), + (0xcaa, 0xcb3), + (0xcb5, 0xcb9), + (0xcbd, 0xcbd), + (0xcdc, 0xcde), + (0xce0, 0xce1), + (0xcf1, 0xcf2), + (0xd04, 0xd0c), + (0xd0e, 0xd10), + (0xd12, 0xd3a), + (0xd3d, 0xd3d), + (0xd4e, 0xd4e), + (0xd54, 0xd56), + (0xd5f, 0xd61), + (0xd7a, 0xd7f), + (0xd85, 0xd96), + (0xd9a, 0xdb1), + (0xdb3, 0xdbb), + (0xdbd, 0xdbd), + (0xdc0, 0xdc6), + (0xe01, 0xe30), + (0xe32, 0xe33), + (0xe40, 0xe46), + (0xe81, 0xe82), + (0xe84, 0xe84), + (0xe86, 0xe8a), + (0xe8c, 0xea3), + (0xea5, 0xea5), + (0xea7, 0xeb0), + (0xeb2, 0xeb3), + (0xebd, 0xebd), + (0xec0, 0xec4), + (0xec6, 0xec6), + (0xedc, 0xedf), + (0xf00, 0xf00), + (0xf40, 0xf47), + (0xf49, 0xf6c), + (0xf88, 0xf8c), + (0x1000, 0x102a), + (0x103f, 0x103f), + (0x1050, 0x1055), + (0x105a, 0x105d), + (0x1061, 0x1061), + (0x1065, 0x1066), + (0x106e, 0x1070), + (0x1075, 0x1081), + (0x108e, 0x108e), + (0x10a0, 0x10c5), + (0x10c7, 0x10c7), + (0x10cd, 0x10cd), + (0x10d0, 0x10fa), + (0x10fc, 0x1248), + (0x124a, 0x124d), + (0x1250, 0x1256), + (0x1258, 0x1258), + (0x125a, 0x125d), + (0x1260, 0x1288), + (0x128a, 0x128d), + (0x1290, 0x12b0), + (0x12b2, 0x12b5), + (0x12b8, 0x12be), + (0x12c0, 0x12c0), + (0x12c2, 0x12c5), + (0x12c8, 0x12d6), + (0x12d8, 0x1310), + (0x1312, 0x1315), + (0x1318, 0x135a), + (0x1380, 0x138f), + (0x13a0, 0x13f5), + (0x13f8, 0x13fd), + (0x1401, 0x166c), + (0x166f, 0x167f), + (0x1681, 0x169a), + (0x16a0, 0x16ea), + (0x16f1, 0x16f8), + (0x1700, 0x1711), + (0x171f, 0x1731), + (0x1740, 0x1751), + (0x1760, 0x176c), + (0x176e, 0x1770), + (0x1780, 0x17b3), + (0x17d7, 0x17d7), + (0x17dc, 0x17dc), + (0x1820, 0x1878), + (0x1880, 0x1884), + (0x1887, 0x18a8), + (0x18aa, 0x18aa), + (0x18b0, 0x18f5), + (0x1900, 0x191e), + (0x1950, 0x196d), + (0x1970, 0x1974), + (0x1980, 0x19ab), + (0x19b0, 0x19c9), + (0x1a00, 0x1a16), + (0x1a20, 0x1a54), + (0x1aa7, 0x1aa7), + (0x1b05, 0x1b33), + (0x1b45, 0x1b4c), + (0x1b83, 0x1ba0), + (0x1bae, 0x1baf), + (0x1bba, 0x1be5), + (0x1c00, 0x1c23), + (0x1c4d, 0x1c4f), + (0x1c5a, 0x1c7d), + (0x1c80, 0x1c8a), + (0x1c90, 0x1cba), + (0x1cbd, 0x1cbf), + (0x1ce9, 0x1cec), + (0x1cee, 0x1cf3), + (0x1cf5, 0x1cf6), + (0x1cfa, 0x1cfa), + (0x1d00, 0x1dbf), + (0x1e00, 0x1f15), + (0x1f18, 0x1f1d), + (0x1f20, 0x1f45), + (0x1f48, 0x1f4d), + (0x1f50, 0x1f57), + (0x1f59, 0x1f59), + (0x1f5b, 0x1f5b), + (0x1f5d, 0x1f5d), + (0x1f5f, 0x1f7d), + (0x1f80, 0x1fb4), + (0x1fb6, 0x1fbc), + (0x1fbe, 0x1fbe), + (0x1fc2, 0x1fc4), + (0x1fc6, 0x1fcc), + (0x1fd0, 0x1fd3), + (0x1fd6, 0x1fdb), + (0x1fe0, 0x1fec), + (0x1ff2, 0x1ff4), + (0x1ff6, 0x1ffc), + (0x2071, 0x2071), + (0x207f, 0x207f), + (0x2090, 0x209c), + (0x2102, 0x2102), + (0x2107, 0x2107), + (0x210a, 0x2113), + (0x2115, 0x2115), + (0x2119, 0x211d), + (0x2124, 0x2124), + (0x2126, 0x2126), + (0x2128, 0x2128), + (0x212a, 0x212d), + (0x212f, 0x2139), + (0x213c, 0x213f), + (0x2145, 0x2149), + (0x214e, 0x214e), + (0x2183, 0x2184), + (0x2c00, 0x2ce4), + (0x2ceb, 0x2cee), + (0x2cf2, 0x2cf3), + (0x2d00, 0x2d25), + (0x2d27, 0x2d27), + (0x2d2d, 0x2d2d), + (0x2d30, 0x2d67), + (0x2d6f, 0x2d6f), + (0x2d80, 0x2d96), + (0x2da0, 0x2da6), + (0x2da8, 0x2dae), + (0x2db0, 0x2db6), + (0x2db8, 0x2dbe), + (0x2dc0, 0x2dc6), + (0x2dc8, 0x2dce), + (0x2dd0, 0x2dd6), + (0x2dd8, 0x2dde), + (0x2e2f, 0x2e2f), + (0x3005, 0x3006), + (0x3031, 0x3035), + (0x303b, 0x303c), + (0x3041, 0x3096), + (0x309d, 0x309f), + (0x30a1, 0x30fa), + (0x30fc, 0x30ff), + (0x3105, 0x312f), + (0x3131, 0x318e), + (0x31a0, 0x31bf), + (0x31f0, 0x31ff), + (0x3400, 0x4dbf), + (0x4e00, 0xa48c), + (0xa4d0, 0xa4fd), + (0xa500, 0xa60c), + (0xa610, 0xa61f), + (0xa62a, 0xa62b), + (0xa640, 0xa66e), + (0xa67f, 0xa69d), + (0xa6a0, 0xa6e5), + (0xa717, 0xa71f), + (0xa722, 0xa788), + (0xa78b, 0xa7dc), + (0xa7f1, 0xa801), + (0xa803, 0xa805), + (0xa807, 0xa80a), + (0xa80c, 0xa822), + (0xa840, 0xa873), + (0xa882, 0xa8b3), + (0xa8f2, 0xa8f7), + (0xa8fb, 0xa8fb), + (0xa8fd, 0xa8fe), + (0xa90a, 0xa925), + (0xa930, 0xa946), + (0xa960, 0xa97c), + (0xa984, 0xa9b2), + (0xa9cf, 0xa9cf), + (0xa9e0, 0xa9e4), + (0xa9e6, 0xa9ef), + (0xa9fa, 0xa9fe), + (0xaa00, 0xaa28), + (0xaa40, 0xaa42), + (0xaa44, 0xaa4b), + (0xaa60, 0xaa76), + (0xaa7a, 0xaa7a), + (0xaa7e, 0xaaaf), + (0xaab1, 0xaab1), + (0xaab5, 0xaab6), + (0xaab9, 0xaabd), + (0xaac0, 0xaac0), + (0xaac2, 0xaac2), + (0xaadb, 0xaadd), + (0xaae0, 0xaaea), + (0xaaf2, 0xaaf4), + (0xab01, 0xab06), + (0xab09, 0xab0e), + (0xab11, 0xab16), + (0xab20, 0xab26), + (0xab28, 0xab2e), + (0xab30, 0xab5a), + (0xab5c, 0xab69), + (0xab70, 0xabe2), + (0xac00, 0xd7a3), + (0xd7b0, 0xd7c6), + (0xd7cb, 0xd7fb), + (0xf900, 0xfa6d), + (0xfa70, 0xfad9), + (0xfb00, 0xfb06), + (0xfb13, 0xfb17), + (0xfb1d, 0xfb1d), + (0xfb1f, 0xfb28), + (0xfb2a, 0xfb36), + (0xfb38, 0xfb3c), + (0xfb3e, 0xfb3e), + (0xfb40, 0xfb41), + (0xfb43, 0xfb44), + (0xfb46, 0xfbb1), + (0xfbd3, 0xfd3d), + (0xfd50, 0xfd8f), + (0xfd92, 0xfdc7), + (0xfdf0, 0xfdfb), + (0xfe70, 0xfe74), + (0xfe76, 0xfefc), + (0xff21, 0xff3a), + (0xff41, 0xff5a), + (0xff66, 0xffbe), + (0xffc2, 0xffc7), + (0xffca, 0xffcf), + (0xffd2, 0xffd7), + (0xffda, 0xffdc), + (0x10000, 0x1000b), + (0x1000d, 0x10026), + (0x10028, 0x1003a), + (0x1003c, 0x1003d), + (0x1003f, 0x1004d), + (0x10050, 0x1005d), + (0x10080, 0x100fa), + (0x10280, 0x1029c), + (0x102a0, 0x102d0), + (0x10300, 0x1031f), + (0x1032d, 0x10340), + (0x10342, 0x10349), + (0x10350, 0x10375), + (0x10380, 0x1039d), + (0x103a0, 0x103c3), + (0x103c8, 0x103cf), + (0x10400, 0x1049d), + (0x104b0, 0x104d3), + (0x104d8, 0x104fb), + (0x10500, 0x10527), + (0x10530, 0x10563), + (0x10570, 0x1057a), + (0x1057c, 0x1058a), + (0x1058c, 0x10592), + (0x10594, 0x10595), + (0x10597, 0x105a1), + (0x105a3, 0x105b1), + (0x105b3, 0x105b9), + (0x105bb, 0x105bc), + (0x105c0, 0x105f3), + (0x10600, 0x10736), + (0x10740, 0x10755), + (0x10760, 0x10767), + (0x10780, 0x10785), + (0x10787, 0x107b0), + (0x107b2, 0x107ba), + (0x10800, 0x10805), + (0x10808, 0x10808), + (0x1080a, 0x10835), + (0x10837, 0x10838), + (0x1083c, 0x1083c), + (0x1083f, 0x10855), + (0x10860, 0x10876), + (0x10880, 0x1089e), + (0x108e0, 0x108f2), + (0x108f4, 0x108f5), + (0x10900, 0x10915), + (0x10920, 0x10939), + (0x10940, 0x10959), + (0x10980, 0x109b7), + (0x109be, 0x109bf), + (0x10a00, 0x10a00), + (0x10a10, 0x10a13), + (0x10a15, 0x10a17), + (0x10a19, 0x10a35), + (0x10a60, 0x10a7c), + (0x10a80, 0x10a9c), + (0x10ac0, 0x10ac7), + (0x10ac9, 0x10ae4), + (0x10b00, 0x10b35), + (0x10b40, 0x10b55), + (0x10b60, 0x10b72), + (0x10b80, 0x10b91), + (0x10c00, 0x10c48), + (0x10c80, 0x10cb2), + (0x10cc0, 0x10cf2), + (0x10d00, 0x10d23), + (0x10d4a, 0x10d65), + (0x10d6f, 0x10d85), + (0x10e80, 0x10ea9), + (0x10eb0, 0x10eb1), + (0x10ec2, 0x10ec7), + (0x10f00, 0x10f1c), + (0x10f27, 0x10f27), + (0x10f30, 0x10f45), + (0x10f70, 0x10f81), + (0x10fb0, 0x10fc4), + (0x10fe0, 0x10ff6), + (0x11003, 0x11037), + (0x11071, 0x11072), + (0x11075, 0x11075), + (0x11083, 0x110af), + (0x110d0, 0x110e8), + (0x11103, 0x11126), + (0x11144, 0x11144), + (0x11147, 0x11147), + (0x11150, 0x11172), + (0x11176, 0x11176), + (0x11183, 0x111b2), + (0x111c1, 0x111c4), + (0x111da, 0x111da), + (0x111dc, 0x111dc), + (0x11200, 0x11211), + (0x11213, 0x1122b), + (0x1123f, 0x11240), + (0x11280, 0x11286), + (0x11288, 0x11288), + (0x1128a, 0x1128d), + (0x1128f, 0x1129d), + (0x1129f, 0x112a8), + (0x112b0, 0x112de), + (0x11305, 0x1130c), + (0x1130f, 0x11310), + (0x11313, 0x11328), + (0x1132a, 0x11330), + (0x11332, 0x11333), + (0x11335, 0x11339), + (0x1133d, 0x1133d), + (0x11350, 0x11350), + (0x1135d, 0x11361), + (0x11380, 0x11389), + (0x1138b, 0x1138b), + (0x1138e, 0x1138e), + (0x11390, 0x113b5), + (0x113b7, 0x113b7), + (0x113d1, 0x113d1), + (0x113d3, 0x113d3), + (0x11400, 0x11434), + (0x11447, 0x1144a), + (0x1145f, 0x11461), + (0x11480, 0x114af), + (0x114c4, 0x114c5), + (0x114c7, 0x114c7), + (0x11580, 0x115ae), + (0x115d8, 0x115db), + (0x11600, 0x1162f), + (0x11644, 0x11644), + (0x11680, 0x116aa), + (0x116b8, 0x116b8), + (0x11700, 0x1171a), + (0x11740, 0x11746), + (0x11800, 0x1182b), + (0x118a0, 0x118df), + (0x118ff, 0x11906), + (0x11909, 0x11909), + (0x1190c, 0x11913), + (0x11915, 0x11916), + (0x11918, 0x1192f), + (0x1193f, 0x1193f), + (0x11941, 0x11941), + (0x119a0, 0x119a7), + (0x119aa, 0x119d0), + (0x119e1, 0x119e1), + (0x119e3, 0x119e3), + (0x11a00, 0x11a00), + (0x11a0b, 0x11a32), + (0x11a3a, 0x11a3a), + (0x11a50, 0x11a50), + (0x11a5c, 0x11a89), + (0x11a9d, 0x11a9d), + (0x11ab0, 0x11af8), + (0x11bc0, 0x11be0), + (0x11c00, 0x11c08), + (0x11c0a, 0x11c2e), + (0x11c40, 0x11c40), + (0x11c72, 0x11c8f), + (0x11d00, 0x11d06), + (0x11d08, 0x11d09), + (0x11d0b, 0x11d30), + (0x11d46, 0x11d46), + (0x11d60, 0x11d65), + (0x11d67, 0x11d68), + (0x11d6a, 0x11d89), + (0x11d98, 0x11d98), + (0x11db0, 0x11ddb), + (0x11ee0, 0x11ef2), + (0x11f02, 0x11f02), + (0x11f04, 0x11f10), + (0x11f12, 0x11f33), + (0x11fb0, 0x11fb0), + (0x12000, 0x12399), + (0x12480, 0x12543), + (0x12f90, 0x12ff0), + (0x13000, 0x1342f), + (0x13441, 0x13446), + (0x13460, 0x143fa), + (0x14400, 0x14646), + (0x16100, 0x1611d), + (0x16800, 0x16a38), + (0x16a40, 0x16a5e), + (0x16a70, 0x16abe), + (0x16ad0, 0x16aed), + (0x16b00, 0x16b2f), + (0x16b40, 0x16b43), + (0x16b63, 0x16b77), + (0x16b7d, 0x16b8f), + (0x16d40, 0x16d6c), + (0x16e40, 0x16e7f), + (0x16ea0, 0x16eb8), + (0x16ebb, 0x16ed3), + (0x16f00, 0x16f4a), + (0x16f50, 0x16f50), + (0x16f93, 0x16f9f), + (0x16fe0, 0x16fe1), + (0x16fe3, 0x16fe3), + (0x16ff2, 0x16ff3), + (0x17000, 0x18cd5), + (0x18cff, 0x18d1e), + (0x18d80, 0x18df2), + (0x1aff0, 0x1aff3), + (0x1aff5, 0x1affb), + (0x1affd, 0x1affe), + (0x1b000, 0x1b122), + (0x1b132, 0x1b132), + (0x1b150, 0x1b152), + (0x1b155, 0x1b155), + (0x1b164, 0x1b167), + (0x1b170, 0x1b2fb), + (0x1bc00, 0x1bc6a), + (0x1bc70, 0x1bc7c), + (0x1bc80, 0x1bc88), + (0x1bc90, 0x1bc99), + (0x1d400, 0x1d454), + (0x1d456, 0x1d49c), + (0x1d49e, 0x1d49f), + (0x1d4a2, 0x1d4a2), + (0x1d4a5, 0x1d4a6), + (0x1d4a9, 0x1d4ac), + (0x1d4ae, 0x1d4b9), + (0x1d4bb, 0x1d4bb), + (0x1d4bd, 0x1d4c3), + (0x1d4c5, 0x1d505), + (0x1d507, 0x1d50a), + (0x1d50d, 0x1d514), + (0x1d516, 0x1d51c), + (0x1d51e, 0x1d539), + (0x1d53b, 0x1d53e), + (0x1d540, 0x1d544), + (0x1d546, 0x1d546), + (0x1d54a, 0x1d550), + (0x1d552, 0x1d6a5), + (0x1d6a8, 0x1d6c0), + (0x1d6c2, 0x1d6da), + (0x1d6dc, 0x1d6fa), + (0x1d6fc, 0x1d714), + (0x1d716, 0x1d734), + (0x1d736, 0x1d74e), + (0x1d750, 0x1d76e), + (0x1d770, 0x1d788), + (0x1d78a, 0x1d7a8), + (0x1d7aa, 0x1d7c2), + (0x1d7c4, 0x1d7cb), + (0x1df00, 0x1df1e), + (0x1df25, 0x1df2a), + (0x1e030, 0x1e06d), + (0x1e100, 0x1e12c), + (0x1e137, 0x1e13d), + (0x1e14e, 0x1e14e), + (0x1e290, 0x1e2ad), + (0x1e2c0, 0x1e2eb), + (0x1e4d0, 0x1e4eb), + (0x1e5d0, 0x1e5ed), + (0x1e5f0, 0x1e5f0), + (0x1e6c0, 0x1e6de), + (0x1e6e0, 0x1e6e2), + (0x1e6e4, 0x1e6e5), + (0x1e6e7, 0x1e6ed), + (0x1e6f0, 0x1e6f4), + (0x1e6fe, 0x1e6ff), + (0x1e7e0, 0x1e7e6), + (0x1e7e8, 0x1e7eb), + (0x1e7ed, 0x1e7ee), + (0x1e7f0, 0x1e7fe), + (0x1e800, 0x1e8c4), + (0x1e900, 0x1e943), + (0x1e94b, 0x1e94b), + (0x1ee00, 0x1ee03), + (0x1ee05, 0x1ee1f), + (0x1ee21, 0x1ee22), + (0x1ee24, 0x1ee24), + (0x1ee27, 0x1ee27), + (0x1ee29, 0x1ee32), + (0x1ee34, 0x1ee37), + (0x1ee39, 0x1ee39), + (0x1ee3b, 0x1ee3b), + (0x1ee42, 0x1ee42), + (0x1ee47, 0x1ee47), + (0x1ee49, 0x1ee49), + (0x1ee4b, 0x1ee4b), + (0x1ee4d, 0x1ee4f), + (0x1ee51, 0x1ee52), + (0x1ee54, 0x1ee54), + (0x1ee57, 0x1ee57), + (0x1ee59, 0x1ee59), + (0x1ee5b, 0x1ee5b), + (0x1ee5d, 0x1ee5d), + (0x1ee5f, 0x1ee5f), + (0x1ee61, 0x1ee62), + (0x1ee64, 0x1ee64), + (0x1ee67, 0x1ee6a), + (0x1ee6c, 0x1ee72), + (0x1ee74, 0x1ee77), + (0x1ee79, 0x1ee7c), + (0x1ee7e, 0x1ee7e), + (0x1ee80, 0x1ee89), + (0x1ee8b, 0x1ee9b), + (0x1eea1, 0x1eea3), + (0x1eea5, 0x1eea9), + (0x1eeab, 0x1eebb), + (0x20000, 0x2a6df), + (0x2a700, 0x2b81d), + (0x2b820, 0x2cead), + (0x2ceb0, 0x2ebe0), + (0x2ebf0, 0x2ee5d), + (0x2f800, 0x2fa1d), + (0x30000, 0x3134a), + (0x31350, 0x33479), +]; + +/// General category Lu, inclusive ranges. +pub static UPPERCASE_LETTER: &[(u32, u32)] = &[ + (0x41, 0x5a), + (0xc0, 0xd6), + (0xd8, 0xde), + (0x100, 0x100), + (0x102, 0x102), + (0x104, 0x104), + (0x106, 0x106), + (0x108, 0x108), + (0x10a, 0x10a), + (0x10c, 0x10c), + (0x10e, 0x10e), + (0x110, 0x110), + (0x112, 0x112), + (0x114, 0x114), + (0x116, 0x116), + (0x118, 0x118), + (0x11a, 0x11a), + (0x11c, 0x11c), + (0x11e, 0x11e), + (0x120, 0x120), + (0x122, 0x122), + (0x124, 0x124), + (0x126, 0x126), + (0x128, 0x128), + (0x12a, 0x12a), + (0x12c, 0x12c), + (0x12e, 0x12e), + (0x130, 0x130), + (0x132, 0x132), + (0x134, 0x134), + (0x136, 0x136), + (0x139, 0x139), + (0x13b, 0x13b), + (0x13d, 0x13d), + (0x13f, 0x13f), + (0x141, 0x141), + (0x143, 0x143), + (0x145, 0x145), + (0x147, 0x147), + (0x14a, 0x14a), + (0x14c, 0x14c), + (0x14e, 0x14e), + (0x150, 0x150), + (0x152, 0x152), + (0x154, 0x154), + (0x156, 0x156), + (0x158, 0x158), + (0x15a, 0x15a), + (0x15c, 0x15c), + (0x15e, 0x15e), + (0x160, 0x160), + (0x162, 0x162), + (0x164, 0x164), + (0x166, 0x166), + (0x168, 0x168), + (0x16a, 0x16a), + (0x16c, 0x16c), + (0x16e, 0x16e), + (0x170, 0x170), + (0x172, 0x172), + (0x174, 0x174), + (0x176, 0x176), + (0x178, 0x179), + (0x17b, 0x17b), + (0x17d, 0x17d), + (0x181, 0x182), + (0x184, 0x184), + (0x186, 0x187), + (0x189, 0x18b), + (0x18e, 0x191), + (0x193, 0x194), + (0x196, 0x198), + (0x19c, 0x19d), + (0x19f, 0x1a0), + (0x1a2, 0x1a2), + (0x1a4, 0x1a4), + (0x1a6, 0x1a7), + (0x1a9, 0x1a9), + (0x1ac, 0x1ac), + (0x1ae, 0x1af), + (0x1b1, 0x1b3), + (0x1b5, 0x1b5), + (0x1b7, 0x1b8), + (0x1bc, 0x1bc), + (0x1c4, 0x1c4), + (0x1c7, 0x1c7), + (0x1ca, 0x1ca), + (0x1cd, 0x1cd), + (0x1cf, 0x1cf), + (0x1d1, 0x1d1), + (0x1d3, 0x1d3), + (0x1d5, 0x1d5), + (0x1d7, 0x1d7), + (0x1d9, 0x1d9), + (0x1db, 0x1db), + (0x1de, 0x1de), + (0x1e0, 0x1e0), + (0x1e2, 0x1e2), + (0x1e4, 0x1e4), + (0x1e6, 0x1e6), + (0x1e8, 0x1e8), + (0x1ea, 0x1ea), + (0x1ec, 0x1ec), + (0x1ee, 0x1ee), + (0x1f1, 0x1f1), + (0x1f4, 0x1f4), + (0x1f6, 0x1f8), + (0x1fa, 0x1fa), + (0x1fc, 0x1fc), + (0x1fe, 0x1fe), + (0x200, 0x200), + (0x202, 0x202), + (0x204, 0x204), + (0x206, 0x206), + (0x208, 0x208), + (0x20a, 0x20a), + (0x20c, 0x20c), + (0x20e, 0x20e), + (0x210, 0x210), + (0x212, 0x212), + (0x214, 0x214), + (0x216, 0x216), + (0x218, 0x218), + (0x21a, 0x21a), + (0x21c, 0x21c), + (0x21e, 0x21e), + (0x220, 0x220), + (0x222, 0x222), + (0x224, 0x224), + (0x226, 0x226), + (0x228, 0x228), + (0x22a, 0x22a), + (0x22c, 0x22c), + (0x22e, 0x22e), + (0x230, 0x230), + (0x232, 0x232), + (0x23a, 0x23b), + (0x23d, 0x23e), + (0x241, 0x241), + (0x243, 0x246), + (0x248, 0x248), + (0x24a, 0x24a), + (0x24c, 0x24c), + (0x24e, 0x24e), + (0x370, 0x370), + (0x372, 0x372), + (0x376, 0x376), + (0x37f, 0x37f), + (0x386, 0x386), + (0x388, 0x38a), + (0x38c, 0x38c), + (0x38e, 0x38f), + (0x391, 0x3a1), + (0x3a3, 0x3ab), + (0x3cf, 0x3cf), + (0x3d2, 0x3d4), + (0x3d8, 0x3d8), + (0x3da, 0x3da), + (0x3dc, 0x3dc), + (0x3de, 0x3de), + (0x3e0, 0x3e0), + (0x3e2, 0x3e2), + (0x3e4, 0x3e4), + (0x3e6, 0x3e6), + (0x3e8, 0x3e8), + (0x3ea, 0x3ea), + (0x3ec, 0x3ec), + (0x3ee, 0x3ee), + (0x3f4, 0x3f4), + (0x3f7, 0x3f7), + (0x3f9, 0x3fa), + (0x3fd, 0x42f), + (0x460, 0x460), + (0x462, 0x462), + (0x464, 0x464), + (0x466, 0x466), + (0x468, 0x468), + (0x46a, 0x46a), + (0x46c, 0x46c), + (0x46e, 0x46e), + (0x470, 0x470), + (0x472, 0x472), + (0x474, 0x474), + (0x476, 0x476), + (0x478, 0x478), + (0x47a, 0x47a), + (0x47c, 0x47c), + (0x47e, 0x47e), + (0x480, 0x480), + (0x48a, 0x48a), + (0x48c, 0x48c), + (0x48e, 0x48e), + (0x490, 0x490), + (0x492, 0x492), + (0x494, 0x494), + (0x496, 0x496), + (0x498, 0x498), + (0x49a, 0x49a), + (0x49c, 0x49c), + (0x49e, 0x49e), + (0x4a0, 0x4a0), + (0x4a2, 0x4a2), + (0x4a4, 0x4a4), + (0x4a6, 0x4a6), + (0x4a8, 0x4a8), + (0x4aa, 0x4aa), + (0x4ac, 0x4ac), + (0x4ae, 0x4ae), + (0x4b0, 0x4b0), + (0x4b2, 0x4b2), + (0x4b4, 0x4b4), + (0x4b6, 0x4b6), + (0x4b8, 0x4b8), + (0x4ba, 0x4ba), + (0x4bc, 0x4bc), + (0x4be, 0x4be), + (0x4c0, 0x4c1), + (0x4c3, 0x4c3), + (0x4c5, 0x4c5), + (0x4c7, 0x4c7), + (0x4c9, 0x4c9), + (0x4cb, 0x4cb), + (0x4cd, 0x4cd), + (0x4d0, 0x4d0), + (0x4d2, 0x4d2), + (0x4d4, 0x4d4), + (0x4d6, 0x4d6), + (0x4d8, 0x4d8), + (0x4da, 0x4da), + (0x4dc, 0x4dc), + (0x4de, 0x4de), + (0x4e0, 0x4e0), + (0x4e2, 0x4e2), + (0x4e4, 0x4e4), + (0x4e6, 0x4e6), + (0x4e8, 0x4e8), + (0x4ea, 0x4ea), + (0x4ec, 0x4ec), + (0x4ee, 0x4ee), + (0x4f0, 0x4f0), + (0x4f2, 0x4f2), + (0x4f4, 0x4f4), + (0x4f6, 0x4f6), + (0x4f8, 0x4f8), + (0x4fa, 0x4fa), + (0x4fc, 0x4fc), + (0x4fe, 0x4fe), + (0x500, 0x500), + (0x502, 0x502), + (0x504, 0x504), + (0x506, 0x506), + (0x508, 0x508), + (0x50a, 0x50a), + (0x50c, 0x50c), + (0x50e, 0x50e), + (0x510, 0x510), + (0x512, 0x512), + (0x514, 0x514), + (0x516, 0x516), + (0x518, 0x518), + (0x51a, 0x51a), + (0x51c, 0x51c), + (0x51e, 0x51e), + (0x520, 0x520), + (0x522, 0x522), + (0x524, 0x524), + (0x526, 0x526), + (0x528, 0x528), + (0x52a, 0x52a), + (0x52c, 0x52c), + (0x52e, 0x52e), + (0x531, 0x556), + (0x10a0, 0x10c5), + (0x10c7, 0x10c7), + (0x10cd, 0x10cd), + (0x13a0, 0x13f5), + (0x1c89, 0x1c89), + (0x1c90, 0x1cba), + (0x1cbd, 0x1cbf), + (0x1e00, 0x1e00), + (0x1e02, 0x1e02), + (0x1e04, 0x1e04), + (0x1e06, 0x1e06), + (0x1e08, 0x1e08), + (0x1e0a, 0x1e0a), + (0x1e0c, 0x1e0c), + (0x1e0e, 0x1e0e), + (0x1e10, 0x1e10), + (0x1e12, 0x1e12), + (0x1e14, 0x1e14), + (0x1e16, 0x1e16), + (0x1e18, 0x1e18), + (0x1e1a, 0x1e1a), + (0x1e1c, 0x1e1c), + (0x1e1e, 0x1e1e), + (0x1e20, 0x1e20), + (0x1e22, 0x1e22), + (0x1e24, 0x1e24), + (0x1e26, 0x1e26), + (0x1e28, 0x1e28), + (0x1e2a, 0x1e2a), + (0x1e2c, 0x1e2c), + (0x1e2e, 0x1e2e), + (0x1e30, 0x1e30), + (0x1e32, 0x1e32), + (0x1e34, 0x1e34), + (0x1e36, 0x1e36), + (0x1e38, 0x1e38), + (0x1e3a, 0x1e3a), + (0x1e3c, 0x1e3c), + (0x1e3e, 0x1e3e), + (0x1e40, 0x1e40), + (0x1e42, 0x1e42), + (0x1e44, 0x1e44), + (0x1e46, 0x1e46), + (0x1e48, 0x1e48), + (0x1e4a, 0x1e4a), + (0x1e4c, 0x1e4c), + (0x1e4e, 0x1e4e), + (0x1e50, 0x1e50), + (0x1e52, 0x1e52), + (0x1e54, 0x1e54), + (0x1e56, 0x1e56), + (0x1e58, 0x1e58), + (0x1e5a, 0x1e5a), + (0x1e5c, 0x1e5c), + (0x1e5e, 0x1e5e), + (0x1e60, 0x1e60), + (0x1e62, 0x1e62), + (0x1e64, 0x1e64), + (0x1e66, 0x1e66), + (0x1e68, 0x1e68), + (0x1e6a, 0x1e6a), + (0x1e6c, 0x1e6c), + (0x1e6e, 0x1e6e), + (0x1e70, 0x1e70), + (0x1e72, 0x1e72), + (0x1e74, 0x1e74), + (0x1e76, 0x1e76), + (0x1e78, 0x1e78), + (0x1e7a, 0x1e7a), + (0x1e7c, 0x1e7c), + (0x1e7e, 0x1e7e), + (0x1e80, 0x1e80), + (0x1e82, 0x1e82), + (0x1e84, 0x1e84), + (0x1e86, 0x1e86), + (0x1e88, 0x1e88), + (0x1e8a, 0x1e8a), + (0x1e8c, 0x1e8c), + (0x1e8e, 0x1e8e), + (0x1e90, 0x1e90), + (0x1e92, 0x1e92), + (0x1e94, 0x1e94), + (0x1e9e, 0x1e9e), + (0x1ea0, 0x1ea0), + (0x1ea2, 0x1ea2), + (0x1ea4, 0x1ea4), + (0x1ea6, 0x1ea6), + (0x1ea8, 0x1ea8), + (0x1eaa, 0x1eaa), + (0x1eac, 0x1eac), + (0x1eae, 0x1eae), + (0x1eb0, 0x1eb0), + (0x1eb2, 0x1eb2), + (0x1eb4, 0x1eb4), + (0x1eb6, 0x1eb6), + (0x1eb8, 0x1eb8), + (0x1eba, 0x1eba), + (0x1ebc, 0x1ebc), + (0x1ebe, 0x1ebe), + (0x1ec0, 0x1ec0), + (0x1ec2, 0x1ec2), + (0x1ec4, 0x1ec4), + (0x1ec6, 0x1ec6), + (0x1ec8, 0x1ec8), + (0x1eca, 0x1eca), + (0x1ecc, 0x1ecc), + (0x1ece, 0x1ece), + (0x1ed0, 0x1ed0), + (0x1ed2, 0x1ed2), + (0x1ed4, 0x1ed4), + (0x1ed6, 0x1ed6), + (0x1ed8, 0x1ed8), + (0x1eda, 0x1eda), + (0x1edc, 0x1edc), + (0x1ede, 0x1ede), + (0x1ee0, 0x1ee0), + (0x1ee2, 0x1ee2), + (0x1ee4, 0x1ee4), + (0x1ee6, 0x1ee6), + (0x1ee8, 0x1ee8), + (0x1eea, 0x1eea), + (0x1eec, 0x1eec), + (0x1eee, 0x1eee), + (0x1ef0, 0x1ef0), + (0x1ef2, 0x1ef2), + (0x1ef4, 0x1ef4), + (0x1ef6, 0x1ef6), + (0x1ef8, 0x1ef8), + (0x1efa, 0x1efa), + (0x1efc, 0x1efc), + (0x1efe, 0x1efe), + (0x1f08, 0x1f0f), + (0x1f18, 0x1f1d), + (0x1f28, 0x1f2f), + (0x1f38, 0x1f3f), + (0x1f48, 0x1f4d), + (0x1f59, 0x1f59), + (0x1f5b, 0x1f5b), + (0x1f5d, 0x1f5d), + (0x1f5f, 0x1f5f), + (0x1f68, 0x1f6f), + (0x1fb8, 0x1fbb), + (0x1fc8, 0x1fcb), + (0x1fd8, 0x1fdb), + (0x1fe8, 0x1fec), + (0x1ff8, 0x1ffb), + (0x2102, 0x2102), + (0x2107, 0x2107), + (0x210b, 0x210d), + (0x2110, 0x2112), + (0x2115, 0x2115), + (0x2119, 0x211d), + (0x2124, 0x2124), + (0x2126, 0x2126), + (0x2128, 0x2128), + (0x212a, 0x212d), + (0x2130, 0x2133), + (0x213e, 0x213f), + (0x2145, 0x2145), + (0x2183, 0x2183), + (0x2c00, 0x2c2f), + (0x2c60, 0x2c60), + (0x2c62, 0x2c64), + (0x2c67, 0x2c67), + (0x2c69, 0x2c69), + (0x2c6b, 0x2c6b), + (0x2c6d, 0x2c70), + (0x2c72, 0x2c72), + (0x2c75, 0x2c75), + (0x2c7e, 0x2c80), + (0x2c82, 0x2c82), + (0x2c84, 0x2c84), + (0x2c86, 0x2c86), + (0x2c88, 0x2c88), + (0x2c8a, 0x2c8a), + (0x2c8c, 0x2c8c), + (0x2c8e, 0x2c8e), + (0x2c90, 0x2c90), + (0x2c92, 0x2c92), + (0x2c94, 0x2c94), + (0x2c96, 0x2c96), + (0x2c98, 0x2c98), + (0x2c9a, 0x2c9a), + (0x2c9c, 0x2c9c), + (0x2c9e, 0x2c9e), + (0x2ca0, 0x2ca0), + (0x2ca2, 0x2ca2), + (0x2ca4, 0x2ca4), + (0x2ca6, 0x2ca6), + (0x2ca8, 0x2ca8), + (0x2caa, 0x2caa), + (0x2cac, 0x2cac), + (0x2cae, 0x2cae), + (0x2cb0, 0x2cb0), + (0x2cb2, 0x2cb2), + (0x2cb4, 0x2cb4), + (0x2cb6, 0x2cb6), + (0x2cb8, 0x2cb8), + (0x2cba, 0x2cba), + (0x2cbc, 0x2cbc), + (0x2cbe, 0x2cbe), + (0x2cc0, 0x2cc0), + (0x2cc2, 0x2cc2), + (0x2cc4, 0x2cc4), + (0x2cc6, 0x2cc6), + (0x2cc8, 0x2cc8), + (0x2cca, 0x2cca), + (0x2ccc, 0x2ccc), + (0x2cce, 0x2cce), + (0x2cd0, 0x2cd0), + (0x2cd2, 0x2cd2), + (0x2cd4, 0x2cd4), + (0x2cd6, 0x2cd6), + (0x2cd8, 0x2cd8), + (0x2cda, 0x2cda), + (0x2cdc, 0x2cdc), + (0x2cde, 0x2cde), + (0x2ce0, 0x2ce0), + (0x2ce2, 0x2ce2), + (0x2ceb, 0x2ceb), + (0x2ced, 0x2ced), + (0x2cf2, 0x2cf2), + (0xa640, 0xa640), + (0xa642, 0xa642), + (0xa644, 0xa644), + (0xa646, 0xa646), + (0xa648, 0xa648), + (0xa64a, 0xa64a), + (0xa64c, 0xa64c), + (0xa64e, 0xa64e), + (0xa650, 0xa650), + (0xa652, 0xa652), + (0xa654, 0xa654), + (0xa656, 0xa656), + (0xa658, 0xa658), + (0xa65a, 0xa65a), + (0xa65c, 0xa65c), + (0xa65e, 0xa65e), + (0xa660, 0xa660), + (0xa662, 0xa662), + (0xa664, 0xa664), + (0xa666, 0xa666), + (0xa668, 0xa668), + (0xa66a, 0xa66a), + (0xa66c, 0xa66c), + (0xa680, 0xa680), + (0xa682, 0xa682), + (0xa684, 0xa684), + (0xa686, 0xa686), + (0xa688, 0xa688), + (0xa68a, 0xa68a), + (0xa68c, 0xa68c), + (0xa68e, 0xa68e), + (0xa690, 0xa690), + (0xa692, 0xa692), + (0xa694, 0xa694), + (0xa696, 0xa696), + (0xa698, 0xa698), + (0xa69a, 0xa69a), + (0xa722, 0xa722), + (0xa724, 0xa724), + (0xa726, 0xa726), + (0xa728, 0xa728), + (0xa72a, 0xa72a), + (0xa72c, 0xa72c), + (0xa72e, 0xa72e), + (0xa732, 0xa732), + (0xa734, 0xa734), + (0xa736, 0xa736), + (0xa738, 0xa738), + (0xa73a, 0xa73a), + (0xa73c, 0xa73c), + (0xa73e, 0xa73e), + (0xa740, 0xa740), + (0xa742, 0xa742), + (0xa744, 0xa744), + (0xa746, 0xa746), + (0xa748, 0xa748), + (0xa74a, 0xa74a), + (0xa74c, 0xa74c), + (0xa74e, 0xa74e), + (0xa750, 0xa750), + (0xa752, 0xa752), + (0xa754, 0xa754), + (0xa756, 0xa756), + (0xa758, 0xa758), + (0xa75a, 0xa75a), + (0xa75c, 0xa75c), + (0xa75e, 0xa75e), + (0xa760, 0xa760), + (0xa762, 0xa762), + (0xa764, 0xa764), + (0xa766, 0xa766), + (0xa768, 0xa768), + (0xa76a, 0xa76a), + (0xa76c, 0xa76c), + (0xa76e, 0xa76e), + (0xa779, 0xa779), + (0xa77b, 0xa77b), + (0xa77d, 0xa77e), + (0xa780, 0xa780), + (0xa782, 0xa782), + (0xa784, 0xa784), + (0xa786, 0xa786), + (0xa78b, 0xa78b), + (0xa78d, 0xa78d), + (0xa790, 0xa790), + (0xa792, 0xa792), + (0xa796, 0xa796), + (0xa798, 0xa798), + (0xa79a, 0xa79a), + (0xa79c, 0xa79c), + (0xa79e, 0xa79e), + (0xa7a0, 0xa7a0), + (0xa7a2, 0xa7a2), + (0xa7a4, 0xa7a4), + (0xa7a6, 0xa7a6), + (0xa7a8, 0xa7a8), + (0xa7aa, 0xa7ae), + (0xa7b0, 0xa7b4), + (0xa7b6, 0xa7b6), + (0xa7b8, 0xa7b8), + (0xa7ba, 0xa7ba), + (0xa7bc, 0xa7bc), + (0xa7be, 0xa7be), + (0xa7c0, 0xa7c0), + (0xa7c2, 0xa7c2), + (0xa7c4, 0xa7c7), + (0xa7c9, 0xa7c9), + (0xa7cb, 0xa7cc), + (0xa7ce, 0xa7ce), + (0xa7d0, 0xa7d0), + (0xa7d2, 0xa7d2), + (0xa7d4, 0xa7d4), + (0xa7d6, 0xa7d6), + (0xa7d8, 0xa7d8), + (0xa7da, 0xa7da), + (0xa7dc, 0xa7dc), + (0xa7f5, 0xa7f5), + (0xff21, 0xff3a), + (0x10400, 0x10427), + (0x104b0, 0x104d3), + (0x10570, 0x1057a), + (0x1057c, 0x1058a), + (0x1058c, 0x10592), + (0x10594, 0x10595), + (0x10c80, 0x10cb2), + (0x10d50, 0x10d65), + (0x118a0, 0x118bf), + (0x16e40, 0x16e5f), + (0x16ea0, 0x16eb8), + (0x1d400, 0x1d419), + (0x1d434, 0x1d44d), + (0x1d468, 0x1d481), + (0x1d49c, 0x1d49c), + (0x1d49e, 0x1d49f), + (0x1d4a2, 0x1d4a2), + (0x1d4a5, 0x1d4a6), + (0x1d4a9, 0x1d4ac), + (0x1d4ae, 0x1d4b5), + (0x1d4d0, 0x1d4e9), + (0x1d504, 0x1d505), + (0x1d507, 0x1d50a), + (0x1d50d, 0x1d514), + (0x1d516, 0x1d51c), + (0x1d538, 0x1d539), + (0x1d53b, 0x1d53e), + (0x1d540, 0x1d544), + (0x1d546, 0x1d546), + (0x1d54a, 0x1d550), + (0x1d56c, 0x1d585), + (0x1d5a0, 0x1d5b9), + (0x1d5d4, 0x1d5ed), + (0x1d608, 0x1d621), + (0x1d63c, 0x1d655), + (0x1d670, 0x1d689), + (0x1d6a8, 0x1d6c0), + (0x1d6e2, 0x1d6fa), + (0x1d71c, 0x1d734), + (0x1d756, 0x1d76e), + (0x1d790, 0x1d7a8), + (0x1d7ca, 0x1d7ca), + (0x1e900, 0x1e921), +]; + +/// Property Cased (the final-sigma rule), inclusive ranges. +pub static CASED: &[(u32, u32)] = &[ + (0x41, 0x5a), + (0x61, 0x7a), + (0xaa, 0xaa), + (0xb5, 0xb5), + (0xba, 0xba), + (0xc0, 0xd6), + (0xd8, 0xf6), + (0xf8, 0x1ba), + (0x1bc, 0x1bf), + (0x1c4, 0x293), + (0x296, 0x2b8), + (0x2c0, 0x2c1), + (0x2e0, 0x2e4), + (0x345, 0x345), + (0x370, 0x373), + (0x376, 0x377), + (0x37a, 0x37d), + (0x37f, 0x37f), + (0x386, 0x386), + (0x388, 0x38a), + (0x38c, 0x38c), + (0x38e, 0x3a1), + (0x3a3, 0x3f5), + (0x3f7, 0x481), + (0x48a, 0x52f), + (0x531, 0x556), + (0x560, 0x588), + (0x10a0, 0x10c5), + (0x10c7, 0x10c7), + (0x10cd, 0x10cd), + (0x10d0, 0x10fa), + (0x10fc, 0x10ff), + (0x13a0, 0x13f5), + (0x13f8, 0x13fd), + (0x1c80, 0x1c8a), + (0x1c90, 0x1cba), + (0x1cbd, 0x1cbf), + (0x1d00, 0x1dbf), + (0x1e00, 0x1f15), + (0x1f18, 0x1f1d), + (0x1f20, 0x1f45), + (0x1f48, 0x1f4d), + (0x1f50, 0x1f57), + (0x1f59, 0x1f59), + (0x1f5b, 0x1f5b), + (0x1f5d, 0x1f5d), + (0x1f5f, 0x1f7d), + (0x1f80, 0x1fb4), + (0x1fb6, 0x1fbc), + (0x1fbe, 0x1fbe), + (0x1fc2, 0x1fc4), + (0x1fc6, 0x1fcc), + (0x1fd0, 0x1fd3), + (0x1fd6, 0x1fdb), + (0x1fe0, 0x1fec), + (0x1ff2, 0x1ff4), + (0x1ff6, 0x1ffc), + (0x2071, 0x2071), + (0x207f, 0x207f), + (0x2090, 0x209c), + (0x2102, 0x2102), + (0x2107, 0x2107), + (0x210a, 0x2113), + (0x2115, 0x2115), + (0x2119, 0x211d), + (0x2124, 0x2124), + (0x2126, 0x2126), + (0x2128, 0x2128), + (0x212a, 0x212d), + (0x212f, 0x2134), + (0x2139, 0x2139), + (0x213c, 0x213f), + (0x2145, 0x2149), + (0x214e, 0x214e), + (0x2160, 0x217f), + (0x2183, 0x2184), + (0x24b6, 0x24e9), + (0x2c00, 0x2ce4), + (0x2ceb, 0x2cee), + (0x2cf2, 0x2cf3), + (0x2d00, 0x2d25), + (0x2d27, 0x2d27), + (0x2d2d, 0x2d2d), + (0xa640, 0xa66d), + (0xa680, 0xa69d), + (0xa722, 0xa787), + (0xa78b, 0xa78e), + (0xa790, 0xa7dc), + (0xa7f1, 0xa7f6), + (0xa7f8, 0xa7fa), + (0xab30, 0xab5a), + (0xab5c, 0xab69), + (0xab70, 0xabbf), + (0xfb00, 0xfb06), + (0xfb13, 0xfb17), + (0xff21, 0xff3a), + (0xff41, 0xff5a), + (0x10400, 0x1044f), + (0x104b0, 0x104d3), + (0x104d8, 0x104fb), + (0x10570, 0x1057a), + (0x1057c, 0x1058a), + (0x1058c, 0x10592), + (0x10594, 0x10595), + (0x10597, 0x105a1), + (0x105a3, 0x105b1), + (0x105b3, 0x105b9), + (0x105bb, 0x105bc), + (0x10780, 0x10780), + (0x10783, 0x10785), + (0x10787, 0x107b0), + (0x107b2, 0x107ba), + (0x10c80, 0x10cb2), + (0x10cc0, 0x10cf2), + (0x10d50, 0x10d65), + (0x10d70, 0x10d85), + (0x118a0, 0x118df), + (0x16e40, 0x16e7f), + (0x16ea0, 0x16eb8), + (0x16ebb, 0x16ed3), + (0x1d400, 0x1d454), + (0x1d456, 0x1d49c), + (0x1d49e, 0x1d49f), + (0x1d4a2, 0x1d4a2), + (0x1d4a5, 0x1d4a6), + (0x1d4a9, 0x1d4ac), + (0x1d4ae, 0x1d4b9), + (0x1d4bb, 0x1d4bb), + (0x1d4bd, 0x1d4c3), + (0x1d4c5, 0x1d505), + (0x1d507, 0x1d50a), + (0x1d50d, 0x1d514), + (0x1d516, 0x1d51c), + (0x1d51e, 0x1d539), + (0x1d53b, 0x1d53e), + (0x1d540, 0x1d544), + (0x1d546, 0x1d546), + (0x1d54a, 0x1d550), + (0x1d552, 0x1d6a5), + (0x1d6a8, 0x1d6c0), + (0x1d6c2, 0x1d6da), + (0x1d6dc, 0x1d6fa), + (0x1d6fc, 0x1d714), + (0x1d716, 0x1d734), + (0x1d736, 0x1d74e), + (0x1d750, 0x1d76e), + (0x1d770, 0x1d788), + (0x1d78a, 0x1d7a8), + (0x1d7aa, 0x1d7c2), + (0x1d7c4, 0x1d7cb), + (0x1df00, 0x1df09), + (0x1df0b, 0x1df1e), + (0x1df25, 0x1df2a), + (0x1e030, 0x1e06d), + (0x1e900, 0x1e943), + (0x1f130, 0x1f149), + (0x1f150, 0x1f169), + (0x1f170, 0x1f189), +]; + +/// Property Case_Ignorable (the final-sigma rule), inclusive ranges. +pub static CASE_IGNORABLE: &[(u32, u32)] = &[ + (0x27, 0x27), + (0x2e, 0x2e), + (0x3a, 0x3a), + (0x5e, 0x5e), + (0x60, 0x60), + (0xa8, 0xa8), + (0xad, 0xad), + (0xaf, 0xaf), + (0xb4, 0xb4), + (0xb7, 0xb8), + (0x2b0, 0x36f), + (0x374, 0x375), + (0x37a, 0x37a), + (0x384, 0x385), + (0x387, 0x387), + (0x483, 0x489), + (0x559, 0x559), + (0x55f, 0x55f), + (0x591, 0x5bd), + (0x5bf, 0x5bf), + (0x5c1, 0x5c2), + (0x5c4, 0x5c5), + (0x5c7, 0x5c7), + (0x5f4, 0x5f4), + (0x600, 0x605), + (0x610, 0x61a), + (0x61c, 0x61c), + (0x640, 0x640), + (0x64b, 0x65f), + (0x670, 0x670), + (0x6d6, 0x6dd), + (0x6df, 0x6e8), + (0x6ea, 0x6ed), + (0x70f, 0x70f), + (0x711, 0x711), + (0x730, 0x74a), + (0x7a6, 0x7b0), + (0x7eb, 0x7f5), + (0x7fa, 0x7fa), + (0x7fd, 0x7fd), + (0x816, 0x82d), + (0x859, 0x85b), + (0x888, 0x888), + (0x890, 0x891), + (0x897, 0x89f), + (0x8c9, 0x902), + (0x93a, 0x93a), + (0x93c, 0x93c), + (0x941, 0x948), + (0x94d, 0x94d), + (0x951, 0x957), + (0x962, 0x963), + (0x971, 0x971), + (0x981, 0x981), + (0x9bc, 0x9bc), + (0x9c1, 0x9c4), + (0x9cd, 0x9cd), + (0x9e2, 0x9e3), + (0x9fe, 0x9fe), + (0xa01, 0xa02), + (0xa3c, 0xa3c), + (0xa41, 0xa42), + (0xa47, 0xa48), + (0xa4b, 0xa4d), + (0xa51, 0xa51), + (0xa70, 0xa71), + (0xa75, 0xa75), + (0xa81, 0xa82), + (0xabc, 0xabc), + (0xac1, 0xac5), + (0xac7, 0xac8), + (0xacd, 0xacd), + (0xae2, 0xae3), + (0xafa, 0xaff), + (0xb01, 0xb01), + (0xb3c, 0xb3c), + (0xb3f, 0xb3f), + (0xb41, 0xb44), + (0xb4d, 0xb4d), + (0xb55, 0xb56), + (0xb62, 0xb63), + (0xb82, 0xb82), + (0xbc0, 0xbc0), + (0xbcd, 0xbcd), + (0xc00, 0xc00), + (0xc04, 0xc04), + (0xc3c, 0xc3c), + (0xc3e, 0xc40), + (0xc46, 0xc48), + (0xc4a, 0xc4d), + (0xc55, 0xc56), + (0xc62, 0xc63), + (0xc81, 0xc81), + (0xcbc, 0xcbc), + (0xcbf, 0xcbf), + (0xcc6, 0xcc6), + (0xccc, 0xccd), + (0xce2, 0xce3), + (0xd00, 0xd01), + (0xd3b, 0xd3c), + (0xd41, 0xd44), + (0xd4d, 0xd4d), + (0xd62, 0xd63), + (0xd81, 0xd81), + (0xdca, 0xdca), + (0xdd2, 0xdd4), + (0xdd6, 0xdd6), + (0xe31, 0xe31), + (0xe34, 0xe3a), + (0xe46, 0xe4e), + (0xeb1, 0xeb1), + (0xeb4, 0xebc), + (0xec6, 0xec6), + (0xec8, 0xece), + (0xf18, 0xf19), + (0xf35, 0xf35), + (0xf37, 0xf37), + (0xf39, 0xf39), + (0xf71, 0xf7e), + (0xf80, 0xf84), + (0xf86, 0xf87), + (0xf8d, 0xf97), + (0xf99, 0xfbc), + (0xfc6, 0xfc6), + (0x102d, 0x1030), + (0x1032, 0x1037), + (0x1039, 0x103a), + (0x103d, 0x103e), + (0x1058, 0x1059), + (0x105e, 0x1060), + (0x1071, 0x1074), + (0x1082, 0x1082), + (0x1085, 0x1086), + (0x108d, 0x108d), + (0x109d, 0x109d), + (0x10fc, 0x10fc), + (0x135d, 0x135f), + (0x1712, 0x1714), + (0x1732, 0x1733), + (0x1752, 0x1753), + (0x1772, 0x1773), + (0x17b4, 0x17b5), + (0x17b7, 0x17bd), + (0x17c6, 0x17c6), + (0x17c9, 0x17d3), + (0x17d7, 0x17d7), + (0x17dd, 0x17dd), + (0x180b, 0x180f), + (0x1843, 0x1843), + (0x1885, 0x1886), + (0x18a9, 0x18a9), + (0x1920, 0x1922), + (0x1927, 0x1928), + (0x1932, 0x1932), + (0x1939, 0x193b), + (0x1a17, 0x1a18), + (0x1a1b, 0x1a1b), + (0x1a56, 0x1a56), + (0x1a58, 0x1a5e), + (0x1a60, 0x1a60), + (0x1a62, 0x1a62), + (0x1a65, 0x1a6c), + (0x1a73, 0x1a7c), + (0x1a7f, 0x1a7f), + (0x1aa7, 0x1aa7), + (0x1ab0, 0x1add), + (0x1ae0, 0x1aeb), + (0x1b00, 0x1b03), + (0x1b34, 0x1b34), + (0x1b36, 0x1b3a), + (0x1b3c, 0x1b3c), + (0x1b42, 0x1b42), + (0x1b6b, 0x1b73), + (0x1b80, 0x1b81), + (0x1ba2, 0x1ba5), + (0x1ba8, 0x1ba9), + (0x1bab, 0x1bad), + (0x1be6, 0x1be6), + (0x1be8, 0x1be9), + (0x1bed, 0x1bed), + (0x1bef, 0x1bf1), + (0x1c2c, 0x1c33), + (0x1c36, 0x1c37), + (0x1c78, 0x1c7d), + (0x1cd0, 0x1cd2), + (0x1cd4, 0x1ce0), + (0x1ce2, 0x1ce8), + (0x1ced, 0x1ced), + (0x1cf4, 0x1cf4), + (0x1cf8, 0x1cf9), + (0x1d2c, 0x1d6a), + (0x1d78, 0x1d78), + (0x1d9b, 0x1dff), + (0x1fbd, 0x1fbd), + (0x1fbf, 0x1fc1), + (0x1fcd, 0x1fcf), + (0x1fdd, 0x1fdf), + (0x1fed, 0x1fef), + (0x1ffd, 0x1ffe), + (0x200b, 0x200f), + (0x2018, 0x2019), + (0x2024, 0x2024), + (0x2027, 0x2027), + (0x202a, 0x202e), + (0x2060, 0x2064), + (0x2066, 0x206f), + (0x2071, 0x2071), + (0x207f, 0x207f), + (0x2090, 0x209c), + (0x20d0, 0x20f0), + (0x2c7c, 0x2c7d), + (0x2cef, 0x2cf1), + (0x2d6f, 0x2d6f), + (0x2d7f, 0x2d7f), + (0x2de0, 0x2dff), + (0x2e2f, 0x2e2f), + (0x3005, 0x3005), + (0x302a, 0x302d), + (0x3031, 0x3035), + (0x303b, 0x303b), + (0x3099, 0x309e), + (0x30fc, 0x30fe), + (0xa015, 0xa015), + (0xa4f8, 0xa4fd), + (0xa60c, 0xa60c), + (0xa66f, 0xa672), + (0xa674, 0xa67d), + (0xa67f, 0xa67f), + (0xa69c, 0xa69f), + (0xa6f0, 0xa6f1), + (0xa700, 0xa721), + (0xa770, 0xa770), + (0xa788, 0xa78a), + (0xa7f1, 0xa7f4), + (0xa7f8, 0xa7f9), + (0xa802, 0xa802), + (0xa806, 0xa806), + (0xa80b, 0xa80b), + (0xa825, 0xa826), + (0xa82c, 0xa82c), + (0xa8c4, 0xa8c5), + (0xa8e0, 0xa8f1), + (0xa8ff, 0xa8ff), + (0xa926, 0xa92d), + (0xa947, 0xa951), + (0xa980, 0xa982), + (0xa9b3, 0xa9b3), + (0xa9b6, 0xa9b9), + (0xa9bc, 0xa9bd), + (0xa9cf, 0xa9cf), + (0xa9e5, 0xa9e6), + (0xaa29, 0xaa2e), + (0xaa31, 0xaa32), + (0xaa35, 0xaa36), + (0xaa43, 0xaa43), + (0xaa4c, 0xaa4c), + (0xaa70, 0xaa70), + (0xaa7c, 0xaa7c), + (0xaab0, 0xaab0), + (0xaab2, 0xaab4), + (0xaab7, 0xaab8), + (0xaabe, 0xaabf), + (0xaac1, 0xaac1), + (0xaadd, 0xaadd), + (0xaaec, 0xaaed), + (0xaaf3, 0xaaf4), + (0xaaf6, 0xaaf6), + (0xab5b, 0xab5f), + (0xab69, 0xab6b), + (0xabe5, 0xabe5), + (0xabe8, 0xabe8), + (0xabed, 0xabed), + (0xfb1e, 0xfb1e), + (0xfbb2, 0xfbc2), + (0xfe00, 0xfe0f), + (0xfe13, 0xfe13), + (0xfe20, 0xfe2f), + (0xfe52, 0xfe52), + (0xfe55, 0xfe55), + (0xfeff, 0xfeff), + (0xff07, 0xff07), + (0xff0e, 0xff0e), + (0xff1a, 0xff1a), + (0xff3e, 0xff3e), + (0xff40, 0xff40), + (0xff70, 0xff70), + (0xff9e, 0xff9f), + (0xffe3, 0xffe3), + (0xfff9, 0xfffb), + (0x101fd, 0x101fd), + (0x102e0, 0x102e0), + (0x10376, 0x1037a), + (0x10780, 0x10785), + (0x10787, 0x107b0), + (0x107b2, 0x107ba), + (0x10a01, 0x10a03), + (0x10a05, 0x10a06), + (0x10a0c, 0x10a0f), + (0x10a38, 0x10a3a), + (0x10a3f, 0x10a3f), + (0x10ae5, 0x10ae6), + (0x10d24, 0x10d27), + (0x10d4e, 0x10d4e), + (0x10d69, 0x10d6d), + (0x10d6f, 0x10d6f), + (0x10eab, 0x10eac), + (0x10ec5, 0x10ec5), + (0x10efa, 0x10eff), + (0x10f46, 0x10f50), + (0x10f82, 0x10f85), + (0x11001, 0x11001), + (0x11038, 0x11046), + (0x11070, 0x11070), + (0x11073, 0x11074), + (0x1107f, 0x11081), + (0x110b3, 0x110b6), + (0x110b9, 0x110ba), + (0x110bd, 0x110bd), + (0x110c2, 0x110c2), + (0x110cd, 0x110cd), + (0x11100, 0x11102), + (0x11127, 0x1112b), + (0x1112d, 0x11134), + (0x11173, 0x11173), + (0x11180, 0x11181), + (0x111b6, 0x111be), + (0x111c9, 0x111cc), + (0x111cf, 0x111cf), + (0x1122f, 0x11231), + (0x11234, 0x11234), + (0x11236, 0x11237), + (0x1123e, 0x1123e), + (0x11241, 0x11241), + (0x112df, 0x112df), + (0x112e3, 0x112ea), + (0x11300, 0x11301), + (0x1133b, 0x1133c), + (0x11340, 0x11340), + (0x11366, 0x1136c), + (0x11370, 0x11374), + (0x113bb, 0x113c0), + (0x113ce, 0x113ce), + (0x113d0, 0x113d0), + (0x113d2, 0x113d2), + (0x113e1, 0x113e2), + (0x11438, 0x1143f), + (0x11442, 0x11444), + (0x11446, 0x11446), + (0x1145e, 0x1145e), + (0x114b3, 0x114b8), + (0x114ba, 0x114ba), + (0x114bf, 0x114c0), + (0x114c2, 0x114c3), + (0x115b2, 0x115b5), + (0x115bc, 0x115bd), + (0x115bf, 0x115c0), + (0x115dc, 0x115dd), + (0x11633, 0x1163a), + (0x1163d, 0x1163d), + (0x1163f, 0x11640), + (0x116ab, 0x116ab), + (0x116ad, 0x116ad), + (0x116b0, 0x116b5), + (0x116b7, 0x116b7), + (0x1171d, 0x1171d), + (0x1171f, 0x1171f), + (0x11722, 0x11725), + (0x11727, 0x1172b), + (0x1182f, 0x11837), + (0x11839, 0x1183a), + (0x1193b, 0x1193c), + (0x1193e, 0x1193e), + (0x11943, 0x11943), + (0x119d4, 0x119d7), + (0x119da, 0x119db), + (0x119e0, 0x119e0), + (0x11a01, 0x11a0a), + (0x11a33, 0x11a38), + (0x11a3b, 0x11a3e), + (0x11a47, 0x11a47), + (0x11a51, 0x11a56), + (0x11a59, 0x11a5b), + (0x11a8a, 0x11a96), + (0x11a98, 0x11a99), + (0x11b60, 0x11b60), + (0x11b62, 0x11b64), + (0x11b66, 0x11b66), + (0x11c30, 0x11c36), + (0x11c38, 0x11c3d), + (0x11c3f, 0x11c3f), + (0x11c92, 0x11ca7), + (0x11caa, 0x11cb0), + (0x11cb2, 0x11cb3), + (0x11cb5, 0x11cb6), + (0x11d31, 0x11d36), + (0x11d3a, 0x11d3a), + (0x11d3c, 0x11d3d), + (0x11d3f, 0x11d45), + (0x11d47, 0x11d47), + (0x11d90, 0x11d91), + (0x11d95, 0x11d95), + (0x11d97, 0x11d97), + (0x11dd9, 0x11dd9), + (0x11ef3, 0x11ef4), + (0x11f00, 0x11f01), + (0x11f36, 0x11f3a), + (0x11f40, 0x11f40), + (0x11f42, 0x11f42), + (0x11f5a, 0x11f5a), + (0x13430, 0x13440), + (0x13447, 0x13455), + (0x1611e, 0x16129), + (0x1612d, 0x1612f), + (0x16af0, 0x16af4), + (0x16b30, 0x16b36), + (0x16b40, 0x16b43), + (0x16d40, 0x16d42), + (0x16d6b, 0x16d6c), + (0x16f4f, 0x16f4f), + (0x16f8f, 0x16f9f), + (0x16fe0, 0x16fe1), + (0x16fe3, 0x16fe4), + (0x16ff2, 0x16ff3), + (0x1aff0, 0x1aff3), + (0x1aff5, 0x1affb), + (0x1affd, 0x1affe), + (0x1bc9d, 0x1bc9e), + (0x1bca0, 0x1bca3), + (0x1cf00, 0x1cf2d), + (0x1cf30, 0x1cf46), + (0x1d167, 0x1d169), + (0x1d173, 0x1d182), + (0x1d185, 0x1d18b), + (0x1d1aa, 0x1d1ad), + (0x1d242, 0x1d244), + (0x1da00, 0x1da36), + (0x1da3b, 0x1da6c), + (0x1da75, 0x1da75), + (0x1da84, 0x1da84), + (0x1da9b, 0x1da9f), + (0x1daa1, 0x1daaf), + (0x1e000, 0x1e006), + (0x1e008, 0x1e018), + (0x1e01b, 0x1e021), + (0x1e023, 0x1e024), + (0x1e026, 0x1e02a), + (0x1e030, 0x1e06d), + (0x1e08f, 0x1e08f), + (0x1e130, 0x1e13d), + (0x1e2ae, 0x1e2ae), + (0x1e2ec, 0x1e2ef), + (0x1e4eb, 0x1e4ef), + (0x1e5ee, 0x1e5ef), + (0x1e6e3, 0x1e6e3), + (0x1e6e6, 0x1e6e6), + (0x1e6ee, 0x1e6ef), + (0x1e6f5, 0x1e6f5), + (0x1e6ff, 0x1e6ff), + (0x1e8d0, 0x1e8d6), + (0x1e944, 0x1e94b), + (0x1f3fb, 0x1f3ff), + (0xe0001, 0xe0001), + (0xe0020, 0xe007f), + (0xe0100, 0xe01ef), +]; + +/// JS `toLowerCase()` of one code point: `(first, last, step, delta)`. Every code point +/// `first + k * step <= last` maps to itself plus `delta`. Sorted by `first`, no overlaps. +pub static LOWERCASE: &[(u32, u32, u8, i32)] = &[ + (0x41, 0x5a, 1, 32), + (0xc0, 0xd6, 1, 32), + (0xd8, 0xde, 1, 32), + (0x100, 0x12e, 2, 1), + (0x132, 0x136, 2, 1), + (0x139, 0x147, 2, 1), + (0x14a, 0x176, 2, 1), + (0x178, 0x178, 1, -121), + (0x179, 0x17d, 2, 1), + (0x181, 0x181, 1, 210), + (0x182, 0x184, 2, 1), + (0x186, 0x186, 1, 206), + (0x187, 0x187, 1, 1), + (0x189, 0x18a, 1, 205), + (0x18b, 0x18b, 1, 1), + (0x18e, 0x18e, 1, 79), + (0x18f, 0x18f, 1, 202), + (0x190, 0x190, 1, 203), + (0x191, 0x191, 1, 1), + (0x193, 0x193, 1, 205), + (0x194, 0x194, 1, 207), + (0x196, 0x196, 1, 211), + (0x197, 0x197, 1, 209), + (0x198, 0x198, 1, 1), + (0x19c, 0x19c, 1, 211), + (0x19d, 0x19d, 1, 213), + (0x19f, 0x19f, 1, 214), + (0x1a0, 0x1a4, 2, 1), + (0x1a6, 0x1a6, 1, 218), + (0x1a7, 0x1a7, 1, 1), + (0x1a9, 0x1a9, 1, 218), + (0x1ac, 0x1ac, 1, 1), + (0x1ae, 0x1ae, 1, 218), + (0x1af, 0x1af, 1, 1), + (0x1b1, 0x1b2, 1, 217), + (0x1b3, 0x1b5, 2, 1), + (0x1b7, 0x1b7, 1, 219), + (0x1b8, 0x1b8, 1, 1), + (0x1bc, 0x1bc, 1, 1), + (0x1c4, 0x1c4, 1, 2), + (0x1c5, 0x1c5, 1, 1), + (0x1c7, 0x1c7, 1, 2), + (0x1c8, 0x1c8, 1, 1), + (0x1ca, 0x1ca, 1, 2), + (0x1cb, 0x1db, 2, 1), + (0x1de, 0x1ee, 2, 1), + (0x1f1, 0x1f1, 1, 2), + (0x1f2, 0x1f4, 2, 1), + (0x1f6, 0x1f6, 1, -97), + (0x1f7, 0x1f7, 1, -56), + (0x1f8, 0x21e, 2, 1), + (0x220, 0x220, 1, -130), + (0x222, 0x232, 2, 1), + (0x23a, 0x23a, 1, 10795), + (0x23b, 0x23b, 1, 1), + (0x23d, 0x23d, 1, -163), + (0x23e, 0x23e, 1, 10792), + (0x241, 0x241, 1, 1), + (0x243, 0x243, 1, -195), + (0x244, 0x244, 1, 69), + (0x245, 0x245, 1, 71), + (0x246, 0x24e, 2, 1), + (0x370, 0x372, 2, 1), + (0x376, 0x376, 1, 1), + (0x37f, 0x37f, 1, 116), + (0x386, 0x386, 1, 38), + (0x388, 0x38a, 1, 37), + (0x38c, 0x38c, 1, 64), + (0x38e, 0x38f, 1, 63), + (0x391, 0x3a1, 1, 32), + (0x3a3, 0x3ab, 1, 32), + (0x3cf, 0x3cf, 1, 8), + (0x3d8, 0x3ee, 2, 1), + (0x3f4, 0x3f4, 1, -60), + (0x3f7, 0x3f7, 1, 1), + (0x3f9, 0x3f9, 1, -7), + (0x3fa, 0x3fa, 1, 1), + (0x3fd, 0x3ff, 1, -130), + (0x400, 0x40f, 1, 80), + (0x410, 0x42f, 1, 32), + (0x460, 0x480, 2, 1), + (0x48a, 0x4be, 2, 1), + (0x4c0, 0x4c0, 1, 15), + (0x4c1, 0x4cd, 2, 1), + (0x4d0, 0x52e, 2, 1), + (0x531, 0x556, 1, 48), + (0x10a0, 0x10c5, 1, 7264), + (0x10c7, 0x10c7, 1, 7264), + (0x10cd, 0x10cd, 1, 7264), + (0x13a0, 0x13ef, 1, 38864), + (0x13f0, 0x13f5, 1, 8), + (0x1c89, 0x1c89, 1, 1), + (0x1c90, 0x1cba, 1, -3008), + (0x1cbd, 0x1cbf, 1, -3008), + (0x1e00, 0x1e94, 2, 1), + (0x1e9e, 0x1e9e, 1, -7615), + (0x1ea0, 0x1efe, 2, 1), + (0x1f08, 0x1f0f, 1, -8), + (0x1f18, 0x1f1d, 1, -8), + (0x1f28, 0x1f2f, 1, -8), + (0x1f38, 0x1f3f, 1, -8), + (0x1f48, 0x1f4d, 1, -8), + (0x1f59, 0x1f5f, 2, -8), + (0x1f68, 0x1f6f, 1, -8), + (0x1f88, 0x1f8f, 1, -8), + (0x1f98, 0x1f9f, 1, -8), + (0x1fa8, 0x1faf, 1, -8), + (0x1fb8, 0x1fb9, 1, -8), + (0x1fba, 0x1fbb, 1, -74), + (0x1fbc, 0x1fbc, 1, -9), + (0x1fc8, 0x1fcb, 1, -86), + (0x1fcc, 0x1fcc, 1, -9), + (0x1fd8, 0x1fd9, 1, -8), + (0x1fda, 0x1fdb, 1, -100), + (0x1fe8, 0x1fe9, 1, -8), + (0x1fea, 0x1feb, 1, -112), + (0x1fec, 0x1fec, 1, -7), + (0x1ff8, 0x1ff9, 1, -128), + (0x1ffa, 0x1ffb, 1, -126), + (0x1ffc, 0x1ffc, 1, -9), + (0x2126, 0x2126, 1, -7517), + (0x212a, 0x212a, 1, -8383), + (0x212b, 0x212b, 1, -8262), + (0x2132, 0x2132, 1, 28), + (0x2160, 0x216f, 1, 16), + (0x2183, 0x2183, 1, 1), + (0x24b6, 0x24cf, 1, 26), + (0x2c00, 0x2c2f, 1, 48), + (0x2c60, 0x2c60, 1, 1), + (0x2c62, 0x2c62, 1, -10743), + (0x2c63, 0x2c63, 1, -3814), + (0x2c64, 0x2c64, 1, -10727), + (0x2c67, 0x2c6b, 2, 1), + (0x2c6d, 0x2c6d, 1, -10780), + (0x2c6e, 0x2c6e, 1, -10749), + (0x2c6f, 0x2c6f, 1, -10783), + (0x2c70, 0x2c70, 1, -10782), + (0x2c72, 0x2c72, 1, 1), + (0x2c75, 0x2c75, 1, 1), + (0x2c7e, 0x2c7f, 1, -10815), + (0x2c80, 0x2ce2, 2, 1), + (0x2ceb, 0x2ced, 2, 1), + (0x2cf2, 0x2cf2, 1, 1), + (0xa640, 0xa66c, 2, 1), + (0xa680, 0xa69a, 2, 1), + (0xa722, 0xa72e, 2, 1), + (0xa732, 0xa76e, 2, 1), + (0xa779, 0xa77b, 2, 1), + (0xa77d, 0xa77d, 1, -35332), + (0xa77e, 0xa786, 2, 1), + (0xa78b, 0xa78b, 1, 1), + (0xa78d, 0xa78d, 1, -42280), + (0xa790, 0xa792, 2, 1), + (0xa796, 0xa7a8, 2, 1), + (0xa7aa, 0xa7aa, 1, -42308), + (0xa7ab, 0xa7ab, 1, -42319), + (0xa7ac, 0xa7ac, 1, -42315), + (0xa7ad, 0xa7ad, 1, -42305), + (0xa7ae, 0xa7ae, 1, -42308), + (0xa7b0, 0xa7b0, 1, -42258), + (0xa7b1, 0xa7b1, 1, -42282), + (0xa7b2, 0xa7b2, 1, -42261), + (0xa7b3, 0xa7b3, 1, 928), + (0xa7b4, 0xa7c2, 2, 1), + (0xa7c4, 0xa7c4, 1, -48), + (0xa7c5, 0xa7c5, 1, -42307), + (0xa7c6, 0xa7c6, 1, -35384), + (0xa7c7, 0xa7c9, 2, 1), + (0xa7cb, 0xa7cb, 1, -42343), + (0xa7cc, 0xa7da, 2, 1), + (0xa7dc, 0xa7dc, 1, -42561), + (0xa7f5, 0xa7f5, 1, 1), + (0xff21, 0xff3a, 1, 32), + (0x10400, 0x10427, 1, 40), + (0x104b0, 0x104d3, 1, 40), + (0x10570, 0x1057a, 1, 39), + (0x1057c, 0x1058a, 1, 39), + (0x1058c, 0x10592, 1, 39), + (0x10594, 0x10595, 1, 39), + (0x10c80, 0x10cb2, 1, 64), + (0x10d50, 0x10d65, 1, 32), + (0x118a0, 0x118bf, 1, 32), + (0x16e40, 0x16e5f, 1, 32), + (0x16ea0, 0x16eb8, 1, 27), + (0x1e900, 0x1e921, 1, 34), +]; + +/// Code points whose lowercase is several code points. Sorted. +pub static LOWERCASE_MULTI: &[(u32, &[u32])] = &[ + (0x130, &[0x69, 0x307]), +]; diff --git a/rust/src/value.rs b/rust/src/value.rs new file mode 100644 index 0000000..90dcf65 --- /dev/null +++ b/rust/src/value.rs @@ -0,0 +1,55 @@ +//! A static JSON-like value: the shape `scripts/gen_data.mjs` compiles `spec/data` into. + +/// A compile-time data value. Objects keep the key order of the JSON source. +#[derive(Debug, Clone, Copy, PartialEq)] +#[allow(dead_code)] // the codegen can write every variant; today's data has no numbers +pub enum V { + Null, + Bool(bool), + Num(f64), + Str(&'static str), + Arr(&'static [V]), + Obj(&'static [(&'static str, V)]), +} + +impl V { + /// The member `key` of an object, or `V::Null`. + pub fn get(&self, key: &str) -> V { + if let V::Obj(entries) = self { + for (k, v) in entries.iter() { + if *k == key { + return *v; + } + } + } + V::Null + } + + /// The items of an array (empty for anything else). + pub fn items(&self) -> &'static [V] { + match self { + V::Arr(items) => items, + _ => &[], + } + } + + /// The entries of an object, in source order (empty for anything else). + pub fn entries(&self) -> &'static [(&'static str, V)] { + match self { + V::Obj(entries) => entries, + _ => &[], + } + } + + pub fn as_str(&self) -> Option<&'static str> { + match self { + V::Str(s) => Some(s), + _ => None, + } + } + + /// The string items of an array, skipping anything else. + pub fn strings(&self) -> impl Iterator { + self.items().iter().filter_map(|v| v.as_str()) + } +} diff --git a/rust/src/wire.rs b/rust/src/wire.rs new file mode 100644 index 0000000..df75e10 --- /dev/null +++ b/rust/src/wire.rs @@ -0,0 +1,41 @@ +//! The JSON door into the crate: every public function called with JSON arguments, returning JSON. +//! +//! The shared fixtures, the cross-port diff and fuzzers use it. Options arrive as loose JSON and +//! are resolved with the same fallbacks as the JS reference (a bad value means the default, +//! SPEC R0.8), which the typed Rust API cannot even express. + +use crate::format::{format, FormatInput}; +use crate::json::Json; +use crate::normalize::normalize; +use crate::options::{Resolved, ResolvedFormat}; +use crate::parser::Engine; +use crate::types::{list, RawTrack}; + +fn format_raw(track: &RawTrack, format_options: &Json) -> String { + let input = FormatInput { + artists: &track.artists, + title: &track.title, + versions: track.versions.iter().map(|v| (v.raw.as_str(), v.delimiter)).collect(), + position_raw: track.position.as_ref().map(|p| p.raw.as_str()), + }; + format(&input, &ResolvedFormat::from_json(format_options)) +} + +/// A fixture-style call. `func` is one of `parse`, `parseArtists`, `format`, `normalize`, +/// `parseTracklist`, `applyEdits`. Unknown functions return `null`. Never panics. +/// +/// `format` parses `input` with `options` first, then formats with `format_options`. +pub fn call(func: &str, input: &str, options: &Json, format_options: &Json, edits: &Json) -> Json { + match func { + "parse" => Engine::new(Resolved::from_json(options)).run(input, false).to_json_value(), + "parseArtists" => list(&Engine::new(Resolved::from_json(options)).run_artists(input)), + "format" => { + let track = Engine::new(Resolved::from_json(options)).run(input, false); + Json::Str(format_raw(&track, format_options)) + } + "normalize" => Json::Str(normalize(input)), + "parseTracklist" => crate::tracklist::wire_parse(input, options), + "applyEdits" => crate::tracklist::wire_edits(input, edits), + _ => Json::Null, + } +} diff --git a/rust/src/words.rs b/rust/src/words.rs new file mode 100644 index 0000000..3ddeed8 --- /dev/null +++ b/rust/src/words.rs @@ -0,0 +1,709 @@ +//! Low-level text helpers shared by every rule: the R0.2 whitespace set, R0.3 word keys, +//! R0.4 dedup keys, R0.6 letters/digits and token-sequence (phrase) matching. +//! +//! Strings that are indexed are held as `&[char]`, so indices are code-point indices (R0.5). +//! Where the JS reference observes UTF-16 lengths (`utf16_len`), that is made explicit. + +use std::collections::HashMap; + +use unicode_normalization::UnicodeNormalization; + +use crate::unicode_tables::{ + CASED, CASE_IGNORABLE, LETTER, LOWERCASE, LOWERCASE_MULTI, UPPERCASE_LETTER, +}; + +pub(crate) fn chars(s: &str) -> Vec { + s.chars().collect() +} + +pub(crate) fn string(t: &[char]) -> String { + t.iter().collect() +} + +/// `t[i]`, or `None` out of range (JS `t[i]` → `undefined`). +pub(crate) fn at(t: &[char], i: usize) -> Option { + t.get(i).copied() +} + +/// `t[i - 1]`, or `None` when `i` is 0 or out of range. +pub(crate) fn before(t: &[char], i: usize) -> Option { + i.checked_sub(1).and_then(|j| t.get(j).copied()) +} + +/// `t[a..b]` with both ends clamped (JS `slice` with non-negative arguments). +pub(crate) fn sub(t: &[char], a: usize, b: usize) -> &[char] { + let b = b.min(t.len()); + let a = a.min(b); + t.get(a..b).unwrap_or(&[]) +} + +/// `t[a..]`, clamped. +pub(crate) fn tail(t: &[char], a: usize) -> &[char] { + t.get(a.min(t.len())..).unwrap_or(&[]) +} + +/// R0.2: the exact whitespace code-point set. Never use `char::is_whitespace`. +pub(crate) fn is_whitespace_code(cp: u32) -> bool { + (0x09..=0x0d).contains(&cp) + || cp == 0x20 + || cp == 0x85 + || cp == 0xa0 + || cp == 0x1680 + || (0x2000..=0x200a).contains(&cp) + || cp == 0x2028 + || cp == 0x2029 + || cp == 0x202f + || cp == 0x205f + || cp == 0x3000 +} + +/// R0.2 test on one code point. +pub(crate) fn is_ws(ch: char) -> bool { + is_whitespace_code(ch as u32) +} + +/// R0.2 test on an optional code point (`None` → false). +pub(crate) fn is_whitespace(ch: Option) -> bool { + ch.is_some_and(is_ws) +} + +/// JS `String.prototype.trim()` set: WhiteSpace (with U+FEFF and Zs) + LineTerminator. Not the +/// R0.2 set: U+FEFF is in, U+0085 is out. +pub(crate) fn is_js_space(ch: char) -> bool { + let cp = ch as u32; + (0x09..=0x0d).contains(&cp) + || cp == 0x20 + || cp == 0xa0 + || cp == 0x1680 + || (0x2000..=0x200a).contains(&cp) + || cp == 0x2028 + || cp == 0x2029 + || cp == 0x202f + || cp == 0x205f + || cp == 0x3000 + || cp == 0xfeff +} + +/// JS `trim()`. +pub(crate) fn js_trim(s: &str) -> &str { + s.trim_matches(is_js_space) +} + +/// JS `trimEnd()`. +pub(crate) fn js_trim_end(s: &str) -> &str { + s.trim_end_matches(is_js_space) +} + +/// JS `trim()` on a code-point slice. +pub(crate) fn js_trim_chars(t: &[char]) -> &[char] { + let mut a = 0; + let mut b = t.len(); + while a < b && at(t, a).is_some_and(is_js_space) { + a += 1; + } + while b > a && before(t, b).is_some_and(is_js_space) { + b -= 1; + } + sub(t, a, b) +} + +/// R0.6: ASCII digits only. +pub(crate) fn is_digit(ch: Option) -> bool { + ch.is_some_and(|c| c.is_ascii_digit()) +} + +pub(crate) fn is_all_digits(s: &str) -> bool { + !s.is_empty() && s.chars().all(|c| c.is_ascii_digit()) +} + +fn in_ranges(table: &[(u32, u32)], cp: u32) -> bool { + table + .binary_search_by(|&(lo, hi)| { + if hi < cp { + std::cmp::Ordering::Less + } else if lo > cp { + std::cmp::Ordering::Greater + } else { + std::cmp::Ordering::Equal + } + }) + .is_ok() +} + +/// R0.6: Unicode general category L (JS `/\p{L}/u`). Not `char::is_alphabetic`, which also +/// accepts Nl and combining marks. +pub(crate) fn is_letter(ch: char) -> bool { + in_ranges(LETTER, ch as u32) +} + +/// R0.6 letter test on the code point at `index`. +pub(crate) fn is_letter_at(t: &[char], index: usize) -> bool { + at(t, index).is_some_and(is_letter) +} + +/// R0.6 letter test on the code point that ends just before `index`. +pub(crate) fn is_letter_before(t: &[char], index: usize) -> bool { + before(t, index).is_some_and(is_letter) +} + +/// R6.10 uppercase letter: Unicode general category Lu (JS `/\p{Lu}/u`). Not +/// `char::is_uppercase`, which is the wider `Uppercase` property. +pub(crate) fn is_upper(ch: char) -> bool { + in_ranges(UPPERCASE_LETTER, ch as u32) +} + +/// R6.10 uppercase test on the code point at `index`. +pub(crate) fn is_upper_at(t: &[char], index: usize) -> bool { + at(t, index).is_some_and(is_upper) +} + +/// ASCII-only lowercase (A–Z → a–z). +pub(crate) fn ascii_lower(s: &str) -> String { + s.chars().map(|c| c.to_ascii_lowercase()).collect() +} + +const KEY_STRIPPABLE: &str = ".,!?:;"; + +/// R0.3: the lowercased word with one trailing `. , ! ? : ;` removed. +pub(crate) fn strip_key_punct(lower: &str) -> &str { + match lower.chars().next_back() { + Some(last) if KEY_STRIPPABLE.contains(last) => { + lower.get(..lower.len() - last.len_utf8()).unwrap_or(lower) + } + _ => lower, + } +} + +/// R0.3 word key (stripped form). +pub(crate) fn word_key(word: &str) -> String { + strip_key_punct(&ascii_lower(word)).to_string() +} + +/// R0.3: does `word` match the vocabulary token `token`? The unstripped lowercase form is +/// compared first so entries ending in punctuation (`feat.`) match as written. +pub(crate) fn word_matches(word: &str, token: &str) -> bool { + let lower = ascii_lower(word); + lower == token || strip_key_punct(&lower) == token +} + +/// A set of vocabulary words that can be asked with a `&str`. +pub(crate) trait Vocab { + fn has(&self, key: &str) -> bool; +} + +impl Vocab for std::collections::HashSet<&'static str> { + fn has(&self, key: &str) -> bool { + self.contains(key) + } +} + +impl Vocab for std::collections::HashSet { + fn has(&self, key: &str) -> bool { + self.contains(key) + } +} + +pub(crate) fn in_vocab(word: &str, vocab: &impl Vocab) -> bool { + let lower = ascii_lower(word); + vocab.has(&lower) || vocab.has(strip_key_punct(&lower)) +} + +fn collapse_iter(it: impl Iterator) -> String { + let mut out = String::new(); + let mut pending = false; + for ch in it { + if is_ws(ch) { + pending = !out.is_empty(); + } else { + if pending { + out.push(' '); + } + pending = false; + out.push(ch); + } + } + out +} + +/// Collapse runs of R0.2 whitespace to one U+0020 and trim. +pub(crate) fn collapse_spaces(s: &str) -> String { + collapse_iter(s.chars()) +} + +/// `collapse_spaces` on a code-point slice. +pub(crate) fn collapse_chars(t: &[char]) -> String { + collapse_iter(t.iter().copied()) +} + +/// R0.7: maximal runs of non-whitespace code points. +pub(crate) fn split_words(s: &str) -> Vec { + s.split(is_ws).filter(|w| !w.is_empty()).map(str::to_string).collect() +} + +/// `split_words` on a code-point slice. +pub(crate) fn split_words_chars(t: &[char]) -> Vec { + word_spans(t).into_iter().map(|w| w.text).collect() +} + +/// A word with its code-point span inside the slice it was taken from. +#[derive(Debug, Clone)] +pub(crate) struct WordSpan { + pub text: String, + pub start: usize, + pub end: usize, +} + +pub(crate) fn word_spans(t: &[char]) -> Vec { + let mut spans = Vec::new(); + let mut start: Option = None; + for i in 0..=t.len() { + let boundary = i == t.len() || is_whitespace(at(t, i)); + if boundary { + if let Some(a) = start { + spans.push(WordSpan { text: string(sub(t, a, i)), start: a, end: i }); + } + start = None; + } else if start.is_none() { + start = Some(i); + } + } + spans +} + +pub(crate) fn span_texts(spans: &[WordSpan]) -> Vec { + spans.iter().map(|s| s.text.clone()).collect() +} + +/// The final-sigma rule's "a cased letter follows", looking through case-ignorable code points. +/// A code point that is both cased and case-ignorable (U+0345, modifier letters) is skipped, +/// as in ICU, which is what JS engines run. +fn cased_follows(mut it: impl Iterator) -> bool { + it.find(|c| !in_ranges(CASE_IGNORABLE, *c as u32)).is_some_and(|c| in_ranges(CASED, c as u32)) +} + +/// `toLowerCase()` of one code point out of context, appended to `out`. +fn push_lower(ch: char, out: &mut String) { + let cp = ch as u32; + if cp < 0x80 { + out.push(ch.to_ascii_lowercase()); + return; + } + let i = LOWERCASE.partition_point(|run| run.0 <= cp); + if let Some(&(first, last, step, delta)) = i.checked_sub(1).and_then(|i| LOWERCASE.get(i)) { + if cp <= last && (cp - first) % u32::from(step) == 0 { + let lower = cp.checked_add_signed(delta).and_then(char::from_u32); + out.push(lower.unwrap_or(ch)); + return; + } + } + match LOWERCASE_MULTI.binary_search_by_key(&cp, |m| m.0) { + Ok(i) => { + let to = LOWERCASE_MULTI.get(i).map_or(&[][..], |m| m.1); + out.extend(to.iter().filter_map(|c| char::from_u32(*c))); + } + Err(_) => out.push(ch), + } +} + +/// JS `String.prototype.toLowerCase()`, from the generated tables (the reference engine's +/// Unicode version, whatever the compiler's is). The one context rule: `Σ` is `ς` after a cased +/// letter when no cased letter follows (Final_Sigma), else `σ`. +pub(crate) fn js_lower(s: &str) -> String { + let mut out = String::with_capacity(s.len()); + for (i, ch) in s.char_indices() { + if ch != 'Σ' { + push_lower(ch, &mut out); + continue; + } + let before = s.get(..i).unwrap_or("").chars().rev(); + let after = s.get(i + ch.len_utf8()..).unwrap_or("").chars(); + out.push(if cased_follows(before) && !cased_follows(after) { 'ς' } else { 'σ' }); + } + out +} + +/// R0.4 dedup key: JS `toLowerCase()`, NFD, U+0300–U+036F removed, whitespace collapsed. +pub(crate) fn dedup_key(s: &str) -> String { + let lowered = js_lower(s); + collapse_iter(lowered.nfd().filter(|c| !('\u{300}'..='\u{36f}').contains(c))) +} + +/// Year word: 4 ASCII digits in 1900–2099 (word key, so `2015,` counts). +pub(crate) fn year_of(word: &str) -> Option { + let key = word_key(word); + if key.len() != 4 || !is_all_digits(&key) { + return None; + } + let n: u32 = key.parse().ok()?; + (1900..=2099).contains(&n).then_some(n) +} + +/// Length in UTF-16 code units (JS `string.length`). Offsets are kept in UTF-16 units so that +/// every order-of-appearance comparison (R9) matches the JS reference exactly. +pub(crate) fn utf16_len(t: &[char]) -> usize { + t.iter().map(|c| c.len_utf16()).sum() +} + +/// `utf16_len` as an offset. +pub(crate) fn utf16_off(t: &[char]) -> i64 { + i64::try_from(utf16_len(t)).unwrap_or(i64::MAX) +} + +// --------------------------------------------------------------------------- +// Phrase tables: multi-word vocabulary matched as token sequences, longest first. + +#[derive(Debug)] +struct PhraseEntry { + tokens: Vec, + value: V, +} + +pub(crate) struct PhraseMatch<'a, V> { + pub value: &'a V, + /// Number of words consumed. + pub length: usize, +} + +#[derive(Debug)] +pub(crate) struct PhraseTable { + entries: Vec>, + by_first: HashMap>, + by_last: HashMap>, + keys: std::collections::HashSet, +} + +impl PhraseTable { + pub fn new>(entries: impl IntoIterator) -> Self { + let mut t = PhraseTable { + entries: Vec::new(), + by_first: HashMap::new(), + by_last: HashMap::new(), + keys: std::collections::HashSet::new(), + }; + for (k, v) in entries { + t.add(k.as_ref(), v); + } + t + } + + /// The first entry for a key wins. Keys are ASCII-lowercased and trimmed like JS `trim()`. + pub fn add(&mut self, raw_key: &str, value: V) { + let lowered = ascii_lower(raw_key); + let key = js_trim(&lowered); + let tokens = split_words(key); + let (Some(first), Some(last)) = (tokens.first().cloned(), tokens.last().cloned()) else { + return; + }; + if self.keys.contains(key) { + return; + } + let id = self.entries.len(); + self.keys.insert(key.to_string()); + self.entries.push(PhraseEntry { tokens, value }); + self.insert_sorted(true, first, id); + self.insert_sorted(false, last, id); + } + + fn insert_sorted(&mut self, first: bool, k: String, id: usize) { + let entries = &self.entries; + let list = if first { &mut self.by_first } else { &mut self.by_last }.entry(k).or_default(); + list.push(id); + // Stable, like the JS sort: longest first, insertion order among equals. + list.sort_by_key(|&i| std::cmp::Reverse(entries.get(i).map_or(0, |e| e.tokens.len()))); + } + + /// Longest entry matching words[start …]. + pub fn match_at>(&self, words: &[S], start: usize) -> Option> { + let word = words.get(start)?.as_ref(); + let mut best: Option> = None; + for entry in self.candidates(true, word) { + let n = entry.tokens.len(); + if best.as_ref().is_some_and(|b| n <= b.length) { + continue; + } + if start + n > words.len() { + continue; + } + if tokens_match(words, start, &entry.tokens) { + best = Some(PhraseMatch { value: &entry.value, length: n }); + } + } + best + } + + /// Longest entry matching words[… end-1] (end exclusive). + pub fn match_ending>( + &self, + words: &[S], + end: usize, + ) -> Option> { + let word = words.get(end.checked_sub(1)?)?.as_ref(); + let mut best: Option> = None; + for entry in self.candidates(false, word) { + let n = entry.tokens.len(); + if best.as_ref().is_some_and(|b| n <= b.length) { + continue; + } + let Some(from) = end.checked_sub(n) else { continue }; + if tokens_match(words, from, &entry.tokens) { + best = Some(PhraseMatch { value: &entry.value, length: n }); + } + } + best + } + + /// Entries indexed under the word's lowercase form, then under its stripped form. + fn candidates(&self, first: bool, word: &str) -> impl Iterator> { + let map = if first { &self.by_first } else { &self.by_last }; + let lower = ascii_lower(word); + let stripped = strip_key_punct(&lower); + let a = map.get(lower.as_str()); + let b = if stripped == lower { None } else { map.get(stripped) }; + a.into_iter().chain(b).flatten().filter_map(|&i| self.entries.get(i)) + } +} + +fn tokens_match>(words: &[S], start: usize, tokens: &[String]) -> bool { + tokens + .iter() + .enumerate() + .all(|(k, t)| words.get(start + k).is_some_and(|w| word_matches(w.as_ref(), t))) +} + +#[cfg(test)] +mod tests { + //! R0 primitives against values taken from the JS reference (`scripts/dump_primitives.mjs` + //! writes `tests/data/primitives.json`). `TRACKPARSE_PRIMITIVES=` swaps in another + //! dump, e.g. the `--all` sweep over every Unicode scalar value. + + use super::*; + use crate::json::Json; + + fn data() -> Json { + let text = match std::env::var("TRACKPARSE_PRIMITIVES") { + Ok(path) => std::fs::read_to_string(path).unwrap_or_default(), + Err(_) => include_str!("../tests/data/primitives.json").to_string(), + }; + Json::parse(&text).unwrap_or(Json::Null) + } + + fn num(v: &Json) -> u32 { + match v { + Json::Num(n) => *n as u32, + _ => u32::MAX, + } + } + + /// The dumped code points with one flag string (`"0110…"`) of the named property. + fn code_points(data: &Json, property: &str) -> Vec<(char, bool)> { + let table = data.get("codePoints"); + let runs = table.and_then(|t| t.get("runs")).and_then(Json::as_array).unwrap_or(&[]); + let cps = runs.iter().flat_map(|run| { + let pair = run.as_array().unwrap_or(&[]); + let first = pair.first().map_or(0, num); + let count = pair.get(1).map_or(0, num); + (first..first + count).filter_map(char::from_u32) + }); + let flags = table.and_then(|t| t.get(property)).and_then(Json::as_str).unwrap_or(""); + let out: Vec<(char, bool)> = cps.zip(flags.chars().map(|f| f == '1')).collect(); + assert!(out.len() > 5000, "no code points for {property}"); + assert_eq!(out.len(), flags.len(), "{property}: flags and code points differ in length"); + out + } + + fn check_property(property: &str, test: impl Fn(char) -> bool) { + for (ch, expected) in code_points(&data(), property) { + assert_eq!(test(ch), expected, "{property} of U+{:04X}", ch as u32); + } + } + + #[test] + fn primitives_whitespace_set() { + check_property("whitespace", is_ws); + // R0.2, spelled out: U+0085 is in, U+FEFF, U+200B and U+180E are out. + let set: Vec = (0..=0x10ffff).filter(|&cp| is_whitespace_code(cp)).collect(); + let expected: Vec = (0x09..=0x0d) + .chain([0x20, 0x85, 0xa0, 0x1680]) + .chain(0x2000..=0x200a) + .chain([0x2028, 0x2029, 0x202f, 0x205f, 0x3000]) + .collect(); + assert_eq!(set, expected); + } + + #[test] + fn primitives_letter_is_category_l() { + check_property("letter", is_letter); + assert!(is_letter('a') && is_letter('Я') && is_letter('中') && is_letter('Dž')); + // Nl and marks are alphabetic for Rust's std, but not letters. + assert!('Ⅷ'.is_alphabetic() && !is_letter('Ⅷ')); + assert!('\u{345}'.is_alphabetic() && !is_letter('\u{345}')); + assert!(!is_letter('1') && !is_letter('_') && !is_letter('\u{301}')); + } + + #[test] + fn primitives_upper_is_category_lu() { + check_property("upper", is_upper); + assert!(is_upper('A') && is_upper('Я') && is_upper('𝐀')); + // Other_Uppercase (Ⓐ, Ⅷ) is uppercase for Rust's std, but not Lu; Dž is Lt. + assert!('Ⓐ'.is_uppercase() && !is_upper('Ⓐ')); + assert!('Ⅷ'.is_uppercase() && !is_upper('Ⅷ')); + assert!(!is_upper('Dž') && !is_upper('a') && !is_upper('中')); + } + + #[test] + fn primitives_js_trim_set() { + check_property("jsSpace", is_js_space); + assert_eq!(js_trim("\u{feff} x\u{a0}\u{2028}"), "x"); + assert_eq!(js_trim("\u{85}x\u{85}"), "\u{85}x\u{85}"); // R0.2 whitespace, not JS whitespace + assert_eq!(js_trim_end(" x \u{feff}"), " x"); + assert_eq!(string(js_trim_chars(&chars("\u{3000}x y\t"))), "x y"); + } + + #[test] + fn primitives_strings() { + let data = data(); + let records = data.get("strings").and_then(Json::as_array).unwrap_or(&[]); + assert!(records.len() > 250 || std::env::var("TRACKPARSE_PRIMITIVES").is_ok()); + for r in records { + let field = |key: &str| r.get(key).and_then(Json::as_str).unwrap_or(""); + let s = field("s"); + assert_eq!( + utf16_len(&chars(s)), + r.get("utf16Len").map_or(0, num) as usize, + "utf16Len {s:?}" + ); + assert_eq!(ascii_lower(s), field("asciiLower"), "asciiLower {s:?}"); + assert_eq!(js_lower(s), field("lower"), "toLowerCase {s:?}"); + assert_eq!(word_key(s), field("wordKey"), "wordKey {s:?}"); + assert_eq!(dedup_key(s), field("dedupKey"), "dedupKey {s:?}"); + assert_eq!(collapse_spaces(s), field("collapse"), "collapse {s:?}"); + assert_eq!(collapse_chars(&chars(s)), field("collapse"), "collapse_chars {s:?}"); + assert_eq!(js_trim(s), field("jsTrim"), "jsTrim {s:?}"); + assert_eq!(js_trim_end(s), field("jsTrimEnd"), "jsTrimEnd {s:?}"); + let words: Vec<&str> = r + .get("words") + .and_then(Json::as_array) + .unwrap_or(&[]) + .iter() + .filter_map(Json::as_str) + .collect(); + assert_eq!(split_words(s), words, "splitWords {s:?}"); + assert_eq!(split_words_chars(&chars(s)), words, "split_words_chars {s:?}"); + let year = r.get("year").filter(|y| !matches!(y, Json::Null)).map(num); + assert_eq!(year_of(s), year, "yearOf {s:?}"); + } + } + + /// `toLowerCase()` of every scalar value alone, against the JS dump. The result does not + /// depend on the compiler's Unicode version (`str::to_lowercase` does). + #[test] + fn primitives_lowercase_sweep() { + let data = data(); + let sweep = data.get("lowerSweep").and_then(Json::as_array).unwrap_or(&[]); + assert!(sweep.len() > 1400, "no lowercase sweep"); + let mut expected: HashMap = HashMap::new(); + for pair in sweep { + let pair = pair.as_array().unwrap_or(&[]); + expected.insert( + pair.first().map_or(0, num), + pair.get(1).and_then(Json::as_str).unwrap_or(""), + ); + } + let mut wrong = Vec::new(); + for ch in (0..=0x10ffffu32).filter_map(char::from_u32) { + let s = ch.to_string(); + let want = expected.get(&(ch as u32)).copied().unwrap_or(s.as_str()); + if js_lower(&s) != want { + wrong.push(format!("U+{:04X}: {:?}, JS {:?}", ch as u32, js_lower(&s), want)); + } + } + assert!( + wrong.is_empty(), + "{} differ: {:?}", + wrong.len(), + wrong.iter().take(20).collect::>() + ); + } + + #[test] + fn primitives_lowercase_context() { + assert_eq!(js_lower("ΟΔΥΣΣΕΑΣ"), "οδυσσεας"); + assert_eq!(js_lower("Σ"), "σ"); // nothing cased before it + assert_eq!(js_lower("ΑΣ ΣΑ"), "ας σα"); + assert_eq!(js_lower("ΑΣ'Α"), "ασ'α"); // the apostrophe is case-ignorable + assert_eq!(js_lower("ΑΣ'"), "ας'"); + assert_eq!(js_lower("İΣ"), "i\u{307}ς"); + assert_eq!(js_lower("STRAẞE"), "straße"); + assert_eq!(js_lower("Ꭰꭰᏸ"), "ꭰꭰᏸ"); // Cherokee: uppercase is the base form + assert_eq!(js_lower("ᲐႠა"), "აⴀა"); // Georgian Mtavruli and Asomtavruli + assert_eq!(js_lower("𞤀𞤢"), "𞤢𞤢"); // Adlam + } + + /// Only with the `--all` dump: every scalar value's dedup key (lowercase + NFD + marks). + #[test] + fn primitives_dedup_sweep() { + let data = data(); + let Some(sweep) = data.get("dedupSweep").and_then(Json::as_array) else { return }; + let mut expected: HashMap = HashMap::new(); + for pair in sweep { + let pair = pair.as_array().unwrap_or(&[]); + expected.insert( + pair.first().map_or(0, num), + pair.get(1).and_then(Json::as_str).unwrap_or(""), + ); + } + let mut wrong = Vec::new(); + for ch in (0..=0x10ffffu32).filter_map(char::from_u32) { + let s = ch.to_string(); + let want = expected.get(&(ch as u32)).copied().unwrap_or(s.as_str()); + if dedup_key(&s) != want { + wrong.push(format!("U+{:04X}: {:?}, JS {:?}", ch as u32, dedup_key(&s), want)); + } + } + assert!( + wrong.is_empty(), + "{} differ: {:?}", + wrong.len(), + wrong.iter().take(20).collect::>() + ); + } + + #[test] + fn primitives_word_keys() { + assert_eq!(word_key("FEAT."), "feat"); + assert_eq!(word_key("Remix!!"), "remix!"); + assert_eq!(word_key("É."), "É"); // ASCII lowercase only + assert!(word_matches("Feat.", "feat.") && word_matches("Feat.", "feat")); + assert!(!word_matches("feat", "feat.")); + assert_eq!(strip_key_punct("a;"), "a"); + assert_eq!(strip_key_punct("ä"), "ä"); + } + + #[test] + fn primitives_dedup_keys() { + // JS: "İstanbul".toLowerCase() is "i̇stanbul" (i + U+0307), and the mark is then removed. + assert_eq!(dedup_key("İstanbul"), "istanbul"); + assert_eq!(dedup_key("STRAẞE"), "straße"); + assert_eq!(dedup_key("ΟΔΥΣΣΕΑΣ"), "οδυσσεας"); // final sigma + assert_eq!(dedup_key(" Beyonce\u{301} KNOWLES "), "beyonce knowles"); + assert_eq!(dedup_key("Й"), "и"); // U+0306 is in the removed range + assert_eq!(dedup_key("か\u{3099}"), "か\u{3099}"); // other marks stay + } + + #[test] + fn primitives_phrase_table() { + let t = PhraseTable::new([ + ("Official Video", 1), + ("video", 2), + (" official video ", 3), + ("", 4), + ]); + let words = ["Official", "VIDEO,", "x"]; + assert_eq!(t.match_at(&words, 0).map(|m| (*m.value, m.length)), Some((1, 2))); + assert_eq!(t.match_at(&words, 1).map(|m| (*m.value, m.length)), Some((2, 1))); + assert_eq!(t.match_ending(&words, 2).map(|m| (*m.value, m.length)), Some((1, 2))); + assert!(t.match_ending(&words, 0).is_none() && t.match_at(&words, 3).is_none()); + // The first entry for a key wins (keys are trimmed and lowercased, not collapsed). + assert_eq!(t.match_at(&["official", "video"], 0).map(|m| *m.value), Some(1)); + } +} diff --git a/rust/tests/api.rs b/rust/tests/api.rs new file mode 100644 index 0000000..27510e8 --- /dev/null +++ b/rust/tests/api.rs @@ -0,0 +1,346 @@ +//! The typed public API: it must agree with the JSON door (`wire`), which the shared fixtures +//! and the cross-port diff exercise. +#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::indexing_slicing)] + +use std::time::{Duration, Instant}; + +use trackparse::json::Json; +use trackparse::{ + all_artists, format_track, format_track_with, normalize, parse, parse_artists, + parse_artists_with, parse_with, wire, ArtistRole, ArtistSource, FeatPlacement, FormatOptions, + JoinerStyle, JunkKind, KeywordOptions, Mode, ModeOption, ParseOptions, Parser, SplitAnd, + ToJson, VersionType, VersionsOption, Warning, SPEC_VERSION, +}; + +const INPUTS: &[&str] = &[ + "", + " ", + "Noisia - Stigma", + "Noisia feat. Foreign Beggars - Shellshock (Rockwell Remix) [Official Video]", + "01. Camo & Krooked - Climax (2010)", + "[01:23:45] Sub Focus ft. Alice Gold & Kele - Out the Blue (Wilkinson Remix)", + "Linkin Park - Numb (Official Video) | Warner Records - YouTube", + "03_some_track_name.mp3", + "Jay-Z-Numb.flac", + "Artist \"Quoted Title\" (Lyrics)", + "Кино - Группа крови (Remastered 2015)", + "A, B & C vs D x E - T (F Remix / G Bootleg) - Extended Mix", + "ID - ID", + "Title prod. by Someone (Explicit)", + "Unbalanced (group - Title", + "🎵 Emoji 🎵 - 𝐀𝐁 (👨‍👩‍👧 Remix)", +]; + +fn json(text: &str) -> Json { + Json::parse(text).unwrap() +} + +fn none() -> Json { + json("{}") +} + +#[test] +fn spec_version_is_set() { + assert_eq!(SPEC_VERSION.split('.').count(), 3); +} + +#[test] +fn typed_parse_matches_the_wire() { + for input in INPUTS { + let expected = wire::call("parse", input, &none(), &none(), &json("[]")).write(); + assert_eq!(parse(input).to_json(), expected, "{input:?}"); + assert_eq!(Parser::default().parse(input).to_json(), expected, "{input:?}"); + assert_eq!(parse_with(input, &ParseOptions::default()).to_json(), expected, "{input:?}"); + + let artists = wire::call("parseArtists", input, &none(), &none(), &json("[]")).write(); + let typed = + Json::Arr(parse_artists(input).iter().map(ToJson::to_json_value).collect()).write(); + assert_eq!(typed, artists, "{input:?}"); + + let formatted = wire::call("format", input, &none(), &none(), &json("[]")); + assert_eq!(Json::Str(format_track(&parse(input))), formatted, "{input:?}"); + + assert_eq!( + Json::Str(normalize(input)), + wire::call("normalize", input, &none(), &none(), &json("[]")) + ); + } +} + +#[test] +fn typed_options_match_the_wire() { + let cases: Vec<(ParseOptions, &str)> = vec![ + (ParseOptions::new().mode(ModeOption::Auto), r#"{"mode":"auto"}"#), + (ParseOptions::new().mode(ModeOption::Clean), r#"{"mode":"clean"}"#), + (ParseOptions::new().mode(ModeOption::Youtube), r#"{"mode":"youtube"}"#), + (ParseOptions::new().mode(ModeOption::Filename), r#"{"mode":"filename"}"#), + (ParseOptions::new().mode(ModeOption::Tracklist), r#"{"mode":"tracklist"}"#), + ( + ParseOptions::new().mode(ModeOption::Youtube).uploader("Linkin Park - Topic"), + r#"{"mode":"youtube","uploader":"Linkin Park - Topic"}"#, + ), + ( + ParseOptions::new() + .known_artists(["Camo & Krooked", "A, B"]) + .split_and(SplitAnd::Always), + r#"{"knownArtists":["Camo & Krooked","A, B"],"splitAnd":"always"}"#, + ), + (ParseOptions::new().split_and(SplitAnd::Never), r#"{"splitAnd":"never"}"#), + ( + ParseOptions::new().keywords( + KeywordOptions::new() + .version_head("Rerub", VersionType::Remix) + .version_head("7", VersionType::Edit) + .descriptor("Chunky") + .genre("Neurofunk") + .junk("stigma", JunkKind::Promo) + .feat_marker("alongside"), + ), + r#"{"keywords":{"versionHeads":{"Rerub":"remix","7":"edit"},"descriptors":["Chunky"], + "genres":["Neurofunk"],"junk":{"stigma":"promo"},"featMarkers":["alongside"]}}"#, + ), + (ParseOptions::new().keywords(KeywordOptions::new()), r#"{"keywords":{}}"#), + ]; + let extra = [ + "Noisia alongside Phace - Stigma (Mefjus Rerub) [Neurofunk]", + "Title (Chunky Mix) - Stigma", + "Camo & Krooked and A, B - T (X 7)", + ]; + for (typed, loose) in &cases { + let loose = json(loose); + let parser = Parser::new(typed); + for input in INPUTS.iter().chain(extra.iter()) { + let expected = wire::call("parse", input, &loose, &none(), &json("[]")).write(); + assert_eq!(parser.parse(input).to_json(), expected, "{input:?} with {typed:?}"); + assert_eq!(parse_with(input, typed).to_json(), expected, "{input:?} with {typed:?}"); + let artists = wire::call("parseArtists", input, &loose, &none(), &json("[]")).write(); + let got = Json::Arr( + parse_artists_with(input, typed).iter().map(ToJson::to_json_value).collect(), + ); + assert_eq!(got.write(), artists, "{input:?} with {typed:?}"); + assert_eq!(parser.parse_artists(input), parse_artists_with(input, typed)); + } + } +} + +#[test] +fn typed_format_options_match_the_wire() { + let cases: Vec<(FormatOptions, &str)> = vec![ + (FormatOptions::new(), "{}"), + (FormatOptions::new().feat(FeatPlacement::Source), r#"{"feat":"source"}"#), + (FormatOptions::new().feat(FeatPlacement::Artist), r#"{"feat":"artist"}"#), + (FormatOptions::new().feat(FeatPlacement::Title), r#"{"feat":"title"}"#), + (FormatOptions::new().feat(FeatPlacement::Omit), r#"{"feat":"omit"}"#), + (FormatOptions::new().feat_marker("w/"), r#"{"featMarker":"w/"}"#), + (FormatOptions::new().joiners(JoinerStyle::Canonical), r#"{"joiners":"canonical"}"#), + (FormatOptions::new().joiners(JoinerStyle::Original), r#"{"joiners":"original"}"#), + (FormatOptions::new().versions(VersionsOption::None), r#"{"versions":"none"}"#), + (FormatOptions::new().versions(VersionsOption::All), r#"{"versions":"all"}"#), + ( + FormatOptions::new().producers(false).position(true), + r#"{"producers":false,"position":true}"#, + ), + ( + FormatOptions::new() + .feat(FeatPlacement::Title) + .joiners(JoinerStyle::Canonical) + .position(true), + r#"{"feat":"title","joiners":"canonical","position":true}"#, + ), + ]; + for (typed, loose) in &cases { + let loose = json(loose); + for input in INPUTS { + let expected = wire::call("format", input, &none(), &loose, &json("[]")); + assert_eq!( + Json::Str(format_track_with(&parse(input), typed)), + expected, + "{input:?} {typed:?}" + ); + } + } +} + +#[test] +fn fields_are_typed() { + let track = + parse("01. Noisia feat. Foreign Beggars - Shellshock (Rockwell Remix) [Official Video]"); + assert_eq!(track.mode, Mode::Youtube); + assert_eq!(track.position.as_ref().map(|p| p.number), Some(1)); + assert_eq!(track.artists.len(), 2); + assert_eq!(track.artists[1].role, ArtistRole::Featured); + assert_eq!(track.artists[1].joiner.as_deref(), Some("feat.")); + assert_eq!(track.artists[1].source, ArtistSource::Artist); + assert_eq!(track.title, "Shellshock"); + assert_eq!(track.full_title, "Shellshock (Rockwell Remix)"); + assert_eq!(track.versions[0].version_type, VersionType::Remix); + assert_eq!(track.versions[0].artists[0].role, ArtistRole::Remixer); + assert_eq!(track.junk[0].kind, JunkKind::Video); + assert!(track.warnings.is_empty()); + assert_eq!(parse("no separator here").warnings, [Warning::NoSeparator]); + + let names: Vec = all_artists(&track).into_iter().map(|a| a.name).collect(); + assert_eq!(names, ["Noisia", "Foreign Beggars", "Rockwell"]); +} + +#[test] +fn parser_is_send_and_sync() { + fn check() {} + check::(); +} + +/// Loose JSON options: a bad value means the default (R0.8), exactly as in the JS reference. +#[test] +fn bad_wire_options_fall_back() { + let call = |input: &str, options: &str| { + wire::call("parse", input, &json(options), &none(), &json("[]")) + }; + let default = call("Noisia - Stigma (Official Video)", "{}"); + for bad in [ + "null", + "5", + "\"x\"", + "[]", + r#"{"mode":null}"#, + r#"{"keywords":5,"knownArtists":7,"uploader":3}"#, + ] { + assert_eq!(call("Noisia - Stigma (Official Video)", bad), default, "{bad}"); + } + // An unknown mode skips the youtube detection but not the filename one. + let odd = call("Noisia - Stigma (Official Video)", r#"{"mode":"bogus"}"#); + assert_eq!(odd.get("mode"), Some(&Json::str("clean"))); + let odd = call("Noisia - Stigma.mp3", r#"{"mode":7}"#); + assert_eq!(odd.get("mode"), Some(&Json::str("filename"))); + // keywords values pass through as given, even when they are not a known type or kind. + let custom = call( + "A - B (C Zonk) [Blorp]", + r#"{"keywords":{"versionHeads":{"zonk":"banana"},"junk":{"blorp":"weird"}}}"#, + ); + assert!( + custom.write().contains(r#""type":"banana""#) + && custom.write().contains(r#""kind":"weird""#) + ); + // The same call must not panic for other functions and unknown ones. + assert_eq!(wire::call("nope", "x", &none(), &none(), &json("[]")), Json::Null); +} + +/// R0.8: total, and no super-linear blowup on 10,000 code points. +#[test] +fn long_inputs_finish_quickly() { + let n = 10_000; + let shapes: Vec = vec![ + "a".repeat(n), + "a ".repeat(n / 2), + "a, ".repeat(n / 3), + "a & ".repeat(n / 4), + "- ".repeat(n / 2), + " - ".repeat(n / 3), + "(".repeat(n), + ")".repeat(n), + "()".repeat(n / 2), + "(a) ".repeat(n / 4), + " by ".repeat(n / 4), + "x by (a) ".repeat(n / 9), + "feat. a ".repeat(n / 8), + "a - b (c Remix) ".repeat(n / 16), + "Official Video ".repeat(n / 15), + "\"".repeat(n), + "| ".repeat(n / 2), + " | a".repeat(n / 4), + "1,".repeat(n / 2), + "🎵".repeat(n), + "a\u{301}".repeat(n / 2), + "A-B".repeat(n / 3), + "a / b; ".repeat(n / 7), + "2015 ".repeat(n / 5), + ]; + let modes = [ + ModeOption::Auto, + ModeOption::Clean, + ModeOption::Youtube, + ModeOption::Filename, + ModeOption::Tracklist, + ]; + let known = ParseOptions::new().known_artists(["a & a", "a, a", "A-B"]); + for shape in &shapes { + let input: String = shape.chars().take(n).collect(); + let started = Instant::now(); + for mode in modes { + let track = parse_with(&input, &ParseOptions::new().mode(mode).uploader("Uploader")); + assert_eq!(track.input, input); + let _ = format_track(&track); + } + let _ = parse_with(&input, &known); + let _ = parse_artists(&input); + let _ = normalize(&input); + let elapsed = started.elapsed(); + // Generous: debug builds and busy CI machines. A quadratic path takes far longer. + let label: String = input.chars().take(24).collect(); + if std::env::var("TRACKPARSE_TIMES").is_ok() { + println!("{elapsed:>12?} {label:?}"); + } + assert!(elapsed < Duration::from_secs(10), "{label:?}… took {elapsed:?}"); + } +} + +#[test] +fn numbers_are_written_like_js() { + let cases: &[(f64, &str)] = &[ + (0.0, "0"), + (-0.0, "0"), + (3167.0, "3167"), + (-5.0, "-5"), + (7.5, "7.5"), + (0.001, "0.001"), + (62.125, "62.125"), + (1e21, "1e+21"), + (1e20, "100000000000000000000"), + (123456789012345680000.0, "123456789012345680000"), + (1.5e300, "1.5e+300"), + (-1e300, "-1e+300"), + (1e-6, "0.000001"), + (1e-7, "1e-7"), + (1.25e-9, "1.25e-9"), + (9007199254740993.0, "9007199254740992"), + (f64::INFINITY, "null"), + (f64::NAN, "null"), + ]; + for (n, text) in cases { + assert_eq!(Json::Num(*n).write(), *text); + } +} + +#[test] +fn enums_have_names_both_ways() { + for role in ArtistRole::ALL { + assert_eq!(ArtistRole::from_name(role.as_str()), Some(*role)); + assert_eq!(role.to_string().parse::(), Ok(*role)); + } + assert_eq!(VersionType::ALL.len(), VersionType::NAMES.len()); + assert_eq!(VersionType::NAMES[24], "spedUp"); + assert_eq!("spedUp".parse::(), Ok(VersionType::SpedUp)); + // Names are exact: no case folding, no trimming. + let err = "Remix".parse::().unwrap_err(); + assert_eq!(err.name(), "Remix"); + assert_eq!(err.to_string(), "unknown VersionType name: \"Remix\""); + let boxed: Box = Box::new(err); + assert!(boxed.to_string().contains("VersionType")); + assert_eq!(ModeOption::default(), ModeOption::Auto); + assert_eq!(SplitAnd::default(), SplitAnd::Auto); + assert_eq!(FeatPlacement::default(), FeatPlacement::Source); + assert_eq!(JoinerStyle::default(), JoinerStyle::Original); + assert_eq!(VersionsOption::default(), VersionsOption::All); +} + +#[test] +fn to_json_needs_no_import() { + mod inner { + // No `ToJson` in scope here. + pub fn json(input: &str) -> String { + trackparse::parse(input).to_json() + } + } + let track = parse("Noisia - Stigma"); + assert_eq!(inner::json("Noisia - Stigma"), ToJson::to_json(&track)); + assert_eq!(track.to_json_value().to_string(), track.to_json()); +} diff --git a/rust/tests/data/primitives.json b/rust/tests/data/primitives.json new file mode 100644 index 0000000..046c44b --- /dev/null +++ b/rust/tests/data/primitives.json @@ -0,0 +1,693 @@ +{ +"unicode": "17.0", +"codePoints": {"runs":[[0,593],[688,1],[710,1],[768,2],[837,1],[843,1],[879,2],[890,1],[902,1],[931,1],[962,2],[1012,1],[1040,1],[1072,1],[1094,1],[1345,1],[1488,1],[1569,1],[1596,1],[1600,1],[1632,1],[1847,1],[2098,1],[2307,2],[2349,1],[2600,1],[2851,1],[3102,1],[3353,1],[3585,1],[3604,1],[3633,1],[3855,1],[4106,1],[4256,1],[4304,1],[4357,1],[4608,1],[4859,1],[5024,1],[5110,1],[5112,1],[5361,1],[5612,1],[5759,3],[5863,1],[5870,1],[6114,1],[6158,1],[6365,1],[6616,1],[6867,1],[7118,1],[7296,1],[7312,1],[7369,1],[7468,1],[7620,1],[7838,1],[7871,1],[8072,1],[8122,1],[8124,1],[8188,1],[8191,2],[8202,4],[8208,1],[8213,1],[8232,3],[8239,2],[8287,2],[8305,1],[8373,1],[8450,1],[8486,1],[8490,2],[8544,1],[8560,1],[8579,2],[8624,1],[8875,1],[9126,1],[9377,1],[9398,1],[9424,1],[9628,1],[9879,1],[10130,1],[10381,1],[10632,1],[10883,1],[11134,1],[11264,1],[11385,1],[11636,1],[11823,1],[11887,1],[12138,1],[12288,2],[12293,3],[12321,1],[12337,1],[12353,1],[12389,1],[12449,1],[12640,1],[12891,1],[13142,1],[13312,1],[13393,1],[13644,1],[13895,1],[14146,1],[14397,1],[14648,1],[14899,1],[15150,1],[15401,1],[15652,1],[15903,1],[16154,1],[16405,1],[16656,1],[16907,1],[17158,1],[17409,1],[17660,1],[17911,1],[18162,1],[18413,1],[18664,1],[18915,1],[19166,1],[19417,1],[19668,1],[19919,1],[19968,1],[20170,1],[20421,1],[20672,1],[20923,1],[21174,1],[21425,1],[21676,1],[21927,1],[22178,1],[22429,1],[22680,1],[22931,1],[23182,1],[23433,1],[23684,1],[23935,1],[24186,1],[24437,1],[24688,1],[24939,1],[25190,1],[25441,1],[25692,1],[25943,1],[26194,1],[26445,1],[26696,1],[26947,1],[27198,1],[27449,1],[27700,1],[27951,1],[28202,1],[28453,1],[28704,1],[28955,1],[29206,1],[29457,1],[29708,1],[29959,1],[30210,1],[30461,1],[30712,1],[30963,1],[31214,1],[31465,1],[31716,1],[31967,1],[32218,1],[32469,1],[32720,1],[32971,1],[33222,1],[33473,1],[33724,1],[33975,1],[34226,1],[34477,1],[34728,1],[34979,1],[35230,1],[35481,1],[35732,1],[35983,1],[36234,1],[36485,1],[36736,1],[36987,1],[37238,1],[37489,1],[37740,1],[37991,1],[38242,1],[38493,1],[38744,1],[38995,1],[39246,1],[39497,1],[39748,1],[39999,1],[40250,1],[40501,1],[40752,1],[40959,2],[41003,1],[41254,1],[41505,1],[41756,1],[42007,1],[42258,1],[42509,1],[42560,1],[42760,1],[42893,1],[42994,1],[43011,1],[43262,1],[43513,1],[43764,1],[43888,1],[44015,1],[44032,1],[44266,1],[44517,1],[44768,1],[45019,1],[45270,1],[45521,1],[45772,1],[46023,1],[46274,1],[46525,1],[46776,1],[47027,1],[47278,1],[47529,1],[47780,1],[48031,1],[48282,1],[48533,1],[48784,1],[49035,1],[49286,1],[49537,1],[49788,1],[50039,1],[50290,1],[50541,1],[50792,1],[51043,1],[51294,1],[51545,1],[51796,1],[52047,1],[52298,1],[52549,1],[52800,1],[53051,1],[53302,1],[53553,1],[53804,1],[54055,1],[54306,1],[54557,1],[54808,1],[55059,1],[55203,1],[55295,1],[57344,1],[57569,1],[57820,1],[58071,1],[58322,1],[58573,1],[58824,1],[59075,1],[59326,1],[59577,1],[59828,1],[60079,1],[60330,1],[60581,1],[60832,1],[61083,1],[61334,1],[61585,1],[61836,1],[62087,1],[62338,1],[62589,1],[62840,1],[63091,1],[63342,1],[63593,1],[63743,2],[63844,1],[64095,1],[64256,2],[64275,1],[64346,1],[64597,1],[64848,1],[65099,1],[65112,1],[65279,1],[65288,1],[65313,1],[65345,1],[65350,1],[65392,1],[65533,1],[65535,2],[65601,1],[65852,1],[65856,1],[66103,1],[66354,1],[66560,1],[66600,1],[66605,1],[66736,1],[66856,1],[66928,1],[67107,1],[67358,1],[67609,1],[67860,1],[68111,1],[68362,1],[68613,1],[68736,1],[68864,1],[69115,1],[69366,1],[69617,1],[69868,1],[70119,1],[70370,1],[70621,1],[70872,1],[71123,1],[71374,1],[71625,1],[71840,1],[71876,1],[72127,1],[72378,1],[72629,1],[72880,1],[73131,1],[73382,1],[73633,1],[73884,1],[74135,1],[74386,1],[74637,1],[74888,1],[75139,1],[75390,1],[75641,1],[75892,1],[76143,1],[76394,1],[76645,1],[76896,1],[77147,1],[77398,1],[77649,1],[77900,1],[78151,1],[78402,1],[78653,1],[78904,1],[79155,1],[79406,1],[79657,1],[79908,1],[80159,1],[80410,1],[80661,1],[80912,1],[81163,1],[81414,1],[81665,1],[81916,1],[82167,1],[82418,1],[82669,1],[82920,1],[83171,1],[83422,1],[83673,1],[83924,1],[84175,1],[84426,1],[84677,1],[84928,1],[85179,1],[85430,1],[85681,1],[85932,1],[86183,1],[86434,1],[86685,1],[86936,1],[87187,1],[87438,1],[87689,1],[87940,1],[88191,1],[88442,1],[88693,1],[88944,1],[89195,1],[89446,1],[89697,1],[89948,1],[90199,1],[90450,1],[90701,1],[90952,1],[91203,1],[91454,1],[91705,1],[91956,1],[92207,1],[92458,1],[92709,1],[92960,1],[93211,1],[93462,1],[93713,1],[93760,1],[93964,1],[94176,1],[94215,1],[94466,1],[94717,1],[94968,1],[95219,1],[95470,1],[95721,1],[95972,1],[96223,1],[96474,1],[96725,1],[96976,1],[97227,1],[97478,1],[97729,1],[97980,1],[98231,1],[98482,1],[98733,1],[98984,1],[99235,1],[99486,1],[99737,1],[99988,1],[100239,1],[100490,1],[100741,1],[100992,1],[101243,1],[101494,1],[101745,1],[101996,1],[102247,1],[102498,1],[102749,1],[103000,1],[103251,1],[103502,1],[103753,1],[104004,1],[104255,1],[104506,1],[104757,1],[105008,1],[105259,1],[105510,1],[105761,1],[106012,1],[106263,1],[106514,1],[106765,1],[107016,1],[107267,1],[107518,1],[107769,1],[108020,1],[108271,1],[108522,1],[108773,1],[109024,1],[109275,1],[109526,1],[109777,1],[110028,1],[110279,1],[110530,1],[110781,1],[111032,1],[111283,1],[111534,1],[111785,1],[112036,1],[112287,1],[112538,1],[112789,1],[113040,1],[113291,1],[113542,1],[113793,1],[114044,1],[114295,1],[114546,1],[114797,1],[115048,1],[115299,1],[115550,1],[115801,1],[116052,1],[116303,1],[116554,1],[116805,1],[117056,1],[117307,1],[117558,1],[117809,1],[118060,1],[118311,1],[118562,1],[118813,1],[119064,1],[119315,1],[119566,1],[119808,1],[119817,1],[119834,1],[120068,1],[120319,1],[120488,1],[120570,1],[120821,1],[121072,1],[121323,1],[121574,1],[121825,1],[122076,1],[122327,1],[122578,1],[122829,1],[123080,1],[123331,1],[123582,1],[123833,1],[124084,1],[124335,1],[124586,1],[124837,1],[125088,1],[125184,1],[125218,1],[125339,1],[125590,1],[125841,1],[126092,1],[126343,1],[126594,1],[126845,1],[127096,1],[127280,1],[127347,1],[127467,1],[127598,1],[127849,1],[128100,1],[128351,1],[128512,1],[128602,1],[128853,1],[129104,1],[129355,1],[129606,1],[129857,1],[130108,1],[130359,1],[130610,1],[130861,1],[131072,1],[131112,1],[131363,1],[131614,1],[131865,1],[132116,1],[132367,1],[132618,1],[132869,1],[133120,1],[133371,1],[133622,1],[133873,1],[134124,1],[134375,1],[134626,1],[134877,1],[135128,1],[135379,1],[135630,1],[135881,1],[136132,1],[136383,1],[136634,1],[136885,1],[137136,1],[137387,1],[137638,1],[137889,1],[138140,1],[138391,1],[138642,1],[138893,1],[139144,1],[139395,1],[139646,1],[139897,1],[140148,1],[140399,1],[140650,1],[140901,1],[141152,1],[141403,1],[141654,1],[141905,1],[142156,1],[142407,1],[142658,1],[142909,1],[143160,1],[143411,1],[143662,1],[143913,1],[144164,1],[144415,1],[144666,1],[144917,1],[145168,1],[145419,1],[145670,1],[145921,1],[146172,1],[146423,1],[146674,1],[146925,1],[147176,1],[147427,1],[147678,1],[147929,1],[148180,1],[148431,1],[148682,1],[148933,1],[149184,1],[149435,1],[149686,1],[149937,1],[150188,1],[150439,1],[150690,1],[150941,1],[151192,1],[151443,1],[151694,1],[151945,1],[152196,1],[152447,1],[152698,1],[152949,1],[153200,1],[153451,1],[153702,1],[153953,1],[154204,1],[154455,1],[154706,1],[154957,1],[155208,1],[155459,1],[155710,1],[155961,1],[156212,1],[156463,1],[156714,1],[156965,1],[157216,1],[157467,1],[157718,1],[157969,1],[158220,1],[158471,1],[158722,1],[158973,1],[159224,1],[159475,1],[159726,1],[159977,1],[160228,1],[160479,1],[160730,1],[160981,1],[161232,1],[161483,1],[161734,1],[161985,1],[162236,1],[162487,1],[162738,1],[162989,1],[163240,1],[163491,1],[163742,1],[163993,1],[164244,1],[164495,1],[164746,1],[164997,1],[165248,1],[165499,1],[165750,1],[166001,1],[166252,1],[166503,1],[166754,1],[167005,1],[167256,1],[167507,1],[167758,1],[168009,1],[168260,1],[168511,1],[168762,1],[169013,1],[169264,1],[169515,1],[169766,1],[170017,1],[170268,1],[170519,1],[170770,1],[171021,1],[171272,1],[171523,1],[171774,1],[172025,1],[172276,1],[172527,1],[172778,1],[173029,1],[173280,1],[173531,1],[173782,1],[174033,1],[174284,1],[174535,1],[174786,1],[175037,1],[175288,1],[175539,1],[175790,1],[176041,1],[176292,1],[176543,1],[176794,1],[177045,1],[177296,1],[177547,1],[177798,1],[178049,1],[178300,1],[178551,1],[178802,1],[179053,1],[179304,1],[179555,1],[179806,1],[180057,1],[180308,1],[180559,1],[180810,1],[181061,1],[181312,1],[181563,1],[181814,1],[182065,1],[182316,1],[182567,1],[182818,1],[183069,1],[183320,1],[183571,1],[183822,1],[184073,1],[184324,1],[184575,1],[184826,1],[185077,1],[185328,1],[185579,1],[185830,1],[186081,1],[186332,1],[186583,1],[186834,1],[187085,1],[187336,1],[187587,1],[187838,1],[188089,1],[188340,1],[188591,1],[188842,1],[189093,1],[189344,1],[189595,1],[189846,1],[190097,1],[190348,1],[190599,1],[190850,1],[191101,1],[191352,1],[191603,1],[191854,1],[192105,1],[192356,1],[192607,1],[192858,1],[193109,1],[193360,1],[193611,1],[193862,1],[194113,1],[194364,1],[194615,1],[194866,1],[195117,1],[195368,1],[195619,1],[195870,1],[196121,1],[196372,1],[196607,2],[196623,1],[196874,1],[197125,1],[197376,1],[197627,1],[197878,1],[198129,1],[198380,1],[198631,1],[198882,1],[199133,1],[199384,1],[199635,1],[199886,1],[200137,1],[200388,1],[200639,1],[200890,1],[201141,1],[201392,1],[201643,1],[201894,1],[202145,1],[202396,1],[202647,1],[202898,1],[203149,1],[203400,1],[203651,1],[203902,1],[204153,1],[204404,1],[204655,1],[204906,1],[205157,1],[205408,1],[205659,1],[205910,1],[206161,1],[206412,1],[206663,1],[206914,1],[207165,1],[207416,1],[207667,1],[207918,1],[208169,1],[208420,1],[208671,1],[208922,1],[209173,1],[209424,1],[209675,1],[209926,1],[210177,1],[210428,1],[210679,1],[210930,1],[211181,1],[211432,1],[211683,1],[211934,1],[212185,1],[212436,1],[212687,1],[212938,1],[213189,1],[213440,1],[213691,1],[213942,1],[214193,1],[214444,1],[214695,1],[214946,1],[215197,1],[215448,1],[215699,1],[215950,1],[216201,1],[216452,1],[216703,1],[216954,1],[217205,1],[217456,1],[217707,1],[217958,1],[218209,1],[218460,1],[218711,1],[218962,1],[219213,1],[219464,1],[219715,1],[219966,1],[220217,1],[220468,1],[220719,1],[220970,1],[221221,1],[221472,1],[221723,1],[221974,1],[222225,1],[222476,1],[222727,1],[222978,1],[223229,1],[223480,1],[223731,1],[223982,1],[224233,1],[224484,1],[224735,1],[224986,1],[225237,1],[225488,1],[225739,1],[225990,1],[226241,1],[226492,1],[226743,1],[226994,1],[227245,1],[227496,1],[227747,1],[227998,1],[228249,1],[228500,1],[228751,1],[229002,1],[229253,1],[229504,1],[229755,1],[230006,1],[230257,1],[230508,1],[230759,1],[231010,1],[231261,1],[231512,1],[231763,1],[232014,1],[232265,1],[232516,1],[232767,1],[233018,1],[233269,1],[233520,1],[233771,1],[234022,1],[234273,1],[234524,1],[234775,1],[235026,1],[235277,1],[235528,1],[235779,1],[236030,1],[236281,1],[236532,1],[236783,1],[237034,1],[237285,1],[237536,1],[237787,1],[238038,1],[238289,1],[238540,1],[238791,1],[239042,1],[239293,1],[239544,1],[239795,1],[240046,1],[240297,1],[240548,1],[240799,1],[241050,1],[241301,1],[241552,1],[241803,1],[242054,1],[242305,1],[242556,1],[242807,1],[243058,1],[243309,1],[243560,1],[243811,1],[244062,1],[244313,1],[244564,1],[244815,1],[245066,1],[245317,1],[245568,1],[245819,1],[246070,1],[246321,1],[246572,1],[246823,1],[247074,1],[247325,1],[247576,1],[247827,1],[248078,1],[248329,1],[248580,1],[248831,1],[249082,1],[249333,1],[249584,1],[249835,1],[250086,1],[250337,1],[250588,1],[250839,1],[251090,1],[251341,1],[251592,1],[251843,1],[252094,1],[252345,1],[252596,1],[252847,1],[253098,1],[253349,1],[253600,1],[253851,1],[254102,1],[254353,1],[254604,1],[254855,1],[255106,1],[255357,1],[255608,1],[255859,1],[256110,1],[256361,1],[256612,1],[256863,1],[257114,1],[257365,1],[257616,1],[257867,1],[258118,1],[258369,1],[258620,1],[258871,1],[259122,1],[259373,1],[259624,1],[259875,1],[260126,1],[260377,1],[260628,1],[260879,1],[261130,1],[261381,1],[261632,1],[261883,1],[262134,1],[262385,1],[262636,1],[262887,1],[263138,1],[263389,1],[263640,1],[263891,1],[264142,1],[264393,1],[264644,1],[264895,1],[265146,1],[265397,1],[265648,1],[265899,1],[266150,1],[266401,1],[266652,1],[266903,1],[267154,1],[267405,1],[267656,1],[267907,1],[268158,1],[268409,1],[268660,1],[268911,1],[269162,1],[269413,1],[269664,1],[269915,1],[270166,1],[270417,1],[270668,1],[270919,1],[271170,1],[271421,1],[271672,1],[271923,1],[272174,1],[272425,1],[272676,1],[272927,1],[273178,1],[273429,1],[273680,1],[273931,1],[274182,1],[274433,1],[274684,1],[274935,1],[275186,1],[275437,1],[275688,1],[275939,1],[276190,1],[276441,1],[276692,1],[276943,1],[277194,1],[277445,1],[277696,1],[277947,1],[278198,1],[278449,1],[278700,1],[278951,1],[279202,1],[279453,1],[279704,1],[279955,1],[280206,1],[280457,1],[280708,1],[280959,1],[281210,1],[281461,1],[281712,1],[281963,1],[282214,1],[282465,1],[282716,1],[282967,1],[283218,1],[283469,1],[283720,1],[283971,1],[284222,1],[284473,1],[284724,1],[284975,1],[285226,1],[285477,1],[285728,1],[285979,1],[286230,1],[286481,1],[286732,1],[286983,1],[287234,1],[287485,1],[287736,1],[287987,1],[288238,1],[288489,1],[288740,1],[288991,1],[289242,1],[289493,1],[289744,1],[289995,1],[290246,1],[290497,1],[290748,1],[290999,1],[291250,1],[291501,1],[291752,1],[292003,1],[292254,1],[292505,1],[292756,1],[293007,1],[293258,1],[293509,1],[293760,1],[294011,1],[294262,1],[294513,1],[294764,1],[295015,1],[295266,1],[295517,1],[295768,1],[296019,1],[296270,1],[296521,1],[296772,1],[297023,1],[297274,1],[297525,1],[297776,1],[298027,1],[298278,1],[298529,1],[298780,1],[299031,1],[299282,1],[299533,1],[299784,1],[300035,1],[300286,1],[300537,1],[300788,1],[301039,1],[301290,1],[301541,1],[301792,1],[302043,1],[302294,1],[302545,1],[302796,1],[303047,1],[303298,1],[303549,1],[303800,1],[304051,1],[304302,1],[304553,1],[304804,1],[305055,1],[305306,1],[305557,1],[305808,1],[306059,1],[306310,1],[306561,1],[306812,1],[307063,1],[307314,1],[307565,1],[307816,1],[308067,1],[308318,1],[308569,1],[308820,1],[309071,1],[309322,1],[309573,1],[309824,1],[310075,1],[310326,1],[310577,1],[310828,1],[311079,1],[311330,1],[311581,1],[311832,1],[312083,1],[312334,1],[312585,1],[312836,1],[313087,1],[313338,1],[313589,1],[313840,1],[314091,1],[314342,1],[314593,1],[314844,1],[315095,1],[315346,1],[315597,1],[315848,1],[316099,1],[316350,1],[316601,1],[316852,1],[317103,1],[317354,1],[317605,1],[317856,1],[318107,1],[318358,1],[318609,1],[318860,1],[319111,1],[319362,1],[319613,1],[319864,1],[320115,1],[320366,1],[320617,1],[320868,1],[321119,1],[321370,1],[321621,1],[321872,1],[322123,1],[322374,1],[322625,1],[322876,1],[323127,1],[323378,1],[323629,1],[323880,1],[324131,1],[324382,1],[324633,1],[324884,1],[325135,1],[325386,1],[325637,1],[325888,1],[326139,1],[326390,1],[326641,1],[326892,1],[327143,1],[327394,1],[327645,1],[327896,1],[328147,1],[328398,1],[328649,1],[328900,1],[329151,1],[329402,1],[329653,1],[329904,1],[330155,1],[330406,1],[330657,1],[330908,1],[331159,1],[331410,1],[331661,1],[331912,1],[332163,1],[332414,1],[332665,1],[332916,1],[333167,1],[333418,1],[333669,1],[333920,1],[334171,1],[334422,1],[334673,1],[334924,1],[335175,1],[335426,1],[335677,1],[335928,1],[336179,1],[336430,1],[336681,1],[336932,1],[337183,1],[337434,1],[337685,1],[337936,1],[338187,1],[338438,1],[338689,1],[338940,1],[339191,1],[339442,1],[339693,1],[339944,1],[340195,1],[340446,1],[340697,1],[340948,1],[341199,1],[341450,1],[341701,1],[341952,1],[342203,1],[342454,1],[342705,1],[342956,1],[343207,1],[343458,1],[343709,1],[343960,1],[344211,1],[344462,1],[344713,1],[344964,1],[345215,1],[345466,1],[345717,1],[345968,1],[346219,1],[346470,1],[346721,1],[346972,1],[347223,1],[347474,1],[347725,1],[347976,1],[348227,1],[348478,1],[348729,1],[348980,1],[349231,1],[349482,1],[349733,1],[349984,1],[350235,1],[350486,1],[350737,1],[350988,1],[351239,1],[351490,1],[351741,1],[351992,1],[352243,1],[352494,1],[352745,1],[352996,1],[353247,1],[353498,1],[353749,1],[354000,1],[354251,1],[354502,1],[354753,1],[355004,1],[355255,1],[355506,1],[355757,1],[356008,1],[356259,1],[356510,1],[356761,1],[357012,1],[357263,1],[357514,1],[357765,1],[358016,1],[358267,1],[358518,1],[358769,1],[359020,1],[359271,1],[359522,1],[359773,1],[360024,1],[360275,1],[360526,1],[360777,1],[361028,1],[361279,1],[361530,1],[361781,1],[362032,1],[362283,1],[362534,1],[362785,1],[363036,1],[363287,1],[363538,1],[363789,1],[364040,1],[364291,1],[364542,1],[364793,1],[365044,1],[365295,1],[365546,1],[365797,1],[366048,1],[366299,1],[366550,1],[366801,1],[367052,1],[367303,1],[367554,1],[367805,1],[368056,1],[368307,1],[368558,1],[368809,1],[369060,1],[369311,1],[369562,1],[369813,1],[370064,1],[370315,1],[370566,1],[370817,1],[371068,1],[371319,1],[371570,1],[371821,1],[372072,1],[372323,1],[372574,1],[372825,1],[373076,1],[373327,1],[373578,1],[373829,1],[374080,1],[374331,1],[374582,1],[374833,1],[375084,1],[375335,1],[375586,1],[375837,1],[376088,1],[376339,1],[376590,1],[376841,1],[377092,1],[377343,1],[377594,1],[377845,1],[378096,1],[378347,1],[378598,1],[378849,1],[379100,1],[379351,1],[379602,1],[379853,1],[380104,1],[380355,1],[380606,1],[380857,1],[381108,1],[381359,1],[381610,1],[381861,1],[382112,1],[382363,1],[382614,1],[382865,1],[383116,1],[383367,1],[383618,1],[383869,1],[384120,1],[384371,1],[384622,1],[384873,1],[385124,1],[385375,1],[385626,1],[385877,1],[386128,1],[386379,1],[386630,1],[386881,1],[387132,1],[387383,1],[387634,1],[387885,1],[388136,1],[388387,1],[388638,1],[388889,1],[389140,1],[389391,1],[389642,1],[389893,1],[390144,1],[390395,1],[390646,1],[390897,1],[391148,1],[391399,1],[391650,1],[391901,1],[392152,1],[392403,1],[392654,1],[392905,1],[393156,1],[393407,1],[393658,1],[393909,1],[394160,1],[394411,1],[394662,1],[394913,1],[395164,1],[395415,1],[395666,1],[395917,1],[396168,1],[396419,1],[396670,1],[396921,1],[397172,1],[397423,1],[397674,1],[397925,1],[398176,1],[398427,1],[398678,1],[398929,1],[399180,1],[399431,1],[399682,1],[399933,1],[400184,1],[400435,1],[400686,1],[400937,1],[401188,1],[401439,1],[401690,1],[401941,1],[402192,1],[402443,1],[402694,1],[402945,1],[403196,1],[403447,1],[403698,1],[403949,1],[404200,1],[404451,1],[404702,1],[404953,1],[405204,1],[405455,1],[405706,1],[405957,1],[406208,1],[406459,1],[406710,1],[406961,1],[407212,1],[407463,1],[407714,1],[407965,1],[408216,1],[408467,1],[408718,1],[408969,1],[409220,1],[409471,1],[409722,1],[409973,1],[410224,1],[410475,1],[410726,1],[410977,1],[411228,1],[411479,1],[411730,1],[411981,1],[412232,1],[412483,1],[412734,1],[412985,1],[413236,1],[413487,1],[413738,1],[413989,1],[414240,1],[414491,1],[414742,1],[414993,1],[415244,1],[415495,1],[415746,1],[415997,1],[416248,1],[416499,1],[416750,1],[417001,1],[417252,1],[417503,1],[417754,1],[418005,1],[418256,1],[418507,1],[418758,1],[419009,1],[419260,1],[419511,1],[419762,1],[420013,1],[420264,1],[420515,1],[420766,1],[421017,1],[421268,1],[421519,1],[421770,1],[422021,1],[422272,1],[422523,1],[422774,1],[423025,1],[423276,1],[423527,1],[423778,1],[424029,1],[424280,1],[424531,1],[424782,1],[425033,1],[425284,1],[425535,1],[425786,1],[426037,1],[426288,1],[426539,1],[426790,1],[427041,1],[427292,1],[427543,1],[427794,1],[428045,1],[428296,1],[428547,1],[428798,1],[429049,1],[429300,1],[429551,1],[429802,1],[430053,1],[430304,1],[430555,1],[430806,1],[431057,1],[431308,1],[431559,1],[431810,1],[432061,1],[432312,1],[432563,1],[432814,1],[433065,1],[433316,1],[433567,1],[433818,1],[434069,1],[434320,1],[434571,1],[434822,1],[435073,1],[435324,1],[435575,1],[435826,1],[436077,1],[436328,1],[436579,1],[436830,1],[437081,1],[437332,1],[437583,1],[437834,1],[438085,1],[438336,1],[438587,1],[438838,1],[439089,1],[439340,1],[439591,1],[439842,1],[440093,1],[440344,1],[440595,1],[440846,1],[441097,1],[441348,1],[441599,1],[441850,1],[442101,1],[442352,1],[442603,1],[442854,1],[443105,1],[443356,1],[443607,1],[443858,1],[444109,1],[444360,1],[444611,1],[444862,1],[445113,1],[445364,1],[445615,1],[445866,1],[446117,1],[446368,1],[446619,1],[446870,1],[447121,1],[447372,1],[447623,1],[447874,1],[448125,1],[448376,1],[448627,1],[448878,1],[449129,1],[449380,1],[449631,1],[449882,1],[450133,1],[450384,1],[450635,1],[450886,1],[451137,1],[451388,1],[451639,1],[451890,1],[452141,1],[452392,1],[452643,1],[452894,1],[453145,1],[453396,1],[453647,1],[453898,1],[454149,1],[454400,1],[454651,1],[454902,1],[455153,1],[455404,1],[455655,1],[455906,1],[456157,1],[456408,1],[456659,1],[456910,1],[457161,1],[457412,1],[457663,1],[457914,1],[458165,1],[458416,1],[458667,1],[458918,1],[459169,1],[459420,1],[459671,1],[459922,1],[460173,1],[460424,1],[460675,1],[460926,1],[461177,1],[461428,1],[461679,1],[461930,1],[462181,1],[462432,1],[462683,1],[462934,1],[463185,1],[463436,1],[463687,1],[463938,1],[464189,1],[464440,1],[464691,1],[464942,1],[465193,1],[465444,1],[465695,1],[465946,1],[466197,1],[466448,1],[466699,1],[466950,1],[467201,1],[467452,1],[467703,1],[467954,1],[468205,1],[468456,1],[468707,1],[468958,1],[469209,1],[469460,1],[469711,1],[469962,1],[470213,1],[470464,1],[470715,1],[470966,1],[471217,1],[471468,1],[471719,1],[471970,1],[472221,1],[472472,1],[472723,1],[472974,1],[473225,1],[473476,1],[473727,1],[473978,1],[474229,1],[474480,1],[474731,1],[474982,1],[475233,1],[475484,1],[475735,1],[475986,1],[476237,1],[476488,1],[476739,1],[476990,1],[477241,1],[477492,1],[477743,1],[477994,1],[478245,1],[478496,1],[478747,1],[478998,1],[479249,1],[479500,1],[479751,1],[480002,1],[480253,1],[480504,1],[480755,1],[481006,1],[481257,1],[481508,1],[481759,1],[482010,1],[482261,1],[482512,1],[482763,1],[483014,1],[483265,1],[483516,1],[483767,1],[484018,1],[484269,1],[484520,1],[484771,1],[485022,1],[485273,1],[485524,1],[485775,1],[486026,1],[486277,1],[486528,1],[486779,1],[487030,1],[487281,1],[487532,1],[487783,1],[488034,1],[488285,1],[488536,1],[488787,1],[489038,1],[489289,1],[489540,1],[489791,1],[490042,1],[490293,1],[490544,1],[490795,1],[491046,1],[491297,1],[491548,1],[491799,1],[492050,1],[492301,1],[492552,1],[492803,1],[493054,1],[493305,1],[493556,1],[493807,1],[494058,1],[494309,1],[494560,1],[494811,1],[495062,1],[495313,1],[495564,1],[495815,1],[496066,1],[496317,1],[496568,1],[496819,1],[497070,1],[497321,1],[497572,1],[497823,1],[498074,1],[498325,1],[498576,1],[498827,1],[499078,1],[499329,1],[499580,1],[499831,1],[500082,1],[500333,1],[500584,1],[500835,1],[501086,1],[501337,1],[501588,1],[501839,1],[502090,1],[502341,1],[502592,1],[502843,1],[503094,1],[503345,1],[503596,1],[503847,1],[504098,1],[504349,1],[504600,1],[504851,1],[505102,1],[505353,1],[505604,1],[505855,1],[506106,1],[506357,1],[506608,1],[506859,1],[507110,1],[507361,1],[507612,1],[507863,1],[508114,1],[508365,1],[508616,1],[508867,1],[509118,1],[509369,1],[509620,1],[509871,1],[510122,1],[510373,1],[510624,1],[510875,1],[511126,1],[511377,1],[511628,1],[511879,1],[512130,1],[512381,1],[512632,1],[512883,1],[513134,1],[513385,1],[513636,1],[513887,1],[514138,1],[514389,1],[514640,1],[514891,1],[515142,1],[515393,1],[515644,1],[515895,1],[516146,1],[516397,1],[516648,1],[516899,1],[517150,1],[517401,1],[517652,1],[517903,1],[518154,1],[518405,1],[518656,1],[518907,1],[519158,1],[519409,1],[519660,1],[519911,1],[520162,1],[520413,1],[520664,1],[520915,1],[521166,1],[521417,1],[521668,1],[521919,1],[522170,1],[522421,1],[522672,1],[522923,1],[523174,1],[523425,1],[523676,1],[523927,1],[524178,1],[524429,1],[524680,1],[524931,1],[525182,1],[525433,1],[525684,1],[525935,1],[526186,1],[526437,1],[526688,1],[526939,1],[527190,1],[527441,1],[527692,1],[527943,1],[528194,1],[528445,1],[528696,1],[528947,1],[529198,1],[529449,1],[529700,1],[529951,1],[530202,1],[530453,1],[530704,1],[530955,1],[531206,1],[531457,1],[531708,1],[531959,1],[532210,1],[532461,1],[532712,1],[532963,1],[533214,1],[533465,1],[533716,1],[533967,1],[534218,1],[534469,1],[534720,1],[534971,1],[535222,1],[535473,1],[535724,1],[535975,1],[536226,1],[536477,1],[536728,1],[536979,1],[537230,1],[537481,1],[537732,1],[537983,1],[538234,1],[538485,1],[538736,1],[538987,1],[539238,1],[539489,1],[539740,1],[539991,1],[540242,1],[540493,1],[540744,1],[540995,1],[541246,1],[541497,1],[541748,1],[541999,1],[542250,1],[542501,1],[542752,1],[543003,1],[543254,1],[543505,1],[543756,1],[544007,1],[544258,1],[544509,1],[544760,1],[545011,1],[545262,1],[545513,1],[545764,1],[546015,1],[546266,1],[546517,1],[546768,1],[547019,1],[547270,1],[547521,1],[547772,1],[548023,1],[548274,1],[548525,1],[548776,1],[549027,1],[549278,1],[549529,1],[549780,1],[550031,1],[550282,1],[550533,1],[550784,1],[551035,1],[551286,1],[551537,1],[551788,1],[552039,1],[552290,1],[552541,1],[552792,1],[553043,1],[553294,1],[553545,1],[553796,1],[554047,1],[554298,1],[554549,1],[554800,1],[555051,1],[555302,1],[555553,1],[555804,1],[556055,1],[556306,1],[556557,1],[556808,1],[557059,1],[557310,1],[557561,1],[557812,1],[558063,1],[558314,1],[558565,1],[558816,1],[559067,1],[559318,1],[559569,1],[559820,1],[560071,1],[560322,1],[560573,1],[560824,1],[561075,1],[561326,1],[561577,1],[561828,1],[562079,1],[562330,1],[562581,1],[562832,1],[563083,1],[563334,1],[563585,1],[563836,1],[564087,1],[564338,1],[564589,1],[564840,1],[565091,1],[565342,1],[565593,1],[565844,1],[566095,1],[566346,1],[566597,1],[566848,1],[567099,1],[567350,1],[567601,1],[567852,1],[568103,1],[568354,1],[568605,1],[568856,1],[569107,1],[569358,1],[569609,1],[569860,1],[570111,1],[570362,1],[570613,1],[570864,1],[571115,1],[571366,1],[571617,1],[571868,1],[572119,1],[572370,1],[572621,1],[572872,1],[573123,1],[573374,1],[573625,1],[573876,1],[574127,1],[574378,1],[574629,1],[574880,1],[575131,1],[575382,1],[575633,1],[575884,1],[576135,1],[576386,1],[576637,1],[576888,1],[577139,1],[577390,1],[577641,1],[577892,1],[578143,1],[578394,1],[578645,1],[578896,1],[579147,1],[579398,1],[579649,1],[579900,1],[580151,1],[580402,1],[580653,1],[580904,1],[581155,1],[581406,1],[581657,1],[581908,1],[582159,1],[582410,1],[582661,1],[582912,1],[583163,1],[583414,1],[583665,1],[583916,1],[584167,1],[584418,1],[584669,1],[584920,1],[585171,1],[585422,1],[585673,1],[585924,1],[586175,1],[586426,1],[586677,1],[586928,1],[587179,1],[587430,1],[587681,1],[587932,1],[588183,1],[588434,1],[588685,1],[588936,1],[589187,1],[589438,1],[589689,1],[589940,1],[590191,1],[590442,1],[590693,1],[590944,1],[591195,1],[591446,1],[591697,1],[591948,1],[592199,1],[592450,1],[592701,1],[592952,1],[593203,1],[593454,1],[593705,1],[593956,1],[594207,1],[594458,1],[594709,1],[594960,1],[595211,1],[595462,1],[595713,1],[595964,1],[596215,1],[596466,1],[596717,1],[596968,1],[597219,1],[597470,1],[597721,1],[597972,1],[598223,1],[598474,1],[598725,1],[598976,1],[599227,1],[599478,1],[599729,1],[599980,1],[600231,1],[600482,1],[600733,1],[600984,1],[601235,1],[601486,1],[601737,1],[601988,1],[602239,1],[602490,1],[602741,1],[602992,1],[603243,1],[603494,1],[603745,1],[603996,1],[604247,1],[604498,1],[604749,1],[605000,1],[605251,1],[605502,1],[605753,1],[606004,1],[606255,1],[606506,1],[606757,1],[607008,1],[607259,1],[607510,1],[607761,1],[608012,1],[608263,1],[608514,1],[608765,1],[609016,1],[609267,1],[609518,1],[609769,1],[610020,1],[610271,1],[610522,1],[610773,1],[611024,1],[611275,1],[611526,1],[611777,1],[612028,1],[612279,1],[612530,1],[612781,1],[613032,1],[613283,1],[613534,1],[613785,1],[614036,1],[614287,1],[614538,1],[614789,1],[615040,1],[615291,1],[615542,1],[615793,1],[616044,1],[616295,1],[616546,1],[616797,1],[617048,1],[617299,1],[617550,1],[617801,1],[618052,1],[618303,1],[618554,1],[618805,1],[619056,1],[619307,1],[619558,1],[619809,1],[620060,1],[620311,1],[620562,1],[620813,1],[621064,1],[621315,1],[621566,1],[621817,1],[622068,1],[622319,1],[622570,1],[622821,1],[623072,1],[623323,1],[623574,1],[623825,1],[624076,1],[624327,1],[624578,1],[624829,1],[625080,1],[625331,1],[625582,1],[625833,1],[626084,1],[626335,1],[626586,1],[626837,1],[627088,1],[627339,1],[627590,1],[627841,1],[628092,1],[628343,1],[628594,1],[628845,1],[629096,1],[629347,1],[629598,1],[629849,1],[630100,1],[630351,1],[630602,1],[630853,1],[631104,1],[631355,1],[631606,1],[631857,1],[632108,1],[632359,1],[632610,1],[632861,1],[633112,1],[633363,1],[633614,1],[633865,1],[634116,1],[634367,1],[634618,1],[634869,1],[635120,1],[635371,1],[635622,1],[635873,1],[636124,1],[636375,1],[636626,1],[636877,1],[637128,1],[637379,1],[637630,1],[637881,1],[638132,1],[638383,1],[638634,1],[638885,1],[639136,1],[639387,1],[639638,1],[639889,1],[640140,1],[640391,1],[640642,1],[640893,1],[641144,1],[641395,1],[641646,1],[641897,1],[642148,1],[642399,1],[642650,1],[642901,1],[643152,1],[643403,1],[643654,1],[643905,1],[644156,1],[644407,1],[644658,1],[644909,1],[645160,1],[645411,1],[645662,1],[645913,1],[646164,1],[646415,1],[646666,1],[646917,1],[647168,1],[647419,1],[647670,1],[647921,1],[648172,1],[648423,1],[648674,1],[648925,1],[649176,1],[649427,1],[649678,1],[649929,1],[650180,1],[650431,1],[650682,1],[650933,1],[651184,1],[651435,1],[651686,1],[651937,1],[652188,1],[652439,1],[652690,1],[652941,1],[653192,1],[653443,1],[653694,1],[653945,1],[654196,1],[654447,1],[654698,1],[654949,1],[655200,1],[655451,1],[655702,1],[655953,1],[656204,1],[656455,1],[656706,1],[656957,1],[657208,1],[657459,1],[657710,1],[657961,1],[658212,1],[658463,1],[658714,1],[658965,1],[659216,1],[659467,1],[659718,1],[659969,1],[660220,1],[660471,1],[660722,1],[660973,1],[661224,1],[661475,1],[661726,1],[661977,1],[662228,1],[662479,1],[662730,1],[662981,1],[663232,1],[663483,1],[663734,1],[663985,1],[664236,1],[664487,1],[664738,1],[664989,1],[665240,1],[665491,1],[665742,1],[665993,1],[666244,1],[666495,1],[666746,1],[666997,1],[667248,1],[667499,1],[667750,1],[668001,1],[668252,1],[668503,1],[668754,1],[669005,1],[669256,1],[669507,1],[669758,1],[670009,1],[670260,1],[670511,1],[670762,1],[671013,1],[671264,1],[671515,1],[671766,1],[672017,1],[672268,1],[672519,1],[672770,1],[673021,1],[673272,1],[673523,1],[673774,1],[674025,1],[674276,1],[674527,1],[674778,1],[675029,1],[675280,1],[675531,1],[675782,1],[676033,1],[676284,1],[676535,1],[676786,1],[677037,1],[677288,1],[677539,1],[677790,1],[678041,1],[678292,1],[678543,1],[678794,1],[679045,1],[679296,1],[679547,1],[679798,1],[680049,1],[680300,1],[680551,1],[680802,1],[681053,1],[681304,1],[681555,1],[681806,1],[682057,1],[682308,1],[682559,1],[682810,1],[683061,1],[683312,1],[683563,1],[683814,1],[684065,1],[684316,1],[684567,1],[684818,1],[685069,1],[685320,1],[685571,1],[685822,1],[686073,1],[686324,1],[686575,1],[686826,1],[687077,1],[687328,1],[687579,1],[687830,1],[688081,1],[688332,1],[688583,1],[688834,1],[689085,1],[689336,1],[689587,1],[689838,1],[690089,1],[690340,1],[690591,1],[690842,1],[691093,1],[691344,1],[691595,1],[691846,1],[692097,1],[692348,1],[692599,1],[692850,1],[693101,1],[693352,1],[693603,1],[693854,1],[694105,1],[694356,1],[694607,1],[694858,1],[695109,1],[695360,1],[695611,1],[695862,1],[696113,1],[696364,1],[696615,1],[696866,1],[697117,1],[697368,1],[697619,1],[697870,1],[698121,1],[698372,1],[698623,1],[698874,1],[699125,1],[699376,1],[699627,1],[699878,1],[700129,1],[700380,1],[700631,1],[700882,1],[701133,1],[701384,1],[701635,1],[701886,1],[702137,1],[702388,1],[702639,1],[702890,1],[703141,1],[703392,1],[703643,1],[703894,1],[704145,1],[704396,1],[704647,1],[704898,1],[705149,1],[705400,1],[705651,1],[705902,1],[706153,1],[706404,1],[706655,1],[706906,1],[707157,1],[707408,1],[707659,1],[707910,1],[708161,1],[708412,1],[708663,1],[708914,1],[709165,1],[709416,1],[709667,1],[709918,1],[710169,1],[710420,1],[710671,1],[710922,1],[711173,1],[711424,1],[711675,1],[711926,1],[712177,1],[712428,1],[712679,1],[712930,1],[713181,1],[713432,1],[713683,1],[713934,1],[714185,1],[714436,1],[714687,1],[714938,1],[715189,1],[715440,1],[715691,1],[715942,1],[716193,1],[716444,1],[716695,1],[716946,1],[717197,1],[717448,1],[717699,1],[717950,1],[718201,1],[718452,1],[718703,1],[718954,1],[719205,1],[719456,1],[719707,1],[719958,1],[720209,1],[720460,1],[720711,1],[720962,1],[721213,1],[721464,1],[721715,1],[721966,1],[722217,1],[722468,1],[722719,1],[722970,1],[723221,1],[723472,1],[723723,1],[723974,1],[724225,1],[724476,1],[724727,1],[724978,1],[725229,1],[725480,1],[725731,1],[725982,1],[726233,1],[726484,1],[726735,1],[726986,1],[727237,1],[727488,1],[727739,1],[727990,1],[728241,1],[728492,1],[728743,1],[728994,1],[729245,1],[729496,1],[729747,1],[729998,1],[730249,1],[730500,1],[730751,1],[731002,1],[731253,1],[731504,1],[731755,1],[732006,1],[732257,1],[732508,1],[732759,1],[733010,1],[733261,1],[733512,1],[733763,1],[734014,1],[734265,1],[734516,1],[734767,1],[735018,1],[735269,1],[735520,1],[735771,1],[736022,1],[736273,1],[736524,1],[736775,1],[737026,1],[737277,1],[737528,1],[737779,1],[738030,1],[738281,1],[738532,1],[738783,1],[739034,1],[739285,1],[739536,1],[739787,1],[740038,1],[740289,1],[740540,1],[740791,1],[741042,1],[741293,1],[741544,1],[741795,1],[742046,1],[742297,1],[742548,1],[742799,1],[743050,1],[743301,1],[743552,1],[743803,1],[744054,1],[744305,1],[744556,1],[744807,1],[745058,1],[745309,1],[745560,1],[745811,1],[746062,1],[746313,1],[746564,1],[746815,1],[747066,1],[747317,1],[747568,1],[747819,1],[748070,1],[748321,1],[748572,1],[748823,1],[749074,1],[749325,1],[749576,1],[749827,1],[750078,1],[750329,1],[750580,1],[750831,1],[751082,1],[751333,1],[751584,1],[751835,1],[752086,1],[752337,1],[752588,1],[752839,1],[753090,1],[753341,1],[753592,1],[753843,1],[754094,1],[754345,1],[754596,1],[754847,1],[755098,1],[755349,1],[755600,1],[755851,1],[756102,1],[756353,1],[756604,1],[756855,1],[757106,1],[757357,1],[757608,1],[757859,1],[758110,1],[758361,1],[758612,1],[758863,1],[759114,1],[759365,1],[759616,1],[759867,1],[760118,1],[760369,1],[760620,1],[760871,1],[761122,1],[761373,1],[761624,1],[761875,1],[762126,1],[762377,1],[762628,1],[762879,1],[763130,1],[763381,1],[763632,1],[763883,1],[764134,1],[764385,1],[764636,1],[764887,1],[765138,1],[765389,1],[765640,1],[765891,1],[766142,1],[766393,1],[766644,1],[766895,1],[767146,1],[767397,1],[767648,1],[767899,1],[768150,1],[768401,1],[768652,1],[768903,1],[769154,1],[769405,1],[769656,1],[769907,1],[770158,1],[770409,1],[770660,1],[770911,1],[771162,1],[771413,1],[771664,1],[771915,1],[772166,1],[772417,1],[772668,1],[772919,1],[773170,1],[773421,1],[773672,1],[773923,1],[774174,1],[774425,1],[774676,1],[774927,1],[775178,1],[775429,1],[775680,1],[775931,1],[776182,1],[776433,1],[776684,1],[776935,1],[777186,1],[777437,1],[777688,1],[777939,1],[778190,1],[778441,1],[778692,1],[778943,1],[779194,1],[779445,1],[779696,1],[779947,1],[780198,1],[780449,1],[780700,1],[780951,1],[781202,1],[781453,1],[781704,1],[781955,1],[782206,1],[782457,1],[782708,1],[782959,1],[783210,1],[783461,1],[783712,1],[783963,1],[784214,1],[784465,1],[784716,1],[784967,1],[785218,1],[785469,1],[785720,1],[785971,1],[786222,1],[786473,1],[786724,1],[786975,1],[787226,1],[787477,1],[787728,1],[787979,1],[788230,1],[788481,1],[788732,1],[788983,1],[789234,1],[789485,1],[789736,1],[789987,1],[790238,1],[790489,1],[790740,1],[790991,1],[791242,1],[791493,1],[791744,1],[791995,1],[792246,1],[792497,1],[792748,1],[792999,1],[793250,1],[793501,1],[793752,1],[794003,1],[794254,1],[794505,1],[794756,1],[795007,1],[795258,1],[795509,1],[795760,1],[796011,1],[796262,1],[796513,1],[796764,1],[797015,1],[797266,1],[797517,1],[797768,1],[798019,1],[798270,1],[798521,1],[798772,1],[799023,1],[799274,1],[799525,1],[799776,1],[800027,1],[800278,1],[800529,1],[800780,1],[801031,1],[801282,1],[801533,1],[801784,1],[802035,1],[802286,1],[802537,1],[802788,1],[803039,1],[803290,1],[803541,1],[803792,1],[804043,1],[804294,1],[804545,1],[804796,1],[805047,1],[805298,1],[805549,1],[805800,1],[806051,1],[806302,1],[806553,1],[806804,1],[807055,1],[807306,1],[807557,1],[807808,1],[808059,1],[808310,1],[808561,1],[808812,1],[809063,1],[809314,1],[809565,1],[809816,1],[810067,1],[810318,1],[810569,1],[810820,1],[811071,1],[811322,1],[811573,1],[811824,1],[812075,1],[812326,1],[812577,1],[812828,1],[813079,1],[813330,1],[813581,1],[813832,1],[814083,1],[814334,1],[814585,1],[814836,1],[815087,1],[815338,1],[815589,1],[815840,1],[816091,1],[816342,1],[816593,1],[816844,1],[817095,1],[817346,1],[817597,1],[817848,1],[818099,1],[818350,1],[818601,1],[818852,1],[819103,1],[819354,1],[819605,1],[819856,1],[820107,1],[820358,1],[820609,1],[820860,1],[821111,1],[821362,1],[821613,1],[821864,1],[822115,1],[822366,1],[822617,1],[822868,1],[823119,1],[823370,1],[823621,1],[823872,1],[824123,1],[824374,1],[824625,1],[824876,1],[825127,1],[825378,1],[825629,1],[825880,1],[826131,1],[826382,1],[826633,1],[826884,1],[827135,1],[827386,1],[827637,1],[827888,1],[828139,1],[828390,1],[828641,1],[828892,1],[829143,1],[829394,1],[829645,1],[829896,1],[830147,1],[830398,1],[830649,1],[830900,1],[831151,1],[831402,1],[831653,1],[831904,1],[832155,1],[832406,1],[832657,1],[832908,1],[833159,1],[833410,1],[833661,1],[833912,1],[834163,1],[834414,1],[834665,1],[834916,1],[835167,1],[835418,1],[835669,1],[835920,1],[836171,1],[836422,1],[836673,1],[836924,1],[837175,1],[837426,1],[837677,1],[837928,1],[838179,1],[838430,1],[838681,1],[838932,1],[839183,1],[839434,1],[839685,1],[839936,1],[840187,1],[840438,1],[840689,1],[840940,1],[841191,1],[841442,1],[841693,1],[841944,1],[842195,1],[842446,1],[842697,1],[842948,1],[843199,1],[843450,1],[843701,1],[843952,1],[844203,1],[844454,1],[844705,1],[844956,1],[845207,1],[845458,1],[845709,1],[845960,1],[846211,1],[846462,1],[846713,1],[846964,1],[847215,1],[847466,1],[847717,1],[847968,1],[848219,1],[848470,1],[848721,1],[848972,1],[849223,1],[849474,1],[849725,1],[849976,1],[850227,1],[850478,1],[850729,1],[850980,1],[851231,1],[851482,1],[851733,1],[851984,1],[852235,1],[852486,1],[852737,1],[852988,1],[853239,1],[853490,1],[853741,1],[853992,1],[854243,1],[854494,1],[854745,1],[854996,1],[855247,1],[855498,1],[855749,1],[856000,1],[856251,1],[856502,1],[856753,1],[857004,1],[857255,1],[857506,1],[857757,1],[858008,1],[858259,1],[858510,1],[858761,1],[859012,1],[859263,1],[859514,1],[859765,1],[860016,1],[860267,1],[860518,1],[860769,1],[861020,1],[861271,1],[861522,1],[861773,1],[862024,1],[862275,1],[862526,1],[862777,1],[863028,1],[863279,1],[863530,1],[863781,1],[864032,1],[864283,1],[864534,1],[864785,1],[865036,1],[865287,1],[865538,1],[865789,1],[866040,1],[866291,1],[866542,1],[866793,1],[867044,1],[867295,1],[867546,1],[867797,1],[868048,1],[868299,1],[868550,1],[868801,1],[869052,1],[869303,1],[869554,1],[869805,1],[870056,1],[870307,1],[870558,1],[870809,1],[871060,1],[871311,1],[871562,1],[871813,1],[872064,1],[872315,1],[872566,1],[872817,1],[873068,1],[873319,1],[873570,1],[873821,1],[874072,1],[874323,1],[874574,1],[874825,1],[875076,1],[875327,1],[875578,1],[875829,1],[876080,1],[876331,1],[876582,1],[876833,1],[877084,1],[877335,1],[877586,1],[877837,1],[878088,1],[878339,1],[878590,1],[878841,1],[879092,1],[879343,1],[879594,1],[879845,1],[880096,1],[880347,1],[880598,1],[880849,1],[881100,1],[881351,1],[881602,1],[881853,1],[882104,1],[882355,1],[882606,1],[882857,1],[883108,1],[883359,1],[883610,1],[883861,1],[884112,1],[884363,1],[884614,1],[884865,1],[885116,1],[885367,1],[885618,1],[885869,1],[886120,1],[886371,1],[886622,1],[886873,1],[887124,1],[887375,1],[887626,1],[887877,1],[888128,1],[888379,1],[888630,1],[888881,1],[889132,1],[889383,1],[889634,1],[889885,1],[890136,1],[890387,1],[890638,1],[890889,1],[891140,1],[891391,1],[891642,1],[891893,1],[892144,1],[892395,1],[892646,1],[892897,1],[893148,1],[893399,1],[893650,1],[893901,1],[894152,1],[894403,1],[894654,1],[894905,1],[895156,1],[895407,1],[895658,1],[895909,1],[896160,1],[896411,1],[896662,1],[896913,1],[897164,1],[897415,1],[897666,1],[897917,1],[898168,1],[898419,1],[898670,1],[898921,1],[899172,1],[899423,1],[899674,1],[899925,1],[900176,1],[900427,1],[900678,1],[900929,1],[901180,1],[901431,1],[901682,1],[901933,1],[902184,1],[902435,1],[902686,1],[902937,1],[903188,1],[903439,1],[903690,1],[903941,1],[904192,1],[904443,1],[904694,1],[904945,1],[905196,1],[905447,1],[905698,1],[905949,1],[906200,1],[906451,1],[906702,1],[906953,1],[907204,1],[907455,1],[907706,1],[907957,1],[908208,1],[908459,1],[908710,1],[908961,1],[909212,1],[909463,1],[909714,1],[909965,1],[910216,1],[910467,1],[910718,1],[910969,1],[911220,1],[911471,1],[911722,1],[911973,1],[912224,1],[912475,1],[912726,1],[912977,1],[913228,1],[913479,1],[913730,1],[913981,1],[914232,1],[914483,1],[914734,1],[914985,1],[915236,1],[915487,1],[915738,1],[915989,1],[916240,1],[916491,1],[916742,1],[916993,1],[917244,1],[917495,1],[917505,1],[917746,1],[917760,1],[917997,1],[918248,1],[918499,1],[918750,1],[919001,1],[919252,1],[919503,1],[919754,1],[920005,1],[920256,1],[920507,1],[920758,1],[921009,1],[921260,1],[921511,1],[921762,1],[922013,1],[922264,1],[922515,1],[922766,1],[923017,1],[923268,1],[923519,1],[923770,1],[924021,1],[924272,1],[924523,1],[924774,1],[925025,1],[925276,1],[925527,1],[925778,1],[926029,1],[926280,1],[926531,1],[926782,1],[927033,1],[927284,1],[927535,1],[927786,1],[928037,1],[928288,1],[928539,1],[928790,1],[929041,1],[929292,1],[929543,1],[929794,1],[930045,1],[930296,1],[930547,1],[930798,1],[931049,1],[931300,1],[931551,1],[931802,1],[932053,1],[932304,1],[932555,1],[932806,1],[933057,1],[933308,1],[933559,1],[933810,1],[934061,1],[934312,1],[934563,1],[934814,1],[935065,1],[935316,1],[935567,1],[935818,1],[936069,1],[936320,1],[936571,1],[936822,1],[937073,1],[937324,1],[937575,1],[937826,1],[938077,1],[938328,1],[938579,1],[938830,1],[939081,1],[939332,1],[939583,1],[939834,1],[940085,1],[940336,1],[940587,1],[940838,1],[941089,1],[941340,1],[941591,1],[941842,1],[942093,1],[942344,1],[942595,1],[942846,1],[943097,1],[943348,1],[943599,1],[943850,1],[944101,1],[944352,1],[944603,1],[944854,1],[945105,1],[945356,1],[945607,1],[945858,1],[946109,1],[946360,1],[946611,1],[946862,1],[947113,1],[947364,1],[947615,1],[947866,1],[948117,1],[948368,1],[948619,1],[948870,1],[949121,1],[949372,1],[949623,1],[949874,1],[950125,1],[950376,1],[950627,1],[950878,1],[951129,1],[951380,1],[951631,1],[951882,1],[952133,1],[952384,1],[952635,1],[952886,1],[953137,1],[953388,1],[953639,1],[953890,1],[954141,1],[954392,1],[954643,1],[954894,1],[955145,1],[955396,1],[955647,1],[955898,1],[956149,1],[956400,1],[956651,1],[956902,1],[957153,1],[957404,1],[957655,1],[957906,1],[958157,1],[958408,1],[958659,1],[958910,1],[959161,1],[959412,1],[959663,1],[959914,1],[960165,1],[960416,1],[960667,1],[960918,1],[961169,1],[961420,1],[961671,1],[961922,1],[962173,1],[962424,1],[962675,1],[962926,1],[963177,1],[963428,1],[963679,1],[963930,1],[964181,1],[964432,1],[964683,1],[964934,1],[965185,1],[965436,1],[965687,1],[965938,1],[966189,1],[966440,1],[966691,1],[966942,1],[967193,1],[967444,1],[967695,1],[967946,1],[968197,1],[968448,1],[968699,1],[968950,1],[969201,1],[969452,1],[969703,1],[969954,1],[970205,1],[970456,1],[970707,1],[970958,1],[971209,1],[971460,1],[971711,1],[971962,1],[972213,1],[972464,1],[972715,1],[972966,1],[973217,1],[973468,1],[973719,1],[973970,1],[974221,1],[974472,1],[974723,1],[974974,1],[975225,1],[975476,1],[975727,1],[975978,1],[976229,1],[976480,1],[976731,1],[976982,1],[977233,1],[977484,1],[977735,1],[977986,1],[978237,1],[978488,1],[978739,1],[978990,1],[979241,1],[979492,1],[979743,1],[979994,1],[980245,1],[980496,1],[980747,1],[980998,1],[981249,1],[981500,1],[981751,1],[982002,1],[982253,1],[982504,1],[982755,1],[983006,1],[983257,1],[983508,1],[983759,1],[984010,1],[984261,1],[984512,1],[984763,1],[985014,1],[985265,1],[985516,1],[985767,1],[986018,1],[986269,1],[986520,1],[986771,1],[987022,1],[987273,1],[987524,1],[987775,1],[988026,1],[988277,1],[988528,1],[988779,1],[989030,1],[989281,1],[989532,1],[989783,1],[990034,1],[990285,1],[990536,1],[990787,1],[991038,1],[991289,1],[991540,1],[991791,1],[992042,1],[992293,1],[992544,1],[992795,1],[993046,1],[993297,1],[993548,1],[993799,1],[994050,1],[994301,1],[994552,1],[994803,1],[995054,1],[995305,1],[995556,1],[995807,1],[996058,1],[996309,1],[996560,1],[996811,1],[997062,1],[997313,1],[997564,1],[997815,1],[998066,1],[998317,1],[998568,1],[998819,1],[999070,1],[999321,1],[999572,1],[999823,1],[1000074,1],[1000325,1],[1000576,1],[1000827,1],[1001078,1],[1001329,1],[1001580,1],[1001831,1],[1002082,1],[1002333,1],[1002584,1],[1002835,1],[1003086,1],[1003337,1],[1003588,1],[1003839,1],[1004090,1],[1004341,1],[1004592,1],[1004843,1],[1005094,1],[1005345,1],[1005596,1],[1005847,1],[1006098,1],[1006349,1],[1006600,1],[1006851,1],[1007102,1],[1007353,1],[1007604,1],[1007855,1],[1008106,1],[1008357,1],[1008608,1],[1008859,1],[1009110,1],[1009361,1],[1009612,1],[1009863,1],[1010114,1],[1010365,1],[1010616,1],[1010867,1],[1011118,1],[1011369,1],[1011620,1],[1011871,1],[1012122,1],[1012373,1],[1012624,1],[1012875,1],[1013126,1],[1013377,1],[1013628,1],[1013879,1],[1014130,1],[1014381,1],[1014632,1],[1014883,1],[1015134,1],[1015385,1],[1015636,1],[1015887,1],[1016138,1],[1016389,1],[1016640,1],[1016891,1],[1017142,1],[1017393,1],[1017644,1],[1017895,1],[1018146,1],[1018397,1],[1018648,1],[1018899,1],[1019150,1],[1019401,1],[1019652,1],[1019903,1],[1020154,1],[1020405,1],[1020656,1],[1020907,1],[1021158,1],[1021409,1],[1021660,1],[1021911,1],[1022162,1],[1022413,1],[1022664,1],[1022915,1],[1023166,1],[1023417,1],[1023668,1],[1023919,1],[1024170,1],[1024421,1],[1024672,1],[1024923,1],[1025174,1],[1025425,1],[1025676,1],[1025927,1],[1026178,1],[1026429,1],[1026680,1],[1026931,1],[1027182,1],[1027433,1],[1027684,1],[1027935,1],[1028186,1],[1028437,1],[1028688,1],[1028939,1],[1029190,1],[1029441,1],[1029692,1],[1029943,1],[1030194,1],[1030445,1],[1030696,1],[1030947,1],[1031198,1],[1031449,1],[1031700,1],[1031951,1],[1032202,1],[1032453,1],[1032704,1],[1032955,1],[1033206,1],[1033457,1],[1033708,1],[1033959,1],[1034210,1],[1034461,1],[1034712,1],[1034963,1],[1035214,1],[1035465,1],[1035716,1],[1035967,1],[1036218,1],[1036469,1],[1036720,1],[1036971,1],[1037222,1],[1037473,1],[1037724,1],[1037975,1],[1038226,1],[1038477,1],[1038728,1],[1038979,1],[1039230,1],[1039481,1],[1039732,1],[1039983,1],[1040234,1],[1040485,1],[1040736,1],[1040987,1],[1041238,1],[1041489,1],[1041740,1],[1041991,1],[1042242,1],[1042493,1],[1042744,1],[1042995,1],[1043246,1],[1043497,1],[1043748,1],[1043999,1],[1044250,1],[1044501,1],[1044752,1],[1045003,1],[1045254,1],[1045505,1],[1045756,1],[1046007,1],[1046258,1],[1046509,1],[1046760,1],[1047011,1],[1047262,1],[1047513,1],[1047764,1],[1048015,1],[1048266,1],[1048517,1],[1048768,1],[1049019,1],[1049270,1],[1049521,1],[1049772,1],[1050023,1],[1050274,1],[1050525,1],[1050776,1],[1051027,1],[1051278,1],[1051529,1],[1051780,1],[1052031,1],[1052282,1],[1052533,1],[1052784,1],[1053035,1],[1053286,1],[1053537,1],[1053788,1],[1054039,1],[1054290,1],[1054541,1],[1054792,1],[1055043,1],[1055294,1],[1055545,1],[1055796,1],[1056047,1],[1056298,1],[1056549,1],[1056800,1],[1057051,1],[1057302,1],[1057553,1],[1057804,1],[1058055,1],[1058306,1],[1058557,1],[1058808,1],[1059059,1],[1059310,1],[1059561,1],[1059812,1],[1060063,1],[1060314,1],[1060565,1],[1060816,1],[1061067,1],[1061318,1],[1061569,1],[1061820,1],[1062071,1],[1062322,1],[1062573,1],[1062824,1],[1063075,1],[1063326,1],[1063577,1],[1063828,1],[1064079,1],[1064330,1],[1064581,1],[1064832,1],[1065083,1],[1065334,1],[1065585,1],[1065836,1],[1066087,1],[1066338,1],[1066589,1],[1066840,1],[1067091,1],[1067342,1],[1067593,1],[1067844,1],[1068095,1],[1068346,1],[1068597,1],[1068848,1],[1069099,1],[1069350,1],[1069601,1],[1069852,1],[1070103,1],[1070354,1],[1070605,1],[1070856,1],[1071107,1],[1071358,1],[1071609,1],[1071860,1],[1072111,1],[1072362,1],[1072613,1],[1072864,1],[1073115,1],[1073366,1],[1073617,1],[1073868,1],[1074119,1],[1074370,1],[1074621,1],[1074872,1],[1075123,1],[1075374,1],[1075625,1],[1075876,1],[1076127,1],[1076378,1],[1076629,1],[1076880,1],[1077131,1],[1077382,1],[1077633,1],[1077884,1],[1078135,1],[1078386,1],[1078637,1],[1078888,1],[1079139,1],[1079390,1],[1079641,1],[1079892,1],[1080143,1],[1080394,1],[1080645,1],[1080896,1],[1081147,1],[1081398,1],[1081649,1],[1081900,1],[1082151,1],[1082402,1],[1082653,1],[1082904,1],[1083155,1],[1083406,1],[1083657,1],[1083908,1],[1084159,1],[1084410,1],[1084661,1],[1084912,1],[1085163,1],[1085414,1],[1085665,1],[1085916,1],[1086167,1],[1086418,1],[1086669,1],[1086920,1],[1087171,1],[1087422,1],[1087673,1],[1087924,1],[1088175,1],[1088426,1],[1088677,1],[1088928,1],[1089179,1],[1089430,1],[1089681,1],[1089932,1],[1090183,1],[1090434,1],[1090685,1],[1090936,1],[1091187,1],[1091438,1],[1091689,1],[1091940,1],[1092191,1],[1092442,1],[1092693,1],[1092944,1],[1093195,1],[1093446,1],[1093697,1],[1093948,1],[1094199,1],[1094450,1],[1094701,1],[1094952,1],[1095203,1],[1095454,1],[1095705,1],[1095956,1],[1096207,1],[1096458,1],[1096709,1],[1096960,1],[1097211,1],[1097462,1],[1097713,1],[1097964,1],[1098215,1],[1098466,1],[1098717,1],[1098968,1],[1099219,1],[1099470,1],[1099721,1],[1099972,1],[1100223,1],[1100474,1],[1100725,1],[1100976,1],[1101227,1],[1101478,1],[1101729,1],[1101980,1],[1102231,1],[1102482,1],[1102733,1],[1102984,1],[1103235,1],[1103486,1],[1103737,1],[1103988,1],[1104239,1],[1104490,1],[1104741,1],[1104992,1],[1105243,1],[1105494,1],[1105745,1],[1105996,1],[1106247,1],[1106498,1],[1106749,1],[1107000,1],[1107251,1],[1107502,1],[1107753,1],[1108004,1],[1108255,1],[1108506,1],[1108757,1],[1109008,1],[1109259,1],[1109510,1],[1109761,1],[1110012,1],[1110263,1],[1110514,1],[1110765,1],[1111016,1],[1111267,1],[1111518,1],[1111769,1],[1112020,1],[1112271,1],[1112522,1],[1112773,1],[1113024,1],[1113275,1],[1113526,1],[1113777,1],[1114028,1],[1114109,1],[1114111,1]],"whitespace":"0000000001111100000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000001100000110101000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","letter":"0000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111000000111111111111111111111111110000000000000000000000000000000000000000000000010000000000100001000001111111111111111111111101111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000001111111111111110000111111110011111110111101100010011101011111100000000000000010111100110000000000000110100001100111110011111111111111111111111111101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101011110110111111111111111111111111111111111111111111111100000000000000000000000000001111111110000111100110001111101111101111001000000001111000001111100000000000111101111111111111111110000000000000000000000000000000000111100011111111111111111111111111111111100000000000000000000000000000000000011100000000010000000000000000000000011111110000000000000000011100000100000000000000000000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000001100000001111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","upper":"0000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111101111111000000000000000000000000000000000101010101010101010101010101010101010101010101010101010100101010101010101001010101010101010101010101010101010101010101010110101000110101101110011110110111000110110101011010010110111010110001000000010010010010101010101010100101010101010101010010010111010101010101010101010101010101010101010101010101010101010100000001101100101111010101010000000001011001100100000000000000000001000010000000000000000100010010000000000000000000111100100000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100101000000010000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011010110000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","jsSpace":"0000000001111100000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000001100000110101000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}, +"strings": [ +{"s":"","utf16Len":0,"asciiLower":"","lower":"","wordKey":"","dedupKey":"","collapse":"","words":[],"jsTrim":"","jsTrimEnd":"","year":null}, +{"s":" ","utf16Len":1,"asciiLower":" ","lower":" ","wordKey":" ","dedupKey":"","collapse":"","words":[],"jsTrim":"","jsTrimEnd":"","year":null}, +{"s":"Noisia","utf16Len":6,"asciiLower":"noisia","lower":"noisia","wordKey":"noisia","dedupKey":"noisia","collapse":"Noisia","words":["Noisia"],"jsTrim":"Noisia","jsTrimEnd":"Noisia","year":null}, +{"s":" The Upbeats ","utf16Len":15,"asciiLower":" the upbeats ","lower":" the upbeats ","wordKey":" the upbeats ","dedupKey":"the upbeats","collapse":"The Upbeats","words":["The","Upbeats"],"jsTrim":"The Upbeats","jsTrimEnd":" The Upbeats","year":null}, +{"s":"FEAT.","utf16Len":5,"asciiLower":"feat.","lower":"feat.","wordKey":"feat","dedupKey":"feat.","collapse":"FEAT.","words":["FEAT."],"jsTrim":"FEAT.","jsTrimEnd":"FEAT.","year":null}, +{"s":"Feat","utf16Len":4,"asciiLower":"feat","lower":"feat","wordKey":"feat","dedupKey":"feat","collapse":"Feat","words":["Feat"],"jsTrim":"Feat","jsTrimEnd":"Feat","year":null}, +{"s":"ft.","utf16Len":3,"asciiLower":"ft.","lower":"ft.","wordKey":"ft","dedupKey":"ft.","collapse":"ft.","words":["ft."],"jsTrim":"ft.","jsTrimEnd":"ft.","year":null}, +{"s":"Remix,","utf16Len":6,"asciiLower":"remix,","lower":"remix,","wordKey":"remix","dedupKey":"remix,","collapse":"Remix,","words":["Remix,"],"jsTrim":"Remix,","jsTrimEnd":"Remix,","year":null}, +{"s":"remix!!","utf16Len":7,"asciiLower":"remix!!","lower":"remix!!","wordKey":"remix!","dedupKey":"remix!!","collapse":"remix!!","words":["remix!!"],"jsTrim":"remix!!","jsTrimEnd":"remix!!","year":null}, +{"s":"a.","utf16Len":2,"asciiLower":"a.","lower":"a.","wordKey":"a","dedupKey":"a.","collapse":"a.","words":["a."],"jsTrim":"a.","jsTrimEnd":"a.","year":null}, +{"s":".","utf16Len":1,"asciiLower":".","lower":".","wordKey":"","dedupKey":".","collapse":".","words":["."],"jsTrim":".","jsTrimEnd":".","year":null}, +{"s":"..","utf16Len":2,"asciiLower":"..","lower":"..","wordKey":".","dedupKey":"..","collapse":"..","words":[".."],"jsTrim":"..","jsTrimEnd":"..","year":null}, +{"s":"É.","utf16Len":2,"asciiLower":"É.","lower":"é.","wordKey":"É","dedupKey":"e.","collapse":"É.","words":["É."],"jsTrim":"É.","jsTrimEnd":"É.","year":null}, +{"s":"İ.","utf16Len":2,"asciiLower":"İ.","lower":"i̇.","wordKey":"İ","dedupKey":"i.","collapse":"İ.","words":["İ."],"jsTrim":"İ.","jsTrimEnd":"İ.","year":null}, +{"s":"İstanbul","utf16Len":8,"asciiLower":"İstanbul","lower":"i̇stanbul","wordKey":"İstanbul","dedupKey":"istanbul","collapse":"İstanbul","words":["İstanbul"],"jsTrim":"İstanbul","jsTrimEnd":"İstanbul","year":null}, +{"s":"ISTANBUL","utf16Len":8,"asciiLower":"istanbul","lower":"istanbul","wordKey":"istanbul","dedupKey":"istanbul","collapse":"ISTANBUL","words":["ISTANBUL"],"jsTrim":"ISTANBUL","jsTrimEnd":"ISTANBUL","year":null}, +{"s":"ıstanbul","utf16Len":8,"asciiLower":"ıstanbul","lower":"ıstanbul","wordKey":"ıstanbul","dedupKey":"ıstanbul","collapse":"ıstanbul","words":["ıstanbul"],"jsTrim":"ıstanbul","jsTrimEnd":"ıstanbul","year":null}, +{"s":"İ","utf16Len":2,"asciiLower":"i̇","lower":"i̇","wordKey":"i̇","dedupKey":"i","collapse":"İ","words":["İ"],"jsTrim":"İ","jsTrimEnd":"İ","year":null}, +{"s":"STRAẞE","utf16Len":6,"asciiLower":"straẞe","lower":"straße","wordKey":"straẞe","dedupKey":"straße","collapse":"STRAẞE","words":["STRAẞE"],"jsTrim":"STRAẞE","jsTrimEnd":"STRAẞE","year":null}, +{"s":"Straße","utf16Len":6,"asciiLower":"straße","lower":"straße","wordKey":"straße","dedupKey":"straße","collapse":"Straße","words":["Straße"],"jsTrim":"Straße","jsTrimEnd":"Straße","year":null}, +{"s":"Dž","utf16Len":1,"asciiLower":"Dž","lower":"dž","wordKey":"Dž","dedupKey":"dž","collapse":"Dž","words":["Dž"],"jsTrim":"Dž","jsTrimEnd":"Dž","year":null}, +{"s":"dž","utf16Len":1,"asciiLower":"dž","lower":"dž","wordKey":"dž","dedupKey":"dž","collapse":"dž","words":["dž"],"jsTrim":"dž","jsTrimEnd":"dž","year":null}, +{"s":"DŽ","utf16Len":1,"asciiLower":"DŽ","lower":"dž","wordKey":"DŽ","dedupKey":"dž","collapse":"DŽ","words":["DŽ"],"jsTrim":"DŽ","jsTrimEnd":"DŽ","year":null}, +{"s":"ᾈ","utf16Len":1,"asciiLower":"ᾈ","lower":"ᾀ","wordKey":"ᾈ","dedupKey":"α","collapse":"ᾈ","words":["ᾈ"],"jsTrim":"ᾈ","jsTrimEnd":"ᾈ","year":null}, +{"s":"ᾀ","utf16Len":1,"asciiLower":"ᾀ","lower":"ᾀ","wordKey":"ᾀ","dedupKey":"α","collapse":"ᾀ","words":["ᾀ"],"jsTrim":"ᾀ","jsTrimEnd":"ᾀ","year":null}, +{"s":"ΟΔΥΣΣΕΑΣ","utf16Len":8,"asciiLower":"ΟΔΥΣΣΕΑΣ","lower":"οδυσσεας","wordKey":"ΟΔΥΣΣΕΑΣ","dedupKey":"οδυσσεας","collapse":"ΟΔΥΣΣΕΑΣ","words":["ΟΔΥΣΣΕΑΣ"],"jsTrim":"ΟΔΥΣΣΕΑΣ","jsTrimEnd":"ΟΔΥΣΣΕΑΣ","year":null}, +{"s":"Σίσυφος","utf16Len":7,"asciiLower":"Σίσυφος","lower":"σίσυφος","wordKey":"Σίσυφος","dedupKey":"σισυφος","collapse":"Σίσυφος","words":["Σίσυφος"],"jsTrim":"Σίσυφος","jsTrimEnd":"Σίσυφος","year":null}, +{"s":"ΣΊΣΥΦΟΣ","utf16Len":7,"asciiLower":"ΣΊΣΥΦΟΣ","lower":"σίσυφος","wordKey":"ΣΊΣΥΦΟΣ","dedupKey":"σισυφος","collapse":"ΣΊΣΥΦΟΣ","words":["ΣΊΣΥΦΟΣ"],"jsTrim":"ΣΊΣΥΦΟΣ","jsTrimEnd":"ΣΊΣΥΦΟΣ","year":null}, +{"s":"Σ","utf16Len":1,"asciiLower":"Σ","lower":"σ","wordKey":"Σ","dedupKey":"σ","collapse":"Σ","words":["Σ"],"jsTrim":"Σ","jsTrimEnd":"Σ","year":null}, +{"s":"ΑΣ","utf16Len":2,"asciiLower":"ΑΣ","lower":"ας","wordKey":"ΑΣ","dedupKey":"ας","collapse":"ΑΣ","words":["ΑΣ"],"jsTrim":"ΑΣ","jsTrimEnd":"ΑΣ","year":null}, +{"s":"ΑΣ ","utf16Len":3,"asciiLower":"ΑΣ ","lower":"ας ","wordKey":"ΑΣ ","dedupKey":"ας","collapse":"ΑΣ","words":["ΑΣ"],"jsTrim":"ΑΣ","jsTrimEnd":"ΑΣ","year":null}, +{"s":"ΑΣΑ","utf16Len":3,"asciiLower":"ΑΣΑ","lower":"ασα","wordKey":"ΑΣΑ","dedupKey":"ασα","collapse":"ΑΣΑ","words":["ΑΣΑ"],"jsTrim":"ΑΣΑ","jsTrimEnd":"ΑΣΑ","year":null}, +{"s":"ΑΣ.","utf16Len":3,"asciiLower":"ΑΣ.","lower":"ας.","wordKey":"ΑΣ","dedupKey":"ας.","collapse":"ΑΣ.","words":["ΑΣ."],"jsTrim":"ΑΣ.","jsTrimEnd":"ΑΣ.","year":null}, +{"s":"ΑΣ'","utf16Len":3,"asciiLower":"ΑΣ'","lower":"ας'","wordKey":"ΑΣ'","dedupKey":"ας'","collapse":"ΑΣ'","words":["ΑΣ'"],"jsTrim":"ΑΣ'","jsTrimEnd":"ΑΣ'","year":null}, +{"s":"ΑΣ’Α","utf16Len":4,"asciiLower":"ΑΣ’Α","lower":"ασ’α","wordKey":"ΑΣ’Α","dedupKey":"ασ’α","collapse":"ΑΣ’Α","words":["ΑΣ’Α"],"jsTrim":"ΑΣ’Α","jsTrimEnd":"ΑΣ’Α","year":null}, +{"s":"ΑΣ́","utf16Len":3,"asciiLower":"ΑΣ́","lower":"ας́","wordKey":"ΑΣ́","dedupKey":"ας","collapse":"ΑΣ́","words":["ΑΣ́"],"jsTrim":"ΑΣ́","jsTrimEnd":"ΑΣ́","year":null}, +{"s":"ΆΣ","utf16Len":3,"asciiLower":"ΆΣ","lower":"άς","wordKey":"ΆΣ","dedupKey":"ας","collapse":"ΆΣ","words":["ΆΣ"],"jsTrim":"ΆΣ","jsTrimEnd":"ΆΣ","year":null}, +{"s":"Α­Σ","utf16Len":3,"asciiLower":"Α­Σ","lower":"α­ς","wordKey":"Α­Σ","dedupKey":"α­ς","collapse":"Α­Σ","words":["Α­Σ"],"jsTrim":"Α­Σ","jsTrimEnd":"Α­Σ","year":null}, +{"s":"Σ Σ","utf16Len":3,"asciiLower":"Σ Σ","lower":"σ σ","wordKey":"Σ Σ","dedupKey":"σ σ","collapse":"Σ Σ","words":["Σ","Σ"],"jsTrim":"Σ Σ","jsTrimEnd":"Σ Σ","year":null}, +{"s":"aΣ","utf16Len":2,"asciiLower":"aΣ","lower":"aς","wordKey":"aΣ","dedupKey":"aς","collapse":"aΣ","words":["aΣ"],"jsTrim":"aΣ","jsTrimEnd":"aΣ","year":null}, +{"s":"aΣb","utf16Len":3,"asciiLower":"aΣb","lower":"aσb","wordKey":"aΣb","dedupKey":"aσb","collapse":"aΣb","words":["aΣb"],"jsTrim":"aΣb","jsTrimEnd":"aΣb","year":null}, +{"s":"1Σ","utf16Len":2,"asciiLower":"1Σ","lower":"1σ","wordKey":"1Σ","dedupKey":"1σ","collapse":"1Σ","words":["1Σ"],"jsTrim":"1Σ","jsTrimEnd":"1Σ","year":null}, +{"s":":Σ","utf16Len":2,"asciiLower":":Σ","lower":":σ","wordKey":":Σ","dedupKey":":σ","collapse":":Σ","words":[":Σ"],"jsTrim":":Σ","jsTrimEnd":":Σ","year":null}, +{"s":"ΑΣ-Β","utf16Len":4,"asciiLower":"ΑΣ-Β","lower":"ας-β","wordKey":"ΑΣ-Β","dedupKey":"ας-β","collapse":"ΑΣ-Β","words":["ΑΣ-Β"],"jsTrim":"ΑΣ-Β","jsTrimEnd":"ΑΣ-Β","year":null}, +{"s":"Α.Σ","utf16Len":3,"asciiLower":"Α.Σ","lower":"α.ς","wordKey":"Α.Σ","dedupKey":"α.ς","collapse":"Α.Σ","words":["Α.Σ"],"jsTrim":"Α.Σ","jsTrimEnd":"Α.Σ","year":null}, +{"s":"Α Σ","utf16Len":3,"asciiLower":"Α Σ","lower":"α σ","wordKey":"Α Σ","dedupKey":"α σ","collapse":"Α Σ","words":["Α","Σ"],"jsTrim":"Α Σ","jsTrimEnd":"Α Σ","year":null}, +{"s":"ΑΣ‍","utf16Len":3,"asciiLower":"ΑΣ‍","lower":"ας‍","wordKey":"ΑΣ‍","dedupKey":"ας‍","collapse":"ΑΣ‍","words":["ΑΣ‍"],"jsTrim":"ΑΣ‍","jsTrimEnd":"ΑΣ‍","year":null}, +{"s":"Beyoncé","utf16Len":7,"asciiLower":"beyoncé","lower":"beyoncé","wordKey":"beyoncé","dedupKey":"beyonce","collapse":"Beyoncé","words":["Beyoncé"],"jsTrim":"Beyoncé","jsTrimEnd":"Beyoncé","year":null}, +{"s":"Beyoncé","utf16Len":8,"asciiLower":"beyoncé","lower":"beyoncé","wordKey":"beyoncé","dedupKey":"beyonce","collapse":"Beyoncé","words":["Beyoncé"],"jsTrim":"Beyoncé","jsTrimEnd":"Beyoncé","year":null}, +{"s":"BEYONCÉ","utf16Len":7,"asciiLower":"beyoncÉ","lower":"beyoncé","wordKey":"beyoncÉ","dedupKey":"beyonce","collapse":"BEYONCÉ","words":["BEYONCÉ"],"jsTrim":"BEYONCÉ","jsTrimEnd":"BEYONCÉ","year":null}, +{"s":"Björk","utf16Len":6,"asciiLower":"björk","lower":"björk","wordKey":"björk","dedupKey":"bjork","collapse":"Björk","words":["Björk"],"jsTrim":"Björk","jsTrimEnd":"Björk","year":null}, +{"s":"Björk","utf16Len":5,"asciiLower":"björk","lower":"björk","wordKey":"björk","dedupKey":"bjork","collapse":"Björk","words":["Björk"],"jsTrim":"Björk","jsTrimEnd":"Björk","year":null}, +{"s":"Tiësto","utf16Len":6,"asciiLower":"tiësto","lower":"tiësto","wordKey":"tiësto","dedupKey":"tiesto","collapse":"Tiësto","words":["Tiësto"],"jsTrim":"Tiësto","jsTrimEnd":"Tiësto","year":null}, +{"s":"TIËSTO","utf16Len":6,"asciiLower":"tiËsto","lower":"tiësto","wordKey":"tiËsto","dedupKey":"tiesto","collapse":"TIËSTO","words":["TIËSTO"],"jsTrim":"TIËSTO","jsTrimEnd":"TIËSTO","year":null}, +{"s":"Sigur Rós","utf16Len":9,"asciiLower":"sigur rós","lower":"sigur rós","wordKey":"sigur rós","dedupKey":"sigur ros","collapse":"Sigur Rós","words":["Sigur","Rós"],"jsTrim":"Sigur Rós","jsTrimEnd":"Sigur Rós","year":null}, +{"s":"Mötley Crüe","utf16Len":11,"asciiLower":"mötley crüe","lower":"mötley crüe","wordKey":"mötley crüe","dedupKey":"motley crue","collapse":"Mötley Crüe","words":["Mötley","Crüe"],"jsTrim":"Mötley Crüe","jsTrimEnd":"Mötley Crüe","year":null}, +{"s":"Кино","utf16Len":4,"asciiLower":"Кино","lower":"кино","wordKey":"Кино","dedupKey":"кино","collapse":"Кино","words":["Кино"],"jsTrim":"Кино","jsTrimEnd":"Кино","year":null}, +{"s":"КИНО","utf16Len":4,"asciiLower":"КИНО","lower":"кино","wordKey":"КИНО","dedupKey":"кино","collapse":"КИНО","words":["КИНО"],"jsTrim":"КИНО","jsTrimEnd":"КИНО","year":null}, +{"s":"Ёлка","utf16Len":4,"asciiLower":"Ёлка","lower":"ёлка","wordKey":"Ёлка","dedupKey":"елка","collapse":"Ёлка","words":["Ёлка"],"jsTrim":"Ёлка","jsTrimEnd":"Ёлка","year":null}, +{"s":"ёлка","utf16Len":4,"asciiLower":"ёлка","lower":"ёлка","wordKey":"ёлка","dedupKey":"елка","collapse":"ёлка","words":["ёлка"],"jsTrim":"ёлка","jsTrimEnd":"ёлка","year":null}, +{"s":"Й","utf16Len":1,"asciiLower":"Й","lower":"й","wordKey":"Й","dedupKey":"и","collapse":"Й","words":["Й"],"jsTrim":"Й","jsTrimEnd":"Й","year":null}, +{"s":"й","utf16Len":2,"asciiLower":"й","lower":"й","wordKey":"й","dedupKey":"и","collapse":"й","words":["й"],"jsTrim":"й","jsTrimEnd":"й","year":null}, +{"s":"한국어","utf16Len":3,"asciiLower":"한국어","lower":"한국어","wordKey":"한국어","dedupKey":"한국어","collapse":"한국어","words":["한국어"],"jsTrim":"한국어","jsTrimEnd":"한국어","year":null}, +{"s":"각","utf16Len":1,"asciiLower":"각","lower":"각","wordKey":"각","dedupKey":"각","collapse":"각","words":["각"],"jsTrim":"각","jsTrimEnd":"각","year":null}, +{"s":"각","utf16Len":3,"asciiLower":"각","lower":"각","wordKey":"각","dedupKey":"각","collapse":"각","words":["각"],"jsTrim":"각","jsTrimEnd":"각","year":null}, +{"s":"が","utf16Len":1,"asciiLower":"が","lower":"が","wordKey":"が","dedupKey":"が","collapse":"が","words":["が"],"jsTrim":"が","jsTrimEnd":"が","year":null}, +{"s":"が","utf16Len":2,"asciiLower":"が","lower":"が","wordKey":"が","dedupKey":"が","collapse":"が","words":["が"],"jsTrim":"が","jsTrimEnd":"が","year":null}, +{"s":"full","utf16Len":4,"asciiLower":"full","lower":"full","wordKey":"full","dedupKey":"full","collapse":"full","words":["full"],"jsTrim":"full","jsTrimEnd":"full","year":null}, +{"s":"A","utf16Len":1,"asciiLower":"A","lower":"a","wordKey":"A","dedupKey":"a","collapse":"A","words":["A"],"jsTrim":"A","jsTrimEnd":"A","year":null}, +{"s":"final","utf16Len":4,"asciiLower":"final","lower":"final","wordKey":"final","dedupKey":"final","collapse":"final","words":["final"],"jsTrim":"final","jsTrimEnd":"final","year":null}, +{"s":"ʼn","utf16Len":1,"asciiLower":"ʼn","lower":"ʼn","wordKey":"ʼn","dedupKey":"ʼn","collapse":"ʼn","words":["ʼn"],"jsTrim":"ʼn","jsTrimEnd":"ʼn","year":null}, +{"s":"ǰ","utf16Len":1,"asciiLower":"ǰ","lower":"ǰ","wordKey":"ǰ","dedupKey":"j","collapse":"ǰ","words":["ǰ"],"jsTrim":"ǰ","jsTrimEnd":"ǰ","year":null}, +{"s":"ΐ","utf16Len":1,"asciiLower":"ΐ","lower":"ΐ","wordKey":"ΐ","dedupKey":"ι","collapse":"ΐ","words":["ΐ"],"jsTrim":"ΐ","jsTrimEnd":"ΐ","year":null}, +{"s":"ᾳ","utf16Len":1,"asciiLower":"ᾳ","lower":"ᾳ","wordKey":"ᾳ","dedupKey":"α","collapse":"ᾳ","words":["ᾳ"],"jsTrim":"ᾳ","jsTrimEnd":"ᾳ","year":null}, +{"s":"ᾼ","utf16Len":1,"asciiLower":"ᾼ","lower":"ᾳ","wordKey":"ᾼ","dedupKey":"α","collapse":"ᾼ","words":["ᾼ"],"jsTrim":"ᾼ","jsTrimEnd":"ᾼ","year":null}, +{"s":"Å","utf16Len":1,"asciiLower":"Å","lower":"å","wordKey":"Å","dedupKey":"a","collapse":"Å","words":["Å"],"jsTrim":"Å","jsTrimEnd":"Å","year":null}, +{"s":"Ω","utf16Len":1,"asciiLower":"Ω","lower":"ω","wordKey":"Ω","dedupKey":"ω","collapse":"Ω","words":["Ω"],"jsTrim":"Ω","jsTrimEnd":"Ω","year":null}, +{"s":"Ⅷ","utf16Len":1,"asciiLower":"Ⅷ","lower":"ⅷ","wordKey":"Ⅷ","dedupKey":"ⅷ","collapse":"Ⅷ","words":["Ⅷ"],"jsTrim":"Ⅷ","jsTrimEnd":"Ⅷ","year":null}, +{"s":"ⅷ","utf16Len":1,"asciiLower":"ⅷ","lower":"ⅷ","wordKey":"ⅷ","dedupKey":"ⅷ","collapse":"ⅷ","words":["ⅷ"],"jsTrim":"ⅷ","jsTrimEnd":"ⅷ","year":null}, +{"s":"Ⓐ","utf16Len":1,"asciiLower":"Ⓐ","lower":"ⓐ","wordKey":"Ⓐ","dedupKey":"ⓐ","collapse":"Ⓐ","words":["Ⓐ"],"jsTrim":"Ⓐ","jsTrimEnd":"Ⓐ","year":null}, +{"s":"ⓐ","utf16Len":1,"asciiLower":"ⓐ","lower":"ⓐ","wordKey":"ⓐ","dedupKey":"ⓐ","collapse":"ⓐ","words":["ⓐ"],"jsTrim":"ⓐ","jsTrimEnd":"ⓐ","year":null}, +{"s":"𝐀𝐁","utf16Len":4,"asciiLower":"𝐀𝐁","lower":"𝐀𝐁","wordKey":"𝐀𝐁","dedupKey":"𝐀𝐁","collapse":"𝐀𝐁","words":["𝐀𝐁"],"jsTrim":"𝐀𝐁","jsTrimEnd":"𝐀𝐁","year":null}, +{"s":"𐐀𐐨","utf16Len":4,"asciiLower":"𐐀𐐨","lower":"𐐨𐐨","wordKey":"𐐀𐐨","dedupKey":"𐐨𐐨","collapse":"𐐀𐐨","words":["𐐀𐐨"],"jsTrim":"𐐀𐐨","jsTrimEnd":"𐐀𐐨","year":null}, +{"s":"🎵","utf16Len":2,"asciiLower":"🎵","lower":"🎵","wordKey":"🎵","dedupKey":"🎵","collapse":"🎵","words":["🎵"],"jsTrim":"🎵","jsTrimEnd":"🎵","year":null}, +{"s":"👨‍👩‍👧","utf16Len":8,"asciiLower":"👨‍👩‍👧","lower":"👨‍👩‍👧","wordKey":"👨‍👩‍👧","dedupKey":"👨‍👩‍👧","collapse":"👨‍👩‍👧","words":["👨‍👩‍👧"],"jsTrim":"👨‍👩‍👧","jsTrimEnd":"👨‍👩‍👧","year":null}, +{"s":"🇫🇮","utf16Len":4,"asciiLower":"🇫🇮","lower":"🇫🇮","wordKey":"🇫🇮","dedupKey":"🇫🇮","collapse":"🇫🇮","words":["🇫🇮"],"jsTrim":"🇫🇮","jsTrimEnd":"🇫🇮","year":null}, +{"s":"à́b","utf16Len":4,"asciiLower":"à́b","lower":"à́b","wordKey":"à́b","dedupKey":"ab","collapse":"à́b","words":["à́b"],"jsTrim":"à́b","jsTrimEnd":"à́b","year":null}, +{"s":"ậ","utf16Len":3,"asciiLower":"ậ","lower":"ậ","wordKey":"ậ","dedupKey":"a","collapse":"ậ","words":["ậ"],"jsTrim":"ậ","jsTrimEnd":"ậ","year":null}, +{"s":"ậ","utf16Len":3,"asciiLower":"ậ","lower":"ậ","wordKey":"ậ","dedupKey":"a","collapse":"ậ","words":["ậ"],"jsTrim":"ậ","jsTrimEnd":"ậ","year":null}, +{"s":"a̴","utf16Len":2,"asciiLower":"a̴","lower":"a̴","wordKey":"a̴","dedupKey":"a","collapse":"a̴","words":["a̴"],"jsTrim":"a̴","jsTrimEnd":"a̴","year":null}, +{"s":"a҃","utf16Len":2,"asciiLower":"a҃","lower":"a҃","wordKey":"a҃","dedupKey":"a҃","collapse":"a҃","words":["a҃"],"jsTrim":"a҃","jsTrimEnd":"a҃","year":null}, +{"s":"a᪰","utf16Len":2,"asciiLower":"a᪰","lower":"a᪰","wordKey":"a᪰","dedupKey":"a᪰","collapse":"a᪰","words":["a᪰"],"jsTrim":"a᪰","jsTrimEnd":"a᪰","year":null}, +{"s":"a⃝","utf16Len":2,"asciiLower":"a⃝","lower":"a⃝","wordKey":"a⃝","dedupKey":"a⃝","collapse":"a⃝","words":["a⃝"],"jsTrim":"a⃝","jsTrimEnd":"a⃝","year":null}, +{"s":"aͅ","utf16Len":2,"asciiLower":"aͅ","lower":"aͅ","wordKey":"aͅ","dedupKey":"a","collapse":"aͅ","words":["aͅ"],"jsTrim":"aͅ","jsTrimEnd":"aͅ","year":null}, +{"s":"é́","utf16Len":3,"asciiLower":"é́","lower":"é́","wordKey":"é́","dedupKey":"e","collapse":"é́","words":["é́"],"jsTrim":"é́","jsTrimEnd":"é́","year":null}, +{"s":"ạ̈","utf16Len":2,"asciiLower":"ạ̈","lower":"ạ̈","wordKey":"ạ̈","dedupKey":"a","collapse":"ạ̈","words":["ạ̈"],"jsTrim":"ạ̈","jsTrimEnd":"ạ̈","year":null}, +{"s":"パ","utf16Len":2,"asciiLower":"パ","lower":"パ","wordKey":"パ","dedupKey":"パ","collapse":"パ","words":["パ"],"jsTrim":"パ","jsTrimEnd":"パ","year":null}, +{"s":" x ","utf16Len":3,"asciiLower":" x ","lower":" x ","wordKey":" x ","dedupKey":"x","collapse":"x","words":["x"],"jsTrim":"x","jsTrimEnd":" x","year":null}, +{"s":"…x…","utf16Len":3,"asciiLower":"…x…","lower":"…x…","wordKey":"…x…","dedupKey":"x","collapse":"x","words":["x"],"jsTrim":"…x…","jsTrimEnd":"…x…","year":null}, +{"s":"x","utf16Len":3,"asciiLower":"x","lower":"x","wordKey":"x","dedupKey":"x","collapse":"x","words":["x"],"jsTrim":"x","jsTrimEnd":"x","year":null}, +{"s":"᠎x᠎","utf16Len":3,"asciiLower":"᠎x᠎","lower":"᠎x᠎","wordKey":"᠎x᠎","dedupKey":"᠎x᠎","collapse":"᠎x᠎","words":["᠎x᠎"],"jsTrim":"᠎x᠎","jsTrimEnd":"᠎x᠎","year":null}, +{"s":"​x​","utf16Len":3,"asciiLower":"​x​","lower":"​x​","wordKey":"​x​","dedupKey":"​x​","collapse":"​x​","words":["​x​"],"jsTrim":"​x​","jsTrimEnd":"​x​","year":null}, +{"s":"
x
","utf16Len":3,"asciiLower":"
x
","lower":"
x
","wordKey":"
x
","dedupKey":"x","collapse":"x","words":["x"],"jsTrim":"x","jsTrimEnd":"
x","year":null}, +{"s":" x ","utf16Len":3,"asciiLower":" x ","lower":" x ","wordKey":" x ","dedupKey":"x","collapse":"x","words":["x"],"jsTrim":"x","jsTrimEnd":" x","year":null}, +{"s":"\tx\n","utf16Len":3,"asciiLower":"\tx\n","lower":"\tx\n","wordKey":"\tx\n","dedupKey":"x","collapse":"x","words":["x"],"jsTrim":"x","jsTrimEnd":"\tx","year":null}, +{"s":"\u000bx\f","utf16Len":3,"asciiLower":"\u000bx\f","lower":"\u000bx\f","wordKey":"\u000bx\f","dedupKey":"x","collapse":"x","words":["x"],"jsTrim":"x","jsTrimEnd":"\u000bx","year":null}, +{"s":" x ","utf16Len":3,"asciiLower":" x ","lower":" x ","wordKey":" x ","dedupKey":"x","collapse":"x","words":["x"],"jsTrim":"x","jsTrimEnd":" x","year":null}, +{"s":" x ","utf16Len":3,"asciiLower":" x ","lower":" x ","wordKey":" x ","dedupKey":"x","collapse":"x","words":["x"],"jsTrim":"x","jsTrimEnd":" x","year":null}, +{"s":" x","utf16Len":2,"asciiLower":" x","lower":" x","wordKey":" x","dedupKey":"x","collapse":"x","words":["x"],"jsTrim":"x","jsTrimEnd":" x","year":null}, +{"s":"a   b c","utf16Len":7,"asciiLower":"a   b c","lower":"a   b c","wordKey":"a   b c","dedupKey":"a b c","collapse":"a b c","words":["a","b","c"],"jsTrim":"a   b c","jsTrimEnd":"a   b c","year":null}, +{"s":"a…b","utf16Len":3,"asciiLower":"a…b","lower":"a…b","wordKey":"a…b","dedupKey":"a b","collapse":"a b","words":["a","b"],"jsTrim":"a…b","jsTrimEnd":"a…b","year":null}, +{"s":"ab","utf16Len":3,"asciiLower":"ab","lower":"ab","wordKey":"ab","dedupKey":"ab","collapse":"ab","words":["ab"],"jsTrim":"ab","jsTrimEnd":"ab","year":null}, +{"s":"a​b","utf16Len":3,"asciiLower":"a​b","lower":"a​b","wordKey":"a​b","dedupKey":"a​b","collapse":"a​b","words":["a​b"],"jsTrim":"a​b","jsTrimEnd":"a​b","year":null}, +{"s":"2015","utf16Len":4,"asciiLower":"2015","lower":"2015","wordKey":"2015","dedupKey":"2015","collapse":"2015","words":["2015"],"jsTrim":"2015","jsTrimEnd":"2015","year":2015}, +{"s":"2015,","utf16Len":5,"asciiLower":"2015,","lower":"2015,","wordKey":"2015","dedupKey":"2015,","collapse":"2015,","words":["2015,"],"jsTrim":"2015,","jsTrimEnd":"2015,","year":2015}, +{"s":"2015.","utf16Len":5,"asciiLower":"2015.","lower":"2015.","wordKey":"2015","dedupKey":"2015.","collapse":"2015.","words":["2015."],"jsTrim":"2015.","jsTrimEnd":"2015.","year":2015}, +{"s":"2015..","utf16Len":6,"asciiLower":"2015..","lower":"2015..","wordKey":"2015.","dedupKey":"2015..","collapse":"2015..","words":["2015.."],"jsTrim":"2015..","jsTrimEnd":"2015..","year":null}, +{"s":"1899","utf16Len":4,"asciiLower":"1899","lower":"1899","wordKey":"1899","dedupKey":"1899","collapse":"1899","words":["1899"],"jsTrim":"1899","jsTrimEnd":"1899","year":null}, +{"s":"1900","utf16Len":4,"asciiLower":"1900","lower":"1900","wordKey":"1900","dedupKey":"1900","collapse":"1900","words":["1900"],"jsTrim":"1900","jsTrimEnd":"1900","year":1900}, +{"s":"2099","utf16Len":4,"asciiLower":"2099","lower":"2099","wordKey":"2099","dedupKey":"2099","collapse":"2099","words":["2099"],"jsTrim":"2099","jsTrimEnd":"2099","year":2099}, +{"s":"2100","utf16Len":4,"asciiLower":"2100","lower":"2100","wordKey":"2100","dedupKey":"2100","collapse":"2100","words":["2100"],"jsTrim":"2100","jsTrimEnd":"2100","year":null}, +{"s":"02015","utf16Len":5,"asciiLower":"02015","lower":"02015","wordKey":"02015","dedupKey":"02015","collapse":"02015","words":["02015"],"jsTrim":"02015","jsTrimEnd":"02015","year":null}, +{"s":"201","utf16Len":3,"asciiLower":"201","lower":"201","wordKey":"201","dedupKey":"201","collapse":"201","words":["201"],"jsTrim":"201","jsTrimEnd":"201","year":null}, +{"s":"2015","utf16Len":4,"asciiLower":"2015","lower":"2015","wordKey":"2015","dedupKey":"2015","collapse":"2015","words":["2015"],"jsTrim":"2015","jsTrimEnd":"2015","year":null}, +{"s":"2015","utf16Len":4,"asciiLower":"2015","lower":"2015","wordKey":"2015","dedupKey":"2015","collapse":"2015","words":["2015"],"jsTrim":"2015","jsTrimEnd":"2015","year":null}, +{"s":"2015a","utf16Len":5,"asciiLower":"2015a","lower":"2015a","wordKey":"2015a","dedupKey":"2015a","collapse":"2015a","words":["2015a"],"jsTrim":"2015a","jsTrimEnd":"2015a","year":null}, +{"s":"١٩٩٩","utf16Len":4,"asciiLower":"١٩٩٩","lower":"١٩٩٩","wordKey":"١٩٩٩","dedupKey":"١٩٩٩","collapse":"١٩٩٩","words":["١٩٩٩"],"jsTrim":"١٩٩٩","jsTrimEnd":"١٩٩٩","year":null}, +{"s":"feat.","utf16Len":5,"asciiLower":"feat.","lower":"feat.","wordKey":"feat","dedupKey":"feat.","collapse":"feat.","words":["feat."],"jsTrim":"feat.","jsTrimEnd":"feat.","year":null}, +{"s":"w/","utf16Len":2,"asciiLower":"w/","lower":"w/","wordKey":"w/","dedupKey":"w/","collapse":"w/","words":["w/"],"jsTrim":"w/","jsTrimEnd":"w/","year":null}, +{"s":"b2b","utf16Len":3,"asciiLower":"b2b","lower":"b2b","wordKey":"b2b","dedupKey":"b2b","collapse":"b2b","words":["b2b"],"jsTrim":"b2b","jsTrimEnd":"b2b","year":null}, +{"s":"P!nk","utf16Len":4,"asciiLower":"p!nk","lower":"p!nk","wordKey":"p!nk","dedupKey":"p!nk","collapse":"P!nk","words":["P!nk"],"jsTrim":"P!nk","jsTrimEnd":"P!nk","year":null}, +{"s":"A$AP","utf16Len":4,"asciiLower":"a$ap","lower":"a$ap","wordKey":"a$ap","dedupKey":"a$ap","collapse":"A$AP","words":["A$AP"],"jsTrim":"A$AP","jsTrimEnd":"A$AP","year":null}, +{"s":"AC/DC","utf16Len":5,"asciiLower":"ac/dc","lower":"ac/dc","wordKey":"ac/dc","dedupKey":"ac/dc","collapse":"AC/DC","words":["AC/DC"],"jsTrim":"AC/DC","jsTrimEnd":"AC/DC","year":null}, +{"s":"x","utf16Len":1,"asciiLower":"x","lower":"x","wordKey":"x","dedupKey":"x","collapse":"x","words":["x"],"jsTrim":"x","jsTrimEnd":"x","year":null}, +{"s":"X","utf16Len":1,"asciiLower":"x","lower":"x","wordKey":"x","dedupKey":"x","collapse":"X","words":["X"],"jsTrim":"X","jsTrimEnd":"X","year":null}, +{"s":"&","utf16Len":1,"asciiLower":"&","lower":"&","wordKey":"&","dedupKey":"&","collapse":"&","words":["&"],"jsTrim":"&","jsTrimEnd":"&","year":null}, +{"s":"?","utf16Len":1,"asciiLower":"?","lower":"?","wordKey":"","dedupKey":"?","collapse":"?","words":["?"],"jsTrim":"?","jsTrimEnd":"?","year":null}, +{"s":"??","utf16Len":2,"asciiLower":"??","lower":"??","wordKey":"?","dedupKey":"??","collapse":"??","words":["??"],"jsTrim":"??","jsTrimEnd":"??","year":null}, +{"s":"ID?","utf16Len":3,"asciiLower":"id?","lower":"id?","wordKey":"id","dedupKey":"id?","collapse":"ID?","words":["ID?"],"jsTrim":"ID?","jsTrimEnd":"ID?","year":null}, +{"s":"Ä:","utf16Len":2,"asciiLower":"Ä:","lower":"ä:","wordKey":"Ä","dedupKey":"a:","collapse":"Ä:","words":["Ä:"],"jsTrim":"Ä:","jsTrimEnd":"Ä:","year":null}, +{"s":"Z;","utf16Len":2,"asciiLower":"z;","lower":"z;","wordKey":"z","dedupKey":"z;","collapse":"Z;","words":["Z;"],"jsTrim":"Z;","jsTrimEnd":"Z;","year":null}, +{"s":"[Z]","utf16Len":3,"asciiLower":"[z]","lower":"[z]","wordKey":"[z]","dedupKey":"[z]","collapse":"[Z]","words":["[Z]"],"jsTrim":"[Z]","jsTrimEnd":"[Z]","year":null}, +{"s":"Ź.","utf16Len":3,"asciiLower":"ź.","lower":"ź.","wordKey":"ź","dedupKey":"z.","collapse":"Ź.","words":["Ź."],"jsTrim":"Ź.","jsTrimEnd":"Ź.","year":null}, +{"s":"ẞ","utf16Len":1,"asciiLower":"ẞ","lower":"ß","wordKey":"ẞ","dedupKey":"ß","collapse":"ẞ","words":["ẞ"],"jsTrim":"ẞ","jsTrimEnd":"ẞ","year":null}, +{"s":"ß","utf16Len":1,"asciiLower":"ß","lower":"ß","wordKey":"ß","dedupKey":"ß","collapse":"ß","words":["ß"],"jsTrim":"ß","jsTrimEnd":"ß","year":null}, +{"s":"ſ","utf16Len":1,"asciiLower":"ſ","lower":"ſ","wordKey":"ſ","dedupKey":"ſ","collapse":"ſ","words":["ſ"],"jsTrim":"ſ","jsTrimEnd":"ſ","year":null}, +{"s":"K","utf16Len":1,"asciiLower":"k","lower":"k","wordKey":"k","dedupKey":"k","collapse":"K","words":["K"],"jsTrim":"K","jsTrimEnd":"K","year":null}, +{"s":"DŽungla","utf16Len":6,"asciiLower":"DŽungla","lower":"džungla","wordKey":"DŽungla","dedupKey":"džungla","collapse":"DŽungla","words":["DŽungla"],"jsTrim":"DŽungla","jsTrimEnd":"DŽungla","year":null}, +{"s":"ΌΣΟΣ","utf16Len":4,"asciiLower":"ΌΣΟΣ","lower":"όσος","wordKey":"ΌΣΟΣ","dedupKey":"οσος","collapse":"ΌΣΟΣ","words":["ΌΣΟΣ"],"jsTrim":"ΌΣΟΣ","jsTrimEnd":"ΌΣΟΣ","year":null}, +{"s":"ὈΔΥΣΣΕΎΣ","utf16Len":8,"asciiLower":"ὈΔΥΣΣΕΎΣ","lower":"ὀδυσσεύς","wordKey":"ὈΔΥΣΣΕΎΣ","dedupKey":"οδυσσευς","collapse":"ὈΔΥΣΣΕΎΣ","words":["ὈΔΥΣΣΕΎΣ"],"jsTrim":"ὈΔΥΣΣΕΎΣ","jsTrimEnd":"ὈΔΥΣΣΕΎΣ","year":null}, +{"s":"Ꭰ","utf16Len":1,"asciiLower":"Ꭰ","lower":"ꭰ","wordKey":"Ꭰ","dedupKey":"ꭰ","collapse":"Ꭰ","words":["Ꭰ"],"jsTrim":"Ꭰ","jsTrimEnd":"Ꭰ","year":null}, +{"s":"ꭰ","utf16Len":1,"asciiLower":"ꭰ","lower":"ꭰ","wordKey":"ꭰ","dedupKey":"ꭰ","collapse":"ꭰ","words":["ꭰ"],"jsTrim":"ꭰ","jsTrimEnd":"ꭰ","year":null}, +{"s":"Ა","utf16Len":1,"asciiLower":"Ა","lower":"ა","wordKey":"Ა","dedupKey":"ა","collapse":"Ა","words":["Ა"],"jsTrim":"Ა","jsTrimEnd":"Ა","year":null}, +{"s":"ა","utf16Len":1,"asciiLower":"ა","lower":"ა","wordKey":"ა","dedupKey":"ა","collapse":"ა","words":["ა"],"jsTrim":"ა","jsTrimEnd":"ა","year":null}, +{"s":"Ⴀ","utf16Len":1,"asciiLower":"Ⴀ","lower":"ⴀ","wordKey":"Ⴀ","dedupKey":"ⴀ","collapse":"Ⴀ","words":["Ⴀ"],"jsTrim":"Ⴀ","jsTrimEnd":"Ⴀ","year":null}, +{"s":"Ɥ","utf16Len":1,"asciiLower":"Ɥ","lower":"ɥ","wordKey":"Ɥ","dedupKey":"ɥ","collapse":"Ɥ","words":["Ɥ"],"jsTrim":"Ɥ","jsTrimEnd":"Ɥ","year":null}, +{"s":"Ꟶ","utf16Len":1,"asciiLower":"Ꟶ","lower":"ꟶ","wordKey":"Ꟶ","dedupKey":"ꟶ","collapse":"Ꟶ","words":["Ꟶ"],"jsTrim":"Ꟶ","jsTrimEnd":"Ꟶ","year":null}, +{"s":"𞤀","utf16Len":2,"asciiLower":"𞤀","lower":"𞤢","wordKey":"𞤀","dedupKey":"𞤢","collapse":"𞤀","words":["𞤀"],"jsTrim":"𞤀","jsTrimEnd":"𞤀","year":null}, +{"s":"𑢠","utf16Len":2,"asciiLower":"𑢠","lower":"𑣀","wordKey":"𑢠","dedupKey":"𑣀","collapse":"𑢠","words":["𑢠"],"jsTrim":"𑢠","jsTrimEnd":"𑢠","year":null}, +{"s":"Ꙁ","utf16Len":1,"asciiLower":"Ꙁ","lower":"ꙁ","wordKey":"Ꙁ","dedupKey":"ꙁ","collapse":"Ꙁ","words":["Ꙁ"],"jsTrim":"Ꙁ","jsTrimEnd":"Ꙁ","year":null}, +{"s":"Ⱥ","utf16Len":1,"asciiLower":"Ⱥ","lower":"ⱥ","wordKey":"Ⱥ","dedupKey":"ⱥ","collapse":"Ⱥ","words":["Ⱥ"],"jsTrim":"Ⱥ","jsTrimEnd":"Ⱥ","year":null}, +{"s":"İΣ","utf16Len":2,"asciiLower":"İΣ","lower":"i̇ς","wordKey":"İΣ","dedupKey":"iς","collapse":"İΣ","words":["İΣ"],"jsTrim":"İΣ","jsTrimEnd":"İΣ","year":null}, +{"s":"Σİ","utf16Len":2,"asciiLower":"Σİ","lower":"σi̇","wordKey":"Σİ","dedupKey":"σi","collapse":"Σİ","words":["Σİ"],"jsTrim":"Σİ","jsTrimEnd":"Σİ","year":null}, +{"s":"İΣİ","utf16Len":3,"asciiLower":"İΣİ","lower":"i̇σi̇","wordKey":"İΣİ","dedupKey":"iσi","collapse":"İΣİ","words":["İΣİ"],"jsTrim":"İΣİ","jsTrimEnd":"İΣİ","year":null}, +{"s":"İİ","utf16Len":2,"asciiLower":"İİ","lower":"i̇i̇","wordKey":"İİ","dedupKey":"ii","collapse":"İİ","words":["İİ"],"jsTrim":"İİ","jsTrimEnd":"İİ","year":null}, +{"s":"i̇Σ","utf16Len":3,"asciiLower":"i̇Σ","lower":"i̇ς","wordKey":"i̇Σ","dedupKey":"iς","collapse":"i̇Σ","words":["i̇Σ"],"jsTrim":"i̇Σ","jsTrimEnd":"i̇Σ","year":null}, +{"s":"ẞΣ","utf16Len":2,"asciiLower":"ẞΣ","lower":"ßς","wordKey":"ẞΣ","dedupKey":"ßς","collapse":"ẞΣ","words":["ẞΣ"],"jsTrim":"ẞΣ","jsTrimEnd":"ẞΣ","year":null}, +{"s":"ΣẞΣ","utf16Len":3,"asciiLower":"ΣẞΣ","lower":"σßς","wordKey":"ΣẞΣ","dedupKey":"σßς","collapse":"ΣẞΣ","words":["ΣẞΣ"],"jsTrim":"ΣẞΣ","jsTrimEnd":"ΣẞΣ","year":null}, +{"s":"STRAẞΣ ẞΣ","utf16Len":9,"asciiLower":"straẞΣ ẞΣ","lower":"straßς ßς","wordKey":"straẞΣ ẞΣ","dedupKey":"straßς ßς","collapse":"STRAẞΣ ẞΣ","words":["STRAẞΣ","ẞΣ"],"jsTrim":"STRAẞΣ ẞΣ","jsTrimEnd":"STRAẞΣ ẞΣ","year":null}, +{"s":"ᎠΣ","utf16Len":2,"asciiLower":"ᎠΣ","lower":"ꭰς","wordKey":"ᎠΣ","dedupKey":"ꭰς","collapse":"ᎠΣ","words":["ᎠΣ"],"jsTrim":"ᎠΣ","jsTrimEnd":"ᎠΣ","year":null}, +{"s":"ᎠᎡᎢ","utf16Len":3,"asciiLower":"ᎠᎡᎢ","lower":"ꭰꭱꭲ","wordKey":"ᎠᎡᎢ","dedupKey":"ꭰꭱꭲ","collapse":"ᎠᎡᎢ","words":["ᎠᎡᎢ"],"jsTrim":"ᎠᎡᎢ","jsTrimEnd":"ᎠᎡᎢ","year":null}, +{"s":"ΣᏴ","utf16Len":2,"asciiLower":"ΣᏴ","lower":"σᏼ","wordKey":"ΣᏴ","dedupKey":"σᏼ","collapse":"ΣᏴ","words":["ΣᏴ"],"jsTrim":"ΣᏴ","jsTrimEnd":"ΣᏴ","year":null}, +{"s":"ꭰΣ","utf16Len":2,"asciiLower":"ꭰΣ","lower":"ꭰς","wordKey":"ꭰΣ","dedupKey":"ꭰς","collapse":"ꭰΣ","words":["ꭰΣ"],"jsTrim":"ꭰΣ","jsTrimEnd":"ꭰΣ","year":null}, +{"s":"ᏸΣ","utf16Len":2,"asciiLower":"ᏸΣ","lower":"ᏸς","wordKey":"ᏸΣ","dedupKey":"ᏸς","collapse":"ᏸΣ","words":["ᏸΣ"],"jsTrim":"ᏸΣ","jsTrimEnd":"ᏸΣ","year":null}, +{"s":"ᲐᲑΣ","utf16Len":3,"asciiLower":"ᲐᲑΣ","lower":"აბς","wordKey":"ᲐᲑΣ","dedupKey":"აბς","collapse":"ᲐᲑΣ","words":["ᲐᲑΣ"],"jsTrim":"ᲐᲑΣ","jsTrimEnd":"ᲐᲑΣ","year":null}, +{"s":"ΣᲐ","utf16Len":2,"asciiLower":"ΣᲐ","lower":"σა","wordKey":"ΣᲐ","dedupKey":"σა","collapse":"ΣᲐ","words":["ΣᲐ"],"jsTrim":"ΣᲐ","jsTrimEnd":"ΣᲐ","year":null}, +{"s":"ႠΣ","utf16Len":2,"asciiLower":"ႠΣ","lower":"ⴀς","wordKey":"ႠΣ","dedupKey":"ⴀς","collapse":"ႠΣ","words":["ႠΣ"],"jsTrim":"ႠΣ","jsTrimEnd":"ႠΣ","year":null}, +{"s":"აΣ","utf16Len":2,"asciiLower":"აΣ","lower":"აς","wordKey":"აΣ","dedupKey":"აς","collapse":"აΣ","words":["აΣ"],"jsTrim":"აΣ","jsTrimEnd":"აΣ","year":null}, +{"s":"𞤀Σ","utf16Len":3,"asciiLower":"𞤀Σ","lower":"𞤢ς","wordKey":"𞤀Σ","dedupKey":"𞤢ς","collapse":"𞤀Σ","words":["𞤀Σ"],"jsTrim":"𞤀Σ","jsTrimEnd":"𞤀Σ","year":null}, +{"s":"𞤀𞤁𞤂","utf16Len":6,"asciiLower":"𞤀𞤁𞤂","lower":"𞤢𞤣𞤤","wordKey":"𞤀𞤁𞤂","dedupKey":"𞤢𞤣𞤤","collapse":"𞤀𞤁𞤂","words":["𞤀𞤁𞤂"],"jsTrim":"𞤀𞤁𞤂","jsTrimEnd":"𞤀𞤁𞤂","year":null}, +{"s":"Σ𞤢","utf16Len":3,"asciiLower":"Σ𞤢","lower":"σ𞤢","wordKey":"Σ𞤢","dedupKey":"σ𞤢","collapse":"Σ𞤢","words":["Σ𞤢"],"jsTrim":"Σ𞤢","jsTrimEnd":"Σ𞤢","year":null}, +{"s":"𞤢Σ","utf16Len":3,"asciiLower":"𞤢Σ","lower":"𞤢ς","wordKey":"𞤢Σ","dedupKey":"𞤢ς","collapse":"𞤢Σ","words":["𞤢Σ"],"jsTrim":"𞤢Σ","jsTrimEnd":"𞤢Σ","year":null}, +{"s":"𞥃Σ𞤀","utf16Len":5,"asciiLower":"𞥃Σ𞤀","lower":"𞥃σ𞤢","wordKey":"𞥃Σ𞤀","dedupKey":"𞥃σ𞤢","collapse":"𞥃Σ𞤀","words":["𞥃Σ𞤀"],"jsTrim":"𞥃Σ𞤀","jsTrimEnd":"𞥃Σ𞤀","year":null}, +{"s":"ΑΣ𞤀","utf16Len":4,"asciiLower":"ΑΣ𞤀","lower":"ασ𞤢","wordKey":"ΑΣ𞤀","dedupKey":"ασ𞤢","collapse":"ΑΣ𞤀","words":["ΑΣ𞤀"],"jsTrim":"ΑΣ𞤀","jsTrimEnd":"ΑΣ𞤀","year":null}, +{"s":"ΑΣ ᲐΣ","utf16Len":5,"asciiLower":"ΑΣ ᲐΣ","lower":"ας აς","wordKey":"ΑΣ ᲐΣ","dedupKey":"ας აς","collapse":"ΑΣ ᲐΣ","words":["ΑΣ","ᲐΣ"],"jsTrim":"ΑΣ ᲐΣ","jsTrimEnd":"ΑΣ ᲐΣ","year":null}, +{"s":"DžΣ","utf16Len":2,"asciiLower":"DžΣ","lower":"džς","wordKey":"DžΣ","dedupKey":"džς","collapse":"DžΣ","words":["DžΣ"],"jsTrim":"DžΣ","jsTrimEnd":"DžΣ","year":null}, +{"s":"ʰΣ","utf16Len":2,"asciiLower":"ʰΣ","lower":"ʰσ","wordKey":"ʰΣ","dedupKey":"ʰσ","collapse":"ʰΣ","words":["ʰΣ"],"jsTrim":"ʰΣ","jsTrimEnd":"ʰΣ","year":null}, +{"s":"ΑʰΣ","utf16Len":3,"asciiLower":"ΑʰΣ","lower":"αʰς","wordKey":"ΑʰΣ","dedupKey":"αʰς","collapse":"ΑʰΣ","words":["ΑʰΣ"],"jsTrim":"ΑʰΣ","jsTrimEnd":"ΑʰΣ","year":null}, +{"s":"ΑΣʰ","utf16Len":3,"asciiLower":"ΑΣʰ","lower":"αςʰ","wordKey":"ΑΣʰ","dedupKey":"αςʰ","collapse":"ΑΣʰ","words":["ΑΣʰ"],"jsTrim":"ΑΣʰ","jsTrimEnd":"ΑΣʰ","year":null}, +{"s":"ΑΣʰΑ","utf16Len":4,"asciiLower":"ΑΣʰΑ","lower":"ασʰα","wordKey":"ΑΣʰΑ","dedupKey":"ασʰα","collapse":"ΑΣʰΑ","words":["ΑΣʰΑ"],"jsTrim":"ΑΣʰΑ","jsTrimEnd":"ΑΣʰΑ","year":null}, +{"s":"ᾼΣ","utf16Len":3,"asciiLower":"ᾼΣ","lower":"ᾳς","wordKey":"ᾼΣ","dedupKey":"ας","collapse":"ᾼΣ","words":["ᾼΣ"],"jsTrim":"ᾼΣ","jsTrimEnd":"ᾼΣ","year":null}, +{"s":"ΑΣͅ","utf16Len":3,"asciiLower":"ΑΣͅ","lower":"αςͅ","wordKey":"ΑΣͅ","dedupKey":"ας","collapse":"ΑΣͅ","words":["ΑΣͅ"],"jsTrim":"ΑΣͅ","jsTrimEnd":"ΑΣͅ","year":null}, +{"s":"ΑΣͅΑ","utf16Len":4,"asciiLower":"ΑΣͅΑ","lower":"ασͅα","wordKey":"ΑΣͅΑ","dedupKey":"ασα","collapse":"ΑΣͅΑ","words":["ΑΣͅΑ"],"jsTrim":"ΑΣͅΑ","jsTrimEnd":"ΑΣͅΑ","year":null}, +{"s":"ⒶΣ","utf16Len":2,"asciiLower":"ⒶΣ","lower":"ⓐς","wordKey":"ⒶΣ","dedupKey":"ⓐς","collapse":"ⒶΣ","words":["ⒶΣ"],"jsTrim":"ⒶΣ","jsTrimEnd":"ⒶΣ","year":null}, +{"s":"ⅧΣ","utf16Len":2,"asciiLower":"ⅧΣ","lower":"ⅷς","wordKey":"ⅧΣ","dedupKey":"ⅷς","collapse":"ⅧΣ","words":["ⅧΣ"],"jsTrim":"ⅧΣ","jsTrimEnd":"ⅧΣ","year":null}, +{"s":"ΑΣΣ","utf16Len":3,"asciiLower":"ΑΣΣ","lower":"ασς","wordKey":"ΑΣΣ","dedupKey":"ασς","collapse":"ΑΣΣ","words":["ΑΣΣ"],"jsTrim":"ΑΣΣ","jsTrimEnd":"ΑΣΣ","year":null}, +{"s":"ΣΣ","utf16Len":2,"asciiLower":"ΣΣ","lower":"σς","wordKey":"ΣΣ","dedupKey":"σς","collapse":"ΣΣ","words":["ΣΣ"],"jsTrim":"ΣΣ","jsTrimEnd":"ΣΣ","year":null}, +{"s":"ΣΣΣ","utf16Len":3,"asciiLower":"ΣΣΣ","lower":"σσς","wordKey":"ΣΣΣ","dedupKey":"σσς","collapse":"ΣΣΣ","words":["ΣΣΣ"],"jsTrim":"ΣΣΣ","jsTrimEnd":"ΣΣΣ","year":null}, +{"s":"ΑΣΣ.","utf16Len":4,"asciiLower":"ΑΣΣ.","lower":"ασς.","wordKey":"ΑΣΣ","dedupKey":"ασς.","collapse":"ΑΣΣ.","words":["ΑΣΣ."],"jsTrim":"ΑΣΣ.","jsTrimEnd":"ΑΣΣ.","year":null}, +{"s":"ΑΣ·Σ","utf16Len":4,"asciiLower":"ΑΣ·Σ","lower":"ασ·ς","wordKey":"ΑΣ·Σ","dedupKey":"ασ·ς","collapse":"ΑΣ·Σ","words":["ΑΣ·Σ"],"jsTrim":"ΑΣ·Σ","jsTrimEnd":"ΑΣ·Σ","year":null}, +{"s":"ΑΣ·","utf16Len":3,"asciiLower":"ΑΣ·","lower":"ας·","wordKey":"ΑΣ·","dedupKey":"ας·","collapse":"ΑΣ·","words":["ΑΣ·"],"jsTrim":"ΑΣ·","jsTrimEnd":"ΑΣ·","year":null}, +{"s":"ΑΣ:Α","utf16Len":4,"asciiLower":"ΑΣ:Α","lower":"ασ:α","wordKey":"ΑΣ:Α","dedupKey":"ασ:α","collapse":"ΑΣ:Α","words":["ΑΣ:Α"],"jsTrim":"ΑΣ:Α","jsTrimEnd":"ΑΣ:Α","year":null}, +{"s":"ΑΣ'Α","utf16Len":4,"asciiLower":"ΑΣ'Α","lower":"ασ'α","wordKey":"ΑΣ'Α","dedupKey":"ασ'α","collapse":"ΑΣ'Α","words":["ΑΣ'Α"],"jsTrim":"ΑΣ'Α","jsTrimEnd":"ΑΣ'Α","year":null}, +{"s":"ΑΣ1","utf16Len":3,"asciiLower":"ΑΣ1","lower":"ας1","wordKey":"ΑΣ1","dedupKey":"ας1","collapse":"ΑΣ1","words":["ΑΣ1"],"jsTrim":"ΑΣ1","jsTrimEnd":"ΑΣ1","year":null}, +{"s":"1Σ1","utf16Len":3,"asciiLower":"1Σ1","lower":"1σ1","wordKey":"1Σ1","dedupKey":"1σ1","collapse":"1Σ1","words":["1Σ1"],"jsTrim":"1Σ1","jsTrimEnd":"1Σ1","year":null}, +{"s":"ΑΣ​","utf16Len":3,"asciiLower":"ΑΣ​","lower":"ας​","wordKey":"ΑΣ​","dedupKey":"ας​","collapse":"ΑΣ​","words":["ΑΣ​"],"jsTrim":"ΑΣ​","jsTrimEnd":"ΑΣ​","year":null}, +{"s":"ΑΣ​Α","utf16Len":4,"asciiLower":"ΑΣ​Α","lower":"ασ​α","wordKey":"ΑΣ​Α","dedupKey":"ασ​α","collapse":"ΑΣ​Α","words":["ΑΣ​Α"],"jsTrim":"ΑΣ​Α","jsTrimEnd":"ΑΣ​Α","year":null}, +{"s":"Α­Σ­","utf16Len":4,"asciiLower":"Α­Σ­","lower":"α­ς­","wordKey":"Α­Σ­","dedupKey":"α­ς­","collapse":"Α­Σ­","words":["Α­Σ­"],"jsTrim":"Α­Σ­","jsTrimEnd":"Α­Σ­","year":null}, +{"s":"𝐀Σ","utf16Len":3,"asciiLower":"𝐀Σ","lower":"𝐀ς","wordKey":"𝐀Σ","dedupKey":"𝐀ς","collapse":"𝐀Σ","words":["𝐀Σ"],"jsTrim":"𝐀Σ","jsTrimEnd":"𝐀Σ","year":null}, +{"s":"Σ𝐀","utf16Len":3,"asciiLower":"Σ𝐀","lower":"σ𝐀","wordKey":"Σ𝐀","dedupKey":"σ𝐀","collapse":"Σ𝐀","words":["Σ𝐀"],"jsTrim":"Σ𝐀","jsTrimEnd":"Σ𝐀","year":null}, +{"s":"ΑΣ🎵","utf16Len":4,"asciiLower":"ΑΣ🎵","lower":"ας🎵","wordKey":"ΑΣ🎵","dedupKey":"ας🎵","collapse":"ΑΣ🎵","words":["ΑΣ🎵"],"jsTrim":"ΑΣ🎵","jsTrimEnd":"ΑΣ🎵","year":null}, +{"s":"🎵Σ","utf16Len":3,"asciiLower":"🎵Σ","lower":"🎵σ","wordKey":"🎵Σ","dedupKey":"🎵σ","collapse":"🎵Σ","words":["🎵Σ"],"jsTrim":"🎵Σ","jsTrimEnd":"🎵Σ","year":null}, +{"s":"aΣ a","utf16Len":4,"asciiLower":"aΣ a","lower":"aς a","wordKey":"aΣ a","dedupKey":"aς a","collapse":"aΣ a","words":["aΣ","a"],"jsTrim":"aΣ a","jsTrimEnd":"aΣ a","year":null}, +{"s":"AΣ","utf16Len":2,"asciiLower":"aΣ","lower":"aς","wordKey":"aΣ","dedupKey":"aς","collapse":"AΣ","words":["AΣ"],"jsTrim":"AΣ","jsTrimEnd":"AΣ","year":null}, +{"s":"ÅΣ","utf16Len":2,"asciiLower":"ÅΣ","lower":"åς","wordKey":"ÅΣ","dedupKey":"aς","collapse":"ÅΣ","words":["ÅΣ"],"jsTrim":"ÅΣ","jsTrimEnd":"ÅΣ","year":null}, +{"s":"ΌΣ ΌΣΟ","utf16Len":6,"asciiLower":"ΌΣ ΌΣΟ","lower":"ός όσο","wordKey":"ΌΣ ΌΣΟ","dedupKey":"ος οσο","collapse":"ΌΣ ΌΣΟ","words":["ΌΣ","ΌΣΟ"],"jsTrim":"ΌΣ ΌΣΟ","jsTrimEnd":"ΌΣ ΌΣΟ","year":null}, +{"s":"Ꟑ","utf16Len":1,"asciiLower":"Ꟑ","lower":"ꟑ","wordKey":"Ꟑ","dedupKey":"ꟑ","collapse":"Ꟑ","words":["Ꟑ"],"jsTrim":"Ꟑ","jsTrimEnd":"Ꟑ","year":null}, +{"s":"Ƛ","utf16Len":1,"asciiLower":"Ƛ","lower":"ƛ","wordKey":"Ƛ","dedupKey":"ƛ","collapse":"Ƛ","words":["Ƛ"],"jsTrim":"Ƛ","jsTrimEnd":"Ƛ","year":null}, +{"s":"Ꟛ","utf16Len":1,"asciiLower":"Ꟛ","lower":"ꟛ","wordKey":"Ꟛ","dedupKey":"ꟛ","collapse":"Ꟛ","words":["Ꟛ"],"jsTrim":"Ꟛ","jsTrimEnd":"Ꟛ","year":null}, +{"s":"Ꟗ","utf16Len":1,"asciiLower":"Ꟗ","lower":"ꟗ","wordKey":"Ꟗ","dedupKey":"ꟗ","collapse":"Ꟗ","words":["Ꟗ"],"jsTrim":"Ꟗ","jsTrimEnd":"Ꟗ","year":null}, +{"s":"Ꞔ","utf16Len":1,"asciiLower":"Ꞔ","lower":"ꞔ","wordKey":"Ꞔ","dedupKey":"ꞔ","collapse":"Ꞔ","words":["Ꞔ"],"jsTrim":"Ꞔ","jsTrimEnd":"Ꞔ","year":null}, +{"s":"Ᲊ","utf16Len":1,"asciiLower":"Ᲊ","lower":"ᲊ","wordKey":"Ᲊ","dedupKey":"ᲊ","collapse":"Ᲊ","words":["Ᲊ"],"jsTrim":"Ᲊ","jsTrimEnd":"Ᲊ","year":null}, +{"s":"𐵐","utf16Len":2,"asciiLower":"𐵐","lower":"𐵰","wordKey":"𐵐","dedupKey":"𐵰","collapse":"𐵐","words":["𐵐"],"jsTrim":"𐵐","jsTrimEnd":"𐵐","year":null}, +{"s":"𖺠","utf16Len":2,"asciiLower":"𖺠","lower":"𖺻","wordKey":"𖺠","dedupKey":"𖺻","collapse":"𖺠","words":["𖺠"],"jsTrim":"𖺠","jsTrimEnd":"𖺠","year":null}, +{"s":"'aͅ:","utf16Len":4,"asciiLower":"'aͅ:","lower":"'aͅ:","wordKey":"'aͅ","dedupKey":"'a:","collapse":"'aͅ:","words":["'aͅ:"],"jsTrim":"'aͅ:","jsTrimEnd":"'aͅ:","year":null}, +{"s":"𝐀𝐀ᾼ","utf16Len":6,"asciiLower":"𝐀𝐀ᾼ","lower":"𝐀𝐀ᾳ","wordKey":"𝐀𝐀ᾼ","dedupKey":"𝐀𝐀α","collapse":"𝐀𝐀ᾼ","words":["𝐀𝐀ᾼ"],"jsTrim":"𝐀𝐀ᾼ","jsTrimEnd":"𝐀𝐀ᾼ","year":null}, +{"s":"ᾳ","utf16Len":2,"asciiLower":"ᾳ","lower":"ᾳ","wordKey":"ᾳ","dedupKey":"α","collapse":"ᾳ","words":["ᾳ"],"jsTrim":"ᾳ","jsTrimEnd":"ᾳ","year":null}, +{"s":"Α","utf16Len":1,"asciiLower":"Α","lower":"α","wordKey":"Α","dedupKey":"α","collapse":"Α","words":["Α"],"jsTrim":"Α","jsTrimEnd":"Α","year":null}, +{"s":"𝐀‍-Σ1","utf16Len":6,"asciiLower":"𝐀‍-Σ1","lower":"𝐀‍-σ1","wordKey":"𝐀‍-Σ1","dedupKey":"𝐀‍-σ1","collapse":"𝐀‍-Σ1","words":["𝐀‍-Σ1"],"jsTrim":"𝐀‍-Σ1","jsTrimEnd":"𝐀‍-Σ1","year":null}, +{"s":" 𝐀Α","utf16Len":4,"asciiLower":" 𝐀Α","lower":" 𝐀α","wordKey":" 𝐀Α","dedupKey":"𝐀α","collapse":"𝐀Α","words":["𝐀Α"],"jsTrim":"𝐀Α","jsTrimEnd":" 𝐀Α","year":null}, +{"s":"αΣ:-‍","utf16Len":5,"asciiLower":"αΣ:-‍","lower":"ας:-‍","wordKey":"αΣ:-‍","dedupKey":"ας:-‍","collapse":"αΣ:-‍","words":["αΣ:-‍"],"jsTrim":"αΣ:-‍","jsTrimEnd":"αΣ:-‍","year":null}, +{"s":"‍-Σ.α","utf16Len":5,"asciiLower":"‍-Σ.α","lower":"‍-σ.α","wordKey":"‍-Σ.α","dedupKey":"‍-σ.α","collapse":"‍-Σ.α","words":["‍-Σ.α"],"jsTrim":"‍-Σ.α","jsTrimEnd":"‍-Σ.α","year":null}, +{"s":".'-'","utf16Len":4,"asciiLower":".'-'","lower":".'-'","wordKey":".'-'","dedupKey":".'-'","collapse":".'-'","words":[".'-'"],"jsTrim":".'-'","jsTrimEnd":".'-'","year":null}, +{"s":"a ́á'","utf16Len":6,"asciiLower":"a ́á'","lower":"a ́á'","wordKey":"a ́á'","dedupKey":"a a'","collapse":"a ́á'","words":["a","́á'"],"jsTrim":"a ́á'","jsTrimEnd":"a ́á'","year":null}, +{"s":"1.:a.a","utf16Len":6,"asciiLower":"1.:a.a","lower":"1.:a.a","wordKey":"1.:a.a","dedupKey":"1.:a.a","collapse":"1.:a.a","words":["1.:a.a"],"jsTrim":"1.:a.a","jsTrimEnd":"1.:a.a","year":null}, +{"s":"Αa","utf16Len":2,"asciiLower":"Αa","lower":"αa","wordKey":"Αa","dedupKey":"αa","collapse":"Αa","words":["Αa"],"jsTrim":"Αa","jsTrimEnd":"Αa","year":null}, +{"s":"́'́Α","utf16Len":4,"asciiLower":"́'́Α","lower":"́'́α","wordKey":"́'́Α","dedupKey":"'α","collapse":"́'́Α","words":["́'́Α"],"jsTrim":"́'́Α","jsTrimEnd":"́'́Α","year":null}, +{"s":" Α‍11","utf16Len":5,"asciiLower":" Α‍11","lower":" α‍11","wordKey":" Α‍11","dedupKey":"α‍11","collapse":"Α‍11","words":["Α‍11"],"jsTrim":"Α‍11","jsTrimEnd":" Α‍11","year":null}, +{"s":" ­.1: ","utf16Len":6,"asciiLower":" ­.1: ","lower":" ­.1: ","wordKey":" ­.1: ","dedupKey":"­.1:","collapse":"­.1:","words":["­.1:"],"jsTrim":"­.1:","jsTrimEnd":" ­.1:","year":null}, +{"s":"--","utf16Len":2,"asciiLower":"--","lower":"--","wordKey":"--","dedupKey":"--","collapse":"--","words":["--"],"jsTrim":"--","jsTrimEnd":"--","year":null}, +{"s":".­ ","utf16Len":3,"asciiLower":".­ ","lower":".­ ","wordKey":".­ ","dedupKey":".­","collapse":".­","words":[".­"],"jsTrim":".­","jsTrimEnd":".­","year":null}, +{"s":"‍'","utf16Len":2,"asciiLower":"‍'","lower":"‍'","wordKey":"‍'","dedupKey":"‍'","collapse":"‍'","words":["‍'"],"jsTrim":"‍'","jsTrimEnd":"‍'","year":null}, +{"s":"Σ𝐀:́","utf16Len":5,"asciiLower":"Σ𝐀:́","lower":"σ𝐀:́","wordKey":"Σ𝐀:́","dedupKey":"σ𝐀:","collapse":"Σ𝐀:́","words":["Σ𝐀:́"],"jsTrim":"Σ𝐀:́","jsTrimEnd":"Σ𝐀:́","year":null}, +{"s":"́-","utf16Len":2,"asciiLower":"́-","lower":"́-","wordKey":"́-","dedupKey":"-","collapse":"́-","words":["́-"],"jsTrim":"́-","jsTrimEnd":"́-","year":null}, +{"s":"Σ́Α","utf16Len":3,"asciiLower":"Σ́Α","lower":"σ́α","wordKey":"Σ́Α","dedupKey":"σα","collapse":"Σ́Α","words":["Σ́Α"],"jsTrim":"Σ́Α","jsTrimEnd":"Σ́Α","year":null}, +{"s":"'aa𝐀:ͅ","utf16Len":7,"asciiLower":"'aa𝐀:ͅ","lower":"'aa𝐀:ͅ","wordKey":"'aa𝐀:ͅ","dedupKey":"'aa𝐀:","collapse":"'aa𝐀:ͅ","words":["'aa𝐀:ͅ"],"jsTrim":"'aa𝐀:ͅ","jsTrimEnd":"'aa𝐀:ͅ","year":null}, +{"s":" ­","utf16Len":2,"asciiLower":" ­","lower":" ­","wordKey":" ­","dedupKey":"­","collapse":"­","words":["­"],"jsTrim":"­","jsTrimEnd":" ­","year":null}, +{"s":"-­ͅ","utf16Len":3,"asciiLower":"-­ͅ","lower":"-­ͅ","wordKey":"-­ͅ","dedupKey":"-­","collapse":"-­ͅ","words":["-­ͅ"],"jsTrim":"-­ͅ","jsTrimEnd":"-­ͅ","year":null}, +{"s":"­𝐀.a𝐀","utf16Len":7,"asciiLower":"­𝐀.a𝐀","lower":"­𝐀.a𝐀","wordKey":"­𝐀.a𝐀","dedupKey":"­𝐀.a𝐀","collapse":"­𝐀.a𝐀","words":["­𝐀.a𝐀"],"jsTrim":"­𝐀.a𝐀","jsTrimEnd":"­𝐀.a𝐀","year":null}, +{"s":".-𝐀","utf16Len":4,"asciiLower":".-𝐀","lower":".-𝐀","wordKey":".-𝐀","dedupKey":".-𝐀","collapse":".-𝐀","words":[".-𝐀"],"jsTrim":".-𝐀","jsTrimEnd":".-𝐀","year":null}, +{"s":"α .Σα1","utf16Len":6,"asciiLower":"α .Σα1","lower":"α .σα1","wordKey":"α .Σα1","dedupKey":"α .σα1","collapse":"α .Σα1","words":["α",".Σα1"],"jsTrim":"α .Σα1","jsTrimEnd":"α .Σα1","year":null}, +{"s":" a'α1","utf16Len":5,"asciiLower":" a'α1","lower":" a'α1","wordKey":" a'α1","dedupKey":"a'α1","collapse":"a'α1","words":["a'α1"],"jsTrim":"a'α1","jsTrimEnd":" a'α1","year":null}, +{"s":"𝐀𝐀 :","utf16Len":6,"asciiLower":"𝐀𝐀 :","lower":"𝐀𝐀 :","wordKey":"𝐀𝐀 ","dedupKey":"𝐀𝐀 :","collapse":"𝐀𝐀 :","words":["𝐀𝐀",":"],"jsTrim":"𝐀𝐀 :","jsTrimEnd":"𝐀𝐀 :","year":null}, +{"s":"‍","utf16Len":1,"asciiLower":"‍","lower":"‍","wordKey":"‍","dedupKey":"‍","collapse":"‍","words":["‍"],"jsTrim":"‍","jsTrimEnd":"‍","year":null}, +{"s":"':Α","utf16Len":3,"asciiLower":"':Α","lower":"':α","wordKey":"':Α","dedupKey":"':α","collapse":"':Α","words":["':Α"],"jsTrim":"':Α","jsTrimEnd":"':Α","year":null}, +{"s":".'1­a𝐀","utf16Len":7,"asciiLower":".'1­a𝐀","lower":".'1­a𝐀","wordKey":".'1­a𝐀","dedupKey":".'1­a𝐀","collapse":".'1­a𝐀","words":[".'1­a𝐀"],"jsTrim":".'1­a𝐀","jsTrimEnd":".'1­a𝐀","year":null}, +{"s":"ͅΑa","utf16Len":3,"asciiLower":"ͅΑa","lower":"ͅαa","wordKey":"ͅΑa","dedupKey":"αa","collapse":"ͅΑa","words":["ͅΑa"],"jsTrim":"ͅΑa","jsTrimEnd":"ͅΑa","year":null}, +{"s":"α1-a","utf16Len":4,"asciiLower":"α1-a","lower":"α1-a","wordKey":"α1-a","dedupKey":"α1-a","collapse":"α1-a","words":["α1-a"],"jsTrim":"α1-a","jsTrimEnd":"α1-a","year":null}, +{"s":"𝐀","utf16Len":2,"asciiLower":"𝐀","lower":"𝐀","wordKey":"𝐀","dedupKey":"𝐀","collapse":"𝐀","words":["𝐀"],"jsTrim":"𝐀","jsTrimEnd":"𝐀","year":null}, +{"s":"́‍-","utf16Len":3,"asciiLower":"́‍-","lower":"́‍-","wordKey":"́‍-","dedupKey":"‍-","collapse":"́‍-","words":["́‍-"],"jsTrim":"́‍-","jsTrimEnd":"́‍-","year":null}, +{"s":"Α ","utf16Len":2,"asciiLower":"Α ","lower":"α ","wordKey":"Α ","dedupKey":"α","collapse":"Α","words":["Α"],"jsTrim":"Α","jsTrimEnd":"Α","year":null}, +{"s":"-","utf16Len":1,"asciiLower":"-","lower":"-","wordKey":"-","dedupKey":"-","collapse":"-","words":["-"],"jsTrim":"-","jsTrimEnd":"-","year":null}, +{"s":"aΣ́‍́","utf16Len":5,"asciiLower":"aΣ́‍́","lower":"aς́‍́","wordKey":"aΣ́‍́","dedupKey":"aς‍","collapse":"aΣ́‍́","words":["aΣ́‍́"],"jsTrim":"aΣ́‍́","jsTrimEnd":"aΣ́‍́","year":null}, +{"s":" α","utf16Len":2,"asciiLower":" α","lower":" α","wordKey":" α","dedupKey":"α","collapse":"α","words":["α"],"jsTrim":"α","jsTrimEnd":" α","year":null}, +{"s":"a'1Α","utf16Len":4,"asciiLower":"a'1Α","lower":"a'1α","wordKey":"a'1Α","dedupKey":"a'1α","collapse":"a'1Α","words":["a'1Α"],"jsTrim":"a'1Α","jsTrimEnd":"a'1Α","year":null}, +{"s":"ᾼα Α:","utf16Len":6,"asciiLower":"ᾼα Α:","lower":"ᾳα α:","wordKey":"ᾼα Α","dedupKey":"αα α:","collapse":"ᾼα Α:","words":["ᾼα","Α:"],"jsTrim":"ᾼα Α:","jsTrimEnd":"ᾼα Α:","year":null}, +{"s":":ΣΣ","utf16Len":3,"asciiLower":":ΣΣ","lower":":σς","wordKey":":ΣΣ","dedupKey":":σς","collapse":":ΣΣ","words":[":ΣΣ"],"jsTrim":":ΣΣ","jsTrimEnd":":ΣΣ","year":null}, +{"s":"Σͅ'","utf16Len":3,"asciiLower":"Σͅ'","lower":"σͅ'","wordKey":"Σͅ'","dedupKey":"σ'","collapse":"Σͅ'","words":["Σͅ'"],"jsTrim":"Σͅ'","jsTrimEnd":"Σͅ'","year":null}, +{"s":"­­","utf16Len":2,"asciiLower":"­­","lower":"­­","wordKey":"­­","dedupKey":"­­","collapse":"­­","words":["­­"],"jsTrim":"­­","jsTrimEnd":"­­","year":null}, +{"s":":aα'--","utf16Len":6,"asciiLower":":aα'--","lower":":aα'--","wordKey":":aα'--","dedupKey":":aα'--","collapse":":aα'--","words":[":aα'--"],"jsTrim":":aα'--","jsTrimEnd":":aα'--","year":null}, +{"s":"Α:-","utf16Len":3,"asciiLower":"Α:-","lower":"α:-","wordKey":"Α:-","dedupKey":"α:-","collapse":"Α:-","words":["Α:-"],"jsTrim":"Α:-","jsTrimEnd":"Α:-","year":null}, +{"s":" ","utf16Len":2,"asciiLower":" ","lower":" ","wordKey":" ","dedupKey":"","collapse":"","words":[],"jsTrim":"","jsTrimEnd":"","year":null}, +{"s":"a‍a‍","utf16Len":4,"asciiLower":"a‍a‍","lower":"a‍a‍","wordKey":"a‍a‍","dedupKey":"a‍a‍","collapse":"a‍a‍","words":["a‍a‍"],"jsTrim":"a‍a‍","jsTrimEnd":"a‍a‍","year":null}, +{"s":"Α1­­","utf16Len":4,"asciiLower":"Α1­­","lower":"α1­­","wordKey":"Α1­­","dedupKey":"α1­­","collapse":"Α1­­","words":["Α1­­"],"jsTrim":"Α1­­","jsTrimEnd":"Α1­­","year":null}, +{"s":"ͅ1:𝐀'","utf16Len":6,"asciiLower":"ͅ1:𝐀'","lower":"ͅ1:𝐀'","wordKey":"ͅ1:𝐀'","dedupKey":"1:𝐀'","collapse":"ͅ1:𝐀'","words":["ͅ1:𝐀'"],"jsTrim":"ͅ1:𝐀'","jsTrimEnd":"ͅ1:𝐀'","year":null}, +{"s":"­𝐀ͅͅ‍a","utf16Len":7,"asciiLower":"­𝐀ͅͅ‍a","lower":"­𝐀ͅͅ‍a","wordKey":"­𝐀ͅͅ‍a","dedupKey":"­𝐀‍a","collapse":"­𝐀ͅͅ‍a","words":["­𝐀ͅͅ‍a"],"jsTrim":"­𝐀ͅͅ‍a","jsTrimEnd":"­𝐀ͅͅ‍a","year":null}, +{"s":":","utf16Len":1,"asciiLower":":","lower":":","wordKey":"","dedupKey":":","collapse":":","words":[":"],"jsTrim":":","jsTrimEnd":":","year":null}, +{"s":"1","utf16Len":1,"asciiLower":"1","lower":"1","wordKey":"1","dedupKey":"1","collapse":"1","words":["1"],"jsTrim":"1","jsTrimEnd":"1","year":null}, +{"s":"ͅ","utf16Len":1,"asciiLower":"ͅ","lower":"ͅ","wordKey":"ͅ","dedupKey":"","collapse":"ͅ","words":["ͅ"],"jsTrim":"ͅ","jsTrimEnd":"ͅ","year":null}, +{"s":"Σ́Α­Σ.","utf16Len":6,"asciiLower":"Σ́Α­Σ.","lower":"σ́α­ς.","wordKey":"Σ́Α­Σ","dedupKey":"σα­ς.","collapse":"Σ́Α­Σ.","words":["Σ́Α­Σ."],"jsTrim":"Σ́Α­Σ.","jsTrimEnd":"Σ́Α­Σ.","year":null}, +{"s":"𝐀.‍a­","utf16Len":6,"asciiLower":"𝐀.‍a­","lower":"𝐀.‍a­","wordKey":"𝐀.‍a­","dedupKey":"𝐀.‍a­","collapse":"𝐀.‍a­","words":["𝐀.‍a­"],"jsTrim":"𝐀.‍a­","jsTrimEnd":"𝐀.‍a­","year":null}, +{"s":"a","utf16Len":1,"asciiLower":"a","lower":"a","wordKey":"a","dedupKey":"a","collapse":"a","words":["a"],"jsTrim":"a","jsTrimEnd":"a","year":null}, +{"s":"Α'Σα","utf16Len":4,"asciiLower":"Α'Σα","lower":"α'σα","wordKey":"Α'Σα","dedupKey":"α'σα","collapse":"Α'Σα","words":["Α'Σα"],"jsTrim":"Α'Σα","jsTrimEnd":"Α'Σα","year":null}, +{"s":"'­","utf16Len":2,"asciiLower":"'­","lower":"'­","wordKey":"'­","dedupKey":"'­","collapse":"'­","words":["'­"],"jsTrim":"'­","jsTrimEnd":"'­","year":null}, +{"s":"­a𝐀𝐀𝐀a","utf16Len":9,"asciiLower":"­a𝐀𝐀𝐀a","lower":"­a𝐀𝐀𝐀a","wordKey":"­a𝐀𝐀𝐀a","dedupKey":"­a𝐀𝐀𝐀a","collapse":"­a𝐀𝐀𝐀a","words":["­a𝐀𝐀𝐀a"],"jsTrim":"­a𝐀𝐀𝐀a","jsTrimEnd":"­a𝐀𝐀𝐀a","year":null}, +{"s":"Αα­𝐀1","utf16Len":6,"asciiLower":"Αα­𝐀1","lower":"αα­𝐀1","wordKey":"Αα­𝐀1","dedupKey":"αα­𝐀1","collapse":"Αα­𝐀1","words":["Αα­𝐀1"],"jsTrim":"Αα­𝐀1","jsTrimEnd":"Αα­𝐀1","year":null}, +{"s":"α","utf16Len":1,"asciiLower":"α","lower":"α","wordKey":"α","dedupKey":"α","collapse":"α","words":["α"],"jsTrim":"α","jsTrimEnd":"α","year":null}, +{"s":"-:-́Σ","utf16Len":5,"asciiLower":"-:-́Σ","lower":"-:-́σ","wordKey":"-:-́Σ","dedupKey":"-:-σ","collapse":"-:-́Σ","words":["-:-́Σ"],"jsTrim":"-:-́Σ","jsTrimEnd":"-:-́Σ","year":null}, +{"s":"::","utf16Len":2,"asciiLower":"::","lower":"::","wordKey":":","dedupKey":"::","collapse":"::","words":["::"],"jsTrim":"::","jsTrimEnd":"::","year":null}, +{"s":"1 '","utf16Len":3,"asciiLower":"1 '","lower":"1 '","wordKey":"1 '","dedupKey":"1 '","collapse":"1 '","words":["1","'"],"jsTrim":"1 '","jsTrimEnd":"1 '","year":null}, +{"s":"Α..-𝐀Α","utf16Len":7,"asciiLower":"Α..-𝐀Α","lower":"α..-𝐀α","wordKey":"Α..-𝐀Α","dedupKey":"α..-𝐀α","collapse":"Α..-𝐀Α","words":["Α..-𝐀Α"],"jsTrim":"Α..-𝐀Α","jsTrimEnd":"Α..-𝐀Α","year":null}, +{"s":"Α:","utf16Len":2,"asciiLower":"Α:","lower":"α:","wordKey":"Α","dedupKey":"α:","collapse":"Α:","words":["Α:"],"jsTrim":"Α:","jsTrimEnd":"Α:","year":null}, +{"s":"­ͅ","utf16Len":2,"asciiLower":"­ͅ","lower":"­ͅ","wordKey":"­ͅ","dedupKey":"­","collapse":"­ͅ","words":["­ͅ"],"jsTrim":"­ͅ","jsTrimEnd":"­ͅ","year":null}, +{"s":":ͅ","utf16Len":2,"asciiLower":":ͅ","lower":":ͅ","wordKey":":ͅ","dedupKey":":","collapse":":ͅ","words":[":ͅ"],"jsTrim":":ͅ","jsTrimEnd":":ͅ","year":null}, +{"s":"1:a‍1a","utf16Len":6,"asciiLower":"1:a‍1a","lower":"1:a‍1a","wordKey":"1:a‍1a","dedupKey":"1:a‍1a","collapse":"1:a‍1a","words":["1:a‍1a"],"jsTrim":"1:a‍1a","jsTrimEnd":"1:a‍1a","year":null}, +{"s":"­Α'ͅ‍","utf16Len":5,"asciiLower":"­Α'ͅ‍","lower":"­α'ͅ‍","wordKey":"­Α'ͅ‍","dedupKey":"­α'‍","collapse":"­Α'ͅ‍","words":["­Α'ͅ‍"],"jsTrim":"­Α'ͅ‍","jsTrimEnd":"­Α'ͅ‍","year":null}, +{"s":"1α1'ͅ1","utf16Len":6,"asciiLower":"1α1'ͅ1","lower":"1α1'ͅ1","wordKey":"1α1'ͅ1","dedupKey":"1α1'1","collapse":"1α1'ͅ1","words":["1α1'ͅ1"],"jsTrim":"1α1'ͅ1","jsTrimEnd":"1α1'ͅ1","year":null}, +{"s":"ͅ­","utf16Len":2,"asciiLower":"ͅ­","lower":"ͅ­","wordKey":"ͅ­","dedupKey":"­","collapse":"ͅ­","words":["ͅ­"],"jsTrim":"ͅ­","jsTrimEnd":"ͅ­","year":null}, +{"s":"-Σ","utf16Len":2,"asciiLower":"-Σ","lower":"-σ","wordKey":"-Σ","dedupKey":"-σ","collapse":"-Σ","words":["-Σ"],"jsTrim":"-Σ","jsTrimEnd":"-Σ","year":null}, +{"s":"‍Αa1a","utf16Len":5,"asciiLower":"‍Αa1a","lower":"‍αa1a","wordKey":"‍Αa1a","dedupKey":"‍αa1a","collapse":"‍Αa1a","words":["‍Αa1a"],"jsTrim":"‍Αa1a","jsTrimEnd":"‍Αa1a","year":null}, +{"s":"­","utf16Len":1,"asciiLower":"­","lower":"­","wordKey":"­","dedupKey":"­","collapse":"­","words":["­"],"jsTrim":"­","jsTrimEnd":"­","year":null}, +{"s":"α1'","utf16Len":3,"asciiLower":"α1'","lower":"α1'","wordKey":"α1'","dedupKey":"α1'","collapse":"α1'","words":["α1'"],"jsTrim":"α1'","jsTrimEnd":"α1'","year":null}, +{"s":"­‍𝐀ͅᾳ","utf16Len":7,"asciiLower":"­‍𝐀ͅᾳ","lower":"­‍𝐀ͅᾳ","wordKey":"­‍𝐀ͅᾳ","dedupKey":"­‍𝐀α","collapse":"­‍𝐀ͅᾳ","words":["­‍𝐀ͅᾳ"],"jsTrim":"­‍𝐀ͅᾳ","jsTrimEnd":"­‍𝐀ͅᾳ","year":null}, +{"s":"́'","utf16Len":2,"asciiLower":"́'","lower":"́'","wordKey":"́'","dedupKey":"'","collapse":"́'","words":["́'"],"jsTrim":"́'","jsTrimEnd":"́'","year":null}, +{"s":"ΑΆα","utf16Len":4,"asciiLower":"ΑΆα","lower":"αάα","wordKey":"ΑΆα","dedupKey":"ααα","collapse":"ΑΆα","words":["ΑΆα"],"jsTrim":"ΑΆα","jsTrimEnd":"ΑΆα","year":null}, +{"s":"1:Σ1́α","utf16Len":6,"asciiLower":"1:Σ1́α","lower":"1:σ1́α","wordKey":"1:Σ1́α","dedupKey":"1:σ1α","collapse":"1:Σ1́α","words":["1:Σ1́α"],"jsTrim":"1:Σ1́α","jsTrimEnd":"1:Σ1́α","year":null}, +{"s":"1aΑ ΑΑ","utf16Len":6,"asciiLower":"1aΑ ΑΑ","lower":"1aα αα","wordKey":"1aΑ ΑΑ","dedupKey":"1aα αα","collapse":"1aΑ ΑΑ","words":["1aΑ","ΑΑ"],"jsTrim":"1aΑ ΑΑ","jsTrimEnd":"1aΑ ΑΑ","year":null}, +{"s":"ΆΣ𝐀","utf16Len":5,"asciiLower":"ΆΣ𝐀","lower":"άσ𝐀","wordKey":"ΆΣ𝐀","dedupKey":"ασ𝐀","collapse":"ΆΣ𝐀","words":["ΆΣ𝐀"],"jsTrim":"ΆΣ𝐀","jsTrimEnd":"ΆΣ𝐀","year":null}, +{"s":"Σ́‍αα","utf16Len":5,"asciiLower":"Σ́‍αα","lower":"σ́‍αα","wordKey":"Σ́‍αα","dedupKey":"σ‍αα","collapse":"Σ́‍αα","words":["Σ́‍αα"],"jsTrim":"Σ́‍αα","jsTrimEnd":"Σ́‍αα","year":null}, +{"s":"ͅ­-1‍:","utf16Len":6,"asciiLower":"ͅ­-1‍:","lower":"ͅ­-1‍:","wordKey":"ͅ­-1‍","dedupKey":"­-1‍:","collapse":"ͅ­-1‍:","words":["ͅ­-1‍:"],"jsTrim":"ͅ­-1‍:","jsTrimEnd":"ͅ­-1‍:","year":null}, +{"s":".-α.ͅ","utf16Len":5,"asciiLower":".-α.ͅ","lower":".-α.ͅ","wordKey":".-α.ͅ","dedupKey":".-α.","collapse":".-α.ͅ","words":[".-α.ͅ"],"jsTrim":".-α.ͅ","jsTrimEnd":".-α.ͅ","year":null}, +{"s":"'α'a:.","utf16Len":6,"asciiLower":"'α'a:.","lower":"'α'a:.","wordKey":"'α'a:","dedupKey":"'α'a:.","collapse":"'α'a:.","words":["'α'a:."],"jsTrim":"'α'a:.","jsTrimEnd":"'α'a:.","year":null}, +{"s":"𝐀1𝐀:­","utf16Len":7,"asciiLower":"𝐀1𝐀:­","lower":"𝐀1𝐀:­","wordKey":"𝐀1𝐀:­","dedupKey":"𝐀1𝐀:­","collapse":"𝐀1𝐀:­","words":["𝐀1𝐀:­"],"jsTrim":"𝐀1𝐀:­","jsTrimEnd":"𝐀1𝐀:­","year":null}, +{"s":"'Α'","utf16Len":3,"asciiLower":"'Α'","lower":"'α'","wordKey":"'Α'","dedupKey":"'α'","collapse":"'Α'","words":["'Α'"],"jsTrim":"'Α'","jsTrimEnd":"'Α'","year":null}, +{"s":"𝐀a1- ","utf16Len":6,"asciiLower":"𝐀a1- ","lower":"𝐀a1- ","wordKey":"𝐀a1- ","dedupKey":"𝐀a1-","collapse":"𝐀a1-","words":["𝐀a1-"],"jsTrim":"𝐀a1-","jsTrimEnd":"𝐀a1-","year":null}, +{"s":"áΣ ­.","utf16Len":6,"asciiLower":"áΣ ­.","lower":"áς ­.","wordKey":"áΣ ­","dedupKey":"aς ­.","collapse":"áΣ ­.","words":["áΣ","­."],"jsTrim":"áΣ ­.","jsTrimEnd":"áΣ ­.","year":null}, +{"s":"ͅ'Σ.Σ","utf16Len":5,"asciiLower":"ͅ'Σ.Σ","lower":"ͅ'σ.ς","wordKey":"ͅ'Σ.Σ","dedupKey":"'σ.ς","collapse":"ͅ'Σ.Σ","words":["ͅ'Σ.Σ"],"jsTrim":"ͅ'Σ.Σ","jsTrimEnd":"ͅ'Σ.Σ","year":null}, +{"s":"Σα","utf16Len":2,"asciiLower":"Σα","lower":"σα","wordKey":"Σα","dedupKey":"σα","collapse":"Σα","words":["Σα"],"jsTrim":"Σα","jsTrimEnd":"Σα","year":null}, +{"s":"ααaα1","utf16Len":5,"asciiLower":"ααaα1","lower":"ααaα1","wordKey":"ααaα1","dedupKey":"ααaα1","collapse":"ααaα1","words":["ααaα1"],"jsTrim":"ααaα1","jsTrimEnd":"ααaα1","year":null}, +{"s":"𝐀:.1:1","utf16Len":7,"asciiLower":"𝐀:.1:1","lower":"𝐀:.1:1","wordKey":"𝐀:.1:1","dedupKey":"𝐀:.1:1","collapse":"𝐀:.1:1","words":["𝐀:.1:1"],"jsTrim":"𝐀:.1:1","jsTrimEnd":"𝐀:.1:1","year":null}, +{"s":":ΣΣΣ.","utf16Len":5,"asciiLower":":ΣΣΣ.","lower":":σσς.","wordKey":":ΣΣΣ","dedupKey":":σσς.","collapse":":ΣΣΣ.","words":[":ΣΣΣ."],"jsTrim":":ΣΣΣ.","jsTrimEnd":":ΣΣΣ.","year":null}, +{"s":"ͅ'","utf16Len":2,"asciiLower":"ͅ'","lower":"ͅ'","wordKey":"ͅ'","dedupKey":"'","collapse":"ͅ'","words":["ͅ'"],"jsTrim":"ͅ'","jsTrimEnd":"ͅ'","year":null}, +{"s":"𝐀.1α'𝐀","utf16Len":8,"asciiLower":"𝐀.1α'𝐀","lower":"𝐀.1α'𝐀","wordKey":"𝐀.1α'𝐀","dedupKey":"𝐀.1α'𝐀","collapse":"𝐀.1α'𝐀","words":["𝐀.1α'𝐀"],"jsTrim":"𝐀.1α'𝐀","jsTrimEnd":"𝐀.1α'𝐀","year":null}, +{"s":"a1­.'","utf16Len":5,"asciiLower":"a1­.'","lower":"a1­.'","wordKey":"a1­.'","dedupKey":"a1­.'","collapse":"a1­.'","words":["a1­.'"],"jsTrim":"a1­.'","jsTrimEnd":"a1­.'","year":null}, +{"s":"ͅΣ́","utf16Len":3,"asciiLower":"ͅΣ́","lower":"ͅσ́","wordKey":"ͅΣ́","dedupKey":"σ","collapse":"ͅΣ́","words":["ͅΣ́"],"jsTrim":"ͅΣ́","jsTrimEnd":"ͅΣ́","year":null}, +{"s":"Σ𝐀::́","utf16Len":6,"asciiLower":"Σ𝐀::́","lower":"σ𝐀::́","wordKey":"Σ𝐀::́","dedupKey":"σ𝐀::","collapse":"Σ𝐀::́","words":["Σ𝐀::́"],"jsTrim":"Σ𝐀::́","jsTrimEnd":"Σ𝐀::́","year":null}, +{"s":"Α­α","utf16Len":3,"asciiLower":"Α­α","lower":"α­α","wordKey":"Α­α","dedupKey":"α­α","collapse":"Α­α","words":["Α­α"],"jsTrim":"Α­α","jsTrimEnd":"Α­α","year":null}, +{"s":"‍𝐀","utf16Len":3,"asciiLower":"‍𝐀","lower":"‍𝐀","wordKey":"‍𝐀","dedupKey":"‍𝐀","collapse":"‍𝐀","words":["‍𝐀"],"jsTrim":"‍𝐀","jsTrimEnd":"‍𝐀","year":null}, +{"s":"α ","utf16Len":2,"asciiLower":"α ","lower":"α ","wordKey":"α ","dedupKey":"α","collapse":"α","words":["α"],"jsTrim":"α","jsTrimEnd":"α","year":null}, +{"s":":.aΣ","utf16Len":4,"asciiLower":":.aΣ","lower":":.aς","wordKey":":.aΣ","dedupKey":":.aς","collapse":":.aΣ","words":[":.aΣ"],"jsTrim":":.aΣ","jsTrimEnd":":.aΣ","year":null}, +{"s":"a.Σ","utf16Len":3,"asciiLower":"a.Σ","lower":"a.ς","wordKey":"a.Σ","dedupKey":"a.ς","collapse":"a.Σ","words":["a.Σ"],"jsTrim":"a.Σ","jsTrimEnd":"a.Σ","year":null}, +{"s":"́α.­'","utf16Len":5,"asciiLower":"́α.­'","lower":"́α.­'","wordKey":"́α.­'","dedupKey":"α.­'","collapse":"́α.­'","words":["́α.­'"],"jsTrim":"́α.­'","jsTrimEnd":"́α.­'","year":null}, +{"s":"𝐀1́'ͅ","utf16Len":6,"asciiLower":"𝐀1́'ͅ","lower":"𝐀1́'ͅ","wordKey":"𝐀1́'ͅ","dedupKey":"𝐀1'","collapse":"𝐀1́'ͅ","words":["𝐀1́'ͅ"],"jsTrim":"𝐀1́'ͅ","jsTrimEnd":"𝐀1́'ͅ","year":null}, +{"s":"a:Σ :","utf16Len":5,"asciiLower":"a:Σ :","lower":"a:ς :","wordKey":"a:Σ ","dedupKey":"a:ς :","collapse":"a:Σ :","words":["a:Σ",":"],"jsTrim":"a:Σ :","jsTrimEnd":"a:Σ :","year":null}, +{"s":"-1","utf16Len":2,"asciiLower":"-1","lower":"-1","wordKey":"-1","dedupKey":"-1","collapse":"-1","words":["-1"],"jsTrim":"-1","jsTrimEnd":"-1","year":null}, +{"s":" ­.𝐀‍","utf16Len":6,"asciiLower":" ­.𝐀‍","lower":" ­.𝐀‍","wordKey":" ­.𝐀‍","dedupKey":"­.𝐀‍","collapse":"­.𝐀‍","words":["­.𝐀‍"],"jsTrim":"­.𝐀‍","jsTrimEnd":" ­.𝐀‍","year":null}, +{"s":"ͅ.1́Σ","utf16Len":5,"asciiLower":"ͅ.1́Σ","lower":"ͅ.1́σ","wordKey":"ͅ.1́Σ","dedupKey":".1σ","collapse":"ͅ.1́Σ","words":["ͅ.1́Σ"],"jsTrim":"ͅ.1́Σ","jsTrimEnd":"ͅ.1́Σ","year":null}, +{"s":"-1'","utf16Len":3,"asciiLower":"-1'","lower":"-1'","wordKey":"-1'","dedupKey":"-1'","collapse":"-1'","words":["-1'"],"jsTrim":"-1'","jsTrimEnd":"-1'","year":null}, +{"s":"-‍ .11","utf16Len":6,"asciiLower":"-‍ .11","lower":"-‍ .11","wordKey":"-‍ .11","dedupKey":"-‍ .11","collapse":"-‍ .11","words":["-‍",".11"],"jsTrim":"-‍ .11","jsTrimEnd":"-‍ .11","year":null}, +{"s":"'a'","utf16Len":3,"asciiLower":"'a'","lower":"'a'","wordKey":"'a'","dedupKey":"'a'","collapse":"'a'","words":["'a'"],"jsTrim":"'a'","jsTrimEnd":"'a'","year":null}, +{"s":"́.","utf16Len":2,"asciiLower":"́.","lower":"́.","wordKey":"́","dedupKey":".","collapse":"́.","words":["́."],"jsTrim":"́.","jsTrimEnd":"́.","year":null}, +{"s":"Α­","utf16Len":2,"asciiLower":"Α­","lower":"α­","wordKey":"Α­","dedupKey":"α­","collapse":"Α­","words":["Α­"],"jsTrim":"Α­","jsTrimEnd":"Α­","year":null}, +{"s":"'","utf16Len":1,"asciiLower":"'","lower":"'","wordKey":"'","dedupKey":"'","collapse":"'","words":["'"],"jsTrim":"'","jsTrimEnd":"'","year":null}, +{"s":".́:","utf16Len":3,"asciiLower":".́:","lower":".́:","wordKey":".́","dedupKey":".:","collapse":".́:","words":[".́:"],"jsTrim":".́:","jsTrimEnd":".́:","year":null}, +{"s":" :ͅ","utf16Len":3,"asciiLower":" :ͅ","lower":" :ͅ","wordKey":" :ͅ","dedupKey":":","collapse":":ͅ","words":[":ͅ"],"jsTrim":":ͅ","jsTrimEnd":" :ͅ","year":null}, +{"s":" á‍1","utf16Len":5,"asciiLower":" á‍1","lower":" á‍1","wordKey":" á‍1","dedupKey":"a‍1","collapse":"á‍1","words":["á‍1"],"jsTrim":"á‍1","jsTrimEnd":" á‍1","year":null}, +{"s":"ΣαΑΆ","utf16Len":5,"asciiLower":"ΣαΑΆ","lower":"σααά","wordKey":"ΣαΑΆ","dedupKey":"σααα","collapse":"ΣαΑΆ","words":["ΣαΑΆ"],"jsTrim":"ΣαΑΆ","jsTrimEnd":"ΣαΑΆ","year":null}, +{"s":"--.­","utf16Len":4,"asciiLower":"--.­","lower":"--.­","wordKey":"--.­","dedupKey":"--.­","collapse":"--.­","words":["--.­"],"jsTrim":"--.­","jsTrimEnd":"--.­","year":null}, +{"s":"1Σα","utf16Len":3,"asciiLower":"1Σα","lower":"1σα","wordKey":"1Σα","dedupKey":"1σα","collapse":"1Σα","words":["1Σα"],"jsTrim":"1Σα","jsTrimEnd":"1Σα","year":null}, +{"s":"­‍:­ ","utf16Len":5,"asciiLower":"­‍:­ ","lower":"­‍:­ ","wordKey":"­‍:­ ","dedupKey":"­‍:­","collapse":"­‍:­","words":["­‍:­"],"jsTrim":"­‍:­","jsTrimEnd":"­‍:­","year":null}, +{"s":". ","utf16Len":2,"asciiLower":". ","lower":". ","wordKey":". ","dedupKey":".","collapse":".","words":["."],"jsTrim":".","jsTrimEnd":".","year":null}, +{"s":".1.","utf16Len":3,"asciiLower":".1.","lower":".1.","wordKey":".1","dedupKey":".1.","collapse":".1.","words":[".1."],"jsTrim":".1.","jsTrimEnd":".1.","year":null}, +{"s":"ΣΣ́","utf16Len":3,"asciiLower":"ΣΣ́","lower":"σς́","wordKey":"ΣΣ́","dedupKey":"σς","collapse":"ΣΣ́","words":["ΣΣ́"],"jsTrim":"ΣΣ́","jsTrimEnd":"ΣΣ́","year":null}, +{"s":"a­","utf16Len":2,"asciiLower":"a­","lower":"a­","wordKey":"a­","dedupKey":"a­","collapse":"a­","words":["a­"],"jsTrim":"a­","jsTrimEnd":"a­","year":null}, +{"s":":1.","utf16Len":3,"asciiLower":":1.","lower":":1.","wordKey":":1","dedupKey":":1.","collapse":":1.","words":[":1."],"jsTrim":":1.","jsTrimEnd":":1.","year":null}, +{"s":"­αa a","utf16Len":5,"asciiLower":"­αa a","lower":"­αa a","wordKey":"­αa a","dedupKey":"­αa a","collapse":"­αa a","words":["­αa","a"],"jsTrim":"­αa a","jsTrimEnd":"­αa a","year":null}, +{"s":"­.11́­","utf16Len":6,"asciiLower":"­.11́­","lower":"­.11́­","wordKey":"­.11́­","dedupKey":"­.11­","collapse":"­.11́­","words":["­.11́­"],"jsTrim":"­.11́­","jsTrimEnd":"­.11́­","year":null}, +{"s":" 𞤢Αʰ","utf16Len":5,"asciiLower":" 𞤢Αʰ","lower":" 𞤢αʰ","wordKey":" 𞤢Αʰ","dedupKey":"𞤢αʰ","collapse":"𞤢Αʰ","words":["𞤢Αʰ"],"jsTrim":"𞤢Αʰ","jsTrimEnd":" 𞤢Αʰ","year":null}, +{"s":"-Ა·𝐀:Σ","utf16Len":7,"asciiLower":"-Ა·𝐀:Σ","lower":"-ა·𝐀:ς","wordKey":"-Ა·𝐀:Σ","dedupKey":"-ა·𝐀:ς","collapse":"-Ა·𝐀:Σ","words":["-Ა·𝐀:Σ"],"jsTrim":"-Ა·𝐀:Σ","jsTrimEnd":"-Ა·𝐀:Σ","year":null}, +{"s":"ẞ···İDž","utf16Len":6,"asciiLower":"ẞ···İDž","lower":"ß···i̇dž","wordKey":"ẞ···İDž","dedupKey":"ß···idž","collapse":"ẞ···İDž","words":["ẞ···İDž"],"jsTrim":"ẞ···İDž","jsTrimEnd":"ẞ···İDž","year":null}, +{"s":"Dž ","utf16Len":2,"asciiLower":"Dž ","lower":"dž ","wordKey":"Dž ","dedupKey":"dž","collapse":"Dž","words":["Dž"],"jsTrim":"Dž","jsTrimEnd":"Dž","year":null}, +{"s":"𞤀Σ𞤢Ა.","utf16Len":7,"asciiLower":"𞤀Σ𞤢Ა.","lower":"𞤢σ𞤢ა.","wordKey":"𞤀Σ𞤢Ა","dedupKey":"𞤢σ𞤢ა.","collapse":"𞤀Σ𞤢Ა.","words":["𞤀Σ𞤢Ა."],"jsTrim":"𞤀Σ𞤢Ა.","jsTrimEnd":"𞤀Σ𞤢Ა.","year":null}, +{"s":"𞤢Ꭰ:","utf16Len":4,"asciiLower":"𞤢Ꭰ:","lower":"𞤢ꭰ:","wordKey":"𞤢Ꭰ","dedupKey":"𞤢ꭰ:","collapse":"𞤢Ꭰ:","words":["𞤢Ꭰ:"],"jsTrim":"𞤢Ꭰ:","jsTrimEnd":"𞤢Ꭰ:","year":null}, +{"s":"ẞ 'Ꭰ‍.","utf16Len":6,"asciiLower":"ẞ 'Ꭰ‍.","lower":"ß 'ꭰ‍.","wordKey":"ẞ 'Ꭰ‍","dedupKey":"ß 'ꭰ‍.","collapse":"ẞ 'Ꭰ‍.","words":["ẞ","'Ꭰ‍."],"jsTrim":"ẞ 'Ꭰ‍.","jsTrimEnd":"ẞ 'Ꭰ‍.","year":null}, +{"s":"a 𞤀ꭰα","utf16Len":6,"asciiLower":"a 𞤀ꭰα","lower":"a 𞤢ꭰα","wordKey":"a 𞤀ꭰα","dedupKey":"a 𞤢ꭰα","collapse":"a 𞤀ꭰα","words":["a","𞤀ꭰα"],"jsTrim":"a 𞤀ꭰα","jsTrimEnd":"a 𞤀ꭰα","year":null}, +{"s":"a·­","utf16Len":3,"asciiLower":"a·­","lower":"a·­","wordKey":"a·­","dedupKey":"a·­","collapse":"a·­","words":["a·­"],"jsTrim":"a·­","jsTrimEnd":"a·­","year":null}, +{"s":"αα","utf16Len":2,"asciiLower":"αα","lower":"αα","wordKey":"αα","dedupKey":"αα","collapse":"αα","words":["αα"],"jsTrim":"αα","jsTrimEnd":"αα","year":null}, +{"s":":ẞʰ𝐀𞤀","utf16Len":7,"asciiLower":":ẞʰ𝐀𞤀","lower":":ßʰ𝐀𞤢","wordKey":":ẞʰ𝐀𞤀","dedupKey":":ßʰ𝐀𞤢","collapse":":ẞʰ𝐀𞤀","words":[":ẞʰ𝐀𞤀"],"jsTrim":":ẞʰ𝐀𞤀","jsTrimEnd":":ẞʰ𝐀𞤀","year":null}, +{"s":".­1𞤀ʰẞ","utf16Len":7,"asciiLower":".­1𞤀ʰẞ","lower":".­1𞤢ʰß","wordKey":".­1𞤀ʰẞ","dedupKey":".­1𞤢ʰß","collapse":".­1𞤀ʰẞ","words":[".­1𞤀ʰẞ"],"jsTrim":".­1𞤀ʰẞ","jsTrimEnd":".­1𞤀ʰẞ","year":null}, +{"s":"ͅ..Dž𞤀","utf16Len":6,"asciiLower":"ͅ..Dž𞤀","lower":"ͅ..dž𞤢","wordKey":"ͅ..Dž𞤀","dedupKey":"..dž𞤢","collapse":"ͅ..Dž𞤀","words":["ͅ..Dž𞤀"],"jsTrim":"ͅ..Dž𞤀","jsTrimEnd":"ͅ..Dž𞤀","year":null}, +{"s":"𞤢·'aᲐ:","utf16Len":7,"asciiLower":"𞤢·'aᲐ:","lower":"𞤢·'aა:","wordKey":"𞤢·'aᲐ","dedupKey":"𞤢·'aა:","collapse":"𞤢·'aᲐ:","words":["𞤢·'aᲐ:"],"jsTrim":"𞤢·'aᲐ:","jsTrimEnd":"𞤢·'aᲐ:","year":null}, +{"s":"𞤢","utf16Len":2,"asciiLower":"𞤢","lower":"𞤢","wordKey":"𞤢","dedupKey":"𞤢","collapse":"𞤢","words":["𞤢"],"jsTrim":"𞤢","jsTrimEnd":"𞤢","year":null}, +{"s":"ẞͅაꭰ𞤢","utf16Len":6,"asciiLower":"ẞͅაꭰ𞤢","lower":"ßͅაꭰ𞤢","wordKey":"ẞͅაꭰ𞤢","dedupKey":"ßაꭰ𞤢","collapse":"ẞͅაꭰ𞤢","words":["ẞͅაꭰ𞤢"],"jsTrim":"ẞͅაꭰ𞤢","jsTrimEnd":"ẞͅაꭰ𞤢","year":null}, +{"s":"́α.Ა·","utf16Len":5,"asciiLower":"́α.Ა·","lower":"́α.ა·","wordKey":"́α.Ა·","dedupKey":"α.ა·","collapse":"́α.Ა·","words":["́α.Ა·"],"jsTrim":"́α.Ა·","jsTrimEnd":"́α.Ა·","year":null}, +{"s":" ʰ𝐀","utf16Len":4,"asciiLower":" ʰ𝐀","lower":" ʰ𝐀","wordKey":" ʰ𝐀","dedupKey":"ʰ𝐀","collapse":"ʰ𝐀","words":["ʰ𝐀"],"jsTrim":"ʰ𝐀","jsTrimEnd":" ʰ𝐀","year":null}, +{"s":"İͅ","utf16Len":2,"asciiLower":"İͅ","lower":"i̇ͅ","wordKey":"İͅ","dedupKey":"i","collapse":"İͅ","words":["İͅ"],"jsTrim":"İͅ","jsTrimEnd":"İͅ","year":null}, +{"s":"a-‍.Σ","utf16Len":5,"asciiLower":"a-‍.Σ","lower":"a-‍.σ","wordKey":"a-‍.Σ","dedupKey":"a-‍.σ","collapse":"a-‍.Σ","words":["a-‍.Σ"],"jsTrim":"a-‍.Σ","jsTrimEnd":"a-‍.Σ","year":null}, +{"s":"ꭰαaΣ:","utf16Len":5,"asciiLower":"ꭰαaΣ:","lower":"ꭰαaς:","wordKey":"ꭰαaΣ","dedupKey":"ꭰαaς:","collapse":"ꭰαaΣ:","words":["ꭰαaΣ:"],"jsTrim":"ꭰαaΣ:","jsTrimEnd":"ꭰαaΣ:","year":null}, +{"s":"́Dž'Ა:","utf16Len":5,"asciiLower":"́Dž'Ა:","lower":"́dž'ა:","wordKey":"́Dž'Ა","dedupKey":"dž'ა:","collapse":"́Dž'Ა:","words":["́Dž'Ა:"],"jsTrim":"́Dž'Ა:","jsTrimEnd":"́Dž'Ა:","year":null}, +{"s":"𞤀İa","utf16Len":4,"asciiLower":"𞤀İa","lower":"𞤢i̇a","wordKey":"𞤀İa","dedupKey":"𞤢ia","collapse":"𞤀İa","words":["𞤀İa"],"jsTrim":"𞤀İa","jsTrimEnd":"𞤀İa","year":null}, +{"s":"აʰα","utf16Len":3,"asciiLower":"აʰα","lower":"აʰα","wordKey":"აʰα","dedupKey":"აʰα","collapse":"აʰα","words":["აʰα"],"jsTrim":"აʰα","jsTrimEnd":"აʰα","year":null}, +{"s":" DžİꭰᲐ‍","utf16Len":6,"asciiLower":" DžİꭰᲐ‍","lower":" dži̇ꭰა‍","wordKey":" DžİꭰᲐ‍","dedupKey":"džiꭰა‍","collapse":"DžİꭰᲐ‍","words":["DžİꭰᲐ‍"],"jsTrim":"DžİꭰᲐ‍","jsTrimEnd":" DžİꭰᲐ‍","year":null}, +{"s":"𞤢.ẞ.","utf16Len":5,"asciiLower":"𞤢.ẞ.","lower":"𞤢.ß.","wordKey":"𞤢.ẞ","dedupKey":"𞤢.ß.","collapse":"𞤢.ẞ.","words":["𞤢.ẞ."],"jsTrim":"𞤢.ẞ.","jsTrimEnd":"𞤢.ẞ.","year":null}, +{"s":"İᲐ-­Α","utf16Len":5,"asciiLower":"İᲐ-­Α","lower":"i̇ა-­α","wordKey":"İᲐ-­Α","dedupKey":"iა-­α","collapse":"İᲐ-­Α","words":["İᲐ-­Α"],"jsTrim":"İᲐ-­Α","jsTrimEnd":"İᲐ-­Α","year":null}, +{"s":"ꭰ: ","utf16Len":3,"asciiLower":"ꭰ: ","lower":"ꭰ: ","wordKey":"ꭰ: ","dedupKey":"ꭰ:","collapse":"ꭰ:","words":["ꭰ:"],"jsTrim":"ꭰ:","jsTrimEnd":"ꭰ:","year":null}, +{"s":"ᲐͅⒶ·𞤢","utf16Len":6,"asciiLower":"ᲐͅⒶ·𞤢","lower":"აͅⓐ·𞤢","wordKey":"ᲐͅⒶ·𞤢","dedupKey":"აⓐ·𞤢","collapse":"ᲐͅⒶ·𞤢","words":["ᲐͅⒶ·𞤢"],"jsTrim":"ᲐͅⒶ·𞤢","jsTrimEnd":"ᲐͅⒶ·𞤢","year":null}, +{"s":"‍́ͅ","utf16Len":3,"asciiLower":"‍́ͅ","lower":"‍́ͅ","wordKey":"‍́ͅ","dedupKey":"‍","collapse":"‍́ͅ","words":["‍́ͅ"],"jsTrim":"‍́ͅ","jsTrimEnd":"‍́ͅ","year":null}, +{"s":"აΣ́","utf16Len":3,"asciiLower":"აΣ́","lower":"აς́","wordKey":"აΣ́","dedupKey":"აς","collapse":"აΣ́","words":["აΣ́"],"jsTrim":"აΣ́","jsTrimEnd":"აΣ́","year":null}, +{"s":"ͅͅ-𝐀ᲐⒶ","utf16Len":7,"asciiLower":"ͅͅ-𝐀ᲐⒶ","lower":"ͅͅ-𝐀აⓐ","wordKey":"ͅͅ-𝐀ᲐⒶ","dedupKey":"-𝐀აⓐ","collapse":"ͅͅ-𝐀ᲐⒶ","words":["ͅͅ-𝐀ᲐⒶ"],"jsTrim":"ͅͅ-𝐀ᲐⒶ","jsTrimEnd":"ͅͅ-𝐀ᲐⒶ","year":null}, +{"s":"ა́","utf16Len":2,"asciiLower":"ა́","lower":"ა́","wordKey":"ა́","dedupKey":"ა","collapse":"ა́","words":["ა́"],"jsTrim":"ა́","jsTrimEnd":"ა́","year":null}, +{"s":"ꭰ𞤢‍-","utf16Len":5,"asciiLower":"ꭰ𞤢‍-","lower":"ꭰ𞤢‍-","wordKey":"ꭰ𞤢‍-","dedupKey":"ꭰ𞤢‍-","collapse":"ꭰ𞤢‍-","words":["ꭰ𞤢‍-"],"jsTrim":"ꭰ𞤢‍-","jsTrimEnd":"ꭰ𞤢‍-","year":null}, +{"s":"𝐀Dž","utf16Len":3,"asciiLower":"𝐀Dž","lower":"𝐀dž","wordKey":"𝐀Dž","dedupKey":"𝐀dž","collapse":"𝐀Dž","words":["𝐀Dž"],"jsTrim":"𝐀Dž","jsTrimEnd":"𝐀Dž","year":null}, +{"s":"­𞤢","utf16Len":3,"asciiLower":"­𞤢","lower":"­𞤢","wordKey":"­𞤢","dedupKey":"­𞤢","collapse":"­𞤢","words":["­𞤢"],"jsTrim":"­𞤢","jsTrimEnd":"­𞤢","year":null}, +{"s":"'a‍ẞⒶ","utf16Len":5,"asciiLower":"'a‍ẞⒶ","lower":"'a‍ßⓐ","wordKey":"'a‍ẞⒶ","dedupKey":"'a‍ßⓐ","collapse":"'a‍ẞⒶ","words":["'a‍ẞⒶ"],"jsTrim":"'a‍ẞⒶ","jsTrimEnd":"'a‍ẞⒶ","year":null}, +{"s":":-a","utf16Len":3,"asciiLower":":-a","lower":":-a","wordKey":":-a","dedupKey":":-a","collapse":":-a","words":[":-a"],"jsTrim":":-a","jsTrimEnd":":-a","year":null}, +{"s":"ʰ-","utf16Len":2,"asciiLower":"ʰ-","lower":"ʰ-","wordKey":"ʰ-","dedupKey":"ʰ-","collapse":"ʰ-","words":["ʰ-"],"jsTrim":"ʰ-","jsTrimEnd":"ʰ-","year":null}, +{"s":"Σ𝐀აʰ","utf16Len":5,"asciiLower":"Σ𝐀აʰ","lower":"σ𝐀აʰ","wordKey":"Σ𝐀აʰ","dedupKey":"σ𝐀აʰ","collapse":"Σ𝐀აʰ","words":["Σ𝐀აʰ"],"jsTrim":"Σ𝐀აʰ","jsTrimEnd":"Σ𝐀აʰ","year":null}, +{"s":"‍ ‍აʰ","utf16Len":5,"asciiLower":"‍ ‍აʰ","lower":"‍ ‍აʰ","wordKey":"‍ ‍აʰ","dedupKey":"‍ ‍აʰ","collapse":"‍ ‍აʰ","words":["‍","‍აʰ"],"jsTrim":"‍ ‍აʰ","jsTrimEnd":"‍ ‍აʰ","year":null}, +{"s":"ʰ‍İ","utf16Len":3,"asciiLower":"ʰ‍İ","lower":"ʰ‍i̇","wordKey":"ʰ‍İ","dedupKey":"ʰ‍i","collapse":"ʰ‍İ","words":["ʰ‍İ"],"jsTrim":"ʰ‍İ","jsTrimEnd":"ʰ‍İ","year":null}, +{"s":"'ᾳDža","utf16Len":5,"asciiLower":"'ᾳDža","lower":"'ᾳdža","wordKey":"'ᾳDža","dedupKey":"'αdža","collapse":"'ᾳDža","words":["'ᾳDža"],"jsTrim":"'ᾳDža","jsTrimEnd":"'ᾳDža","year":null}, +{"s":"1ꭰ","utf16Len":2,"asciiLower":"1ꭰ","lower":"1ꭰ","wordKey":"1ꭰ","dedupKey":"1ꭰ","collapse":"1ꭰ","words":["1ꭰ"],"jsTrim":"1ꭰ","jsTrimEnd":"1ꭰ","year":null}, +{"s":"ꭰ‍ ","utf16Len":4,"asciiLower":"ꭰ‍ ","lower":"ꭰ‍ ","wordKey":"ꭰ‍ ","dedupKey":"ꭰ‍","collapse":"ꭰ‍","words":["ꭰ‍"],"jsTrim":"ꭰ‍","jsTrimEnd":"ꭰ‍","year":null}, +{"s":"':","utf16Len":2,"asciiLower":"':","lower":"':","wordKey":"'","dedupKey":"':","collapse":"':","words":["':"],"jsTrim":"':","jsTrimEnd":"':","year":null}, +{"s":"ΑΣΑ'","utf16Len":4,"asciiLower":"ΑΣΑ'","lower":"ασα'","wordKey":"ΑΣΑ'","dedupKey":"ασα'","collapse":"ΑΣΑ'","words":["ΑΣΑ'"],"jsTrim":"ΑΣΑ'","jsTrimEnd":"ΑΣΑ'","year":null}, +{"s":".ʰΣ:Σ ","utf16Len":6,"asciiLower":".ʰΣ:Σ ","lower":".ʰσ:ς ","wordKey":".ʰΣ:Σ ","dedupKey":".ʰσ:ς","collapse":".ʰΣ:Σ","words":[".ʰΣ:Σ"],"jsTrim":".ʰΣ:Σ","jsTrimEnd":".ʰΣ:Σ","year":null}, +{"s":"ᲐⒶ","utf16Len":2,"asciiLower":"ᲐⒶ","lower":"აⓐ","wordKey":"ᲐⒶ","dedupKey":"აⓐ","collapse":"ᲐⒶ","words":["ᲐⒶ"],"jsTrim":"ᲐⒶ","jsTrimEnd":"ᲐⒶ","year":null}, +{"s":"'Ꭰͅა","utf16Len":4,"asciiLower":"'Ꭰͅა","lower":"'ꭰͅა","wordKey":"'Ꭰͅა","dedupKey":"'ꭰა","collapse":"'Ꭰͅა","words":["'Ꭰͅა"],"jsTrim":"'Ꭰͅა","jsTrimEnd":"'Ꭰͅა","year":null}, +{"s":"1𝐀ꭰ𞤢𞤀'","utf16Len":9,"asciiLower":"1𝐀ꭰ𞤢𞤀'","lower":"1𝐀ꭰ𞤢𞤢'","wordKey":"1𝐀ꭰ𞤢𞤀'","dedupKey":"1𝐀ꭰ𞤢𞤢'","collapse":"1𝐀ꭰ𞤢𞤀'","words":["1𝐀ꭰ𞤢𞤀'"],"jsTrim":"1𝐀ꭰ𞤢𞤀'","jsTrimEnd":"1𝐀ꭰ𞤢𞤀'","year":null}, +{"s":"ა𞤀აა","utf16Len":5,"asciiLower":"ა𞤀აა","lower":"ა𞤢აა","wordKey":"ა𞤀აა","dedupKey":"ა𞤢აა","collapse":"ა𞤀აა","words":["ა𞤀აა"],"jsTrim":"ა𞤀აა","jsTrimEnd":"ა𞤀აა","year":null}, +{"s":"·Ꭰẞ","utf16Len":3,"asciiLower":"·Ꭰẞ","lower":"·ꭰß","wordKey":"·Ꭰẞ","dedupKey":"·ꭰß","collapse":"·Ꭰẞ","words":["·Ꭰẞ"],"jsTrim":"·Ꭰẞ","jsTrimEnd":"·Ꭰẞ","year":null}, +{"s":"ͅ𞤢α‍ᾳ","utf16Len":7,"asciiLower":"ͅ𞤢α‍ᾳ","lower":"ͅ𞤢α‍ᾳ","wordKey":"ͅ𞤢α‍ᾳ","dedupKey":"𞤢α‍α","collapse":"ͅ𞤢α‍ᾳ","words":["ͅ𞤢α‍ᾳ"],"jsTrim":"ͅ𞤢α‍ᾳ","jsTrimEnd":"ͅ𞤢α‍ᾳ","year":null}, +{"s":"ꭰʰᎠaͅ1","utf16Len":6,"asciiLower":"ꭰʰᎠaͅ1","lower":"ꭰʰꭰaͅ1","wordKey":"ꭰʰᎠaͅ1","dedupKey":"ꭰʰꭰa1","collapse":"ꭰʰᎠaͅ1","words":["ꭰʰᎠaͅ1"],"jsTrim":"ꭰʰᎠaͅ1","jsTrimEnd":"ꭰʰᎠaͅ1","year":null}, +{"s":"İİᎠ­𞤀","utf16Len":6,"asciiLower":"İİᎠ­𞤀","lower":"i̇i̇ꭰ­𞤢","wordKey":"İİᎠ­𞤀","dedupKey":"iiꭰ­𞤢","collapse":"İİᎠ­𞤀","words":["İİᎠ­𞤀"],"jsTrim":"İİᎠ­𞤀","jsTrimEnd":"İİᎠ­𞤀","year":null}, +{"s":"Ꭰ𝐀ẞ","utf16Len":4,"asciiLower":"Ꭰ𝐀ẞ","lower":"ꭰ𝐀ß","wordKey":"Ꭰ𝐀ẞ","dedupKey":"ꭰ𝐀ß","collapse":"Ꭰ𝐀ẞ","words":["Ꭰ𝐀ẞ"],"jsTrim":"Ꭰ𝐀ẞ","jsTrimEnd":"Ꭰ𝐀ẞ","year":null}, +{"s":"ΑⒶ­Ⓐ","utf16Len":4,"asciiLower":"ΑⒶ­Ⓐ","lower":"αⓐ­ⓐ","wordKey":"ΑⒶ­Ⓐ","dedupKey":"αⓐ­ⓐ","collapse":"ΑⒶ­Ⓐ","words":["ΑⒶ­Ⓐ"],"jsTrim":"ΑⒶ­Ⓐ","jsTrimEnd":"ΑⒶ­Ⓐ","year":null}, +{"s":"Α·́","utf16Len":3,"asciiLower":"Α·́","lower":"α·́","wordKey":"Α·́","dedupKey":"α·","collapse":"Α·́","words":["Α·́"],"jsTrim":"Α·́","jsTrimEnd":"Α·́","year":null}, +{"s":"-𞤀́ͅ.ʰ","utf16Len":7,"asciiLower":"-𞤀́ͅ.ʰ","lower":"-𞤢́ͅ.ʰ","wordKey":"-𞤀́ͅ.ʰ","dedupKey":"-𞤢.ʰ","collapse":"-𞤀́ͅ.ʰ","words":["-𞤀́ͅ.ʰ"],"jsTrim":"-𞤀́ͅ.ʰ","jsTrimEnd":"-𞤀́ͅ.ʰ","year":null}, +{"s":" Σ","utf16Len":2,"asciiLower":" Σ","lower":" σ","wordKey":" Σ","dedupKey":"σ","collapse":"Σ","words":["Σ"],"jsTrim":"Σ","jsTrimEnd":" Σ","year":null}, +{"s":"·ͅΑ𝐀ͅ","utf16Len":6,"asciiLower":"·ͅΑ𝐀ͅ","lower":"·ͅα𝐀ͅ","wordKey":"·ͅΑ𝐀ͅ","dedupKey":"·α𝐀","collapse":"·ͅΑ𝐀ͅ","words":["·ͅΑ𝐀ͅ"],"jsTrim":"·ͅΑ𝐀ͅ","jsTrimEnd":"·ͅΑ𝐀ͅ","year":null}, +{"s":"·Džα1","utf16Len":4,"asciiLower":"·Džα1","lower":"·džα1","wordKey":"·Džα1","dedupKey":"·džα1","collapse":"·Džα1","words":["·Džα1"],"jsTrim":"·Džα1","jsTrimEnd":"·Džα1","year":null}, +{"s":"Σ1Α-ⒶDž","utf16Len":6,"asciiLower":"Σ1Α-ⒶDž","lower":"σ1α-ⓐdž","wordKey":"Σ1Α-ⒶDž","dedupKey":"σ1α-ⓐdž","collapse":"Σ1Α-ⒶDž","words":["Σ1Α-ⒶDž"],"jsTrim":"Σ1Α-ⒶDž","jsTrimEnd":"Σ1Α-ⒶDž","year":null}, +{"s":"Σẞͅ.1'","utf16Len":6,"asciiLower":"Σẞͅ.1'","lower":"σßͅ.1'","wordKey":"Σẞͅ.1'","dedupKey":"σß.1'","collapse":"Σẞͅ.1'","words":["Σẞͅ.1'"],"jsTrim":"Σẞͅ.1'","jsTrimEnd":"Σẞͅ.1'","year":null}, +{"s":"ΑΣİ-ა","utf16Len":5,"asciiLower":"ΑΣİ-ა","lower":"ασi̇-ა","wordKey":"ΑΣİ-ა","dedupKey":"ασi-ა","collapse":"ΑΣİ-ა","words":["ΑΣİ-ა"],"jsTrim":"ΑΣİ-ა","jsTrimEnd":"ΑΣİ-ა","year":null}, +{"s":":·Აͅ-","utf16Len":5,"asciiLower":":·Აͅ-","lower":":·აͅ-","wordKey":":·Აͅ-","dedupKey":":·ა-","collapse":":·Აͅ-","words":[":·Აͅ-"],"jsTrim":":·Აͅ-","jsTrimEnd":":·Აͅ-","year":null}, +{"s":".Ⓐ­ʰ","utf16Len":4,"asciiLower":".Ⓐ­ʰ","lower":".ⓐ­ʰ","wordKey":".Ⓐ­ʰ","dedupKey":".ⓐ­ʰ","collapse":".Ⓐ­ʰ","words":[".Ⓐ­ʰ"],"jsTrim":".Ⓐ­ʰ","jsTrimEnd":".Ⓐ­ʰ","year":null}, +{"s":"́","utf16Len":1,"asciiLower":"́","lower":"́","wordKey":"́","dedupKey":"","collapse":"́","words":["́"],"jsTrim":"́","jsTrimEnd":"́","year":null}, +{"s":"ᾼა","utf16Len":3,"asciiLower":"ᾼა","lower":"ᾳა","wordKey":"ᾼა","dedupKey":"αა","collapse":"ᾼა","words":["ᾼა"],"jsTrim":"ᾼა","jsTrimEnd":"ᾼა","year":null}, +{"s":"Α.","utf16Len":2,"asciiLower":"Α.","lower":"α.","wordKey":"Α","dedupKey":"α.","collapse":"Α.","words":["Α."],"jsTrim":"Α.","jsTrimEnd":"Α.","year":null}, +{"s":"ẞa-","utf16Len":3,"asciiLower":"ẞa-","lower":"ßa-","wordKey":"ẞa-","dedupKey":"ßa-","collapse":"ẞa-","words":["ẞa-"],"jsTrim":"ẞa-","jsTrimEnd":"ẞa-","year":null}, +{"s":"Σა","utf16Len":2,"asciiLower":"Σა","lower":"σა","wordKey":"Σა","dedupKey":"σა","collapse":"Σა","words":["Σა"],"jsTrim":"Σა","jsTrimEnd":"Σა","year":null}, +{"s":"𝐀­","utf16Len":3,"asciiLower":"𝐀­","lower":"𝐀­","wordKey":"𝐀­","dedupKey":"𝐀­","collapse":"𝐀­","words":["𝐀­"],"jsTrim":"𝐀­","jsTrimEnd":"𝐀­","year":null}, +{"s":"Ⓐ-1ꭰ𞤀","utf16Len":6,"asciiLower":"Ⓐ-1ꭰ𞤀","lower":"ⓐ-1ꭰ𞤢","wordKey":"Ⓐ-1ꭰ𞤀","dedupKey":"ⓐ-1ꭰ𞤢","collapse":"Ⓐ-1ꭰ𞤀","words":["Ⓐ-1ꭰ𞤀"],"jsTrim":"Ⓐ-1ꭰ𞤀","jsTrimEnd":"Ⓐ-1ꭰ𞤀","year":null}, +{"s":" ́ͅ","utf16Len":3,"asciiLower":" ́ͅ","lower":" ́ͅ","wordKey":" ́ͅ","dedupKey":"","collapse":"́ͅ","words":["́ͅ"],"jsTrim":"́ͅ","jsTrimEnd":" ́ͅ","year":null}, +{"s":"ა.𞤀a","utf16Len":5,"asciiLower":"ა.𞤀a","lower":"ა.𞤢a","wordKey":"ა.𞤀a","dedupKey":"ა.𞤢a","collapse":"ა.𞤀a","words":["ა.𞤀a"],"jsTrim":"ა.𞤀a","jsTrimEnd":"ა.𞤀a","year":null}, +{"s":"Ა:.İ","utf16Len":4,"asciiLower":"Ა:.İ","lower":"ა:.i̇","wordKey":"Ა:.İ","dedupKey":"ა:.i","collapse":"Ა:.İ","words":["Ა:.İ"],"jsTrim":"Ა:.İ","jsTrimEnd":"Ა:.İ","year":null}, +{"s":"Dž𝐀","utf16Len":3,"asciiLower":"Dž𝐀","lower":"dž𝐀","wordKey":"Dž𝐀","dedupKey":"dž𝐀","collapse":"Dž𝐀","words":["Dž𝐀"],"jsTrim":"Dž𝐀","jsTrimEnd":"Dž𝐀","year":null}, +{"s":"ͅ‍Ა","utf16Len":3,"asciiLower":"ͅ‍Ა","lower":"ͅ‍ა","wordKey":"ͅ‍Ა","dedupKey":"‍ა","collapse":"ͅ‍Ა","words":["ͅ‍Ა"],"jsTrim":"ͅ‍Ა","jsTrimEnd":"ͅ‍Ა","year":null}, +{"s":".αΑᾳ­","utf16Len":6,"asciiLower":".αΑᾳ­","lower":".ααᾳ­","wordKey":".αΑᾳ­","dedupKey":".ααα­","collapse":".αΑᾳ­","words":[".αΑᾳ­"],"jsTrim":".αΑᾳ­","jsTrimEnd":".αΑᾳ­","year":null}, +{"s":"Ა­́αΣ","utf16Len":5,"asciiLower":"Ა­́αΣ","lower":"ა­́ας","wordKey":"Ა­́αΣ","dedupKey":"ა­ας","collapse":"Ა­́αΣ","words":["Ა­́αΣ"],"jsTrim":"Ა­́αΣ","jsTrimEnd":"Ა­́αΣ","year":null}, +{"s":"𝐀-­ꭰ","utf16Len":5,"asciiLower":"𝐀-­ꭰ","lower":"𝐀-­ꭰ","wordKey":"𝐀-­ꭰ","dedupKey":"𝐀-­ꭰ","collapse":"𝐀-­ꭰ","words":["𝐀-­ꭰ"],"jsTrim":"𝐀-­ꭰ","jsTrimEnd":"𝐀-­ꭰ","year":null}, +{"s":"a𞤢­-","utf16Len":5,"asciiLower":"a𞤢­-","lower":"a𞤢­-","wordKey":"a𞤢­-","dedupKey":"a𞤢­-","collapse":"a𞤢­-","words":["a𞤢­-"],"jsTrim":"a𞤢­-","jsTrimEnd":"a𞤢­-","year":null}, +{"s":"-ᲐᲐΣᲐ","utf16Len":5,"asciiLower":"-ᲐᲐΣᲐ","lower":"-ააσა","wordKey":"-ᲐᲐΣᲐ","dedupKey":"-ააσა","collapse":"-ᲐᲐΣᲐ","words":["-ᲐᲐΣᲐ"],"jsTrim":"-ᲐᲐΣᲐ","jsTrimEnd":"-ᲐᲐΣᲐ","year":null}, +{"s":"a:· Džა","utf16Len":6,"asciiLower":"a:· Džა","lower":"a:· džა","wordKey":"a:· Džა","dedupKey":"a:· džა","collapse":"a:· Džა","words":["a:·","Džა"],"jsTrim":"a:· Džა","jsTrimEnd":"a:· Džა","year":null}, +{"s":"'Ⓐ𝐀Σ.","utf16Len":6,"asciiLower":"'Ⓐ𝐀Σ.","lower":"'ⓐ𝐀ς.","wordKey":"'Ⓐ𝐀Σ","dedupKey":"'ⓐ𝐀ς.","collapse":"'Ⓐ𝐀Σ.","words":["'Ⓐ𝐀Σ."],"jsTrim":"'Ⓐ𝐀Σ.","jsTrimEnd":"'Ⓐ𝐀Σ.","year":null}, +{"s":"ʰα𞤀𞤀α","utf16Len":7,"asciiLower":"ʰα𞤀𞤀α","lower":"ʰα𞤢𞤢α","wordKey":"ʰα𞤀𞤀α","dedupKey":"ʰα𞤢𞤢α","collapse":"ʰα𞤀𞤀α","words":["ʰα𞤀𞤀α"],"jsTrim":"ʰα𞤀𞤀α","jsTrimEnd":"ʰα𞤀𞤀α","year":null}, +{"s":"𞤀́𝐀‍‍","utf16Len":7,"asciiLower":"𞤀́𝐀‍‍","lower":"𞤢́𝐀‍‍","wordKey":"𞤀́𝐀‍‍","dedupKey":"𞤢𝐀‍‍","collapse":"𞤀́𝐀‍‍","words":["𞤀́𝐀‍‍"],"jsTrim":"𞤀́𝐀‍‍","jsTrimEnd":"𞤀́𝐀‍‍","year":null}, +{"s":"ΣͅაⒶ́ა","utf16Len":6,"asciiLower":"ΣͅაⒶ́ა","lower":"σͅაⓐ́ა","wordKey":"ΣͅაⒶ́ა","dedupKey":"σაⓐა","collapse":"ΣͅაⒶ́ა","words":["ΣͅაⒶ́ა"],"jsTrim":"ΣͅაⒶ́ა","jsTrimEnd":"ΣͅაⒶ́ა","year":null}, +{"s":"Ა:𞤀","utf16Len":4,"asciiLower":"Ა:𞤀","lower":"ა:𞤢","wordKey":"Ა:𞤀","dedupKey":"ა:𞤢","collapse":"Ა:𞤀","words":["Ა:𞤀"],"jsTrim":"Ა:𞤀","jsTrimEnd":"Ა:𞤀","year":null}, +{"s":"́ʰⒶⒶ","utf16Len":4,"asciiLower":"́ʰⒶⒶ","lower":"́ʰⓐⓐ","wordKey":"́ʰⒶⒶ","dedupKey":"ʰⓐⓐ","collapse":"́ʰⒶⒶ","words":["́ʰⒶⒶ"],"jsTrim":"́ʰⒶⒶ","jsTrimEnd":"́ʰⒶⒶ","year":null}, +{"s":"𞤀'́აᲐ","utf16Len":6,"asciiLower":"𞤀'́აᲐ","lower":"𞤢'́აა","wordKey":"𞤀'́აᲐ","dedupKey":"𞤢'აა","collapse":"𞤀'́აᲐ","words":["𞤀'́აᲐ"],"jsTrim":"𞤀'́აᲐ","jsTrimEnd":"𞤀'́აᲐ","year":null}, +{"s":"­Აİ","utf16Len":3,"asciiLower":"­Აİ","lower":"­აi̇","wordKey":"­Აİ","dedupKey":"­აi","collapse":"­Აİ","words":["­Აİ"],"jsTrim":"­Აİ","jsTrimEnd":"­Აİ","year":null}, +{"s":"İΑꭰẞ","utf16Len":4,"asciiLower":"İΑꭰẞ","lower":"i̇αꭰß","wordKey":"İΑꭰẞ","dedupKey":"iαꭰß","collapse":"İΑꭰẞ","words":["İΑꭰẞ"],"jsTrim":"İΑꭰẞ","jsTrimEnd":"İΑꭰẞ","year":null}, +{"s":"‍́ͅDžDž","utf16Len":5,"asciiLower":"‍́ͅDžDž","lower":"‍́ͅdždž","wordKey":"‍́ͅDžDž","dedupKey":"‍dždž","collapse":"‍́ͅDžDž","words":["‍́ͅDžDž"],"jsTrim":"‍́ͅDžDž","jsTrimEnd":"‍́ͅDžDž","year":null}, +{"s":"ʰẞ","utf16Len":2,"asciiLower":"ʰẞ","lower":"ʰß","wordKey":"ʰẞ","dedupKey":"ʰß","collapse":"ʰẞ","words":["ʰẞ"],"jsTrim":"ʰẞ","jsTrimEnd":"ʰẞ","year":null}, +{"s":"1aaⒶ","utf16Len":4,"asciiLower":"1aaⒶ","lower":"1aaⓐ","wordKey":"1aaⒶ","dedupKey":"1aaⓐ","collapse":"1aaⒶ","words":["1aaⒶ"],"jsTrim":"1aaⒶ","jsTrimEnd":"1aaⒶ","year":null}, +{"s":"Ⓐ:­Σ‍·","utf16Len":6,"asciiLower":"Ⓐ:­Σ‍·","lower":"ⓐ:­ς‍·","wordKey":"Ⓐ:­Σ‍·","dedupKey":"ⓐ:­ς‍·","collapse":"Ⓐ:­Σ‍·","words":["Ⓐ:­Σ‍·"],"jsTrim":"Ⓐ:­Σ‍·","jsTrimEnd":"Ⓐ:­Σ‍·","year":null}, +{"s":"ͅDžᎠ","utf16Len":3,"asciiLower":"ͅDžᎠ","lower":"ͅdžꭰ","wordKey":"ͅDžᎠ","dedupKey":"džꭰ","collapse":"ͅDžᎠ","words":["ͅDžᎠ"],"jsTrim":"ͅDžᎠ","jsTrimEnd":"ͅDžᎠ","year":null}, +{"s":"-'","utf16Len":2,"asciiLower":"-'","lower":"-'","wordKey":"-'","dedupKey":"-'","collapse":"-'","words":["-'"],"jsTrim":"-'","jsTrimEnd":"-'","year":null}, +{"s":"ͅ‍́.ა","utf16Len":5,"asciiLower":"ͅ‍́.ა","lower":"ͅ‍́.ა","wordKey":"ͅ‍́.ა","dedupKey":"‍.ა","collapse":"ͅ‍́.ა","words":["ͅ‍́.ა"],"jsTrim":"ͅ‍́.ა","jsTrimEnd":"ͅ‍́.ა","year":null}, +{"s":"ͅᎠ","utf16Len":2,"asciiLower":"ͅᎠ","lower":"ͅꭰ","wordKey":"ͅᎠ","dedupKey":"ꭰ","collapse":"ͅᎠ","words":["ͅᎠ"],"jsTrim":"ͅᎠ","jsTrimEnd":"ͅᎠ","year":null}, +{"s":"ა: .ʰ𞤀","utf16Len":7,"asciiLower":"ა: .ʰ𞤀","lower":"ა: .ʰ𞤢","wordKey":"ა: .ʰ𞤀","dedupKey":"ა: .ʰ𞤢","collapse":"ა: .ʰ𞤀","words":["ა:",".ʰ𞤀"],"jsTrim":"ა: .ʰ𞤀","jsTrimEnd":"ა: .ʰ𞤀","year":null}, +{"s":"ΣDžaʰ","utf16Len":4,"asciiLower":"ΣDžaʰ","lower":"σdžaʰ","wordKey":"ΣDžaʰ","dedupKey":"σdžaʰ","collapse":"ΣDžaʰ","words":["ΣDžaʰ"],"jsTrim":"ΣDžaʰ","jsTrimEnd":"ΣDžaʰ","year":null}, +{"s":"ꭰDžİაᲐ","utf16Len":5,"asciiLower":"ꭰDžİაᲐ","lower":"ꭰdži̇აა","wordKey":"ꭰDžİაᲐ","dedupKey":"ꭰdžiაა","collapse":"ꭰDžİაᲐ","words":["ꭰDžİაᲐ"],"jsTrim":"ꭰDžİაᲐ","jsTrimEnd":"ꭰDžİაᲐ","year":null}, +{"s":"aა","utf16Len":2,"asciiLower":"aა","lower":"aა","wordKey":"aა","dedupKey":"aა","collapse":"aა","words":["aა"],"jsTrim":"aა","jsTrimEnd":"aა","year":null}, +{"s":":𝐀","utf16Len":3,"asciiLower":":𝐀","lower":":𝐀","wordKey":":𝐀","dedupKey":":𝐀","collapse":":𝐀","words":[":𝐀"],"jsTrim":":𝐀","jsTrimEnd":":𝐀","year":null}, +{"s":"DžͅᲐα","utf16Len":4,"asciiLower":"DžͅᲐα","lower":"džͅაα","wordKey":"DžͅᲐα","dedupKey":"džაα","collapse":"DžͅᲐα","words":["DžͅᲐα"],"jsTrim":"DžͅᲐα","jsTrimEnd":"DžͅᲐα","year":null}, +{"s":"aᎠẞꭰΑ","utf16Len":5,"asciiLower":"aᎠẞꭰΑ","lower":"aꭰßꭰα","wordKey":"aᎠẞꭰΑ","dedupKey":"aꭰßꭰα","collapse":"aᎠẞꭰΑ","words":["aᎠẞꭰΑ"],"jsTrim":"aᎠẞꭰΑ","jsTrimEnd":"aᎠẞꭰΑ","year":null}, +{"s":"ͅΣ1","utf16Len":3,"asciiLower":"ͅΣ1","lower":"ͅσ1","wordKey":"ͅΣ1","dedupKey":"σ1","collapse":"ͅΣ1","words":["ͅΣ1"],"jsTrim":"ͅΣ1","jsTrimEnd":"ͅΣ1","year":null}, +{"s":"ᲐΣaİꭰ́","utf16Len":6,"asciiLower":"ᲐΣaİꭰ́","lower":"აσai̇ꭰ́","wordKey":"ᲐΣaİꭰ́","dedupKey":"აσaiꭰ","collapse":"ᲐΣaİꭰ́","words":["ᲐΣaİꭰ́"],"jsTrim":"ᲐΣaİꭰ́","jsTrimEnd":"ᲐΣaİꭰ́","year":null}, +{"s":"𞤢ΑDž","utf16Len":4,"asciiLower":"𞤢ΑDž","lower":"𞤢αdž","wordKey":"𞤢ΑDž","dedupKey":"𞤢αdž","collapse":"𞤢ΑDž","words":["𞤢ΑDž"],"jsTrim":"𞤢ΑDž","jsTrimEnd":"𞤢ΑDž","year":null}, +{"s":"Σ- ꭰᲐა","utf16Len":6,"asciiLower":"Σ- ꭰᲐა","lower":"σ- ꭰაა","wordKey":"Σ- ꭰᲐა","dedupKey":"σ- ꭰაა","collapse":"Σ- ꭰᲐა","words":["Σ-","ꭰᲐა"],"jsTrim":"Σ- ꭰᲐა","jsTrimEnd":"Σ- ꭰᲐა","year":null}, +{"s":"'ΣⒶꭰẞ","utf16Len":5,"asciiLower":"'ΣⒶꭰẞ","lower":"'σⓐꭰß","wordKey":"'ΣⒶꭰẞ","dedupKey":"'σⓐꭰß","collapse":"'ΣⒶꭰẞ","words":["'ΣⒶꭰẞ"],"jsTrim":"'ΣⒶꭰẞ","jsTrimEnd":"'ΣⒶꭰẞ","year":null}, +{"s":"Ꭰ·Džİ𞤢","utf16Len":6,"asciiLower":"Ꭰ·Džİ𞤢","lower":"ꭰ·dži̇𞤢","wordKey":"Ꭰ·Džİ𞤢","dedupKey":"ꭰ·dži𞤢","collapse":"Ꭰ·Džİ𞤢","words":["Ꭰ·Džİ𞤢"],"jsTrim":"Ꭰ·Džİ𞤢","jsTrimEnd":"Ꭰ·Džİ𞤢","year":null}, +{"s":"ʰ·Ꭰა1ა","utf16Len":6,"asciiLower":"ʰ·Ꭰა1ა","lower":"ʰ·ꭰა1ა","wordKey":"ʰ·Ꭰა1ა","dedupKey":"ʰ·ꭰა1ა","collapse":"ʰ·Ꭰა1ა","words":["ʰ·Ꭰა1ა"],"jsTrim":"ʰ·Ꭰა1ა","jsTrimEnd":"ʰ·Ꭰა1ა","year":null}, +{"s":"𞤢İ","utf16Len":3,"asciiLower":"𞤢İ","lower":"𞤢i̇","wordKey":"𞤢İ","dedupKey":"𞤢i","collapse":"𞤢İ","words":["𞤢İ"],"jsTrim":"𞤢İ","jsTrimEnd":"𞤢İ","year":null}, +{"s":"aΑDž","utf16Len":3,"asciiLower":"aΑDž","lower":"aαdž","wordKey":"aΑDž","dedupKey":"aαdž","collapse":"aΑDž","words":["aΑDž"],"jsTrim":"aΑDž","jsTrimEnd":"aΑDž","year":null}, +{"s":"a𞤀'","utf16Len":4,"asciiLower":"a𞤀'","lower":"a𞤢'","wordKey":"a𞤀'","dedupKey":"a𞤢'","collapse":"a𞤀'","words":["a𞤀'"],"jsTrim":"a𞤀'","jsTrimEnd":"a𞤀'","year":null}, +{"s":"-ა𞤀ᲐᎠ","utf16Len":6,"asciiLower":"-ა𞤀ᲐᎠ","lower":"-ა𞤢აꭰ","wordKey":"-ა𞤀ᲐᎠ","dedupKey":"-ა𞤢აꭰ","collapse":"-ა𞤀ᲐᎠ","words":["-ა𞤀ᲐᎠ"],"jsTrim":"-ა𞤀ᲐᎠ","jsTrimEnd":"-ა𞤀ᲐᎠ","year":null}, +{"s":"aİ́","utf16Len":3,"asciiLower":"aİ́","lower":"ai̇́","wordKey":"aİ́","dedupKey":"ai","collapse":"aİ́","words":["aİ́"],"jsTrim":"aİ́","jsTrimEnd":"aİ́","year":null}, +{"s":"𞤢𞤀İა ","utf16Len":7,"asciiLower":"𞤢𞤀İა ","lower":"𞤢𞤢i̇ა ","wordKey":"𞤢𞤀İა ","dedupKey":"𞤢𞤢iა","collapse":"𞤢𞤀İა","words":["𞤢𞤀İა"],"jsTrim":"𞤢𞤀İა","jsTrimEnd":"𞤢𞤀İა","year":null}, +{"s":"ꭰͅᎠ-α","utf16Len":5,"asciiLower":"ꭰͅᎠ-α","lower":"ꭰͅꭰ-α","wordKey":"ꭰͅᎠ-α","dedupKey":"ꭰꭰ-α","collapse":"ꭰͅᎠ-α","words":["ꭰͅᎠ-α"],"jsTrim":"ꭰͅᎠ-α","jsTrimEnd":"ꭰͅᎠ-α","year":null}, +{"s":"Ⓐ ẞΑ𝐀ʰ","utf16Len":7,"asciiLower":"Ⓐ ẞΑ𝐀ʰ","lower":"ⓐ ßα𝐀ʰ","wordKey":"Ⓐ ẞΑ𝐀ʰ","dedupKey":"ⓐ ßα𝐀ʰ","collapse":"Ⓐ ẞΑ𝐀ʰ","words":["Ⓐ","ẞΑ𝐀ʰ"],"jsTrim":"Ⓐ ẞΑ𝐀ʰ","jsTrimEnd":"Ⓐ ẞΑ𝐀ʰ","year":null}, +{"s":"𞤀́Dž‍ʰ","utf16Len":6,"asciiLower":"𞤀́Dž‍ʰ","lower":"𞤢́dž‍ʰ","wordKey":"𞤀́Dž‍ʰ","dedupKey":"𞤢dž‍ʰ","collapse":"𞤀́Dž‍ʰ","words":["𞤀́Dž‍ʰ"],"jsTrim":"𞤀́Dž‍ʰ","jsTrimEnd":"𞤀́Dž‍ʰ","year":null}, +{"s":"aΣᲐΣ","utf16Len":4,"asciiLower":"aΣᲐΣ","lower":"aσაς","wordKey":"aΣᲐΣ","dedupKey":"aσაς","collapse":"aΣᲐΣ","words":["aΣᲐΣ"],"jsTrim":"aΣᲐΣ","jsTrimEnd":"aΣᲐΣ","year":null}, +{"s":"Σ‍­ẞ-","utf16Len":5,"asciiLower":"Σ‍­ẞ-","lower":"σ‍­ß-","wordKey":"Σ‍­ẞ-","dedupKey":"σ‍­ß-","collapse":"Σ‍­ẞ-","words":["Σ‍­ẞ-"],"jsTrim":"Σ‍­ẞ-","jsTrimEnd":"Σ‍­ẞ-","year":null}, +{"s":":Აͅα","utf16Len":4,"asciiLower":":Აͅα","lower":":აͅα","wordKey":":Აͅα","dedupKey":":აα","collapse":":Აͅα","words":[":Აͅα"],"jsTrim":":Აͅα","jsTrimEnd":":Აͅα","year":null}, +{"s":"Ⓐ́Ⓐ-","utf16Len":4,"asciiLower":"Ⓐ́Ⓐ-","lower":"ⓐ́ⓐ-","wordKey":"Ⓐ́Ⓐ-","dedupKey":"ⓐⓐ-","collapse":"Ⓐ́Ⓐ-","words":["Ⓐ́Ⓐ-"],"jsTrim":"Ⓐ́Ⓐ-","jsTrimEnd":"Ⓐ́Ⓐ-","year":null}, +{"s":"a𝐀","utf16Len":3,"asciiLower":"a𝐀","lower":"a𝐀","wordKey":"a𝐀","dedupKey":"a𝐀","collapse":"a𝐀","words":["a𝐀"],"jsTrim":"a𝐀","jsTrimEnd":"a𝐀","year":null}, +{"s":"Σ 𝐀","utf16Len":4,"asciiLower":"Σ 𝐀","lower":"σ 𝐀","wordKey":"Σ 𝐀","dedupKey":"σ 𝐀","collapse":"Σ 𝐀","words":["Σ","𝐀"],"jsTrim":"Σ 𝐀","jsTrimEnd":"Σ 𝐀","year":null}, +{"s":" Ⓐ́ꭰꭰ","utf16Len":5,"asciiLower":" Ⓐ́ꭰꭰ","lower":" ⓐ́ꭰꭰ","wordKey":" Ⓐ́ꭰꭰ","dedupKey":"ⓐꭰꭰ","collapse":"Ⓐ́ꭰꭰ","words":["Ⓐ́ꭰꭰ"],"jsTrim":"Ⓐ́ꭰꭰ","jsTrimEnd":" Ⓐ́ꭰꭰ","year":null}, +{"s":"ΑᾳᎠ","utf16Len":4,"asciiLower":"ΑᾳᎠ","lower":"αᾳꭰ","wordKey":"ΑᾳᎠ","dedupKey":"ααꭰ","collapse":"ΑᾳᎠ","words":["ΑᾳᎠ"],"jsTrim":"ΑᾳᎠ","jsTrimEnd":"ΑᾳᎠ","year":null}, +{"s":"'‍ꭰͅİ","utf16Len":5,"asciiLower":"'‍ꭰͅİ","lower":"'‍ꭰͅi̇","wordKey":"'‍ꭰͅİ","dedupKey":"'‍ꭰi","collapse":"'‍ꭰͅİ","words":["'‍ꭰͅİ"],"jsTrim":"'‍ꭰͅİ","jsTrimEnd":"'‍ꭰͅİ","year":null}, +{"s":"a‍ͅ𝐀","utf16Len":5,"asciiLower":"a‍ͅ𝐀","lower":"a‍ͅ𝐀","wordKey":"a‍ͅ𝐀","dedupKey":"a‍𝐀","collapse":"a‍ͅ𝐀","words":["a‍ͅ𝐀"],"jsTrim":"a‍ͅ𝐀","jsTrimEnd":"a‍ͅ𝐀","year":null}, +{"s":"Dž'","utf16Len":2,"asciiLower":"Dž'","lower":"dž'","wordKey":"Dž'","dedupKey":"dž'","collapse":"Dž'","words":["Dž'"],"jsTrim":"Dž'","jsTrimEnd":"Dž'","year":null}, +{"s":"Ꭰ·.1ͅ·","utf16Len":6,"asciiLower":"Ꭰ·.1ͅ·","lower":"ꭰ·.1ͅ·","wordKey":"Ꭰ·.1ͅ·","dedupKey":"ꭰ·.1·","collapse":"Ꭰ·.1ͅ·","words":["Ꭰ·.1ͅ·"],"jsTrim":"Ꭰ·.1ͅ·","jsTrimEnd":"Ꭰ·.1ͅ·","year":null}, +{"s":"·ΣꭰᎠẞ","utf16Len":5,"asciiLower":"·ΣꭰᎠẞ","lower":"·σꭰꭰß","wordKey":"·ΣꭰᎠẞ","dedupKey":"·σꭰꭰß","collapse":"·ΣꭰᎠẞ","words":["·ΣꭰᎠẞ"],"jsTrim":"·ΣꭰᎠẞ","jsTrimEnd":"·ΣꭰᎠẞ","year":null}, +{"s":"·Ꭰẞẞ𝐀","utf16Len":6,"asciiLower":"·Ꭰẞẞ𝐀","lower":"·ꭰßß𝐀","wordKey":"·Ꭰẞẞ𝐀","dedupKey":"·ꭰßß𝐀","collapse":"·Ꭰẞẞ𝐀","words":["·Ꭰẞẞ𝐀"],"jsTrim":"·Ꭰẞẞ𝐀","jsTrimEnd":"·Ꭰẞẞ𝐀","year":null}, +{"s":"άDž","utf16Len":3,"asciiLower":"άDž","lower":"άdž","wordKey":"άDž","dedupKey":"αdž","collapse":"άDž","words":["άDž"],"jsTrim":"άDž","jsTrimEnd":"άDž","year":null}, +{"s":"­́1ꭰꭰ","utf16Len":5,"asciiLower":"­́1ꭰꭰ","lower":"­́1ꭰꭰ","wordKey":"­́1ꭰꭰ","dedupKey":"­1ꭰꭰ","collapse":"­́1ꭰꭰ","words":["­́1ꭰꭰ"],"jsTrim":"­́1ꭰꭰ","jsTrimEnd":"­́1ꭰꭰ","year":null}, +{"s":"𞤀­ᎠDžİ1","utf16Len":7,"asciiLower":"𞤀­ᎠDžİ1","lower":"𞤢­ꭰdži̇1","wordKey":"𞤀­ᎠDžİ1","dedupKey":"𞤢­ꭰdži1","collapse":"𞤀­ᎠDžİ1","words":["𞤀­ᎠDžİ1"],"jsTrim":"𞤀­ᎠDžİ1","jsTrimEnd":"𞤀­ᎠDžİ1","year":null}, +{"s":"άΣΑ-.","utf16Len":6,"asciiLower":"άΣΑ-.","lower":"άσα-.","wordKey":"άΣΑ-","dedupKey":"ασα-.","collapse":"άΣΑ-.","words":["άΣΑ-."],"jsTrim":"άΣΑ-.","jsTrimEnd":"άΣΑ-.","year":null}, +{"s":"𝐀ꭰⒶ𞤀Ⓐꭰ","utf16Len":8,"asciiLower":"𝐀ꭰⒶ𞤀Ⓐꭰ","lower":"𝐀ꭰⓐ𞤢ⓐꭰ","wordKey":"𝐀ꭰⒶ𞤀Ⓐꭰ","dedupKey":"𝐀ꭰⓐ𞤢ⓐꭰ","collapse":"𝐀ꭰⒶ𞤀Ⓐꭰ","words":["𝐀ꭰⒶ𞤀Ⓐꭰ"],"jsTrim":"𝐀ꭰⒶ𞤀Ⓐꭰ","jsTrimEnd":"𝐀ꭰⒶ𞤀Ⓐꭰ","year":null}, +{"s":"ΣΣİΣ","utf16Len":4,"asciiLower":"ΣΣİΣ","lower":"σσi̇ς","wordKey":"ΣΣİΣ","dedupKey":"σσiς","collapse":"ΣΣİΣ","words":["ΣΣİΣ"],"jsTrim":"ΣΣİΣ","jsTrimEnd":"ΣΣİΣ","year":null}, +{"s":"𝐀ʰᲐ:α","utf16Len":6,"asciiLower":"𝐀ʰᲐ:α","lower":"𝐀ʰა:α","wordKey":"𝐀ʰᲐ:α","dedupKey":"𝐀ʰა:α","collapse":"𝐀ʰᲐ:α","words":["𝐀ʰᲐ:α"],"jsTrim":"𝐀ʰᲐ:α","jsTrimEnd":"𝐀ʰᲐ:α","year":null}, +{"s":"ꭰᲐ","utf16Len":2,"asciiLower":"ꭰᲐ","lower":"ꭰა","wordKey":"ꭰᲐ","dedupKey":"ꭰა","collapse":"ꭰᲐ","words":["ꭰᲐ"],"jsTrim":"ꭰᲐ","jsTrimEnd":"ꭰᲐ","year":null}, +{"s":"ꭰͅΣ Dž","utf16Len":5,"asciiLower":"ꭰͅΣ Dž","lower":"ꭰͅς dž","wordKey":"ꭰͅΣ Dž","dedupKey":"ꭰς dž","collapse":"ꭰͅΣ Dž","words":["ꭰͅΣ","Dž"],"jsTrim":"ꭰͅΣ Dž","jsTrimEnd":"ꭰͅΣ Dž","year":null}, +{"s":"𝐀 - Σ ","utf16Len":7,"asciiLower":"𝐀 - Σ ","lower":"𝐀 - σ ","wordKey":"𝐀 - Σ ","dedupKey":"𝐀 - σ","collapse":"𝐀 - Σ","words":["𝐀","-","Σ"],"jsTrim":"𝐀 - Σ","jsTrimEnd":"𝐀 - Σ","year":null}, +{"s":"·Ⓐ","utf16Len":2,"asciiLower":"·Ⓐ","lower":"·ⓐ","wordKey":"·Ⓐ","dedupKey":"·ⓐ","collapse":"·Ⓐ","words":["·Ⓐ"],"jsTrim":"·Ⓐ","jsTrimEnd":"·Ⓐ","year":null}, +{"s":"𝐀ა‍","utf16Len":4,"asciiLower":"𝐀ა‍","lower":"𝐀ა‍","wordKey":"𝐀ა‍","dedupKey":"𝐀ა‍","collapse":"𝐀ა‍","words":["𝐀ა‍"],"jsTrim":"𝐀ა‍","jsTrimEnd":"𝐀ა‍","year":null}, +{"s":"ͅΣᲐⒶ.","utf16Len":5,"asciiLower":"ͅΣᲐⒶ.","lower":"ͅσაⓐ.","wordKey":"ͅΣᲐⒶ","dedupKey":"σაⓐ.","collapse":"ͅΣᲐⒶ.","words":["ͅΣᲐⒶ."],"jsTrim":"ͅΣᲐⒶ.","jsTrimEnd":"ͅΣᲐⒶ.","year":null}, +{"s":"1İ1Ꭰ'𞤢","utf16Len":7,"asciiLower":"1İ1Ꭰ'𞤢","lower":"1i̇1ꭰ'𞤢","wordKey":"1İ1Ꭰ'𞤢","dedupKey":"1i1ꭰ'𞤢","collapse":"1İ1Ꭰ'𞤢","words":["1İ1Ꭰ'𞤢"],"jsTrim":"1İ1Ꭰ'𞤢","jsTrimEnd":"1İ1Ꭰ'𞤢","year":null}, +{"s":"𞤀𞤀ʰα.ẞ","utf16Len":8,"asciiLower":"𞤀𞤀ʰα.ẞ","lower":"𞤢𞤢ʰα.ß","wordKey":"𞤀𞤀ʰα.ẞ","dedupKey":"𞤢𞤢ʰα.ß","collapse":"𞤀𞤀ʰα.ẞ","words":["𞤀𞤀ʰα.ẞ"],"jsTrim":"𞤀𞤀ʰα.ẞ","jsTrimEnd":"𞤀𞤀ʰα.ẞ","year":null}, +{"s":"ꭰ𝐀‍.","utf16Len":5,"asciiLower":"ꭰ𝐀‍.","lower":"ꭰ𝐀‍.","wordKey":"ꭰ𝐀‍","dedupKey":"ꭰ𝐀‍.","collapse":"ꭰ𝐀‍.","words":["ꭰ𝐀‍."],"jsTrim":"ꭰ𝐀‍.","jsTrimEnd":"ꭰ𝐀‍.","year":null}, +{"s":"ᲐΑΣ·ა𝐀","utf16Len":7,"asciiLower":"ᲐΑΣ·ა𝐀","lower":"აασ·ა𝐀","wordKey":"ᲐΑΣ·ა𝐀","dedupKey":"აασ·ა𝐀","collapse":"ᲐΑΣ·ა𝐀","words":["ᲐΑΣ·ა𝐀"],"jsTrim":"ᲐΑΣ·ა𝐀","jsTrimEnd":"ᲐΑΣ·ა𝐀","year":null}, +{"s":"ꭰᎠ‍𞤀","utf16Len":5,"asciiLower":"ꭰᎠ‍𞤀","lower":"ꭰꭰ‍𞤢","wordKey":"ꭰᎠ‍𞤀","dedupKey":"ꭰꭰ‍𞤢","collapse":"ꭰᎠ‍𞤀","words":["ꭰᎠ‍𞤀"],"jsTrim":"ꭰᎠ‍𞤀","jsTrimEnd":"ꭰᎠ‍𞤀","year":null}, +{"s":"ʰͅ-‍Ა1","utf16Len":6,"asciiLower":"ʰͅ-‍Ა1","lower":"ʰͅ-‍ა1","wordKey":"ʰͅ-‍Ა1","dedupKey":"ʰ-‍ა1","collapse":"ʰͅ-‍Ა1","words":["ʰͅ-‍Ა1"],"jsTrim":"ʰͅ-‍Ა1","jsTrimEnd":"ʰͅ-‍Ა1","year":null}, +{"s":"ẞʰ­","utf16Len":3,"asciiLower":"ẞʰ­","lower":"ßʰ­","wordKey":"ẞʰ­","dedupKey":"ßʰ­","collapse":"ẞʰ­","words":["ẞʰ­"],"jsTrim":"ẞʰ­","jsTrimEnd":"ẞʰ­","year":null}, +{"s":":α","utf16Len":2,"asciiLower":":α","lower":":α","wordKey":":α","dedupKey":":α","collapse":":α","words":[":α"],"jsTrim":":α","jsTrimEnd":":α","year":null}, +{"s":"ʰ","utf16Len":1,"asciiLower":"ʰ","lower":"ʰ","wordKey":"ʰ","dedupKey":"ʰ","collapse":"ʰ","words":["ʰ"],"jsTrim":"ʰ","jsTrimEnd":"ʰ","year":null}, +{"s":"-𞤀Σ·","utf16Len":5,"asciiLower":"-𞤀Σ·","lower":"-𞤢ς·","wordKey":"-𞤀Σ·","dedupKey":"-𞤢ς·","collapse":"-𞤀Σ·","words":["-𞤀Σ·"],"jsTrim":"-𞤀Σ·","jsTrimEnd":"-𞤀Σ·","year":null}, +{"s":" ᲐΣⒶ ­","utf16Len":6,"asciiLower":" ᲐΣⒶ ­","lower":" აσⓐ ­","wordKey":" ᲐΣⒶ ­","dedupKey":"აσⓐ ­","collapse":"ᲐΣⒶ ­","words":["ᲐΣⒶ","­"],"jsTrim":"ᲐΣⒶ ­","jsTrimEnd":" ᲐΣⒶ ­","year":null}, +{"s":"𝐀Σα'́ͅ","utf16Len":7,"asciiLower":"𝐀Σα'́ͅ","lower":"𝐀σα'́ͅ","wordKey":"𝐀Σα'́ͅ","dedupKey":"𝐀σα'","collapse":"𝐀Σα'́ͅ","words":["𝐀Σα'́ͅ"],"jsTrim":"𝐀Σα'́ͅ","jsTrimEnd":"𝐀Σα'́ͅ","year":null}, +{"s":"-­ᲐᎠ‍","utf16Len":5,"asciiLower":"-­ᲐᎠ‍","lower":"-­აꭰ‍","wordKey":"-­ᲐᎠ‍","dedupKey":"-­აꭰ‍","collapse":"-­ᲐᎠ‍","words":["-­ᲐᎠ‍"],"jsTrim":"-­ᲐᎠ‍","jsTrimEnd":"-­ᲐᎠ‍","year":null}, +{"s":"Ა𝐀́","utf16Len":4,"asciiLower":"Ა𝐀́","lower":"ა𝐀́","wordKey":"Ა𝐀́","dedupKey":"ა𝐀","collapse":"Ა𝐀́","words":["Ა𝐀́"],"jsTrim":"Ა𝐀́","jsTrimEnd":"Ა𝐀́","year":null}, +{"s":"İ","utf16Len":1,"asciiLower":"İ","lower":"i̇","wordKey":"İ","dedupKey":"i","collapse":"İ","words":["İ"],"jsTrim":"İ","jsTrimEnd":"İ","year":null}, +{"s":"𝐀·","utf16Len":3,"asciiLower":"𝐀·","lower":"𝐀·","wordKey":"𝐀·","dedupKey":"𝐀·","collapse":"𝐀·","words":["𝐀·"],"jsTrim":"𝐀·","jsTrimEnd":"𝐀·","year":null}, +{"s":"𝐀́ẞ­Ა","utf16Len":6,"asciiLower":"𝐀́ẞ­Ა","lower":"𝐀́ß­ა","wordKey":"𝐀́ẞ­Ა","dedupKey":"𝐀ß­ა","collapse":"𝐀́ẞ­Ა","words":["𝐀́ẞ­Ა"],"jsTrim":"𝐀́ẞ­Ა","jsTrimEnd":"𝐀́ẞ­Ა","year":null}, +{"s":"ʰ.ʰ𞤢α","utf16Len":6,"asciiLower":"ʰ.ʰ𞤢α","lower":"ʰ.ʰ𞤢α","wordKey":"ʰ.ʰ𞤢α","dedupKey":"ʰ.ʰ𞤢α","collapse":"ʰ.ʰ𞤢α","words":["ʰ.ʰ𞤢α"],"jsTrim":"ʰ.ʰ𞤢α","jsTrimEnd":"ʰ.ʰ𞤢α","year":null}, +{"s":"a ­𞤢","utf16Len":5,"asciiLower":"a ­𞤢","lower":"a ­𞤢","wordKey":"a ­𞤢","dedupKey":"a ­𞤢","collapse":"a ­𞤢","words":["a","­𞤢"],"jsTrim":"a ­𞤢","jsTrimEnd":"a ­𞤢","year":null}, +{"s":"ꭰ:ͅ","utf16Len":3,"asciiLower":"ꭰ:ͅ","lower":"ꭰ:ͅ","wordKey":"ꭰ:ͅ","dedupKey":"ꭰ:","collapse":"ꭰ:ͅ","words":["ꭰ:ͅ"],"jsTrim":"ꭰ:ͅ","jsTrimEnd":"ꭰ:ͅ","year":null}, +{"s":":İ-","utf16Len":3,"asciiLower":":İ-","lower":":i̇-","wordKey":":İ-","dedupKey":":i-","collapse":":İ-","words":[":İ-"],"jsTrim":":İ-","jsTrimEnd":":İ-","year":null}, +{"s":"‍𞤀","utf16Len":3,"asciiLower":"‍𞤀","lower":"‍𞤢","wordKey":"‍𞤀","dedupKey":"‍𞤢","collapse":"‍𞤀","words":["‍𞤀"],"jsTrim":"‍𞤀","jsTrimEnd":"‍𞤀","year":null}, +{"s":"‍𞤀ΣⒶ.Ⓐ","utf16Len":7,"asciiLower":"‍𞤀ΣⒶ.Ⓐ","lower":"‍𞤢σⓐ.ⓐ","wordKey":"‍𞤀ΣⒶ.Ⓐ","dedupKey":"‍𞤢σⓐ.ⓐ","collapse":"‍𞤀ΣⒶ.Ⓐ","words":["‍𞤀ΣⒶ.Ⓐ"],"jsTrim":"‍𞤀ΣⒶ.Ⓐ","jsTrimEnd":"‍𞤀ΣⒶ.Ⓐ","year":null}, +{"s":"­𝐀𞤢ა1-","utf16Len":8,"asciiLower":"­𝐀𞤢ა1-","lower":"­𝐀𞤢ა1-","wordKey":"­𝐀𞤢ა1-","dedupKey":"­𝐀𞤢ა1-","collapse":"­𝐀𞤢ა1-","words":["­𝐀𞤢ა1-"],"jsTrim":"­𝐀𞤢ა1-","jsTrimEnd":"­𝐀𞤢ა1-","year":null}, +{"s":":ͅΣDž","utf16Len":4,"asciiLower":":ͅΣDž","lower":":ͅσdž","wordKey":":ͅΣDž","dedupKey":":σdž","collapse":":ͅΣDž","words":[":ͅΣDž"],"jsTrim":":ͅΣDž","jsTrimEnd":":ͅΣDž","year":null}, +{"s":"ẞ́ͅ1́Σ","utf16Len":6,"asciiLower":"ẞ́ͅ1́Σ","lower":"ß́ͅ1́σ","wordKey":"ẞ́ͅ1́Σ","dedupKey":"ß1σ","collapse":"ẞ́ͅ1́Σ","words":["ẞ́ͅ1́Σ"],"jsTrim":"ẞ́ͅ1́Σ","jsTrimEnd":"ẞ́ͅ1́Σ","year":null}, +{"s":"a.·ͅ.","utf16Len":5,"asciiLower":"a.·ͅ.","lower":"a.·ͅ.","wordKey":"a.·ͅ","dedupKey":"a.·.","collapse":"a.·ͅ.","words":["a.·ͅ."],"jsTrim":"a.·ͅ.","jsTrimEnd":"a.·ͅ.","year":null}, +{"s":"𞤢·'­ẞ","utf16Len":6,"asciiLower":"𞤢·'­ẞ","lower":"𞤢·'­ß","wordKey":"𞤢·'­ẞ","dedupKey":"𞤢·'­ß","collapse":"𞤢·'­ẞ","words":["𞤢·'­ẞ"],"jsTrim":"𞤢·'­ẞ","jsTrimEnd":"𞤢·'­ẞ","year":null}, +{"s":"Ꭰ'ẞ­‍","utf16Len":5,"asciiLower":"Ꭰ'ẞ­‍","lower":"ꭰ'ß­‍","wordKey":"Ꭰ'ẞ­‍","dedupKey":"ꭰ'ß­‍","collapse":"Ꭰ'ẞ­‍","words":["Ꭰ'ẞ­‍"],"jsTrim":"Ꭰ'ẞ­‍","jsTrimEnd":"Ꭰ'ẞ­‍","year":null}, +{"s":"ʰⒶẞ","utf16Len":3,"asciiLower":"ʰⒶẞ","lower":"ʰⓐß","wordKey":"ʰⒶẞ","dedupKey":"ʰⓐß","collapse":"ʰⒶẞ","words":["ʰⒶẞ"],"jsTrim":"ʰⒶẞ","jsTrimEnd":"ʰⒶẞ","year":null}, +{"s":"1ΣΣ𞤢ẞa","utf16Len":7,"asciiLower":"1ΣΣ𞤢ẞa","lower":"1σσ𞤢ßa","wordKey":"1ΣΣ𞤢ẞa","dedupKey":"1σσ𞤢ßa","collapse":"1ΣΣ𞤢ẞa","words":["1ΣΣ𞤢ẞa"],"jsTrim":"1ΣΣ𞤢ẞa","jsTrimEnd":"1ΣΣ𞤢ẞa","year":null}, +{"s":"Ა ","utf16Len":2,"asciiLower":"Ა ","lower":"ა ","wordKey":"Ა ","dedupKey":"ა","collapse":"Ა","words":["Ა"],"jsTrim":"Ა","jsTrimEnd":"Ა","year":null}, +{"s":"ʰꭰ­Σ𝐀'","utf16Len":7,"asciiLower":"ʰꭰ­Σ𝐀'","lower":"ʰꭰ­σ𝐀'","wordKey":"ʰꭰ­Σ𝐀'","dedupKey":"ʰꭰ­σ𝐀'","collapse":"ʰꭰ­Σ𝐀'","words":["ʰꭰ­Σ𝐀'"],"jsTrim":"ʰꭰ­Σ𝐀'","jsTrimEnd":"ʰꭰ­Σ𝐀'","year":null}, +{"s":"ʰ𞤀Σ","utf16Len":4,"asciiLower":"ʰ𞤀Σ","lower":"ʰ𞤢ς","wordKey":"ʰ𞤀Σ","dedupKey":"ʰ𞤢ς","collapse":"ʰ𞤀Σ","words":["ʰ𞤀Σ"],"jsTrim":"ʰ𞤀Σ","jsTrimEnd":"ʰ𞤀Σ","year":null}, +{"s":"́Ⓐͅ","utf16Len":3,"asciiLower":"́Ⓐͅ","lower":"́ⓐͅ","wordKey":"́Ⓐͅ","dedupKey":"ⓐ","collapse":"́Ⓐͅ","words":["́Ⓐͅ"],"jsTrim":"́Ⓐͅ","jsTrimEnd":"́Ⓐͅ","year":null}, +{"s":"𞤢­Σ","utf16Len":4,"asciiLower":"𞤢­Σ","lower":"𞤢­ς","wordKey":"𞤢­Σ","dedupKey":"𞤢­ς","collapse":"𞤢­Σ","words":["𞤢­Σ"],"jsTrim":"𞤢­Σ","jsTrimEnd":"𞤢­Σ","year":null}, +{"s":"ꭰΣ-Σ.","utf16Len":5,"asciiLower":"ꭰΣ-Σ.","lower":"ꭰς-σ.","wordKey":"ꭰΣ-Σ","dedupKey":"ꭰς-σ.","collapse":"ꭰΣ-Σ.","words":["ꭰΣ-Σ."],"jsTrim":"ꭰΣ-Σ.","jsTrimEnd":"ꭰΣ-Σ.","year":null}, +{"s":":ͅ­Ꭰ","utf16Len":4,"asciiLower":":ͅ­Ꭰ","lower":":ͅ­ꭰ","wordKey":":ͅ­Ꭰ","dedupKey":":­ꭰ","collapse":":ͅ­Ꭰ","words":[":ͅ­Ꭰ"],"jsTrim":":ͅ­Ꭰ","jsTrimEnd":":ͅ­Ꭰ","year":null}, +{"s":" :Ა𝐀ͅ ","utf16Len":7,"asciiLower":" :Ა𝐀ͅ ","lower":" :ა𝐀ͅ ","wordKey":" :Ა𝐀ͅ ","dedupKey":":ა𝐀","collapse":":Ა𝐀ͅ","words":[":Ა𝐀ͅ"],"jsTrim":":Ა𝐀ͅ","jsTrimEnd":" :Ა𝐀ͅ","year":null}, +{"s":"ꭰ1𞤢","utf16Len":4,"asciiLower":"ꭰ1𞤢","lower":"ꭰ1𞤢","wordKey":"ꭰ1𞤢","dedupKey":"ꭰ1𞤢","collapse":"ꭰ1𞤢","words":["ꭰ1𞤢"],"jsTrim":"ꭰ1𞤢","jsTrimEnd":"ꭰ1𞤢","year":null}, +{"s":"აDžꭰʰ Σ","utf16Len":6,"asciiLower":"აDžꭰʰ Σ","lower":"აdžꭰʰ σ","wordKey":"აDžꭰʰ Σ","dedupKey":"აdžꭰʰ σ","collapse":"აDžꭰʰ Σ","words":["აDžꭰʰ","Σ"],"jsTrim":"აDžꭰʰ Σ","jsTrimEnd":"აDžꭰʰ Σ","year":null}, +{"s":"Dž‍­𞤢 ","utf16Len":6,"asciiLower":"Dž‍­𞤢 ","lower":"dž‍­𞤢 ","wordKey":"Dž‍­𞤢 ","dedupKey":"dž‍­𞤢","collapse":"Dž‍­𞤢","words":["Dž‍­𞤢"],"jsTrim":"Dž‍­𞤢","jsTrimEnd":"Dž‍­𞤢","year":null}, +{"s":"'-­İ𝐀","utf16Len":6,"asciiLower":"'-­İ𝐀","lower":"'-­i̇𝐀","wordKey":"'-­İ𝐀","dedupKey":"'-­i𝐀","collapse":"'-­İ𝐀","words":["'-­İ𝐀"],"jsTrim":"'-­İ𝐀","jsTrimEnd":"'-­İ𝐀","year":null}, +{"s":"𞤢Ა","utf16Len":3,"asciiLower":"𞤢Ა","lower":"𞤢ა","wordKey":"𞤢Ა","dedupKey":"𞤢ა","collapse":"𞤢Ა","words":["𞤢Ა"],"jsTrim":"𞤢Ა","jsTrimEnd":"𞤢Ა","year":null}, +{"s":"İ­1 Dž","utf16Len":5,"asciiLower":"İ­1 Dž","lower":"i̇­1 dž","wordKey":"İ­1 Dž","dedupKey":"i­1 dž","collapse":"İ­1 Dž","words":["İ­1","Dž"],"jsTrim":"İ­1 Dž","jsTrimEnd":"İ­1 Dž","year":null}, +{"s":"ͅᎠ:","utf16Len":3,"asciiLower":"ͅᎠ:","lower":"ͅꭰ:","wordKey":"ͅᎠ","dedupKey":"ꭰ:","collapse":"ͅᎠ:","words":["ͅᎠ:"],"jsTrim":"ͅᎠ:","jsTrimEnd":"ͅᎠ:","year":null}, +{"s":"ᲐⒶ·‍ꭰͅ","utf16Len":6,"asciiLower":"ᲐⒶ·‍ꭰͅ","lower":"აⓐ·‍ꭰͅ","wordKey":"ᲐⒶ·‍ꭰͅ","dedupKey":"აⓐ·‍ꭰ","collapse":"ᲐⒶ·‍ꭰͅ","words":["ᲐⒶ·‍ꭰͅ"],"jsTrim":"ᲐⒶ·‍ꭰͅ","jsTrimEnd":"ᲐⒶ·‍ꭰͅ","year":null}, +{"s":"აİ‍Džა","utf16Len":5,"asciiLower":"აİ‍Džა","lower":"აi̇‍džა","wordKey":"აİ‍Džა","dedupKey":"აi‍džა","collapse":"აİ‍Džა","words":["აİ‍Džა"],"jsTrim":"აİ‍Džა","jsTrimEnd":"აİ‍Džა","year":null}, +{"s":"ꭰͅ:","utf16Len":3,"asciiLower":"ꭰͅ:","lower":"ꭰͅ:","wordKey":"ꭰͅ","dedupKey":"ꭰ:","collapse":"ꭰͅ:","words":["ꭰͅ:"],"jsTrim":"ꭰͅ:","jsTrimEnd":"ꭰͅ:","year":null}, +{"s":"ᲐᎠ'ẞͅ","utf16Len":5,"asciiLower":"ᲐᎠ'ẞͅ","lower":"აꭰ'ßͅ","wordKey":"ᲐᎠ'ẞͅ","dedupKey":"აꭰ'ß","collapse":"ᲐᎠ'ẞͅ","words":["ᲐᎠ'ẞͅ"],"jsTrim":"ᲐᎠ'ẞͅ","jsTrimEnd":"ᲐᎠ'ẞͅ","year":null}, +{"s":"𝐀αΣ‍𝐀","utf16Len":7,"asciiLower":"𝐀αΣ‍𝐀","lower":"𝐀ασ‍𝐀","wordKey":"𝐀αΣ‍𝐀","dedupKey":"𝐀ασ‍𝐀","collapse":"𝐀αΣ‍𝐀","words":["𝐀αΣ‍𝐀"],"jsTrim":"𝐀αΣ‍𝐀","jsTrimEnd":"𝐀αΣ‍𝐀","year":null}, +{"s":"ͅᎠΣ́‍","utf16Len":5,"asciiLower":"ͅᎠΣ́‍","lower":"ͅꭰς́‍","wordKey":"ͅᎠΣ́‍","dedupKey":"ꭰς‍","collapse":"ͅᎠΣ́‍","words":["ͅᎠΣ́‍"],"jsTrim":"ͅᎠΣ́‍","jsTrimEnd":"ͅᎠΣ́‍","year":null}, +{"s":"𞤀𞤢α'ΑΣ","utf16Len":8,"asciiLower":"𞤀𞤢α'ΑΣ","lower":"𞤢𞤢α'ας","wordKey":"𞤀𞤢α'ΑΣ","dedupKey":"𞤢𞤢α'ας","collapse":"𞤀𞤢α'ΑΣ","words":["𞤀𞤢α'ΑΣ"],"jsTrim":"𞤀𞤢α'ΑΣ","jsTrimEnd":"𞤀𞤢α'ΑΣ","year":null}, +{"s":"αა-","utf16Len":3,"asciiLower":"αა-","lower":"αა-","wordKey":"αა-","dedupKey":"αა-","collapse":"αა-","words":["αა-"],"jsTrim":"αა-","jsTrimEnd":"αა-","year":null}, +{"s":"'İაαᲐ","utf16Len":5,"asciiLower":"'İაαᲐ","lower":"'i̇აαა","wordKey":"'İაαᲐ","dedupKey":"'iაαა","collapse":"'İაαᲐ","words":["'İაαᲐ"],"jsTrim":"'İაαᲐ","jsTrimEnd":"'İაαᲐ","year":null}, +{"s":"ꭰ𞤀'İ‍","utf16Len":6,"asciiLower":"ꭰ𞤀'İ‍","lower":"ꭰ𞤢'i̇‍","wordKey":"ꭰ𞤀'İ‍","dedupKey":"ꭰ𞤢'i‍","collapse":"ꭰ𞤀'İ‍","words":["ꭰ𞤀'İ‍"],"jsTrim":"ꭰ𞤀'İ‍","jsTrimEnd":"ꭰ𞤀'İ‍","year":null}, +{"s":"'İ:ꭰ","utf16Len":4,"asciiLower":"'İ:ꭰ","lower":"'i̇:ꭰ","wordKey":"'İ:ꭰ","dedupKey":"'i:ꭰ","collapse":"'İ:ꭰ","words":["'İ:ꭰ"],"jsTrim":"'İ:ꭰ","jsTrimEnd":"'İ:ꭰ","year":null}, +{"s":" აẞ‍Ა𞤀","utf16Len":7,"asciiLower":" აẞ‍Ა𞤀","lower":" აß‍ა𞤢","wordKey":" აẞ‍Ა𞤀","dedupKey":"აß‍ა𞤢","collapse":"აẞ‍Ა𞤀","words":["აẞ‍Ა𞤀"],"jsTrim":"აẞ‍Ა𞤀","jsTrimEnd":" აẞ‍Ა𞤀","year":null}, +{"s":"a𞤢.Α.Σ","utf16Len":7,"asciiLower":"a𞤢.Α.Σ","lower":"a𞤢.α.ς","wordKey":"a𞤢.Α.Σ","dedupKey":"a𞤢.α.ς","collapse":"a𞤢.Α.Σ","words":["a𞤢.Α.Σ"],"jsTrim":"a𞤢.Α.Σ","jsTrimEnd":"a𞤢.Α.Σ","year":null}, +{"s":"Ꭰ·𞤢ẞͅ","utf16Len":6,"asciiLower":"Ꭰ·𞤢ẞͅ","lower":"ꭰ·𞤢ßͅ","wordKey":"Ꭰ·𞤢ẞͅ","dedupKey":"ꭰ·𞤢ß","collapse":"Ꭰ·𞤢ẞͅ","words":["Ꭰ·𞤢ẞͅ"],"jsTrim":"Ꭰ·𞤢ẞͅ","jsTrimEnd":"Ꭰ·𞤢ẞͅ","year":null}, +{"s":"Ა-ΣẞᲐ","utf16Len":5,"asciiLower":"Ა-ΣẞᲐ","lower":"ა-σßა","wordKey":"Ა-ΣẞᲐ","dedupKey":"ა-σßა","collapse":"Ა-ΣẞᲐ","words":["Ა-ΣẞᲐ"],"jsTrim":"Ა-ΣẞᲐ","jsTrimEnd":"Ა-ΣẞᲐ","year":null}, +{"s":"𞤀ა·.‍","utf16Len":6,"asciiLower":"𞤀ა·.‍","lower":"𞤢ა·.‍","wordKey":"𞤀ა·.‍","dedupKey":"𞤢ა·.‍","collapse":"𞤀ა·.‍","words":["𞤀ა·.‍"],"jsTrim":"𞤀ა·.‍","jsTrimEnd":"𞤀ა·.‍","year":null}, +{"s":"ẞ́","utf16Len":2,"asciiLower":"ẞ́","lower":"ß́","wordKey":"ẞ́","dedupKey":"ß","collapse":"ẞ́","words":["ẞ́"],"jsTrim":"ẞ́","jsTrimEnd":"ẞ́","year":null}, +{"s":"DžʰΣΣ","utf16Len":4,"asciiLower":"DžʰΣΣ","lower":"džʰσς","wordKey":"DžʰΣΣ","dedupKey":"džʰσς","collapse":"DžʰΣΣ","words":["DžʰΣΣ"],"jsTrim":"DžʰΣΣ","jsTrimEnd":"DžʰΣΣ","year":null}, +{"s":" Ა","utf16Len":2,"asciiLower":" Ა","lower":" ა","wordKey":" Ა","dedupKey":"ა","collapse":"Ა","words":["Ა"],"jsTrim":"Ა","jsTrimEnd":" Ა","year":null}, +{"s":"·:α.","utf16Len":4,"asciiLower":"·:α.","lower":"·:α.","wordKey":"·:α","dedupKey":"·:α.","collapse":"·:α.","words":["·:α."],"jsTrim":"·:α.","jsTrimEnd":"·:α.","year":null}, +{"s":"ꭰ .Σ-","utf16Len":5,"asciiLower":"ꭰ .Σ-","lower":"ꭰ .σ-","wordKey":"ꭰ .Σ-","dedupKey":"ꭰ .σ-","collapse":"ꭰ .Σ-","words":["ꭰ",".Σ-"],"jsTrim":"ꭰ .Σ-","jsTrimEnd":"ꭰ .Σ-","year":null}, +{"s":"'αʰⒶꭰ1","utf16Len":6,"asciiLower":"'αʰⒶꭰ1","lower":"'αʰⓐꭰ1","wordKey":"'αʰⒶꭰ1","dedupKey":"'αʰⓐꭰ1","collapse":"'αʰⒶꭰ1","words":["'αʰⒶꭰ1"],"jsTrim":"'αʰⒶꭰ1","jsTrimEnd":"'αʰⒶꭰ1","year":null}, +{"s":"ͅ ΣʰΣ","utf16Len":5,"asciiLower":"ͅ ΣʰΣ","lower":"ͅ σʰς","wordKey":"ͅ ΣʰΣ","dedupKey":"σʰς","collapse":"ͅ ΣʰΣ","words":["ͅ","ΣʰΣ"],"jsTrim":"ͅ ΣʰΣ","jsTrimEnd":"ͅ ΣʰΣ","year":null}, +{"s":"­'","utf16Len":2,"asciiLower":"­'","lower":"­'","wordKey":"­'","dedupKey":"­'","collapse":"­'","words":["­'"],"jsTrim":"­'","jsTrimEnd":"­'","year":null}, +{"s":"İა‍'Ꭰ","utf16Len":5,"asciiLower":"İა‍'Ꭰ","lower":"i̇ა‍'ꭰ","wordKey":"İა‍'Ꭰ","dedupKey":"iა‍'ꭰ","collapse":"İა‍'Ꭰ","words":["İა‍'Ꭰ"],"jsTrim":"İა‍'Ꭰ","jsTrimEnd":"İა‍'Ꭰ","year":null}, +{"s":"ᎠᲐİ1́","utf16Len":5,"asciiLower":"ᎠᲐİ1́","lower":"ꭰაi̇1́","wordKey":"ᎠᲐİ1́","dedupKey":"ꭰაi1","collapse":"ᎠᲐİ1́","words":["ᎠᲐİ1́"],"jsTrim":"ᎠᲐİ1́","jsTrimEnd":"ᎠᲐİ1́","year":null}, +{"s":":ꭰ𞤢Ꭰ𝐀‍","utf16Len":8,"asciiLower":":ꭰ𞤢Ꭰ𝐀‍","lower":":ꭰ𞤢ꭰ𝐀‍","wordKey":":ꭰ𞤢Ꭰ𝐀‍","dedupKey":":ꭰ𞤢ꭰ𝐀‍","collapse":":ꭰ𞤢Ꭰ𝐀‍","words":[":ꭰ𞤢Ꭰ𝐀‍"],"jsTrim":":ꭰ𞤢Ꭰ𝐀‍","jsTrimEnd":":ꭰ𞤢Ꭰ𝐀‍","year":null}, +{"s":"­Ა‍́","utf16Len":4,"asciiLower":"­Ა‍́","lower":"­ა‍́","wordKey":"­Ა‍́","dedupKey":"­ა‍","collapse":"­Ა‍́","words":["­Ა‍́"],"jsTrim":"­Ა‍́","jsTrimEnd":"­Ა‍́","year":null}, +{"s":"ͅ𞤢‍Ꭰ·Ⓐ","utf16Len":7,"asciiLower":"ͅ𞤢‍Ꭰ·Ⓐ","lower":"ͅ𞤢‍ꭰ·ⓐ","wordKey":"ͅ𞤢‍Ꭰ·Ⓐ","dedupKey":"𞤢‍ꭰ·ⓐ","collapse":"ͅ𞤢‍Ꭰ·Ⓐ","words":["ͅ𞤢‍Ꭰ·Ⓐ"],"jsTrim":"ͅ𞤢‍Ꭰ·Ⓐ","jsTrimEnd":"ͅ𞤢‍Ꭰ·Ⓐ","year":null}, +{"s":"ꭰ́İ","utf16Len":3,"asciiLower":"ꭰ́İ","lower":"ꭰ́i̇","wordKey":"ꭰ́İ","dedupKey":"ꭰi","collapse":"ꭰ́İ","words":["ꭰ́İ"],"jsTrim":"ꭰ́İ","jsTrimEnd":"ꭰ́İ","year":null}, +{"s":"'aα ","utf16Len":4,"asciiLower":"'aα ","lower":"'aα ","wordKey":"'aα ","dedupKey":"'aα","collapse":"'aα","words":["'aα"],"jsTrim":"'aα","jsTrimEnd":"'aα","year":null}, +{"s":"İ.ꭰαꭰ1","utf16Len":6,"asciiLower":"İ.ꭰαꭰ1","lower":"i̇.ꭰαꭰ1","wordKey":"İ.ꭰαꭰ1","dedupKey":"i.ꭰαꭰ1","collapse":"İ.ꭰαꭰ1","words":["İ.ꭰαꭰ1"],"jsTrim":"İ.ꭰαꭰ1","jsTrimEnd":"İ.ꭰαꭰ1","year":null}, +{"s":"Α11ა𝐀","utf16Len":6,"asciiLower":"Α11ა𝐀","lower":"α11ა𝐀","wordKey":"Α11ა𝐀","dedupKey":"α11ა𝐀","collapse":"Α11ა𝐀","words":["Α11ა𝐀"],"jsTrim":"Α11ა𝐀","jsTrimEnd":"Α11ა𝐀","year":null}, +{"s":"-ά","utf16Len":3,"asciiLower":"-ά","lower":"-ά","wordKey":"-ά","dedupKey":"-α","collapse":"-ά","words":["-ά"],"jsTrim":"-ά","jsTrimEnd":"-ά","year":null}, +{"s":"­́Ⓐ­","utf16Len":4,"asciiLower":"­́Ⓐ­","lower":"­́ⓐ­","wordKey":"­́Ⓐ­","dedupKey":"­ⓐ­","collapse":"­́Ⓐ­","words":["­́Ⓐ­"],"jsTrim":"­́Ⓐ­","jsTrimEnd":"­́Ⓐ­","year":null}, +{"s":"­𞤀1'","utf16Len":5,"asciiLower":"­𞤀1'","lower":"­𞤢1'","wordKey":"­𞤀1'","dedupKey":"­𞤢1'","collapse":"­𞤀1'","words":["­𞤀1'"],"jsTrim":"­𞤀1'","jsTrimEnd":"­𞤀1'","year":null}, +{"s":"Σ́ა𝐀","utf16Len":5,"asciiLower":"Σ́ა𝐀","lower":"σ́ა𝐀","wordKey":"Σ́ა𝐀","dedupKey":"σა𝐀","collapse":"Σ́ა𝐀","words":["Σ́ა𝐀"],"jsTrim":"Σ́ა𝐀","jsTrimEnd":"Σ́ა𝐀","year":null}, +{"s":"Აẞİ","utf16Len":3,"asciiLower":"Აẞİ","lower":"აßi̇","wordKey":"Აẞİ","dedupKey":"აßi","collapse":"Აẞİ","words":["Აẞİ"],"jsTrim":"Აẞİ","jsTrimEnd":"Აẞİ","year":null}, +{"s":"'𞤢ΣⒶ·","utf16Len":6,"asciiLower":"'𞤢ΣⒶ·","lower":"'𞤢σⓐ·","wordKey":"'𞤢ΣⒶ·","dedupKey":"'𞤢σⓐ·","collapse":"'𞤢ΣⒶ·","words":["'𞤢ΣⒶ·"],"jsTrim":"'𞤢ΣⒶ·","jsTrimEnd":"'𞤢ΣⒶ·","year":null}, +{"s":"­Σ'‍","utf16Len":4,"asciiLower":"­Σ'‍","lower":"­σ'‍","wordKey":"­Σ'‍","dedupKey":"­σ'‍","collapse":"­Σ'‍","words":["­Σ'‍"],"jsTrim":"­Σ'‍","jsTrimEnd":"­Σ'‍","year":null}, +{"s":"a𝐀aᲐ́","utf16Len":6,"asciiLower":"a𝐀aᲐ́","lower":"a𝐀aა́","wordKey":"a𝐀aᲐ́","dedupKey":"a𝐀aა","collapse":"a𝐀aᲐ́","words":["a𝐀aᲐ́"],"jsTrim":"a𝐀aᲐ́","jsTrimEnd":"a𝐀aᲐ́","year":null}, +{"s":":.","utf16Len":2,"asciiLower":":.","lower":":.","wordKey":":","dedupKey":":.","collapse":":.","words":[":."],"jsTrim":":.","jsTrimEnd":":.","year":null}, +{"s":"á'Ა𝐀","utf16Len":6,"asciiLower":"á'Ა𝐀","lower":"á'ა𝐀","wordKey":"á'Ა𝐀","dedupKey":"a'ა𝐀","collapse":"á'Ა𝐀","words":["á'Ა𝐀"],"jsTrim":"á'Ა𝐀","jsTrimEnd":"á'Ა𝐀","year":null}, +{"s":"́Σa","utf16Len":3,"asciiLower":"́Σa","lower":"́σa","wordKey":"́Σa","dedupKey":"σa","collapse":"́Σa","words":["́Σa"],"jsTrim":"́Σa","jsTrimEnd":"́Σa","year":null}, +{"s":"α.İⒶ","utf16Len":4,"asciiLower":"α.İⒶ","lower":"α.i̇ⓐ","wordKey":"α.İⒶ","dedupKey":"α.iⓐ","collapse":"α.İⒶ","words":["α.İⒶ"],"jsTrim":"α.İⒶ","jsTrimEnd":"α.İⒶ","year":null}, +{"s":".'·Ა","utf16Len":4,"asciiLower":".'·Ა","lower":".'·ა","wordKey":".'·Ა","dedupKey":".'·ა","collapse":".'·Ა","words":[".'·Ა"],"jsTrim":".'·Ა","jsTrimEnd":".'·Ა","year":null}, +{"s":"Dž‍.‍a","utf16Len":5,"asciiLower":"Dž‍.‍a","lower":"dž‍.‍a","wordKey":"Dž‍.‍a","dedupKey":"dž‍.‍a","collapse":"Dž‍.‍a","words":["Dž‍.‍a"],"jsTrim":"Dž‍.‍a","jsTrimEnd":"Dž‍.‍a","year":null}, +{"s":"İⒶ‍İΑ𞤀","utf16Len":7,"asciiLower":"İⒶ‍İΑ𞤀","lower":"i̇ⓐ‍i̇α𞤢","wordKey":"İⒶ‍İΑ𞤀","dedupKey":"iⓐ‍iα𞤢","collapse":"İⒶ‍İΑ𞤀","words":["İⒶ‍İΑ𞤀"],"jsTrim":"İⒶ‍İΑ𞤀","jsTrimEnd":"İⒶ‍İΑ𞤀","year":null}, +{"s":"́:𞤢ͅʰΣ","utf16Len":7,"asciiLower":"́:𞤢ͅʰΣ","lower":"́:𞤢ͅʰς","wordKey":"́:𞤢ͅʰΣ","dedupKey":":𞤢ʰς","collapse":"́:𞤢ͅʰΣ","words":["́:𞤢ͅʰΣ"],"jsTrim":"́:𞤢ͅʰΣ","jsTrimEnd":"́:𞤢ͅʰΣ","year":null}, +{"s":"‍α1","utf16Len":3,"asciiLower":"‍α1","lower":"‍α1","wordKey":"‍α1","dedupKey":"‍α1","collapse":"‍α1","words":["‍α1"],"jsTrim":"‍α1","jsTrimEnd":"‍α1","year":null}, +{"s":"ͅΣΣα","utf16Len":4,"asciiLower":"ͅΣΣα","lower":"ͅσσα","wordKey":"ͅΣΣα","dedupKey":"σσα","collapse":"ͅΣΣα","words":["ͅΣΣα"],"jsTrim":"ͅΣΣα","jsTrimEnd":"ͅΣΣα","year":null}, +{"s":"·aa -Ⓐ","utf16Len":6,"asciiLower":"·aa -Ⓐ","lower":"·aa -ⓐ","wordKey":"·aa -Ⓐ","dedupKey":"·aa -ⓐ","collapse":"·aa -Ⓐ","words":["·aa","-Ⓐ"],"jsTrim":"·aa -Ⓐ","jsTrimEnd":"·aa -Ⓐ","year":null}, +{"s":"́­.𞤀Σ.","utf16Len":7,"asciiLower":"́­.𞤀Σ.","lower":"́­.𞤢ς.","wordKey":"́­.𞤀Σ","dedupKey":"­.𞤢ς.","collapse":"́­.𞤀Σ.","words":["́­.𞤀Σ."],"jsTrim":"́­.𞤀Σ.","jsTrimEnd":"́­.𞤀Σ.","year":null}, +{"s":"ααẞ.Ⓐ","utf16Len":5,"asciiLower":"ααẞ.Ⓐ","lower":"ααß.ⓐ","wordKey":"ααẞ.Ⓐ","dedupKey":"ααß.ⓐ","collapse":"ααẞ.Ⓐ","words":["ααẞ.Ⓐ"],"jsTrim":"ααẞ.Ⓐ","jsTrimEnd":"ααẞ.Ⓐ","year":null}, +{"s":":ʰ𝐀","utf16Len":4,"asciiLower":":ʰ𝐀","lower":":ʰ𝐀","wordKey":":ʰ𝐀","dedupKey":":ʰ𝐀","collapse":":ʰ𝐀","words":[":ʰ𝐀"],"jsTrim":":ʰ𝐀","jsTrimEnd":":ʰ𝐀","year":null}, +{"s":"Αაʰꭰ","utf16Len":4,"asciiLower":"Αაʰꭰ","lower":"αაʰꭰ","wordKey":"Αაʰꭰ","dedupKey":"αაʰꭰ","collapse":"Αაʰꭰ","words":["Αაʰꭰ"],"jsTrim":"Αაʰꭰ","jsTrimEnd":"Αაʰꭰ","year":null}, +{"s":"1Ꭰ","utf16Len":2,"asciiLower":"1Ꭰ","lower":"1ꭰ","wordKey":"1Ꭰ","dedupKey":"1ꭰ","collapse":"1Ꭰ","words":["1Ꭰ"],"jsTrim":"1Ꭰ","jsTrimEnd":"1Ꭰ","year":null}, +{"s":"Ⓐ𞤀𝐀Dž‍­","utf16Len":8,"asciiLower":"Ⓐ𞤀𝐀Dž‍­","lower":"ⓐ𞤢𝐀dž‍­","wordKey":"Ⓐ𞤀𝐀Dž‍­","dedupKey":"ⓐ𞤢𝐀dž‍­","collapse":"Ⓐ𞤀𝐀Dž‍­","words":["Ⓐ𞤀𝐀Dž‍­"],"jsTrim":"Ⓐ𞤀𝐀Dž‍­","jsTrimEnd":"Ⓐ𞤀𝐀Dž‍­","year":null}, +{"s":" ͅⒶ","utf16Len":3,"asciiLower":" ͅⒶ","lower":" ͅⓐ","wordKey":" ͅⒶ","dedupKey":"ⓐ","collapse":"ͅⒶ","words":["ͅⒶ"],"jsTrim":"ͅⒶ","jsTrimEnd":" ͅⒶ","year":null}, +{"s":"‍Ꭰ𝐀ꭰ","utf16Len":5,"asciiLower":"‍Ꭰ𝐀ꭰ","lower":"‍ꭰ𝐀ꭰ","wordKey":"‍Ꭰ𝐀ꭰ","dedupKey":"‍ꭰ𝐀ꭰ","collapse":"‍Ꭰ𝐀ꭰ","words":["‍Ꭰ𝐀ꭰ"],"jsTrim":"‍Ꭰ𝐀ꭰ","jsTrimEnd":"‍Ꭰ𝐀ꭰ","year":null}, +{"s":"1ʰ𞤢·Ꭰ","utf16Len":6,"asciiLower":"1ʰ𞤢·Ꭰ","lower":"1ʰ𞤢·ꭰ","wordKey":"1ʰ𞤢·Ꭰ","dedupKey":"1ʰ𞤢·ꭰ","collapse":"1ʰ𞤢·Ꭰ","words":["1ʰ𞤢·Ꭰ"],"jsTrim":"1ʰ𞤢·Ꭰ","jsTrimEnd":"1ʰ𞤢·Ꭰ","year":null}, +{"s":"-1-","utf16Len":3,"asciiLower":"-1-","lower":"-1-","wordKey":"-1-","dedupKey":"-1-","collapse":"-1-","words":["-1-"],"jsTrim":"-1-","jsTrimEnd":"-1-","year":null}, +{"s":"'𝐀ʰ Აa","utf16Len":7,"asciiLower":"'𝐀ʰ Აa","lower":"'𝐀ʰ აa","wordKey":"'𝐀ʰ Აa","dedupKey":"'𝐀ʰ აa","collapse":"'𝐀ʰ Აa","words":["'𝐀ʰ","Აa"],"jsTrim":"'𝐀ʰ Აa","jsTrimEnd":"'𝐀ʰ Აa","year":null}, +{"s":"́ꭰ","utf16Len":2,"asciiLower":"́ꭰ","lower":"́ꭰ","wordKey":"́ꭰ","dedupKey":"ꭰ","collapse":"́ꭰ","words":["́ꭰ"],"jsTrim":"́ꭰ","jsTrimEnd":"́ꭰ","year":null}, +{"s":"α-1α‍","utf16Len":5,"asciiLower":"α-1α‍","lower":"α-1α‍","wordKey":"α-1α‍","dedupKey":"α-1α‍","collapse":"α-1α‍","words":["α-1α‍"],"jsTrim":"α-1α‍","jsTrimEnd":"α-1α‍","year":null}, +{"s":" ͅⒶa","utf16Len":4,"asciiLower":" ͅⒶa","lower":" ͅⓐa","wordKey":" ͅⒶa","dedupKey":"ⓐa","collapse":"ͅⒶa","words":["ͅⒶa"],"jsTrim":"ͅⒶa","jsTrimEnd":" ͅⒶa","year":null}, +{"s":" Ⓐ ᎠⒶ","utf16Len":5,"asciiLower":" Ⓐ ᎠⒶ","lower":" ⓐ ꭰⓐ","wordKey":" Ⓐ ᎠⒶ","dedupKey":"ⓐ ꭰⓐ","collapse":"Ⓐ ᎠⒶ","words":["Ⓐ","ᎠⒶ"],"jsTrim":"Ⓐ ᎠⒶ","jsTrimEnd":" Ⓐ ᎠⒶ","year":null}, +{"s":"·.·ẞ𞤀ʰ","utf16Len":7,"asciiLower":"·.·ẞ𞤀ʰ","lower":"·.·ß𞤢ʰ","wordKey":"·.·ẞ𞤀ʰ","dedupKey":"·.·ß𞤢ʰ","collapse":"·.·ẞ𞤀ʰ","words":["·.·ẞ𞤀ʰ"],"jsTrim":"·.·ẞ𞤀ʰ","jsTrimEnd":"·.·ẞ𞤀ʰ","year":null}, +{"s":"ẞ-·Ⓐ","utf16Len":4,"asciiLower":"ẞ-·Ⓐ","lower":"ß-·ⓐ","wordKey":"ẞ-·Ⓐ","dedupKey":"ß-·ⓐ","collapse":"ẞ-·Ⓐ","words":["ẞ-·Ⓐ"],"jsTrim":"ẞ-·Ⓐ","jsTrimEnd":"ẞ-·Ⓐ","year":null}, +{"s":"ẞͅꭰ","utf16Len":3,"asciiLower":"ẞͅꭰ","lower":"ßͅꭰ","wordKey":"ẞͅꭰ","dedupKey":"ßꭰ","collapse":"ẞͅꭰ","words":["ẞͅꭰ"],"jsTrim":"ẞͅꭰ","jsTrimEnd":"ẞͅꭰ","year":null}, +{"s":"İⒶ‍‍","utf16Len":4,"asciiLower":"İⒶ‍‍","lower":"i̇ⓐ‍‍","wordKey":"İⒶ‍‍","dedupKey":"iⓐ‍‍","collapse":"İⒶ‍‍","words":["İⒶ‍‍"],"jsTrim":"İⒶ‍‍","jsTrimEnd":"İⒶ‍‍","year":null}, +{"s":"·","utf16Len":1,"asciiLower":"·","lower":"·","wordKey":"·","dedupKey":"·","collapse":"·","words":["·"],"jsTrim":"·","jsTrimEnd":"·","year":null}, +{"s":"‍·a‍Dž","utf16Len":5,"asciiLower":"‍·a‍Dž","lower":"‍·a‍dž","wordKey":"‍·a‍Dž","dedupKey":"‍·a‍dž","collapse":"‍·a‍Dž","words":["‍·a‍Dž"],"jsTrim":"‍·a‍Dž","jsTrimEnd":"‍·a‍Dž","year":null}, +{"s":"ᲐᎠẞ","utf16Len":3,"asciiLower":"ᲐᎠẞ","lower":"აꭰß","wordKey":"ᲐᎠẞ","dedupKey":"აꭰß","collapse":"ᲐᎠẞ","words":["ᲐᎠẞ"],"jsTrim":"ᲐᎠẞ","jsTrimEnd":"ᲐᎠẞ","year":null}, +{"s":"‍ꭰ1́'","utf16Len":5,"asciiLower":"‍ꭰ1́'","lower":"‍ꭰ1́'","wordKey":"‍ꭰ1́'","dedupKey":"‍ꭰ1'","collapse":"‍ꭰ1́'","words":["‍ꭰ1́'"],"jsTrim":"‍ꭰ1́'","jsTrimEnd":"‍ꭰ1́'","year":null}, +{"s":"́ͅ.Ა́1","utf16Len":6,"asciiLower":"́ͅ.Ა́1","lower":"́ͅ.ა́1","wordKey":"́ͅ.Ა́1","dedupKey":".ა1","collapse":"́ͅ.Ა́1","words":["́ͅ.Ა́1"],"jsTrim":"́ͅ.Ა́1","jsTrimEnd":"́ͅ.Ა́1","year":null}, +{"s":"1·","utf16Len":2,"asciiLower":"1·","lower":"1·","wordKey":"1·","dedupKey":"1·","collapse":"1·","words":["1·"],"jsTrim":"1·","jsTrimEnd":"1·","year":null}, +{"s":"·Α'Σ","utf16Len":4,"asciiLower":"·Α'Σ","lower":"·α'ς","wordKey":"·Α'Σ","dedupKey":"·α'ς","collapse":"·Α'Σ","words":["·Α'Σ"],"jsTrim":"·Α'Σ","jsTrimEnd":"·Α'Σ","year":null}, +{"s":"ʰʰᲐ.αꭰ","utf16Len":6,"asciiLower":"ʰʰᲐ.αꭰ","lower":"ʰʰა.αꭰ","wordKey":"ʰʰᲐ.αꭰ","dedupKey":"ʰʰა.αꭰ","collapse":"ʰʰᲐ.αꭰ","words":["ʰʰᲐ.αꭰ"],"jsTrim":"ʰʰᲐ.αꭰ","jsTrimEnd":"ʰʰᲐ.αꭰ","year":null}, +{"s":"‍İ","utf16Len":2,"asciiLower":"‍İ","lower":"‍i̇","wordKey":"‍İ","dedupKey":"‍i","collapse":"‍İ","words":["‍İ"],"jsTrim":"‍İ","jsTrimEnd":"‍İ","year":null}, +{"s":"ά-́","utf16Len":4,"asciiLower":"ά-́","lower":"ά-́","wordKey":"ά-́","dedupKey":"α-","collapse":"ά-́","words":["ά-́"],"jsTrim":"ά-́","jsTrimEnd":"ά-́","year":null}, +{"s":"a1𝐀‍","utf16Len":5,"asciiLower":"a1𝐀‍","lower":"a1𝐀‍","wordKey":"a1𝐀‍","dedupKey":"a1𝐀‍","collapse":"a1𝐀‍","words":["a1𝐀‍"],"jsTrim":"a1𝐀‍","jsTrimEnd":"a1𝐀‍","year":null}, +{"s":"'ͅDžİᲐ́","utf16Len":6,"asciiLower":"'ͅDžİᲐ́","lower":"'ͅdži̇ა́","wordKey":"'ͅDžİᲐ́","dedupKey":"'džiა","collapse":"'ͅDžİᲐ́","words":["'ͅDžİᲐ́"],"jsTrim":"'ͅDžİᲐ́","jsTrimEnd":"'ͅDžİᲐ́","year":null}, +{"s":"𞤢1","utf16Len":3,"asciiLower":"𞤢1","lower":"𞤢1","wordKey":"𞤢1","dedupKey":"𞤢1","collapse":"𞤢1","words":["𞤢1"],"jsTrim":"𞤢1","jsTrimEnd":"𞤢1","year":null}, +{"s":"İʰ1","utf16Len":3,"asciiLower":"İʰ1","lower":"i̇ʰ1","wordKey":"İʰ1","dedupKey":"iʰ1","collapse":"İʰ1","words":["İʰ1"],"jsTrim":"İʰ1","jsTrimEnd":"İʰ1","year":null}, +{"s":"ʰ ","utf16Len":2,"asciiLower":"ʰ ","lower":"ʰ ","wordKey":"ʰ ","dedupKey":"ʰ","collapse":"ʰ","words":["ʰ"],"jsTrim":"ʰ","jsTrimEnd":"ʰ","year":null}, +{"s":"Ა𝐀𝐀","utf16Len":5,"asciiLower":"Ა𝐀𝐀","lower":"ა𝐀𝐀","wordKey":"Ა𝐀𝐀","dedupKey":"ა𝐀𝐀","collapse":"Ა𝐀𝐀","words":["Ა𝐀𝐀"],"jsTrim":"Ა𝐀𝐀","jsTrimEnd":"Ა𝐀𝐀","year":null}, +{"s":"-·ა","utf16Len":3,"asciiLower":"-·ა","lower":"-·ა","wordKey":"-·ა","dedupKey":"-·ა","collapse":"-·ა","words":["-·ა"],"jsTrim":"-·ა","jsTrimEnd":"-·ა","year":null}, +{"s":"ͅ.ა","utf16Len":3,"asciiLower":"ͅ.ა","lower":"ͅ.ა","wordKey":"ͅ.ა","dedupKey":".ა","collapse":"ͅ.ა","words":["ͅ.ა"],"jsTrim":"ͅ.ა","jsTrimEnd":"ͅ.ა","year":null}, +{"s":"áaᎠ-","utf16Len":5,"asciiLower":"áaᎠ-","lower":"áaꭰ-","wordKey":"áaᎠ-","dedupKey":"aaꭰ-","collapse":"áaᎠ-","words":["áaᎠ-"],"jsTrim":"áaᎠ-","jsTrimEnd":"áaᎠ-","year":null}, +{"s":" Α","utf16Len":2,"asciiLower":" Α","lower":" α","wordKey":" Α","dedupKey":"α","collapse":"Α","words":["Α"],"jsTrim":"Α","jsTrimEnd":" Α","year":null}, +{"s":"́ẞ́","utf16Len":3,"asciiLower":"́ẞ́","lower":"́ß́","wordKey":"́ẞ́","dedupKey":"ß","collapse":"́ẞ́","words":["́ẞ́"],"jsTrim":"́ẞ́","jsTrimEnd":"́ẞ́","year":null}, +{"s":"ΣΣ·ა.","utf16Len":5,"asciiLower":"ΣΣ·ა.","lower":"σσ·ა.","wordKey":"ΣΣ·ა","dedupKey":"σσ·ა.","collapse":"ΣΣ·ა.","words":["ΣΣ·ა."],"jsTrim":"ΣΣ·ა.","jsTrimEnd":"ΣΣ·ა.","year":null}, +{"s":"ΑⒶ","utf16Len":2,"asciiLower":"ΑⒶ","lower":"αⓐ","wordKey":"ΑⒶ","dedupKey":"αⓐ","collapse":"ΑⒶ","words":["ΑⒶ"],"jsTrim":"ΑⒶ","jsTrimEnd":"ΑⒶ","year":null}, +{"s":"­aͅ𞤀 Ა","utf16Len":7,"asciiLower":"­aͅ𞤀 Ა","lower":"­aͅ𞤢 ა","wordKey":"­aͅ𞤀 Ა","dedupKey":"­a𞤢 ა","collapse":"­aͅ𞤀 Ა","words":["­aͅ𞤀","Ა"],"jsTrim":"­aͅ𞤀 Ა","jsTrimEnd":"­aͅ𞤀 Ა","year":null}, +{"s":"­Ⓐİ","utf16Len":3,"asciiLower":"­Ⓐİ","lower":"­ⓐi̇","wordKey":"­Ⓐİ","dedupKey":"­ⓐi","collapse":"­Ⓐİ","words":["­Ⓐİ"],"jsTrim":"­Ⓐİ","jsTrimEnd":"­Ⓐİ","year":null}, +{"s":"ᎠΣꭰΣΣİ","utf16Len":6,"asciiLower":"ᎠΣꭰΣΣİ","lower":"ꭰσꭰσσi̇","wordKey":"ᎠΣꭰΣΣİ","dedupKey":"ꭰσꭰσσi","collapse":"ᎠΣꭰΣΣİ","words":["ᎠΣꭰΣΣİ"],"jsTrim":"ᎠΣꭰΣΣİ","jsTrimEnd":"ᎠΣꭰΣΣİ","year":null}, +{"s":"ẞͅ Ꭰ'Ꭰ","utf16Len":6,"asciiLower":"ẞͅ Ꭰ'Ꭰ","lower":"ßͅ ꭰ'ꭰ","wordKey":"ẞͅ Ꭰ'Ꭰ","dedupKey":"ß ꭰ'ꭰ","collapse":"ẞͅ Ꭰ'Ꭰ","words":["ẞͅ","Ꭰ'Ꭰ"],"jsTrim":"ẞͅ Ꭰ'Ꭰ","jsTrimEnd":"ẞͅ Ꭰ'Ꭰ","year":null}, +{"s":"Ა𞤢𝐀ͅ1Ⓐ","utf16Len":8,"asciiLower":"Ა𞤢𝐀ͅ1Ⓐ","lower":"ა𞤢𝐀ͅ1ⓐ","wordKey":"Ა𞤢𝐀ͅ1Ⓐ","dedupKey":"ა𞤢𝐀1ⓐ","collapse":"Ა𞤢𝐀ͅ1Ⓐ","words":["Ა𞤢𝐀ͅ1Ⓐ"],"jsTrim":"Ა𞤢𝐀ͅ1Ⓐ","jsTrimEnd":"Ა𞤢𝐀ͅ1Ⓐ","year":null}, +{"s":"İa-აა:","utf16Len":6,"asciiLower":"İa-აა:","lower":"i̇a-აა:","wordKey":"İa-აა","dedupKey":"ia-აა:","collapse":"İa-აა:","words":["İa-აა:"],"jsTrim":"İa-აა:","jsTrimEnd":"İa-აა:","year":null}, +{"s":" α𞤢","utf16Len":4,"asciiLower":" α𞤢","lower":" α𞤢","wordKey":" α𞤢","dedupKey":"α𞤢","collapse":"α𞤢","words":["α𞤢"],"jsTrim":"α𞤢","jsTrimEnd":" α𞤢","year":null}, +{"s":"DžᎠ­","utf16Len":3,"asciiLower":"DžᎠ­","lower":"džꭰ­","wordKey":"DžᎠ­","dedupKey":"džꭰ­","collapse":"DžᎠ­","words":["DžᎠ­"],"jsTrim":"DžᎠ­","jsTrimEnd":"DžᎠ­","year":null}, +{"s":"aα𝐀α':","utf16Len":7,"asciiLower":"aα𝐀α':","lower":"aα𝐀α':","wordKey":"aα𝐀α'","dedupKey":"aα𝐀α':","collapse":"aα𝐀α':","words":["aα𝐀α':"],"jsTrim":"aα𝐀α':","jsTrimEnd":"aα𝐀α':","year":null}, +{"s":"𝐀ʰΣ1-","utf16Len":6,"asciiLower":"𝐀ʰΣ1-","lower":"𝐀ʰς1-","wordKey":"𝐀ʰΣ1-","dedupKey":"𝐀ʰς1-","collapse":"𝐀ʰΣ1-","words":["𝐀ʰΣ1-"],"jsTrim":"𝐀ʰΣ1-","jsTrimEnd":"𝐀ʰΣ1-","year":null}, +{"s":"·́","utf16Len":2,"asciiLower":"·́","lower":"·́","wordKey":"·́","dedupKey":"·","collapse":"·́","words":["·́"],"jsTrim":"·́","jsTrimEnd":"·́","year":null}, +{"s":"Σ'ა:ẞ","utf16Len":5,"asciiLower":"Σ'ა:ẞ","lower":"σ'ა:ß","wordKey":"Σ'ა:ẞ","dedupKey":"σ'ა:ß","collapse":"Σ'ა:ẞ","words":["Σ'ა:ẞ"],"jsTrim":"Σ'ა:ẞ","jsTrimEnd":"Σ'ა:ẞ","year":null}, +{"s":"-.Ⓐ","utf16Len":3,"asciiLower":"-.Ⓐ","lower":"-.ⓐ","wordKey":"-.Ⓐ","dedupKey":"-.ⓐ","collapse":"-.Ⓐ","words":["-.Ⓐ"],"jsTrim":"-.Ⓐ","jsTrimEnd":"-.Ⓐ","year":null}, +{"s":"1𞤀-·","utf16Len":5,"asciiLower":"1𞤀-·","lower":"1𞤢-·","wordKey":"1𞤀-·","dedupKey":"1𞤢-·","collapse":"1𞤀-·","words":["1𞤀-·"],"jsTrim":"1𞤀-·","jsTrimEnd":"1𞤀-·","year":null}, +{"s":"a­­","utf16Len":3,"asciiLower":"a­­","lower":"a­­","wordKey":"a­­","dedupKey":"a­­","collapse":"a­­","words":["a­­"],"jsTrim":"a­­","jsTrimEnd":"a­­","year":null}, +{"s":"𝐀1ᲐᎠ𞤢'","utf16Len":8,"asciiLower":"𝐀1ᲐᎠ𞤢'","lower":"𝐀1აꭰ𞤢'","wordKey":"𝐀1ᲐᎠ𞤢'","dedupKey":"𝐀1აꭰ𞤢'","collapse":"𝐀1ᲐᎠ𞤢'","words":["𝐀1ᲐᎠ𞤢'"],"jsTrim":"𝐀1ᲐᎠ𞤢'","jsTrimEnd":"𝐀1ᲐᎠ𞤢'","year":null}, +{"s":"ͅ·Α‍","utf16Len":4,"asciiLower":"ͅ·Α‍","lower":"ͅ·α‍","wordKey":"ͅ·Α‍","dedupKey":"·α‍","collapse":"ͅ·Α‍","words":["ͅ·Α‍"],"jsTrim":"ͅ·Α‍","jsTrimEnd":"ͅ·Α‍","year":null}, +{"s":"αᲐΣ𝐀a","utf16Len":6,"asciiLower":"αᲐΣ𝐀a","lower":"αაσ𝐀a","wordKey":"αᲐΣ𝐀a","dedupKey":"αაσ𝐀a","collapse":"αᲐΣ𝐀a","words":["αᲐΣ𝐀a"],"jsTrim":"αᲐΣ𝐀a","jsTrimEnd":"αᲐΣ𝐀a","year":null}, +{"s":"Αİ","utf16Len":2,"asciiLower":"Αİ","lower":"αi̇","wordKey":"Αİ","dedupKey":"αi","collapse":"Αİ","words":["Αİ"],"jsTrim":"Αİ","jsTrimEnd":"Αİ","year":null}, +{"s":"𞤀ͅᲐ­­ა","utf16Len":7,"asciiLower":"𞤀ͅᲐ­­ა","lower":"𞤢ͅა­­ა","wordKey":"𞤀ͅᲐ­­ა","dedupKey":"𞤢ა­­ა","collapse":"𞤀ͅᲐ­­ა","words":["𞤀ͅᲐ­­ა"],"jsTrim":"𞤀ͅᲐ­­ა","jsTrimEnd":"𞤀ͅᲐ­­ა","year":null}, +{"s":"Σꭰ́·","utf16Len":4,"asciiLower":"Σꭰ́·","lower":"σꭰ́·","wordKey":"Σꭰ́·","dedupKey":"σꭰ·","collapse":"Σꭰ́·","words":["Σꭰ́·"],"jsTrim":"Σꭰ́·","jsTrimEnd":"Σꭰ́·","year":null}, +{"s":"ẞ·","utf16Len":2,"asciiLower":"ẞ·","lower":"ß·","wordKey":"ẞ·","dedupKey":"ß·","collapse":"ẞ·","words":["ẞ·"],"jsTrim":"ẞ·","jsTrimEnd":"ẞ·","year":null}, +{"s":"𝐀ᎠDžΣʰ","utf16Len":6,"asciiLower":"𝐀ᎠDžΣʰ","lower":"𝐀ꭰdžςʰ","wordKey":"𝐀ᎠDžΣʰ","dedupKey":"𝐀ꭰdžςʰ","collapse":"𝐀ᎠDžΣʰ","words":["𝐀ᎠDžΣʰ"],"jsTrim":"𝐀ᎠDžΣʰ","jsTrimEnd":"𝐀ᎠDžΣʰ","year":null}, +{"s":"Აა","utf16Len":2,"asciiLower":"Აა","lower":"აა","wordKey":"Აა","dedupKey":"აა","collapse":"Აა","words":["Აა"],"jsTrim":"Აა","jsTrimEnd":"Აა","year":null}, +{"s":"Აꭰ­'ẞa","utf16Len":6,"asciiLower":"Აꭰ­'ẞa","lower":"აꭰ­'ßa","wordKey":"Აꭰ­'ẞa","dedupKey":"აꭰ­'ßa","collapse":"Აꭰ­'ẞa","words":["Აꭰ­'ẞa"],"jsTrim":"Აꭰ­'ẞa","jsTrimEnd":"Აꭰ­'ẞa","year":null}, +{"s":"ΑΑΑ","utf16Len":3,"asciiLower":"ΑΑΑ","lower":"ααα","wordKey":"ΑΑΑ","dedupKey":"ααα","collapse":"ΑΑΑ","words":["ΑΑΑ"],"jsTrim":"ΑΑΑ","jsTrimEnd":"ΑΑΑ","year":null}, +{"s":"‍́","utf16Len":2,"asciiLower":"‍́","lower":"‍́","wordKey":"‍́","dedupKey":"‍","collapse":"‍́","words":["‍́"],"jsTrim":"‍́","jsTrimEnd":"‍́","year":null}, +{"s":"Dž𝐀.","utf16Len":4,"asciiLower":"Dž𝐀.","lower":"dž𝐀.","wordKey":"Dž𝐀","dedupKey":"dž𝐀.","collapse":"Dž𝐀.","words":["Dž𝐀."],"jsTrim":"Dž𝐀.","jsTrimEnd":"Dž𝐀.","year":null}, +{"s":"́·αⒶꭰ","utf16Len":5,"asciiLower":"́·αⒶꭰ","lower":"́·αⓐꭰ","wordKey":"́·αⒶꭰ","dedupKey":"·αⓐꭰ","collapse":"́·αⒶꭰ","words":["́·αⒶꭰ"],"jsTrim":"́·αⒶꭰ","jsTrimEnd":"́·αⒶꭰ","year":null}, +{"s":"𝐀ʰ·აᎠ","utf16Len":6,"asciiLower":"𝐀ʰ·აᎠ","lower":"𝐀ʰ·აꭰ","wordKey":"𝐀ʰ·აᎠ","dedupKey":"𝐀ʰ·აꭰ","collapse":"𝐀ʰ·აᎠ","words":["𝐀ʰ·აᎠ"],"jsTrim":"𝐀ʰ·აᎠ","jsTrimEnd":"𝐀ʰ·აᎠ","year":null}, +{"s":"ΑᎠᎠΑᲐ","utf16Len":5,"asciiLower":"ΑᎠᎠΑᲐ","lower":"αꭰꭰαა","wordKey":"ΑᎠᎠΑᲐ","dedupKey":"αꭰꭰαა","collapse":"ΑᎠᎠΑᲐ","words":["ΑᎠᎠΑᲐ"],"jsTrim":"ΑᎠᎠΑᲐ","jsTrimEnd":"ΑᎠᎠΑᲐ","year":null}, +{"s":"Σ·ꭰᲐ α","utf16Len":6,"asciiLower":"Σ·ꭰᲐ α","lower":"σ·ꭰა α","wordKey":"Σ·ꭰᲐ α","dedupKey":"σ·ꭰა α","collapse":"Σ·ꭰᲐ α","words":["Σ·ꭰᲐ","α"],"jsTrim":"Σ·ꭰᲐ α","jsTrimEnd":"Σ·ꭰᲐ α","year":null}, +{"s":"İͅα𞤀­́","utf16Len":7,"asciiLower":"İͅα𞤀­́","lower":"i̇ͅα𞤢­́","wordKey":"İͅα𞤀­́","dedupKey":"iα𞤢­","collapse":"İͅα𞤀­́","words":["İͅα𞤀­́"],"jsTrim":"İͅα𞤀­́","jsTrimEnd":"İͅα𞤀­́","year":null}, +{"s":"ʰα1","utf16Len":3,"asciiLower":"ʰα1","lower":"ʰα1","wordKey":"ʰα1","dedupKey":"ʰα1","collapse":"ʰα1","words":["ʰα1"],"jsTrim":"ʰα1","jsTrimEnd":"ʰα1","year":null}, +{"s":"aaꭰ·","utf16Len":4,"asciiLower":"aaꭰ·","lower":"aaꭰ·","wordKey":"aaꭰ·","dedupKey":"aaꭰ·","collapse":"aaꭰ·","words":["aaꭰ·"],"jsTrim":"aaꭰ·","jsTrimEnd":"aaꭰ·","year":null}, +{"s":"':Ꭰ𞤀Σ","utf16Len":6,"asciiLower":"':Ꭰ𞤀Σ","lower":"':ꭰ𞤢ς","wordKey":"':Ꭰ𞤀Σ","dedupKey":"':ꭰ𞤢ς","collapse":"':Ꭰ𞤀Σ","words":["':Ꭰ𞤀Σ"],"jsTrim":"':Ꭰ𞤀Σ","jsTrimEnd":"':Ꭰ𞤀Σ","year":null} +], +"lowerSweep": [[65,"a"],[66,"b"],[67,"c"],[68,"d"],[69,"e"],[70,"f"],[71,"g"],[72,"h"],[73,"i"],[74,"j"],[75,"k"],[76,"l"],[77,"m"],[78,"n"],[79,"o"],[80,"p"],[81,"q"],[82,"r"],[83,"s"],[84,"t"],[85,"u"],[86,"v"],[87,"w"],[88,"x"],[89,"y"],[90,"z"],[192,"à"],[193,"á"],[194,"â"],[195,"ã"],[196,"ä"],[197,"å"],[198,"æ"],[199,"ç"],[200,"è"],[201,"é"],[202,"ê"],[203,"ë"],[204,"ì"],[205,"í"],[206,"î"],[207,"ï"],[208,"ð"],[209,"ñ"],[210,"ò"],[211,"ó"],[212,"ô"],[213,"õ"],[214,"ö"],[216,"ø"],[217,"ù"],[218,"ú"],[219,"û"],[220,"ü"],[221,"ý"],[222,"þ"],[256,"ā"],[258,"ă"],[260,"ą"],[262,"ć"],[264,"ĉ"],[266,"ċ"],[268,"č"],[270,"ď"],[272,"đ"],[274,"ē"],[276,"ĕ"],[278,"ė"],[280,"ę"],[282,"ě"],[284,"ĝ"],[286,"ğ"],[288,"ġ"],[290,"ģ"],[292,"ĥ"],[294,"ħ"],[296,"ĩ"],[298,"ī"],[300,"ĭ"],[302,"į"],[304,"i̇"],[306,"ij"],[308,"ĵ"],[310,"ķ"],[313,"ĺ"],[315,"ļ"],[317,"ľ"],[319,"ŀ"],[321,"ł"],[323,"ń"],[325,"ņ"],[327,"ň"],[330,"ŋ"],[332,"ō"],[334,"ŏ"],[336,"ő"],[338,"œ"],[340,"ŕ"],[342,"ŗ"],[344,"ř"],[346,"ś"],[348,"ŝ"],[350,"ş"],[352,"š"],[354,"ţ"],[356,"ť"],[358,"ŧ"],[360,"ũ"],[362,"ū"],[364,"ŭ"],[366,"ů"],[368,"ű"],[370,"ų"],[372,"ŵ"],[374,"ŷ"],[376,"ÿ"],[377,"ź"],[379,"ż"],[381,"ž"],[385,"ɓ"],[386,"ƃ"],[388,"ƅ"],[390,"ɔ"],[391,"ƈ"],[393,"ɖ"],[394,"ɗ"],[395,"ƌ"],[398,"ǝ"],[399,"ə"],[400,"ɛ"],[401,"ƒ"],[403,"ɠ"],[404,"ɣ"],[406,"ɩ"],[407,"ɨ"],[408,"ƙ"],[412,"ɯ"],[413,"ɲ"],[415,"ɵ"],[416,"ơ"],[418,"ƣ"],[420,"ƥ"],[422,"ʀ"],[423,"ƨ"],[425,"ʃ"],[428,"ƭ"],[430,"ʈ"],[431,"ư"],[433,"ʊ"],[434,"ʋ"],[435,"ƴ"],[437,"ƶ"],[439,"ʒ"],[440,"ƹ"],[444,"ƽ"],[452,"dž"],[453,"dž"],[455,"lj"],[456,"lj"],[458,"nj"],[459,"nj"],[461,"ǎ"],[463,"ǐ"],[465,"ǒ"],[467,"ǔ"],[469,"ǖ"],[471,"ǘ"],[473,"ǚ"],[475,"ǜ"],[478,"ǟ"],[480,"ǡ"],[482,"ǣ"],[484,"ǥ"],[486,"ǧ"],[488,"ǩ"],[490,"ǫ"],[492,"ǭ"],[494,"ǯ"],[497,"dz"],[498,"dz"],[500,"ǵ"],[502,"ƕ"],[503,"ƿ"],[504,"ǹ"],[506,"ǻ"],[508,"ǽ"],[510,"ǿ"],[512,"ȁ"],[514,"ȃ"],[516,"ȅ"],[518,"ȇ"],[520,"ȉ"],[522,"ȋ"],[524,"ȍ"],[526,"ȏ"],[528,"ȑ"],[530,"ȓ"],[532,"ȕ"],[534,"ȗ"],[536,"ș"],[538,"ț"],[540,"ȝ"],[542,"ȟ"],[544,"ƞ"],[546,"ȣ"],[548,"ȥ"],[550,"ȧ"],[552,"ȩ"],[554,"ȫ"],[556,"ȭ"],[558,"ȯ"],[560,"ȱ"],[562,"ȳ"],[570,"ⱥ"],[571,"ȼ"],[573,"ƚ"],[574,"ⱦ"],[577,"ɂ"],[579,"ƀ"],[580,"ʉ"],[581,"ʌ"],[582,"ɇ"],[584,"ɉ"],[586,"ɋ"],[588,"ɍ"],[590,"ɏ"],[880,"ͱ"],[882,"ͳ"],[886,"ͷ"],[895,"ϳ"],[902,"ά"],[904,"έ"],[905,"ή"],[906,"ί"],[908,"ό"],[910,"ύ"],[911,"ώ"],[913,"α"],[914,"β"],[915,"γ"],[916,"δ"],[917,"ε"],[918,"ζ"],[919,"η"],[920,"θ"],[921,"ι"],[922,"κ"],[923,"λ"],[924,"μ"],[925,"ν"],[926,"ξ"],[927,"ο"],[928,"π"],[929,"ρ"],[931,"σ"],[932,"τ"],[933,"υ"],[934,"φ"],[935,"χ"],[936,"ψ"],[937,"ω"],[938,"ϊ"],[939,"ϋ"],[975,"ϗ"],[984,"ϙ"],[986,"ϛ"],[988,"ϝ"],[990,"ϟ"],[992,"ϡ"],[994,"ϣ"],[996,"ϥ"],[998,"ϧ"],[1000,"ϩ"],[1002,"ϫ"],[1004,"ϭ"],[1006,"ϯ"],[1012,"θ"],[1015,"ϸ"],[1017,"ϲ"],[1018,"ϻ"],[1021,"ͻ"],[1022,"ͼ"],[1023,"ͽ"],[1024,"ѐ"],[1025,"ё"],[1026,"ђ"],[1027,"ѓ"],[1028,"є"],[1029,"ѕ"],[1030,"і"],[1031,"ї"],[1032,"ј"],[1033,"љ"],[1034,"њ"],[1035,"ћ"],[1036,"ќ"],[1037,"ѝ"],[1038,"ў"],[1039,"џ"],[1040,"а"],[1041,"б"],[1042,"в"],[1043,"г"],[1044,"д"],[1045,"е"],[1046,"ж"],[1047,"з"],[1048,"и"],[1049,"й"],[1050,"к"],[1051,"л"],[1052,"м"],[1053,"н"],[1054,"о"],[1055,"п"],[1056,"р"],[1057,"с"],[1058,"т"],[1059,"у"],[1060,"ф"],[1061,"х"],[1062,"ц"],[1063,"ч"],[1064,"ш"],[1065,"щ"],[1066,"ъ"],[1067,"ы"],[1068,"ь"],[1069,"э"],[1070,"ю"],[1071,"я"],[1120,"ѡ"],[1122,"ѣ"],[1124,"ѥ"],[1126,"ѧ"],[1128,"ѩ"],[1130,"ѫ"],[1132,"ѭ"],[1134,"ѯ"],[1136,"ѱ"],[1138,"ѳ"],[1140,"ѵ"],[1142,"ѷ"],[1144,"ѹ"],[1146,"ѻ"],[1148,"ѽ"],[1150,"ѿ"],[1152,"ҁ"],[1162,"ҋ"],[1164,"ҍ"],[1166,"ҏ"],[1168,"ґ"],[1170,"ғ"],[1172,"ҕ"],[1174,"җ"],[1176,"ҙ"],[1178,"қ"],[1180,"ҝ"],[1182,"ҟ"],[1184,"ҡ"],[1186,"ң"],[1188,"ҥ"],[1190,"ҧ"],[1192,"ҩ"],[1194,"ҫ"],[1196,"ҭ"],[1198,"ү"],[1200,"ұ"],[1202,"ҳ"],[1204,"ҵ"],[1206,"ҷ"],[1208,"ҹ"],[1210,"һ"],[1212,"ҽ"],[1214,"ҿ"],[1216,"ӏ"],[1217,"ӂ"],[1219,"ӄ"],[1221,"ӆ"],[1223,"ӈ"],[1225,"ӊ"],[1227,"ӌ"],[1229,"ӎ"],[1232,"ӑ"],[1234,"ӓ"],[1236,"ӕ"],[1238,"ӗ"],[1240,"ә"],[1242,"ӛ"],[1244,"ӝ"],[1246,"ӟ"],[1248,"ӡ"],[1250,"ӣ"],[1252,"ӥ"],[1254,"ӧ"],[1256,"ө"],[1258,"ӫ"],[1260,"ӭ"],[1262,"ӯ"],[1264,"ӱ"],[1266,"ӳ"],[1268,"ӵ"],[1270,"ӷ"],[1272,"ӹ"],[1274,"ӻ"],[1276,"ӽ"],[1278,"ӿ"],[1280,"ԁ"],[1282,"ԃ"],[1284,"ԅ"],[1286,"ԇ"],[1288,"ԉ"],[1290,"ԋ"],[1292,"ԍ"],[1294,"ԏ"],[1296,"ԑ"],[1298,"ԓ"],[1300,"ԕ"],[1302,"ԗ"],[1304,"ԙ"],[1306,"ԛ"],[1308,"ԝ"],[1310,"ԟ"],[1312,"ԡ"],[1314,"ԣ"],[1316,"ԥ"],[1318,"ԧ"],[1320,"ԩ"],[1322,"ԫ"],[1324,"ԭ"],[1326,"ԯ"],[1329,"ա"],[1330,"բ"],[1331,"գ"],[1332,"դ"],[1333,"ե"],[1334,"զ"],[1335,"է"],[1336,"ը"],[1337,"թ"],[1338,"ժ"],[1339,"ի"],[1340,"լ"],[1341,"խ"],[1342,"ծ"],[1343,"կ"],[1344,"հ"],[1345,"ձ"],[1346,"ղ"],[1347,"ճ"],[1348,"մ"],[1349,"յ"],[1350,"ն"],[1351,"շ"],[1352,"ո"],[1353,"չ"],[1354,"պ"],[1355,"ջ"],[1356,"ռ"],[1357,"ս"],[1358,"վ"],[1359,"տ"],[1360,"ր"],[1361,"ց"],[1362,"ւ"],[1363,"փ"],[1364,"ք"],[1365,"օ"],[1366,"ֆ"],[4256,"ⴀ"],[4257,"ⴁ"],[4258,"ⴂ"],[4259,"ⴃ"],[4260,"ⴄ"],[4261,"ⴅ"],[4262,"ⴆ"],[4263,"ⴇ"],[4264,"ⴈ"],[4265,"ⴉ"],[4266,"ⴊ"],[4267,"ⴋ"],[4268,"ⴌ"],[4269,"ⴍ"],[4270,"ⴎ"],[4271,"ⴏ"],[4272,"ⴐ"],[4273,"ⴑ"],[4274,"ⴒ"],[4275,"ⴓ"],[4276,"ⴔ"],[4277,"ⴕ"],[4278,"ⴖ"],[4279,"ⴗ"],[4280,"ⴘ"],[4281,"ⴙ"],[4282,"ⴚ"],[4283,"ⴛ"],[4284,"ⴜ"],[4285,"ⴝ"],[4286,"ⴞ"],[4287,"ⴟ"],[4288,"ⴠ"],[4289,"ⴡ"],[4290,"ⴢ"],[4291,"ⴣ"],[4292,"ⴤ"],[4293,"ⴥ"],[4295,"ⴧ"],[4301,"ⴭ"],[5024,"ꭰ"],[5025,"ꭱ"],[5026,"ꭲ"],[5027,"ꭳ"],[5028,"ꭴ"],[5029,"ꭵ"],[5030,"ꭶ"],[5031,"ꭷ"],[5032,"ꭸ"],[5033,"ꭹ"],[5034,"ꭺ"],[5035,"ꭻ"],[5036,"ꭼ"],[5037,"ꭽ"],[5038,"ꭾ"],[5039,"ꭿ"],[5040,"ꮀ"],[5041,"ꮁ"],[5042,"ꮂ"],[5043,"ꮃ"],[5044,"ꮄ"],[5045,"ꮅ"],[5046,"ꮆ"],[5047,"ꮇ"],[5048,"ꮈ"],[5049,"ꮉ"],[5050,"ꮊ"],[5051,"ꮋ"],[5052,"ꮌ"],[5053,"ꮍ"],[5054,"ꮎ"],[5055,"ꮏ"],[5056,"ꮐ"],[5057,"ꮑ"],[5058,"ꮒ"],[5059,"ꮓ"],[5060,"ꮔ"],[5061,"ꮕ"],[5062,"ꮖ"],[5063,"ꮗ"],[5064,"ꮘ"],[5065,"ꮙ"],[5066,"ꮚ"],[5067,"ꮛ"],[5068,"ꮜ"],[5069,"ꮝ"],[5070,"ꮞ"],[5071,"ꮟ"],[5072,"ꮠ"],[5073,"ꮡ"],[5074,"ꮢ"],[5075,"ꮣ"],[5076,"ꮤ"],[5077,"ꮥ"],[5078,"ꮦ"],[5079,"ꮧ"],[5080,"ꮨ"],[5081,"ꮩ"],[5082,"ꮪ"],[5083,"ꮫ"],[5084,"ꮬ"],[5085,"ꮭ"],[5086,"ꮮ"],[5087,"ꮯ"],[5088,"ꮰ"],[5089,"ꮱ"],[5090,"ꮲ"],[5091,"ꮳ"],[5092,"ꮴ"],[5093,"ꮵ"],[5094,"ꮶ"],[5095,"ꮷ"],[5096,"ꮸ"],[5097,"ꮹ"],[5098,"ꮺ"],[5099,"ꮻ"],[5100,"ꮼ"],[5101,"ꮽ"],[5102,"ꮾ"],[5103,"ꮿ"],[5104,"ᏸ"],[5105,"ᏹ"],[5106,"ᏺ"],[5107,"ᏻ"],[5108,"ᏼ"],[5109,"ᏽ"],[7305,"ᲊ"],[7312,"ა"],[7313,"ბ"],[7314,"გ"],[7315,"დ"],[7316,"ე"],[7317,"ვ"],[7318,"ზ"],[7319,"თ"],[7320,"ი"],[7321,"კ"],[7322,"ლ"],[7323,"მ"],[7324,"ნ"],[7325,"ო"],[7326,"პ"],[7327,"ჟ"],[7328,"რ"],[7329,"ს"],[7330,"ტ"],[7331,"უ"],[7332,"ფ"],[7333,"ქ"],[7334,"ღ"],[7335,"ყ"],[7336,"შ"],[7337,"ჩ"],[7338,"ც"],[7339,"ძ"],[7340,"წ"],[7341,"ჭ"],[7342,"ხ"],[7343,"ჯ"],[7344,"ჰ"],[7345,"ჱ"],[7346,"ჲ"],[7347,"ჳ"],[7348,"ჴ"],[7349,"ჵ"],[7350,"ჶ"],[7351,"ჷ"],[7352,"ჸ"],[7353,"ჹ"],[7354,"ჺ"],[7357,"ჽ"],[7358,"ჾ"],[7359,"ჿ"],[7680,"ḁ"],[7682,"ḃ"],[7684,"ḅ"],[7686,"ḇ"],[7688,"ḉ"],[7690,"ḋ"],[7692,"ḍ"],[7694,"ḏ"],[7696,"ḑ"],[7698,"ḓ"],[7700,"ḕ"],[7702,"ḗ"],[7704,"ḙ"],[7706,"ḛ"],[7708,"ḝ"],[7710,"ḟ"],[7712,"ḡ"],[7714,"ḣ"],[7716,"ḥ"],[7718,"ḧ"],[7720,"ḩ"],[7722,"ḫ"],[7724,"ḭ"],[7726,"ḯ"],[7728,"ḱ"],[7730,"ḳ"],[7732,"ḵ"],[7734,"ḷ"],[7736,"ḹ"],[7738,"ḻ"],[7740,"ḽ"],[7742,"ḿ"],[7744,"ṁ"],[7746,"ṃ"],[7748,"ṅ"],[7750,"ṇ"],[7752,"ṉ"],[7754,"ṋ"],[7756,"ṍ"],[7758,"ṏ"],[7760,"ṑ"],[7762,"ṓ"],[7764,"ṕ"],[7766,"ṗ"],[7768,"ṙ"],[7770,"ṛ"],[7772,"ṝ"],[7774,"ṟ"],[7776,"ṡ"],[7778,"ṣ"],[7780,"ṥ"],[7782,"ṧ"],[7784,"ṩ"],[7786,"ṫ"],[7788,"ṭ"],[7790,"ṯ"],[7792,"ṱ"],[7794,"ṳ"],[7796,"ṵ"],[7798,"ṷ"],[7800,"ṹ"],[7802,"ṻ"],[7804,"ṽ"],[7806,"ṿ"],[7808,"ẁ"],[7810,"ẃ"],[7812,"ẅ"],[7814,"ẇ"],[7816,"ẉ"],[7818,"ẋ"],[7820,"ẍ"],[7822,"ẏ"],[7824,"ẑ"],[7826,"ẓ"],[7828,"ẕ"],[7838,"ß"],[7840,"ạ"],[7842,"ả"],[7844,"ấ"],[7846,"ầ"],[7848,"ẩ"],[7850,"ẫ"],[7852,"ậ"],[7854,"ắ"],[7856,"ằ"],[7858,"ẳ"],[7860,"ẵ"],[7862,"ặ"],[7864,"ẹ"],[7866,"ẻ"],[7868,"ẽ"],[7870,"ế"],[7872,"ề"],[7874,"ể"],[7876,"ễ"],[7878,"ệ"],[7880,"ỉ"],[7882,"ị"],[7884,"ọ"],[7886,"ỏ"],[7888,"ố"],[7890,"ồ"],[7892,"ổ"],[7894,"ỗ"],[7896,"ộ"],[7898,"ớ"],[7900,"ờ"],[7902,"ở"],[7904,"ỡ"],[7906,"ợ"],[7908,"ụ"],[7910,"ủ"],[7912,"ứ"],[7914,"ừ"],[7916,"ử"],[7918,"ữ"],[7920,"ự"],[7922,"ỳ"],[7924,"ỵ"],[7926,"ỷ"],[7928,"ỹ"],[7930,"ỻ"],[7932,"ỽ"],[7934,"ỿ"],[7944,"ἀ"],[7945,"ἁ"],[7946,"ἂ"],[7947,"ἃ"],[7948,"ἄ"],[7949,"ἅ"],[7950,"ἆ"],[7951,"ἇ"],[7960,"ἐ"],[7961,"ἑ"],[7962,"ἒ"],[7963,"ἓ"],[7964,"ἔ"],[7965,"ἕ"],[7976,"ἠ"],[7977,"ἡ"],[7978,"ἢ"],[7979,"ἣ"],[7980,"ἤ"],[7981,"ἥ"],[7982,"ἦ"],[7983,"ἧ"],[7992,"ἰ"],[7993,"ἱ"],[7994,"ἲ"],[7995,"ἳ"],[7996,"ἴ"],[7997,"ἵ"],[7998,"ἶ"],[7999,"ἷ"],[8008,"ὀ"],[8009,"ὁ"],[8010,"ὂ"],[8011,"ὃ"],[8012,"ὄ"],[8013,"ὅ"],[8025,"ὑ"],[8027,"ὓ"],[8029,"ὕ"],[8031,"ὗ"],[8040,"ὠ"],[8041,"ὡ"],[8042,"ὢ"],[8043,"ὣ"],[8044,"ὤ"],[8045,"ὥ"],[8046,"ὦ"],[8047,"ὧ"],[8072,"ᾀ"],[8073,"ᾁ"],[8074,"ᾂ"],[8075,"ᾃ"],[8076,"ᾄ"],[8077,"ᾅ"],[8078,"ᾆ"],[8079,"ᾇ"],[8088,"ᾐ"],[8089,"ᾑ"],[8090,"ᾒ"],[8091,"ᾓ"],[8092,"ᾔ"],[8093,"ᾕ"],[8094,"ᾖ"],[8095,"ᾗ"],[8104,"ᾠ"],[8105,"ᾡ"],[8106,"ᾢ"],[8107,"ᾣ"],[8108,"ᾤ"],[8109,"ᾥ"],[8110,"ᾦ"],[8111,"ᾧ"],[8120,"ᾰ"],[8121,"ᾱ"],[8122,"ὰ"],[8123,"ά"],[8124,"ᾳ"],[8136,"ὲ"],[8137,"έ"],[8138,"ὴ"],[8139,"ή"],[8140,"ῃ"],[8152,"ῐ"],[8153,"ῑ"],[8154,"ὶ"],[8155,"ί"],[8168,"ῠ"],[8169,"ῡ"],[8170,"ὺ"],[8171,"ύ"],[8172,"ῥ"],[8184,"ὸ"],[8185,"ό"],[8186,"ὼ"],[8187,"ώ"],[8188,"ῳ"],[8486,"ω"],[8490,"k"],[8491,"å"],[8498,"ⅎ"],[8544,"ⅰ"],[8545,"ⅱ"],[8546,"ⅲ"],[8547,"ⅳ"],[8548,"ⅴ"],[8549,"ⅵ"],[8550,"ⅶ"],[8551,"ⅷ"],[8552,"ⅸ"],[8553,"ⅹ"],[8554,"ⅺ"],[8555,"ⅻ"],[8556,"ⅼ"],[8557,"ⅽ"],[8558,"ⅾ"],[8559,"ⅿ"],[8579,"ↄ"],[9398,"ⓐ"],[9399,"ⓑ"],[9400,"ⓒ"],[9401,"ⓓ"],[9402,"ⓔ"],[9403,"ⓕ"],[9404,"ⓖ"],[9405,"ⓗ"],[9406,"ⓘ"],[9407,"ⓙ"],[9408,"ⓚ"],[9409,"ⓛ"],[9410,"ⓜ"],[9411,"ⓝ"],[9412,"ⓞ"],[9413,"ⓟ"],[9414,"ⓠ"],[9415,"ⓡ"],[9416,"ⓢ"],[9417,"ⓣ"],[9418,"ⓤ"],[9419,"ⓥ"],[9420,"ⓦ"],[9421,"ⓧ"],[9422,"ⓨ"],[9423,"ⓩ"],[11264,"ⰰ"],[11265,"ⰱ"],[11266,"ⰲ"],[11267,"ⰳ"],[11268,"ⰴ"],[11269,"ⰵ"],[11270,"ⰶ"],[11271,"ⰷ"],[11272,"ⰸ"],[11273,"ⰹ"],[11274,"ⰺ"],[11275,"ⰻ"],[11276,"ⰼ"],[11277,"ⰽ"],[11278,"ⰾ"],[11279,"ⰿ"],[11280,"ⱀ"],[11281,"ⱁ"],[11282,"ⱂ"],[11283,"ⱃ"],[11284,"ⱄ"],[11285,"ⱅ"],[11286,"ⱆ"],[11287,"ⱇ"],[11288,"ⱈ"],[11289,"ⱉ"],[11290,"ⱊ"],[11291,"ⱋ"],[11292,"ⱌ"],[11293,"ⱍ"],[11294,"ⱎ"],[11295,"ⱏ"],[11296,"ⱐ"],[11297,"ⱑ"],[11298,"ⱒ"],[11299,"ⱓ"],[11300,"ⱔ"],[11301,"ⱕ"],[11302,"ⱖ"],[11303,"ⱗ"],[11304,"ⱘ"],[11305,"ⱙ"],[11306,"ⱚ"],[11307,"ⱛ"],[11308,"ⱜ"],[11309,"ⱝ"],[11310,"ⱞ"],[11311,"ⱟ"],[11360,"ⱡ"],[11362,"ɫ"],[11363,"ᵽ"],[11364,"ɽ"],[11367,"ⱨ"],[11369,"ⱪ"],[11371,"ⱬ"],[11373,"ɑ"],[11374,"ɱ"],[11375,"ɐ"],[11376,"ɒ"],[11378,"ⱳ"],[11381,"ⱶ"],[11390,"ȿ"],[11391,"ɀ"],[11392,"ⲁ"],[11394,"ⲃ"],[11396,"ⲅ"],[11398,"ⲇ"],[11400,"ⲉ"],[11402,"ⲋ"],[11404,"ⲍ"],[11406,"ⲏ"],[11408,"ⲑ"],[11410,"ⲓ"],[11412,"ⲕ"],[11414,"ⲗ"],[11416,"ⲙ"],[11418,"ⲛ"],[11420,"ⲝ"],[11422,"ⲟ"],[11424,"ⲡ"],[11426,"ⲣ"],[11428,"ⲥ"],[11430,"ⲧ"],[11432,"ⲩ"],[11434,"ⲫ"],[11436,"ⲭ"],[11438,"ⲯ"],[11440,"ⲱ"],[11442,"ⲳ"],[11444,"ⲵ"],[11446,"ⲷ"],[11448,"ⲹ"],[11450,"ⲻ"],[11452,"ⲽ"],[11454,"ⲿ"],[11456,"ⳁ"],[11458,"ⳃ"],[11460,"ⳅ"],[11462,"ⳇ"],[11464,"ⳉ"],[11466,"ⳋ"],[11468,"ⳍ"],[11470,"ⳏ"],[11472,"ⳑ"],[11474,"ⳓ"],[11476,"ⳕ"],[11478,"ⳗ"],[11480,"ⳙ"],[11482,"ⳛ"],[11484,"ⳝ"],[11486,"ⳟ"],[11488,"ⳡ"],[11490,"ⳣ"],[11499,"ⳬ"],[11501,"ⳮ"],[11506,"ⳳ"],[42560,"ꙁ"],[42562,"ꙃ"],[42564,"ꙅ"],[42566,"ꙇ"],[42568,"ꙉ"],[42570,"ꙋ"],[42572,"ꙍ"],[42574,"ꙏ"],[42576,"ꙑ"],[42578,"ꙓ"],[42580,"ꙕ"],[42582,"ꙗ"],[42584,"ꙙ"],[42586,"ꙛ"],[42588,"ꙝ"],[42590,"ꙟ"],[42592,"ꙡ"],[42594,"ꙣ"],[42596,"ꙥ"],[42598,"ꙧ"],[42600,"ꙩ"],[42602,"ꙫ"],[42604,"ꙭ"],[42624,"ꚁ"],[42626,"ꚃ"],[42628,"ꚅ"],[42630,"ꚇ"],[42632,"ꚉ"],[42634,"ꚋ"],[42636,"ꚍ"],[42638,"ꚏ"],[42640,"ꚑ"],[42642,"ꚓ"],[42644,"ꚕ"],[42646,"ꚗ"],[42648,"ꚙ"],[42650,"ꚛ"],[42786,"ꜣ"],[42788,"ꜥ"],[42790,"ꜧ"],[42792,"ꜩ"],[42794,"ꜫ"],[42796,"ꜭ"],[42798,"ꜯ"],[42802,"ꜳ"],[42804,"ꜵ"],[42806,"ꜷ"],[42808,"ꜹ"],[42810,"ꜻ"],[42812,"ꜽ"],[42814,"ꜿ"],[42816,"ꝁ"],[42818,"ꝃ"],[42820,"ꝅ"],[42822,"ꝇ"],[42824,"ꝉ"],[42826,"ꝋ"],[42828,"ꝍ"],[42830,"ꝏ"],[42832,"ꝑ"],[42834,"ꝓ"],[42836,"ꝕ"],[42838,"ꝗ"],[42840,"ꝙ"],[42842,"ꝛ"],[42844,"ꝝ"],[42846,"ꝟ"],[42848,"ꝡ"],[42850,"ꝣ"],[42852,"ꝥ"],[42854,"ꝧ"],[42856,"ꝩ"],[42858,"ꝫ"],[42860,"ꝭ"],[42862,"ꝯ"],[42873,"ꝺ"],[42875,"ꝼ"],[42877,"ᵹ"],[42878,"ꝿ"],[42880,"ꞁ"],[42882,"ꞃ"],[42884,"ꞅ"],[42886,"ꞇ"],[42891,"ꞌ"],[42893,"ɥ"],[42896,"ꞑ"],[42898,"ꞓ"],[42902,"ꞗ"],[42904,"ꞙ"],[42906,"ꞛ"],[42908,"ꞝ"],[42910,"ꞟ"],[42912,"ꞡ"],[42914,"ꞣ"],[42916,"ꞥ"],[42918,"ꞧ"],[42920,"ꞩ"],[42922,"ɦ"],[42923,"ɜ"],[42924,"ɡ"],[42925,"ɬ"],[42926,"ɪ"],[42928,"ʞ"],[42929,"ʇ"],[42930,"ʝ"],[42931,"ꭓ"],[42932,"ꞵ"],[42934,"ꞷ"],[42936,"ꞹ"],[42938,"ꞻ"],[42940,"ꞽ"],[42942,"ꞿ"],[42944,"ꟁ"],[42946,"ꟃ"],[42948,"ꞔ"],[42949,"ʂ"],[42950,"ᶎ"],[42951,"ꟈ"],[42953,"ꟊ"],[42955,"ɤ"],[42956,"ꟍ"],[42958,"꟏"],[42960,"ꟑ"],[42962,"ꟓ"],[42964,"ꟕ"],[42966,"ꟗ"],[42968,"ꟙ"],[42970,"ꟛ"],[42972,"ƛ"],[42997,"ꟶ"],[65313,"a"],[65314,"b"],[65315,"c"],[65316,"d"],[65317,"e"],[65318,"f"],[65319,"g"],[65320,"h"],[65321,"i"],[65322,"j"],[65323,"k"],[65324,"l"],[65325,"m"],[65326,"n"],[65327,"o"],[65328,"p"],[65329,"q"],[65330,"r"],[65331,"s"],[65332,"t"],[65333,"u"],[65334,"v"],[65335,"w"],[65336,"x"],[65337,"y"],[65338,"z"],[66560,"𐐨"],[66561,"𐐩"],[66562,"𐐪"],[66563,"𐐫"],[66564,"𐐬"],[66565,"𐐭"],[66566,"𐐮"],[66567,"𐐯"],[66568,"𐐰"],[66569,"𐐱"],[66570,"𐐲"],[66571,"𐐳"],[66572,"𐐴"],[66573,"𐐵"],[66574,"𐐶"],[66575,"𐐷"],[66576,"𐐸"],[66577,"𐐹"],[66578,"𐐺"],[66579,"𐐻"],[66580,"𐐼"],[66581,"𐐽"],[66582,"𐐾"],[66583,"𐐿"],[66584,"𐑀"],[66585,"𐑁"],[66586,"𐑂"],[66587,"𐑃"],[66588,"𐑄"],[66589,"𐑅"],[66590,"𐑆"],[66591,"𐑇"],[66592,"𐑈"],[66593,"𐑉"],[66594,"𐑊"],[66595,"𐑋"],[66596,"𐑌"],[66597,"𐑍"],[66598,"𐑎"],[66599,"𐑏"],[66736,"𐓘"],[66737,"𐓙"],[66738,"𐓚"],[66739,"𐓛"],[66740,"𐓜"],[66741,"𐓝"],[66742,"𐓞"],[66743,"𐓟"],[66744,"𐓠"],[66745,"𐓡"],[66746,"𐓢"],[66747,"𐓣"],[66748,"𐓤"],[66749,"𐓥"],[66750,"𐓦"],[66751,"𐓧"],[66752,"𐓨"],[66753,"𐓩"],[66754,"𐓪"],[66755,"𐓫"],[66756,"𐓬"],[66757,"𐓭"],[66758,"𐓮"],[66759,"𐓯"],[66760,"𐓰"],[66761,"𐓱"],[66762,"𐓲"],[66763,"𐓳"],[66764,"𐓴"],[66765,"𐓵"],[66766,"𐓶"],[66767,"𐓷"],[66768,"𐓸"],[66769,"𐓹"],[66770,"𐓺"],[66771,"𐓻"],[66928,"𐖗"],[66929,"𐖘"],[66930,"𐖙"],[66931,"𐖚"],[66932,"𐖛"],[66933,"𐖜"],[66934,"𐖝"],[66935,"𐖞"],[66936,"𐖟"],[66937,"𐖠"],[66938,"𐖡"],[66940,"𐖣"],[66941,"𐖤"],[66942,"𐖥"],[66943,"𐖦"],[66944,"𐖧"],[66945,"𐖨"],[66946,"𐖩"],[66947,"𐖪"],[66948,"𐖫"],[66949,"𐖬"],[66950,"𐖭"],[66951,"𐖮"],[66952,"𐖯"],[66953,"𐖰"],[66954,"𐖱"],[66956,"𐖳"],[66957,"𐖴"],[66958,"𐖵"],[66959,"𐖶"],[66960,"𐖷"],[66961,"𐖸"],[66962,"𐖹"],[66964,"𐖻"],[66965,"𐖼"],[68736,"𐳀"],[68737,"𐳁"],[68738,"𐳂"],[68739,"𐳃"],[68740,"𐳄"],[68741,"𐳅"],[68742,"𐳆"],[68743,"𐳇"],[68744,"𐳈"],[68745,"𐳉"],[68746,"𐳊"],[68747,"𐳋"],[68748,"𐳌"],[68749,"𐳍"],[68750,"𐳎"],[68751,"𐳏"],[68752,"𐳐"],[68753,"𐳑"],[68754,"𐳒"],[68755,"𐳓"],[68756,"𐳔"],[68757,"𐳕"],[68758,"𐳖"],[68759,"𐳗"],[68760,"𐳘"],[68761,"𐳙"],[68762,"𐳚"],[68763,"𐳛"],[68764,"𐳜"],[68765,"𐳝"],[68766,"𐳞"],[68767,"𐳟"],[68768,"𐳠"],[68769,"𐳡"],[68770,"𐳢"],[68771,"𐳣"],[68772,"𐳤"],[68773,"𐳥"],[68774,"𐳦"],[68775,"𐳧"],[68776,"𐳨"],[68777,"𐳩"],[68778,"𐳪"],[68779,"𐳫"],[68780,"𐳬"],[68781,"𐳭"],[68782,"𐳮"],[68783,"𐳯"],[68784,"𐳰"],[68785,"𐳱"],[68786,"𐳲"],[68944,"𐵰"],[68945,"𐵱"],[68946,"𐵲"],[68947,"𐵳"],[68948,"𐵴"],[68949,"𐵵"],[68950,"𐵶"],[68951,"𐵷"],[68952,"𐵸"],[68953,"𐵹"],[68954,"𐵺"],[68955,"𐵻"],[68956,"𐵼"],[68957,"𐵽"],[68958,"𐵾"],[68959,"𐵿"],[68960,"𐶀"],[68961,"𐶁"],[68962,"𐶂"],[68963,"𐶃"],[68964,"𐶄"],[68965,"𐶅"],[71840,"𑣀"],[71841,"𑣁"],[71842,"𑣂"],[71843,"𑣃"],[71844,"𑣄"],[71845,"𑣅"],[71846,"𑣆"],[71847,"𑣇"],[71848,"𑣈"],[71849,"𑣉"],[71850,"𑣊"],[71851,"𑣋"],[71852,"𑣌"],[71853,"𑣍"],[71854,"𑣎"],[71855,"𑣏"],[71856,"𑣐"],[71857,"𑣑"],[71858,"𑣒"],[71859,"𑣓"],[71860,"𑣔"],[71861,"𑣕"],[71862,"𑣖"],[71863,"𑣗"],[71864,"𑣘"],[71865,"𑣙"],[71866,"𑣚"],[71867,"𑣛"],[71868,"𑣜"],[71869,"𑣝"],[71870,"𑣞"],[71871,"𑣟"],[93760,"𖹠"],[93761,"𖹡"],[93762,"𖹢"],[93763,"𖹣"],[93764,"𖹤"],[93765,"𖹥"],[93766,"𖹦"],[93767,"𖹧"],[93768,"𖹨"],[93769,"𖹩"],[93770,"𖹪"],[93771,"𖹫"],[93772,"𖹬"],[93773,"𖹭"],[93774,"𖹮"],[93775,"𖹯"],[93776,"𖹰"],[93777,"𖹱"],[93778,"𖹲"],[93779,"𖹳"],[93780,"𖹴"],[93781,"𖹵"],[93782,"𖹶"],[93783,"𖹷"],[93784,"𖹸"],[93785,"𖹹"],[93786,"𖹺"],[93787,"𖹻"],[93788,"𖹼"],[93789,"𖹽"],[93790,"𖹾"],[93791,"𖹿"],[93856,"𖺻"],[93857,"𖺼"],[93858,"𖺽"],[93859,"𖺾"],[93860,"𖺿"],[93861,"𖻀"],[93862,"𖻁"],[93863,"𖻂"],[93864,"𖻃"],[93865,"𖻄"],[93866,"𖻅"],[93867,"𖻆"],[93868,"𖻇"],[93869,"𖻈"],[93870,"𖻉"],[93871,"𖻊"],[93872,"𖻋"],[93873,"𖻌"],[93874,"𖻍"],[93875,"𖻎"],[93876,"𖻏"],[93877,"𖻐"],[93878,"𖻑"],[93879,"𖻒"],[93880,"𖻓"],[125184,"𞤢"],[125185,"𞤣"],[125186,"𞤤"],[125187,"𞤥"],[125188,"𞤦"],[125189,"𞤧"],[125190,"𞤨"],[125191,"𞤩"],[125192,"𞤪"],[125193,"𞤫"],[125194,"𞤬"],[125195,"𞤭"],[125196,"𞤮"],[125197,"𞤯"],[125198,"𞤰"],[125199,"𞤱"],[125200,"𞤲"],[125201,"𞤳"],[125202,"𞤴"],[125203,"𞤵"],[125204,"𞤶"],[125205,"𞤷"],[125206,"𞤸"],[125207,"𞤹"],[125208,"𞤺"],[125209,"𞤻"],[125210,"𞤼"],[125211,"𞤽"],[125212,"𞤾"],[125213,"𞤿"],[125214,"𞥀"],[125215,"𞥁"],[125216,"𞥂"],[125217,"𞥃"]] +} diff --git a/rust/tests/fixtures.rs b/rust/tests/fixtures.rs new file mode 100644 index 0000000..35e72a4 --- /dev/null +++ b/rust/tests/fixtures.rs @@ -0,0 +1,331 @@ +//! Runs every shared fixture in `spec/fixtures` through `trackparse::wire::call`. +//! +//! - Matching follows spec/fixtures/README.md (partial / exact, artist shorthand, `specVersion` +//! never compared); status `pass` / `xfail` / `ambiguous`. +//! - `tests/skip.json` lists port-specific known failures; a listed case that passes fails the +//! run, so the list can only shrink. +//! - `TRACKPARSE_REPORT=1 cargo test --test fixtures -- --nocapture` prints the pass rate per file +//! and per rule instead of failing (the conformance report). +#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::indexing_slicing)] + +use std::collections::BTreeMap; +use std::path::{Path, PathBuf}; + +use serde_json::{Map, Value}; +use trackparse::json::Json; + +fn spec_dir() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")).join("../spec") +} + +fn walk(dir: &Path, out: &mut Vec) { + let mut entries: Vec = + std::fs::read_dir(dir).unwrap().map(|e| e.unwrap().path()).collect(); + entries.sort(); + for p in entries { + if p.is_dir() { + walk(&p, out); + } else if p.extension().is_some_and(|e| e == "json") { + out.push(p); + } + } +} + +fn show(v: &Value) -> String { + serde_json::to_string(v).unwrap() +} + +/// `match: "partial"` (README rules 1–4). `None` on a match. +fn match_partial(expected: &Value, actual: &Value, path: &str) -> Option { + match expected { + Value::Array(e) => { + let Value::Array(a) = actual else { + return Some(format!("{path}: expected an array, got {}", show(actual))); + }; + if a.len() != e.len() { + return Some(format!( + "{path}: expected {} items, got {}: {}", + e.len(), + a.len(), + show(actual) + )); + } + for (i, (ev, av)) in e.iter().zip(a).enumerate() { + // Rule 4: artist shorthand. + if let (Value::String(name), Value::Object(o)) = (ev, av) { + if let Some(actual_name) = o.get("name") { + if actual_name != ev { + return Some(format!( + "{path}[{i}].name: expected {name:?}, got {}", + show(actual_name) + )); + } + continue; + } + } + if let Some(d) = match_partial(ev, av, &format!("{path}[{i}]")) { + return Some(d); + } + } + None + } + Value::Object(e) => { + let Value::Object(a) = actual else { + return Some(format!("{path}: expected an object, got {}", show(actual))); + }; + for (k, ev) in e { + let Some(av) = a.get(k) else { return Some(format!("{path}.{k}: missing")) }; + if let Some(d) = match_partial(ev, av, &format!("{path}.{k}")) { + return Some(d); + } + } + None + } + _ => (!same(expected, actual)) + .then(|| format!("{path}: expected {}, got {}", show(expected), show(actual))), + } +} + +/// Scalars compare as in JS: numbers by value (`7` equals `7.0`). +fn same(e: &Value, a: &Value) -> bool { + match (e, a) { + (Value::Number(x), Value::Number(y)) => x.as_f64() == y.as_f64(), + _ => e == a, + } +} + +/// Deep equality of complete values (README rule 5). +fn match_exact(expected: &Value, actual: &Value, path: &str) -> Option { + match (expected, actual) { + (Value::Array(e), Value::Array(a)) if e.len() == a.len() => e + .iter() + .zip(a) + .enumerate() + .find_map(|(i, (ev, av))| match_exact(ev, av, &format!("{path}[{i}]"))), + (Value::Object(e), Value::Object(a)) => { + let mut ek: Vec<&String> = e.keys().collect(); + let mut ak: Vec<&String> = a.keys().collect(); + ek.sort(); + ak.sort(); + if ek != ak { + return Some(format!("{path}: expected keys {ek:?}, got {ak:?}")); + } + ek.into_iter().find_map(|k| match_exact(&e[k], &a[k], &format!("{path}.{k}"))) + } + (Value::Array(_) | Value::Object(_), _) => { + Some(format!("{path}: expected {}, got {}", show(expected), show(actual))) + } + _ => (!same(expected, actual)) + .then(|| format!("{path}: expected {}, got {}", show(expected), show(actual))), + } +} + +/// README rule 6: a top-level `specVersion` is never compared. +fn without_spec_version(v: &Value) -> Value { + match v { + Value::Object(o) if o.contains_key("specVersion") => { + let mut o = o.clone(); + o.remove("specVersion"); + Value::Object(o) + } + _ => v.clone(), + } +} + +fn matches(expected: &Value, actual: &Value, exact: bool) -> Option { + let (e, a) = (without_spec_version(expected), without_spec_version(actual)); + if exact { + match_exact(&e, &a, "$") + } else { + match_partial(&e, &a, "$") + } +} + +/// serde_json → the crate's own JSON (through text, which also exercises `Json::parse`). +/// Non-finite numbers travel as marker strings (see `load`) and become `1e999` again here, which +/// `Json::parse` reads as infinity, as JS does. +fn to_crate_json(v: &Value) -> Json { + let text = serde_json::to_string(v) + .unwrap() + .replace(&format!("\"{NEG_INFINITY}\""), "-1e999") + .replace(&format!("\"{INFINITY}\""), "1e999"); + Json::parse(&text).expect("round trip") +} + +fn merged(defaults: Option<&Value>, own: Option<&Value>) -> Value { + let mut out = Map::new(); + for src in [defaults, own].into_iter().flatten() { + if let Value::Object(o) = src { + for (k, v) in o { + out.insert(k.clone(), v.clone()); + } + } + } + Value::Object(out) +} + +struct Outcome { + /// `None` when the case behaves as its status demands. + failure: Option, +} + +fn run_case(file: &Value, case: &Value) -> Outcome { + let defaults = file.get("defaults"); + let func = case + .get("fn") + .or_else(|| defaults.and_then(|d| d.get("fn"))) + .and_then(Value::as_str) + .unwrap_or("parse"); + let options = merged(defaults.and_then(|d| d.get("options")), case.get("options")); + let format_options = + merged(defaults.and_then(|d| d.get("formatOptions")), case.get("formatOptions")); + let edits = case.get("edits").cloned().unwrap_or(Value::Array(vec![])); + let input = case.get("input").and_then(Value::as_str).unwrap_or(""); + + let result = std::panic::catch_unwind(|| { + trackparse::wire::call( + func, + input, + &to_crate_json(&options), + &to_crate_json(&format_options), + &to_crate_json(&edits), + ) + }); + let actual: Value = match result { + Ok(json) => serde_json::from_str(&json.write()).expect("the crate wrote invalid JSON"), + Err(_) => return Outcome { failure: Some("panicked".into()) }, + }; + + let status = case.get("status").and_then(Value::as_str).unwrap_or("pass"); + let exact = case.get("match").and_then(Value::as_str) == Some("exact"); + let mismatch = if status == "ambiguous" { + let any = case.get("expectedAny").and_then(Value::as_array).cloned().unwrap_or_default(); + let diffs: Vec> = any.iter().map(|e| matches(e, &actual, exact)).collect(); + if diffs.iter().any(Option::is_none) { + None + } else { + Some(format!( + "no expectedAny entry matched: {:?}", + diffs.into_iter().flatten().collect::>() + )) + } + } else { + matches(case.get("expected").unwrap_or(&Value::Null), &actual, exact) + }; + let failure = if status == "xfail" { + mismatch.is_none().then(|| "xfail case unexpectedly passes".to_string()) + } else { + mismatch + }; + Outcome { failure } +} + +const INFINITY: &str = "\u{1}trackparse:+infinity"; +const NEG_INFINITY: &str = "\u{1}trackparse:-infinity"; + +/// `1e999` is not a number serde_json reads; fixtures use it for infinity (R13.9.6). It is read +/// as a marker string (only where a value can stand, after `: `), which `to_crate_json` turns back into the number. +fn load(path: &Path) -> Value { + let text = std::fs::read_to_string(path).unwrap(); + let marker = |m: &str| serde_json::to_string(m).unwrap(); + serde_json::from_str( + &text + .replace(": -1e999", &format!(": {}", marker(NEG_INFINITY))) + .replace(": 1e999", &format!(": {}", marker(INFINITY))), + ) + .unwrap_or_else(|e| panic!("{}: {e}", path.display())) +} + +#[test] +fn shared_fixtures() { + let report = std::env::var("TRACKPARSE_REPORT").is_ok(); + let only = std::env::var("TRACKPARSE_ONLY").ok(); // substring of the file name or case id + let skip: BTreeMap = serde_json::from_str( + &std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/skip.json")) + .unwrap(), + ) + .unwrap(); + + let mut files = Vec::new(); + walk(&spec_dir().join("fixtures"), &mut files); + let mut failures: Vec = Vec::new(); + let mut per_file: Vec<(String, usize, usize)> = Vec::new(); + let mut per_rule: BTreeMap = BTreeMap::new(); + let (mut total, mut passed) = (0usize, 0usize); + + for path in &files { + let data = load(path); + let Some(cases) = data.get("cases").and_then(Value::as_array) else { continue }; + let name = path.strip_prefix(spec_dir().join("fixtures")).unwrap().display().to_string(); + let (mut n, mut ok) = (0usize, 0usize); + for case in cases { + let id = case.get("id").and_then(Value::as_str).unwrap_or("?"); + if let Some(f) = &only { + if !name.contains(f.as_str()) && !id.contains(f.as_str()) { + continue; + } + } + let mut problem = run_case(&data, case).failure; + if let Some(reason) = skip.get(id) { + problem = match problem { + None => Some(format!( + "skip-listed ({reason}) but now passes: remove it from tests/skip.json" + )), + Some(_) => None, + }; + } + n += 1; + let good = problem.is_none(); + if good { + ok += 1; + } + for rule in case + .get("rules") + .and_then(Value::as_array) + .into_iter() + .flatten() + .filter_map(Value::as_str) + { + let e = per_rule.entry(rule.to_string()).or_default(); + e.0 += 1; + e.1 += usize::from(good); + } + if let Some(p) = problem { + if failures.len() < 40 { + failures.push(format!( + "{id}\n input: {}\n {p}", + case.get("input").map(show).unwrap_or_default() + )); + } + } + } + total += n; + passed += ok; + per_file.push((name, ok, n)); + } + + if report { + println!("\nconformance: {passed} / {total}"); + for (name, ok, n) in &per_file { + println!(" {:>5} / {:<5} {}{}", ok, n, name, if ok == n { "" } else { " <--" }); + } + println!("by rule (failing only):"); + for (rule, (n, ok)) in &per_rule { + if ok != n { + println!(" {rule:<10} {ok} / {n}"); + } + } + for f in failures.iter().take(15) { + println!("\n{f}"); + } + return; + } + assert!(total > 0, "no fixtures found"); + assert!( + passed == total, + "{} of {} fixture cases fail; first ones:\n\n{}", + total - passed, + total, + failures.join("\n\n") + ); +} diff --git a/rust/tests/properties.rs b/rust/tests/properties.rs new file mode 100644 index 0000000..57f8590 --- /dev/null +++ b/rust/tests/properties.rs @@ -0,0 +1,510 @@ +//! SPEC.md "Invariants" for single tracks, checked on generated strings. +//! +//! The generator is a small deterministic PRNG over the fragments of the JS property tests +//! (`js/test/properties.test.ts`) plus random code points, so a failure is reproducible from its +//! case number. The tracklist invariants (R13.11) are in `tracklist_properties.rs`. +#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::indexing_slicing)] + +use std::collections::HashSet; +use std::time::{Duration, Instant}; + +use trackparse::{ + all_artists, format_track, format_track_with, normalize, parse, parse_artists, + parse_artists_with, parse_with, ArtistRole, FeatPlacement, FormatOptions, JoinerStyle, Junk, + JunkKind, Mode, ModeOption, ParseOptions, ParsedTrack, Parser, Position, SplitAnd, + VersionDelimiter, +}; + +/// mulberry32. +struct Rng(u32); + +impl Rng { + fn next(&mut self) -> u32 { + self.0 = self.0.wrapping_add(0x6d2b_79f5); + let mut t = self.0; + t = (t ^ (t >> 15)).wrapping_mul(t | 1); + t ^= t.wrapping_add((t ^ (t >> 7)).wrapping_mul(t | 61)); + t ^ (t >> 14) + } + + fn below(&mut self, n: usize) -> usize { + self.next() as usize % n + } + + fn pick<'a>(&mut self, items: &[&'a str]) -> &'a str { + items[self.below(items.len())] + } + + fn chance(&mut self, percent: usize) -> bool { + self.below(100) < percent + } +} + +/// Characters that exercise every scanner branch (the `tricky` set of the JS tests; its lone +/// surrogate cannot be in a Rust string and is U+FFFD here). +const TRICKY: &[&str] = &[ + " ", + " ", + "-", + " - ", + " – ", + "—", + "(", + ")", + "[", + "]", + "{", + "}", + "\"", + "'", + "“", + "|", + " | ", + ",", + ";", + "&", + " & ", + " x ", + " feat. ", + " ft ", + "prod. by ", + " by ", + ".", + ":", + "_", + "0", + "1", + "01. ", + "3:45 ", + "Remix", + " Mix", + "VIP", + "Official Video", + "ID", + "\u{200b}", + "\u{a0}", + "\u{3000}", + "é", + "e\u{301}", + "𝄞", + "\u{fffd}", + "×", + "/", + ".mp3", +]; + +/// One random code point, biased to the ranges the rules look at. +fn any_char(rng: &mut Rng) -> char { + let cp = match rng.below(10) { + 0..=3 => rng.below(0x80) as u32, + 4 => rng.below(0x100) as u32, + 5 => 0x300 + rng.below(0x70) as u32, // combining marks + 6 => 0x2000 + rng.below(0x70) as u32, // spaces, dashes, quotes, invisibles + 7 => rng.below(0x1_0000) as u32, + 8 => 0xff00 + rng.below(0xf0) as u32, // fullwidth forms + _ => rng.below(0x11_0000) as u32, + }; + char::from_u32(cp).unwrap_or('\u{fffd}') +} + +fn random_chars(rng: &mut Rng, max: usize) -> String { + (0..rng.below(max + 1)).map(|_| any_char(rng)).collect() +} + +fn noisy_string(rng: &mut Rng) -> String { + let mut out = String::new(); + for _ in 0..rng.below(25) { + if rng.chance(50) { + out.push_str(rng.pick(TRICKY)); + } else { + out.push_str(&random_chars(rng, 4)); + } + } + out +} + +fn any_string(rng: &mut Rng) -> String { + if rng.chance(50) { + random_chars(rng, 60) + } else { + noisy_string(rng) + } +} + +const ARTISTS: &[&str] = + &["Noisia", "Phace", "Fox Stevenson", "Sub Focus", "Mefjus", "Camo & Krooked", "Alix Perez"]; +const TITLES: &[&str] = + &["Tentacles", "Bruises", "Out the Blue", "Dead Limit", "Stigma", "Blind Faith"]; +const REMIXERS: &[&str] = &["Skrillex", "Magnetude", "Wilkinson", "Break"]; +const JOINERS: &[&str] = &[" & ", ", ", " x ", " vs. "]; + +/// A track-shaped input for the metamorphic and round-trip properties. +fn track_string(rng: &mut Rng) -> String { + let mut artists: Vec<&str> = Vec::new(); + for _ in 0..1 + rng.below(3) { + let a = rng.pick(ARTISTS); + if !artists.contains(&a) { + artists.push(a); + } + } + let mut s = artists.join(rng.pick(JOINERS)); + if rng.chance(50) { + let feat = rng.pick(ARTISTS); + if !artists.contains(&feat) { + s.push_str(&format!(" feat. {feat}")); + } + } + s.push_str(&format!(" - {}", rng.pick(TITLES))); + if rng.chance(50) { + s.push_str(&format!(" ({} Remix)", rng.pick(REMIXERS))); + } + s +} + +/// A track-shaped input that parses without warnings. +fn quiet_track(rng: &mut Rng) -> String { + loop { + let s = track_string(rng); + if parse(&s).warnings.is_empty() { + return s; + } + } +} + +fn without_input(mut track: ParsedTrack) -> ParsedTrack { + track.input = String::new(); + track +} + +/// Every public single-track function, in every mode, with the string as its own options. +fn exercise(s: &str) { + let default = parse(s); + let _ = (format_track(&default), all_artists(&default), default.to_json()); + let _ = (parse_artists(s), normalize(s)); + for mode in ModeOption::ALL { + let options = ParseOptions::new() + .mode(*mode) + .uploader(s) + .known_artists([s, "a", ""]) + .split_and(SplitAnd::Always); + let parser = Parser::new(&options); + let track = parser.parse(s); + assert_eq!(track.input, s); + assert_eq!(track, parse_with(s, &options)); + assert_eq!(parser.parse_artists(s), parse_artists_with(s, &options)); + for feat in FeatPlacement::ALL { + let format = FormatOptions::new() + .feat(*feat) + .feat_marker(s) + .joiners(JoinerStyle::Canonical) + .position(true); + let _ = format_track_with(&track, &format); + } + } +} + +#[test] +fn totality_never_panics() { + let mut rng = Rng(1); + for _ in 0..3000 { + exercise(&any_string(&mut rng)); + } + for s in ["", " ", "\0", "\u{feff}", "-", " - ", "(", ")", "((((", "]]]]", "\u{10ffff}"] { + exercise(s); + } + for fragment in TRICKY { + exercise(fragment); + exercise(&fragment.repeat(50)); + } +} + +/// The blocks of the JS suite, plus the credit shapes that once made dedup quadratic. +const BLOCKS: &[&str] = &[ + "(", + "a - ", + "A & B, ", + "feat. X ", + "[Remix] ", + "-a", + " by x", + "\"q\" ", + "xxxxxxx", + "prod. A feat. B ", + "a by me ", + "(x) - ", + "Official Video ", + "x - Official Video ", + "Remix - ", + "a feat. ", + "a & ", + "(a remix) ", +]; + +fn repeated(block: &str, code_points: usize) -> String { + block.chars().cycle().take(code_points).collect() +} + +fn timed_parse(input: &str, options: &ParseOptions) -> Duration { + let start = Instant::now(); + let track = parse_with(input, options); + let elapsed = start.elapsed(); + assert_eq!(track.input, input); + elapsed +} + +#[test] +fn totality_ten_thousand_code_points() { + // Invariant 1 asks for "well under 100 ms"; an optimized build needs a few milliseconds. The + // ceiling is generous because tests run unoptimized and on shared CI machines: it catches + // super-linear blowups, not noise. + for block in BLOCKS { + let input = repeated(block, 10_000); + for mode in [ModeOption::Auto, ModeOption::Youtube, ModeOption::Filename] { + let elapsed = timed_parse(&input, &ParseOptions::new().mode(mode)); + assert!(elapsed < Duration::from_secs(2), "{block:?} in {mode}: {elapsed:?}"); + } + } +} + +#[test] +fn repeated_fragments_scale_below_quadratic() { + // Four times the input: linear work takes about 4 times as long, quadratic work 16 times. + // Thousands of duplicate credits (`a feat. a feat. …`) were quadratic in R9.2 before the + // per-list index in `assemble.rs` (a ratio of 15 here). The better of two runs keeps + // scheduler noise out. + fn best(run: impl Fn() -> usize) -> f64 { + let once = || { + let start = Instant::now(); + assert!(run() > 0); + start.elapsed().as_secs_f64() + }; + once().min(once()) + } + let blocks = ["a feat. ", "A feat. a, ", "(feat. a) ", "a & "]; + for block in blocks { + let (small, large) = (repeated(block, 40_000), repeated(block, 160_000)); + let credits = best(|| parse_artists(&large).len()) / best(|| parse_artists(&small).len()); + let track = best(|| parse(&large).input.len()) / best(|| parse(&small).input.len()); + println!("{block:?}: parse_artists x{credits:.1}, parse x{track:.1}"); + assert!(credits < 8.0, "{block:?}: parse_artists takes {credits:.1} times as long"); + assert!(track < 8.0, "{block:?}: parse takes {track:.1} times as long"); + } +} + +#[test] +fn repeated_trailing_junk_is_linear() { + let input = format!("A - T {}", "Official Video ".repeat(2_666)); + let start = Instant::now(); + let track = parse_with(&input, &ParseOptions::new().mode(ModeOption::Youtube)); + assert_eq!(track.title, "T"); + assert_eq!(track.junk.len(), 2_666); + assert!(start.elapsed() < Duration::from_secs(2), "{:?}", start.elapsed()); +} + +#[test] +fn normalize_is_idempotent() { + let mut rng = Rng(2); + for case in 0..4000 { + let s = any_string(&mut rng); + let once = normalize(&s); + assert_eq!(normalize(&once), once, "case {case}: {s:?}"); + } +} + +#[test] +fn noise_insensitive() { + let mut rng = Rng(3); + for case in 0..300 { + let s = track_string(&mut rng); + let base = without_input(parse(&s)); + let cut = { + let at = rng.below(s.chars().count() + 1); + let byte = s.char_indices().nth(at).map_or(s.len(), |(i, _)| i); + format!("{}\u{200b}{}", &s[..byte], &s[byte..]) + }; + let noisy = [s.replace(' ', " "), s.replace(" - ", " – "), s.replace(" - ", " — "), cut]; + for n in noisy { + assert_eq!(without_input(parse(&n)), base, "case {case}: {n:?}"); + } + } +} + +/// R0.2 whitespace. +fn is_ws(c: char) -> bool { + matches!(c, + '\u{9}'..='\u{d}' | ' ' | '\u{85}' | '\u{a0}' | '\u{1680}' | '\u{2000}'..='\u{200a}' + | '\u{2028}' | '\u{2029}' | '\u{202f}' | '\u{205f}' | '\u{3000}') +} + +#[test] +fn artist_hygiene() { + let mut rng = Rng(5); + for case in 0..3000 { + let s = if rng.chance(70) { any_string(&mut rng) } else { track_string(&mut rng) }; + let track = parse(&s); + let mut seen: HashSet<(bool, &str)> = HashSet::new(); + for artist in &track.artists { + let name = artist.name.as_str(); + assert!(!name.is_empty(), "case {case}: empty name in {s:?}"); + assert_eq!(name.trim_matches(is_ws), name, "case {case}: untrimmed name in {s:?}"); + // R9.2: producers are deduped only among producers. (The R0.4 dedup key is not + // public; names that are equal as written share it.) + let class = artist.role == ArtistRole::Producer; + assert!(seen.insert((class, name)), "case {case}: duplicate {name:?} in {s:?}"); + } + } +} + +/// Invariant 6: the words of `normalize(input)`, minus separators, joiners, feat markers and +/// bracket characters. Neither the JS nor the Python suite has this property; it is checked here +/// as the spec states it, on track-shaped inputs with an optional position and junk group. +fn content_words(normalized: &str) -> Vec { + normalized + .split(is_ws) + .filter(|w| !matches!(*w, "-" | "&" | "x" | "vs." | "feat.")) + .map(|w| w.trim_matches(|c| matches!(c, '(' | ')' | '[' | ']' | ',' | '.')).to_string()) + .filter(|w| !w.is_empty()) + .collect() +} + +fn output_strings(track: &ParsedTrack) -> Vec<&str> { + let mut out = vec![track.title.as_str(), track.full_title.as_str()]; + out.extend(track.artists.iter().map(|a| a.name.as_str())); + for version in &track.versions { + out.push(&version.raw); + out.extend(version.artists.iter().map(|a| a.name.as_str())); + } + out.extend(track.junk.iter().map(|j| j.raw.as_str())); + out.extend(track.position.iter().map(|p| p.raw.as_str())); + out.extend(track.timestamp.iter().map(|t| t.raw.as_str())); + out +} + +#[test] +fn conservation_no_word_goes_missing() { + let mut rng = Rng(6); + for case in 0..1000 { + let mut s = track_string(&mut rng); + if rng.chance(30) { + s = format!("{}{s}", rng.pick(&["01. ", "7. ", "12. ", "[03:45] ", "1:02:03 "])); + } + if rng.chance(30) { + s.push_str(rng.pick(&[" (Official Video)", " [HD]", " [Free Download]", " (VIP)"])); + } + let track = parse(&s); + let fields = output_strings(&track); + for word in content_words(&normalize(&s)) { + assert!( + fields.iter().any(|f| f.contains(word.as_str())), + "case {case}: {word:?} of {s:?} is in no output field: {}", + track.to_json() + ); + } + } +} + +#[test] +fn metamorphic_position_prefix_only_sets_position() { + let mut rng = Rng(7); + for case in 0..200 { + let s = quiet_track(&mut rng); + let plain = without_input(parse(&s)); + let mut numbered = without_input(parse(&format!("01. {s}"))); + assert_eq!( + numbered.position.take(), + Some(Position { raw: "01".into(), number: 1 }), + "case {case}: {s:?}" + ); + assert_eq!(numbered, plain, "case {case}: {s:?}"); + } +} + +#[test] +fn metamorphic_official_video_only_adds_junk() { + let mut rng = Rng(8); + for case in 0..200 { + let s = quiet_track(&mut rng); + let plain = without_input(parse(&s)); + let mut noisy = without_input(parse(&format!("{s} (Official Video)"))); + let mut junk = plain.junk.clone(); + junk.push(Junk { raw: "Official Video".into(), kind: JunkKind::Video }); + assert_eq!(noisy.junk, junk, "case {case}: {s:?}"); + assert!(noisy.mode == plain.mode || noisy.mode == Mode::Youtube, "case {case}: {s:?}"); + noisy.junk = plain.junk.clone(); + noisy.mode = plain.mode; + assert_eq!(noisy, plain, "case {case}: {s:?}"); + } +} + +/// A warning-free track that ends with ` (X Remix)`, cut before that group. +fn quiet_remix(rng: &mut Rng) -> (String, String) { + loop { + let s = quiet_track(rng); + if s.ends_with(" Remix)") { + let open = s.rfind('(').unwrap(); + return (s[..open].to_string(), s[open + 1..s.len() - 1].to_string()); + } + } +} + +#[test] +fn metamorphic_square_brackets_change_only_the_delimiter() { + let mut rng = Rng(9); + for case in 0..200 { + let (head, group) = quiet_remix(&mut rng); + let round = without_input(parse(&format!("{head}({group})"))); + let mut square = without_input(parse(&format!("{head}[{group}]"))); + assert_eq!(square.versions.last().unwrap().delimiter, VersionDelimiter::Square); + for version in &mut square.versions { + version.delimiter = VersionDelimiter::Paren; + } + square.full_title = round.full_title.clone(); + assert_eq!(square, round, "case {case}: {head:?} {group:?}"); + } +} + +#[test] +fn metamorphic_keyword_case_changes_only_raw() { + let mut rng = Rng(10); + for case in 0..200 { + let (head, group) = quiet_remix(&mut rng); + let lower = without_input(parse(&format!("{head}({group})"))); + let shouted = group.replace(" Remix", " REMIX"); + let mut upper = without_input(parse(&format!("{head}({shouted})"))); + assert_eq!(upper.versions.last().unwrap().raw, shouted, "case {case}"); + for (version, same) in upper.versions.iter_mut().zip(&lower.versions) { + version.raw = same.raw.clone(); + } + upper.full_title = lower.full_title.clone(); + assert_eq!(upper, lower, "case {case}: {head:?} {group:?}"); + } +} + +/// What R11.6 promises to keep: names with roles, the title, and each version's type and names. +type Shape = (Vec<(String, ArtistRole)>, String, Vec<(String, Vec)>); + +fn shape(track: &ParsedTrack) -> Shape { + ( + track.artists.iter().map(|a| (a.name.clone(), a.role)).collect(), + track.title.clone(), + track + .versions + .iter() + .map(|v| { + (v.version_type.to_string(), v.artists.iter().map(|a| a.name.clone()).collect()) + }) + .collect(), + ) +} + +#[test] +fn round_trip_through_format_track() { + let mut rng = Rng(11); + for case in 0..500 { + let s = quiet_track(&mut rng); + let first = parse(&s); + let formatted = format_track(&first); + let second = parse(&formatted); + assert_eq!(shape(&second), shape(&first), "case {case}: {s:?} -> {formatted:?}"); + } +} diff --git a/rust/tests/serde.rs b/rust/tests/serde.rs new file mode 100644 index 0000000..f52e744 --- /dev/null +++ b/rust/tests/serde.rs @@ -0,0 +1,486 @@ +//! The `serde` feature: `serde_json::to_string(&x)` is the text of `x.to_json()` for every +//! output type, over every shared fixture input, and the typed options and edits read from JSON +//! give what the JSON door (`wire`) gives. +#![cfg(feature = "serde")] +#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::indexing_slicing)] + +use std::path::{Path, PathBuf}; + +use serde::de::DeserializeOwned; +use serde::Serialize; +use serde_json::{Map, Value}; +use trackparse::json::Json; +use trackparse::tracklist::{ + apply_edits, parse_tracklist, parse_tracklist_with, Edit, EditResult, EditWarningCode, + EntryKind, Eol, Severity, Tracklist, TracklistOptions, WarningCode, +}; +use trackparse::{ + format_track, format_track_with, parse, parse_artists, parse_artists_with, parse_with, wire, + Artist, ArtistRole, ArtistSource, FeatPlacement, FormatOptions, JoinerStyle, JunkKind, + KeywordOptions, Mode, ModeOption, ParseOptions, ParsedTrack, SplitAnd, VersionDelimiter, + VersionType, VersionsOption, Warning, +}; + +fn walk(dir: &Path, out: &mut Vec) { + let mut entries: Vec = + std::fs::read_dir(dir).unwrap().map(|e| e.unwrap().path()).collect(); + entries.sort(); + for p in entries { + if p.is_dir() { + walk(&p, out); + } else if p.extension().is_some_and(|e| e == "json") { + out.push(p); + } + } +} + +fn merged(defaults: Option<&Value>, own: Option<&Value>) -> Value { + let mut out = Map::new(); + for src in [defaults, own].into_iter().flatten() { + if let Value::Object(o) = src { + for (k, v) in o { + out.insert(k.clone(), v.clone()); + } + } + } + Value::Object(out) +} + +/// The value as the crate's own JSON, for the `wire` door. +fn crate_json(value: &T) -> Json { + Json::parse(&serde_json::to_string(value).unwrap()).unwrap() +} + +fn none() -> Json { + Json::Obj(Vec::new()) +} + +/// `serde_json` writes the text of `to_json()`, and reads it back to an equal value. +fn same(value: &T, json: String) { + assert_eq!(serde_json::to_string(value).unwrap(), json); + let back: T = serde_json::from_str(&json).unwrap_or_else(|e| panic!("{e}: {json}")); + assert_eq!(&back, value, "round trip of {json}"); +} + +fn same_value(a: &T, b: &T) -> bool { + a == b +} + +fn same_artists(artists: &[Artist]) -> String { + let json = format!("[{}]", artists.iter().map(Artist::to_json).collect::>().join(",")); + same(&artists.to_vec(), json.clone()); + json +} + +#[derive(Default, Debug)] +struct Counts { + cases: usize, + typed_options: usize, + typed_edits: usize, +} + +fn check_case( + func: &str, + input: &str, + options: &Value, + format_options: &Value, + edits: &Value, + n: &mut Counts, +) { + n.cases += 1; + match func { + "parse" | "format" | "parseArtists" => { + let track: ParsedTrack = parse(input); + same(&track, track.to_json()); + same_artists(&parse_artists(input)); + // Options the typed API can express: the typed call is the JSON door's call. + if let Ok(typed) = serde_json::from_value::(options.clone()) { + n.typed_options += 1; + let again = crate_json(&typed); + same(&typed, again.write()); + let track = parse_with(input, &typed); + same(&track, track.to_json()); + assert_eq!( + track.to_json(), + wire::call("parse", input, &again, &none(), &none()).write() + ); + let artists = same_artists(&parse_artists_with(input, &typed)); + assert_eq!( + artists, + wire::call("parseArtists", input, &again, &none(), &none()).write() + ); + if let Ok(format) = serde_json::from_value::(format_options.clone()) + { + let format_again = crate_json(&format); + same(&format, format_again.write()); + let text = format_track_with(&track, &format); + assert_eq!( + Json::Str(text), + wire::call("format", input, &again, &format_again, &none()) + ); + } + } + } + "parseTracklist" | "applyEdits" => { + let list: Tracklist = parse_tracklist(input); + same(&list, list.to_json()); + if let Ok(typed) = serde_json::from_value::(options.clone()) { + n.typed_options += 1; + let again = crate_json(&typed); + same(&typed, again.write()); + let list = parse_tracklist_with(input, &typed); + same(&list, list.to_json()); + assert_eq!( + list.to_json(), + wire::call("parseTracklist", input, &again, &none(), &none()).write() + ); + } + if let Ok(typed) = serde_json::from_value::>(edits.clone()) { + n.typed_edits += typed.len(); + for edit in &typed { + if same_value(edit, edit) { + same(edit, edit.to_json()); + } else { + // Non-finite seconds (`null`) read back as NaN, which equals nothing. + assert_eq!(serde_json::to_string(edit).unwrap(), edit.to_json()); + } + } + let result: EditResult = apply_edits(input, &typed); + same(&result, result.to_json()); + assert_eq!( + result.to_json(), + wire::call("applyEdits", input, &none(), &none(), &crate_json(&typed)).write() + ); + } + } + _ => {} + } +} + +#[test] +fn serde_json_writes_to_json_for_every_fixture_input() { + let mut files = Vec::new(); + walk(&Path::new(env!("CARGO_MANIFEST_DIR")).join("../spec/fixtures"), &mut files); + let mut n = Counts::default(); + for path in &files { + // `1e999` (infinity) is not JSON serde_json reads; such edits have no typed form anyway. + let text = std::fs::read_to_string(path) + .unwrap() + .replace("-1e999", "null") + .replace("1e999", "null"); + let data: Value = serde_json::from_str(&text).unwrap(); + let Some(cases) = data.get("cases").and_then(Value::as_array) else { continue }; + let defaults = data.get("defaults"); + for case in cases { + let func = case + .get("fn") + .or_else(|| defaults.and_then(|d| d.get("fn"))) + .and_then(Value::as_str) + .unwrap_or("parse"); + let options = merged(defaults.and_then(|d| d.get("options")), case.get("options")); + let format_options = + merged(defaults.and_then(|d| d.get("formatOptions")), case.get("formatOptions")); + let edits = case.get("edits").cloned().unwrap_or(Value::Array(vec![])); + let input = case.get("input").and_then(Value::as_str).unwrap_or(""); + check_case(func, input, &options, &format_options, &edits, &mut n); + } + } + println!("{n:?}"); + assert!(n.cases > 13_000, "{n:?}"); + assert!(n.typed_options > 12_000, "{n:?}"); + assert!(n.typed_edits > 50, "{n:?}"); +} + +#[test] +fn enums_are_their_spec_names() { + fn names( + all: &[T], + as_str: impl Fn(T) -> &'static str, + ) { + for value in all { + let json = serde_json::to_string(value).unwrap(); + assert_eq!(json, serde_json::to_string(as_str(*value)).unwrap()); + assert_eq!(&serde_json::from_str::(&json).unwrap(), value); + } + assert!(serde_json::from_str::("\"no such name\"").is_err()); + assert!(serde_json::from_str::("1").is_err()); + } + names(Mode::ALL, Mode::as_str); + names(ArtistRole::ALL, ArtistRole::as_str); + names(ArtistSource::ALL, ArtistSource::as_str); + names(VersionType::ALL, VersionType::as_str); + names(VersionDelimiter::ALL, VersionDelimiter::as_str); + names(JunkKind::ALL, JunkKind::as_str); + names(Warning::ALL, Warning::as_str); + names(ModeOption::ALL, ModeOption::as_str); + names(SplitAnd::ALL, SplitAnd::as_str); + names(FeatPlacement::ALL, FeatPlacement::as_str); + names(JoinerStyle::ALL, JoinerStyle::as_str); + names(VersionsOption::ALL, VersionsOption::as_str); + names(EntryKind::ALL, EntryKind::as_str); + names(Eol::ALL, Eol::as_str); + names(WarningCode::ALL, WarningCode::as_str); + names(Severity::ALL, Severity::as_str); + names(EditWarningCode::ALL, EditWarningCode::as_str); +} + +#[test] +fn options_read_and_write_the_spec_keys() { + let options: ParseOptions = serde_json::from_str( + r#"{"mode":"youtube","uploader":"Noisia","knownArtists":["Chase & Status"], + "splitAnd":"never","keywords":{"versionHeads":{"rerub":"remix","7":"edit"}, + "junk":{"out now":"promo"},"featMarkers":["starring"]}}"#, + ) + .unwrap(); + let keywords = KeywordOptions::new() + .version_head("rerub", VersionType::Remix) + .version_head("7", VersionType::Edit) + .junk("out now", JunkKind::Promo) + .feat_marker("starring"); + let expected = ParseOptions::new() + .mode(ModeOption::Youtube) + .uploader("Noisia") + .known_artists(["Chase & Status"]) + .split_and(SplitAnd::Never) + .keywords(keywords); + assert_eq!(options, expected); + assert_eq!( + serde_json::to_string(&options).unwrap(), + concat!( + r#"{"mode":"youtube","uploader":"Noisia","knownArtists":["Chase & Status"],"#, + r#""splitAnd":"never","keywords":{"versionHeads":{"rerub":"remix","7":"edit"},"#, + r#""descriptors":[],"genres":[],"junk":{"out now":"promo"},"featMarkers":["starring"]}}"# + ) + ); + // Missing keys are the defaults; a bad value is an error (the typed API has no fallbacks). + assert_eq!(serde_json::from_str::("{}").unwrap(), ParseOptions::default()); + assert_eq!(serde_json::from_str::("{}").unwrap(), FormatOptions::default()); + assert_eq!( + serde_json::from_str::("{}").unwrap(), + TracklistOptions::default() + ); + assert!(serde_json::from_str::(r#"{"mode":"radio"}"#).is_err()); + assert_eq!( + serde_json::to_string(&FormatOptions::new().feat(FeatPlacement::Omit)).unwrap(), + r#"{"feat":"omit","joiners":"original","versions":"all","producers":true,"position":false}"# + ); + assert_eq!( + serde_json::to_string(&TracklistOptions::new().audio_seconds(3600.5)).unwrap(), + r#"{"mode":"tracklist","knownArtists":[],"splitAnd":"auto","audioSeconds":3600.5,"markerWords":[]}"# + ); +} + +#[test] +fn edits_read_and_write_the_spec_form() { + let edits: Vec = serde_json::from_str( + r#"[{"op":"set-time","line":3,"seconds":90},{"op":"shift","seconds":-1.5,"from":2}, + {"op":"shift","seconds":10,"lines":[1,2]},{"op":"sort-by-time"}, + {"op":"set-rest","line":1,"rest":"A - B"},{"op":"insert","after":0,"text":"x"}, + {"op":"delete","line":4}]"#, + ) + .unwrap(); + assert_eq!( + edits, + [ + Edit::set_time(3, 90.0), + Edit::shift_from(-1.5, 2), + Edit::shift_lines(10.0, [1, 2]), + Edit::sort_by_time(), + Edit::set_rest(1, "A - B"), + Edit::insert(0, "x"), + Edit::delete(4), + ] + ); + assert_eq!( + serde_json::to_string(&edits).unwrap(), + concat!( + r#"[{"op":"set-time","line":3,"seconds":90},{"op":"shift","seconds":-1.5,"from":2},"#, + r#"{"op":"shift","seconds":10,"lines":[1,2]},{"op":"sort-by-time"},"#, + r#"{"op":"set-rest","line":1,"rest":"A - B"},{"op":"insert","after":0,"text":"x"},"#, + r#"{"op":"delete","line":4}]"# + ) + ); + assert!(serde_json::from_str::(r#"{"op":"rename","line":1}"#).is_err()); + assert_eq!(format_track(&parse("A - B")), "A - B"); +} + +/// `serde_json` writes `json`, which is also `to_json()`. +fn text(value: &T, to_json: String, json: &str) { + assert_eq!(to_json, json); + assert_eq!(serde_json::to_string(value).unwrap(), json); +} + +#[test] +fn numbers_are_written_as_to_json_writes_them() { + // Whole seconds of 2^53 and more: the digits JavaScript prints, not the exact integer. + let big = [ + (9007199254740992.0, "9007199254740992"), + (9007199254740994.0, "9007199254740994"), + (2f64.powi(60), "1152921504606847000"), + (-(2f64.powi(60)), "-1152921504606847000"), + (2f64.powi(63), "9223372036854776000"), + (2f64.powi(64), "18446744073709552000"), + (-(2f64.powi(64)), "-18446744073709552000"), + (1e20, "100000000000000000000"), + (123456789012345680000.0, "123456789012345680000"), + (-0.0, "0"), + (0.1, "0.1"), + (3600.5, "3600.5"), + (0.00001, "0.00001"), + (1.5e-7, "1.5e-7"), + ]; + for (seconds, digits) in big { + let edit = Edit::set_time(1, seconds); + text(&edit, edit.to_json(), &format!(r#"{{"op":"set-time","line":1,"seconds":{digits}}}"#)); + // Read back: the same double. (Without its `float_roundtrip` feature `serde_json` may + // read a long digit string one unit in the last place off; allow exactly that.) + let Edit::SetTime { seconds: back, .. } = serde_json::from_str(&edit.to_json()).unwrap() + else { + panic!("{digits}") + }; + assert!((back - seconds).abs() <= seconds.abs() * f64::EPSILON, "{digits}: {back}"); + let edit = Edit::shift(seconds); + text(&edit, edit.to_json(), &format!(r#"{{"op":"shift","seconds":{digits}}}"#)); + let options = TracklistOptions::new().audio_seconds(seconds); + let json = serde_json::to_string(&options).unwrap(); + assert!(json.contains(&format!(r#""audioSeconds":{digits},"#)), "{json}"); + let back = serde_json::from_str::(&json).unwrap().audio_seconds.unwrap(); + assert!((back - seconds).abs() <= seconds.abs() * f64::EPSILON, "{digits}: {back}"); + } + + // Where `serde_json` has its own float notation the characters can differ from `to_json()` + // (which writes what JavaScript writes): `1e-6` for `0.000001`, and in serde_json releases + // that write floats with ryu, `1e21` for `1e+21`. It is the same number and reads back equal from either text. + for (seconds, js) in [(0.000001, "0.000001"), (0.0000025, "0.0000025"), (1e21, "1e+21")] { + let edit = Edit::shift(seconds); + assert_eq!(edit.to_json(), format!(r#"{{"op":"shift","seconds":{js}}}"#)); + let json = serde_json::to_string(&edit).unwrap(); + assert_eq!(serde_json::from_str::(&json).unwrap(), edit); + assert_eq!(serde_json::from_str::(&edit.to_json()).unwrap(), edit); + } + assert_eq!( + serde_json::to_string(&Edit::shift(0.000001)).unwrap(), + r#"{"op":"shift","seconds":1e-6}"# + ); +} + +#[test] +fn non_finite_seconds_are_null_and_read_back_as_nan() { + for seconds in [f64::NAN, f64::INFINITY, f64::NEG_INFINITY] { + let edit = Edit::set_time(2, seconds); + text(&edit, edit.to_json(), r#"{"op":"set-time","line":2,"seconds":null}"#); + let back: Edit = serde_json::from_str(&edit.to_json()).unwrap(); + assert!(matches!(back, Edit::SetTime { line: 2, seconds } if seconds.is_nan()), "{back:?}"); + // Either way the edit is invalid (R13.9.6). + let text = "00:00 A - B\n01:00 C - D"; + assert_eq!(apply_edits(text, &[back]), apply_edits(text, &[edit])); + assert_eq!(apply_edits(text, &[Edit::shift(seconds)]).warnings[0].line, None); + + let options = TracklistOptions::new().audio_seconds(seconds); + let json = serde_json::to_string(&options).unwrap(); + assert!(json.contains(r#""audioSeconds":null"#), "{json}"); + // A non-finite length is ignored (R13.10), so reading it back as "not set" is the same. + assert_eq!(serde_json::from_str::(&json).unwrap().audio_seconds, None); + } + assert!(serde_json::from_str::(r#"{"op":"set-time","line":2,"seconds":"5"}"#).is_err()); +} + +#[test] +fn line_numbers_above_2_53_are_js_numbers() { + let edit = Edit::delete(usize::MAX); + text(&edit, edit.to_json(), r#"{"op":"delete","line":18446744073709552000}"#); + assert_eq!(serde_json::from_str::(&edit.to_json()).unwrap(), edit); + + let odd = (1usize << 53) + 1; + for edit in [Edit::set_time(odd, 1.0), Edit::set_rest(odd, "x"), Edit::insert(odd, "x")] { + let json = edit.to_json(); + assert!(json.contains("9007199254740992"), "{json}"); + assert_eq!(serde_json::to_string(&edit).unwrap(), json); + } + let edit = Edit::shift_lines(1.0, [1, odd, usize::MAX]); + text( + &edit, + edit.to_json(), + r#"{"op":"shift","seconds":1,"lines":[1,9007199254740992,18446744073709552000]}"#, + ); + assert_eq!( + serde_json::from_str::(&edit.to_json()).unwrap(), + Edit::shift_lines(1.0, [1, 1 << 53, usize::MAX]) + ); + let edit = Edit::shift_from(1.0, usize::MAX); + text(&edit, edit.to_json(), r#"{"op":"shift","seconds":1,"from":18446744073709552000}"#); + assert_eq!(serde_json::from_str::(&edit.to_json()).unwrap(), edit); + + // The warning carries the edit's line as a `usize`, and its JSON is the wire's. + let result = apply_edits("00:00 a - b", &[Edit::delete(usize::MAX), Edit::delete(5)]); + assert_eq!(result.warnings[0].line, Some(usize::MAX)); + same(&result, result.to_json()); + assert_eq!( + result.to_json(), + wire::call( + "applyEdits", + "00:00 a - b", + &none(), + &none(), + &crate_json(&[Edit::delete(usize::MAX), Edit::delete(5)]) + ) + .write() + ); + + // A line is a non-negative whole number; `3.0` is one, as in JavaScript. + assert_eq!( + serde_json::from_str::(r#"{"op":"delete","line":3.0}"#).unwrap(), + Edit::delete(3) + ); + for bad in ["-1", "1.5", "\"1\"", "null", "true"] { + let json = format!(r#"{{"op":"delete","line":{bad}}}"#); + assert!(serde_json::from_str::(&json).is_err(), "{json}"); + } + assert_eq!( + serde_json::from_str::(r#"{"op":"shift","seconds":1}"#).unwrap(), + Edit::shift(1.0) + ); +} + +#[test] +fn keyword_maps_have_no_repeated_keys() { + // A repeated key keeps its first place and takes the last value, like a JS object. + let keywords = KeywordOptions::new() + .version_head("rerub", VersionType::Remix) + .version_head("touch", VersionType::Edit) + .version_head("rerub", VersionType::Vip) + .junk("out now", JunkKind::Promo) + .junk("out now", JunkKind::Label); + let unique = KeywordOptions::new() + .version_head("rerub", VersionType::Vip) + .version_head("touch", VersionType::Edit) + .junk("out now", JunkKind::Label); + let json = serde_json::to_string(&keywords).unwrap(); + assert_eq!( + json, + concat!( + r#"{"versionHeads":{"rerub":"vip","touch":"edit"},"descriptors":[],"genres":[],"#, + r#""junk":{"out now":"label"},"featMarkers":[]}"# + ) + ); + assert_eq!(serde_json::from_str::(&json).unwrap(), unique); + let repeated = r#"{"versionHeads":{"rerub":"remix","touch":"edit","rerub":"vip"}, + "junk":{"out now":"promo","out now":"label"}}"#; + assert_eq!(serde_json::from_str::(repeated).unwrap(), unique); + // All three mean the same options. + let input = "Noisia - Stigma (Phace Rerub) [Out Now]"; + let with = |k: &KeywordOptions| parse_with(input, &ParseOptions::new().keywords(k.clone())); + assert_eq!(with(&keywords), with(&unique)); + assert_eq!(with(&unique).versions[0].version_type, VersionType::Vip); + assert_eq!( + with(&keywords).to_json(), + wire::call( + "parse", + input, + &Json::parse(&format!(r#"{{"keywords":{repeated}}}"#)).unwrap(), + &none(), + &none() + ) + .write() + ); +} diff --git a/rust/tests/skip.json b/rust/tests/skip.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/rust/tests/skip.json @@ -0,0 +1 @@ +{} diff --git a/rust/tests/tracklist_api.rs b/rust/tests/tracklist_api.rs new file mode 100644 index 0000000..bd4bd13 --- /dev/null +++ b/rust/tests/tracklist_api.rs @@ -0,0 +1,404 @@ +//! The typed tracklist API: it must agree with the JSON door (`wire`), which the shared fixtures +//! and the cross-port diff exercise. +#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::indexing_slicing)] + +use trackparse::json::Json; +use trackparse::tracklist::{ + apply_edits, apply_edits_with, parse_tracklist, parse_tracklist_with, Edit, EditResult, + EditWarning, EditWarningCode, EntryKind, Eol, Parts, Severity, Stats, Suggestion, TimeValue, + Tracklist, TracklistEntry, TracklistOptions, TracklistWarning, WarningCode, +}; +use trackparse::{ + wire, JunkKind, KeywordOptions, Mode, ModeOption, SplitAnd, ToJson, VersionType, SPEC_VERSION, +}; + +const TEXTS: &[&str] = &[ + "", + "\n", + "00:00 Noisia - Stigma\n03:30 Phace - Psycho\nrecorded live\n07:15 Mefjus - Sinkhole", + "Tracklist:\r\n[00:00] Intro\r\n[01:30] 1 Noisia - Stigma\r\n[05:00] 2 Phace - Psycho\r\n", + "**00:00** *Noisia* - Stigma\r- 03:30 Camo & Krooked - Climax\rw/ Mefjus - Sinkhole\r", + "0:00 A - B\n1:22:21 C - D\n1:03:00 E - F\n1:75 bad\nhttps://example.com\n", + "01:02:03.250 🎵 - 𝐀𝐁 (👨‍👩‍👧 Remix)\u{2028}still the same line\n\u{3000}\n12:34,5 x", + "1 Noisia - Stigma\n2 Phace - Psycho\n4 Mefjus - Sinkhole\n4 A - B", +]; + +fn json(text: &str) -> Json { + Json::parse(text).unwrap() +} + +fn none() -> Json { + json("{}") +} + +fn wire_parse(text: &str, options: &str) -> String { + wire::call("parseTracklist", text, &json(options), &none(), &json("[]")).write() +} + +fn wire_edits(text: &str, edits: &str) -> String { + wire::call("applyEdits", text, &none(), &none(), &json(edits)).write() +} + +#[test] +fn typed_parse_matches_the_wire() { + for text in TEXTS { + assert_eq!(parse_tracklist(text).to_json(), wire_parse(text, "{}"), "{text:?}"); + let default = parse_tracklist_with(text, &TracklistOptions::default()); + assert_eq!(default, parse_tracklist(text), "{text:?}"); + } +} + +#[test] +fn typed_options_match_the_wire() { + let keywords = KeywordOptions::new() + .version_head("rub", VersionType::Remix) + .junk("free dl", JunkKind::Promo); + let cases: Vec<(TracklistOptions, &str)> = vec![ + (TracklistOptions::new().mode(ModeOption::Auto), r#"{"mode":"auto"}"#), + (TracklistOptions::new().mode(ModeOption::Clean), r#"{"mode":"clean"}"#), + (TracklistOptions::new().mode(ModeOption::Youtube), r#"{"mode":"youtube"}"#), + (TracklistOptions::new().mode(ModeOption::Filename), r#"{"mode":"filename"}"#), + (TracklistOptions::new().mode(ModeOption::Tracklist), r#"{"mode":"tracklist"}"#), + (TracklistOptions::new().audio_seconds(200.0), r#"{"audioSeconds":200}"#), + (TracklistOptions::new().audio_seconds(-1.0), r#"{"audioSeconds":-1}"#), + (TracklistOptions::new().audio_seconds(f64::NAN), r#"{"audioSeconds":null}"#), + (TracklistOptions::new().audio_seconds(f64::INFINITY), r#"{"audioSeconds":1e999}"#), + ( + TracklistOptions::new().marker_words(["recorded", "x-y z"]), + r#"{"markerWords":["recorded","x-y z"]}"#, + ), + ( + TracklistOptions::new().known_artists(["Camo & Krooked"]), + r#"{"knownArtists":["Camo & Krooked"]}"#, + ), + (TracklistOptions::new().split_and(SplitAnd::Never), r#"{"splitAnd":"never"}"#), + (TracklistOptions::new().split_and(SplitAnd::Always), r#"{"splitAnd":"always"}"#), + ( + TracklistOptions::new().keywords(keywords), + r#"{"keywords":{"versionHeads":{"rub":"remix"},"junk":{"free dl":"promo"}}}"#, + ), + ]; + let extra = + "00:00 Camo & Krooked - Climax (Noisia Rub) free dl\n02:00 A and B - C\nrecorded live"; + for (typed, loose) in &cases { + for text in TEXTS.iter().chain([&extra]) { + assert_eq!( + parse_tracklist_with(text, typed).to_json(), + wire_parse(text, loose), + "{loose} {text:?}" + ); + } + } +} + +#[test] +fn bad_wire_options_fall_back() { + let text = TEXTS[2]; + let default = wire_parse(text, "{}"); + for loose in [ + "null", + "5", + "[]", + r#""x""#, + r#"{"mode":"bogus"}"#, + r#"{"mode":7,"splitAnd":"bogus","keywords":[],"knownArtists":"x"}"#, + r#"{"audioSeconds":"60","markerWords":"recorded"}"#, + r#"{"audioSeconds":true,"markerWords":[5,null]}"#, + r#"{"uploader":"Noisia"}"#, + ] { + assert_eq!(wire_parse(text, loose), default, "{loose}"); + } +} + +#[test] +fn entries_carry_every_field() { + let list = + parse_tracklist("Tracklist:\r\n[00:00] Intro\r01:30 - 1. Noisia - Stigma\n\nw/ A - B"); + assert_eq!(list.spec_version, SPEC_VERSION); + let kinds: Vec = list.entries.iter().map(|e| e.kind).collect(); + assert_eq!( + kinds, + [ + EntryKind::Header, + EntryKind::Marker, + EntryKind::Track, + EntryKind::Blank, + EntryKind::Track + ] + ); + let eols: Vec = list.entries.iter().map(|e| e.eol).collect(); + assert_eq!(eols, [Eol::CrLf, Eol::Cr, Eol::Lf, Eol::Lf, Eol::None]); + assert_eq!(Eol::CrLf.as_str(), "\r\n"); + + let e = &list.entries[2]; + assert_eq!(e.line, 3); + assert_eq!( + e.parts, + Parts { + lead: String::new(), + time: "01:30".into(), + gap: " - ".into(), + rest: "1. Noisia - Stigma".into() + } + ); + assert_eq!(e.time, Some(TimeValue { raw: "01:30".into(), seconds: 90.0 })); + let track = e.track.as_ref().unwrap(); + assert_eq!(track.mode, Mode::Tracklist); + assert_eq!(track.position.as_ref().unwrap().number, 1); + assert_eq!((track.artists[0].name.as_str(), track.title.as_str()), ("Noisia", "Stigma")); + assert!(!e.layered); + assert!(list.entries[4].layered); + assert!(list.entries[0].track.is_none()); + assert_eq!( + list.stats, + Stats { + lines: 5, + tracks: 2, + markers: 1, + timed: 2, + first_time: Some(0.0), + last_time: Some(90.0) + } + ); +} + +#[test] +fn warnings_and_suggestions() { + // The JS reference's output for this text. + let list = parse_tracklist( + "0:10 A - B\n58:00 K - L\n1:22:21 C - D\n1:03:00 E - F\n1:04:00 G - H\nI - J\n1:75 x - y", + ); + let warning = |code, line, suggestion| TracklistWarning { + code, + line, + severity: if code == WarningCode::NoStartAtZero { + Severity::Info + } else { + Severity::Warning + }, + suggestion, + }; + let fix = Suggestion { line: 3, raw: "1:02:21".into(), seconds: 3741.0 }; + assert_eq!( + list.warnings, + [ + warning(WarningCode::NoStartAtZero, 1, None), + warning(WarningCode::TimeOutOfOrder, 4, Some(fix)), + warning(WarningCode::TimeMissing, 6, None), + warning(WarningCode::TimeMissing, 7, None), + warning(WarningCode::InvalidTime, 7, None), + ] + ); + assert_eq!(WarningCode::ALL.len(), 9); + assert_eq!(WarningCode::from_name("line-unparsed"), Some(WarningCode::LineUnparsed)); +} + +#[test] +fn json_has_the_schema_keys_in_order() { + let list: Tracklist = parse_tracklist("00:00.5 Noisia - Stigma\n00:00 x"); + let value = list.to_json_value(); + let keys = |v: &Json| -> Vec { + v.as_object().unwrap().iter().map(|(k, _)| k.clone()).collect() + }; + assert_eq!(keys(&value), ["specVersion", "entries", "warnings", "stats"]); + let entry: &TracklistEntry = &list.entries[0]; + let entry_json = entry.to_json_value(); + assert_eq!( + keys(&entry_json), + ["line", "kind", "eol", "raw", "parts", "time", "track", "layered"] + ); + assert_eq!(keys(entry_json.get("parts").unwrap()), ["lead", "time", "gap", "rest"]); + assert_eq!(entry_json.get("time").unwrap().write(), r#"{"raw":"00:00.5","seconds":0.5}"#); + assert_eq!( + keys(value.get("stats").unwrap()), + ["lines", "tracks", "markers", "timed", "firstTime", "lastTime"] + ); + let warning = &value.get("warnings").unwrap().as_array().unwrap()[0]; + assert_eq!(keys(warning), ["code", "line", "severity", "suggestion"]); + // Whole seconds are integers in JSON. + assert!(parse_tracklist("52:47 A - B").to_json().contains(r#""seconds":3167}"#)); + assert_eq!( + parse_tracklist("").to_json(), + format!( + r#"{{"specVersion":"{SPEC_VERSION}","entries":[],"warnings":[],"stats":{{"lines":0,"tracks":0,"markers":0,"timed":0,"firstTime":null,"lastTime":null}}}}"# + ) + ); +} + +#[test] +fn typed_edits_match_the_wire() { + let cases: Vec<(Vec, &str)> = vec![ + (vec![], "[]"), + ( + vec![Edit::SetTime { line: 2, seconds: 3725.0 }], + r#"[{"op":"set-time","line":2,"seconds":3725}]"#, + ), + ( + vec![Edit::SetTime { line: 2, seconds: -4.5 }], + r#"[{"op":"set-time","line":2,"seconds":-4.5}]"#, + ), + ( + vec![Edit::SetTime { line: 9, seconds: 1.0 }], + r#"[{"op":"set-time","line":9,"seconds":1}]"#, + ), + ( + vec![Edit::SetTime { line: 1, seconds: f64::INFINITY }], + r#"[{"op":"set-time","line":1,"seconds":1e999}]"#, + ), + ( + vec![Edit::SetTime { line: 1, seconds: f64::NAN }], + r#"[{"op":"set-time","line":1,"seconds":null}]"#, + ), + ( + vec![Edit::SetTime { line: 1, seconds: 360_000.0 }], + r#"[{"op":"set-time","line":1,"seconds":360000}]"#, + ), + ( + vec![Edit::Shift { seconds: 30.0, lines: None, from: None }], + r#"[{"op":"shift","seconds":30}]"#, + ), + ( + vec![Edit::Shift { seconds: -3600.0, lines: None, from: Some(2) }], + r#"[{"op":"shift","seconds":-3600,"from":2}]"#, + ), + ( + vec![Edit::Shift { seconds: 0.25, lines: Some(vec![4, 1, 4]), from: Some(3) }], + r#"[{"op":"shift","seconds":0.25,"lines":[4,1,4],"from":3}]"#, + ), + ( + vec![Edit::Shift { seconds: 1.0, lines: Some(vec![0]), from: None }], + r#"[{"op":"shift","seconds":1,"lines":[0]}]"#, + ), + (vec![Edit::SortByTime], r#"[{"op":"sort-by-time"}]"#), + ( + vec![Edit::SetRest { line: 1, rest: "New - Rest".into() }], + r#"[{"op":"set-rest","line":1,"rest":"New - Rest"}]"#, + ), + ( + vec![Edit::SetRest { line: 1, rest: "a\nb".into() }], + r#"[{"op":"set-rest","line":1,"rest":"a\nb"}]"#, + ), + ( + vec![Edit::Insert { after: 0, text: "00:00 X - Y".into() }], + r#"[{"op":"insert","after":0,"text":"00:00 X - Y"}]"#, + ), + ( + vec![Edit::Insert { after: 99, text: "x".into() }], + r#"[{"op":"insert","after":99,"text":"x"}]"#, + ), + (vec![Edit::Delete { line: 1 }], r#"[{"op":"delete","line":1}]"#), + ( + vec![ + Edit::Delete { line: 1 }, + Edit::Insert { after: 1, text: "9:59:59 Late - One".into() }, + Edit::SortByTime, + Edit::Shift { seconds: 5000.0, lines: None, from: None }, + ], + r#"[{"op":"delete","line":1},{"op":"insert","after":1,"text":"9:59:59 Late - One"},{"op":"sort-by-time"},{"op":"shift","seconds":5000}]"#, + ), + ]; + for (typed, loose) in &cases { + let listed = Json::Arr(typed.iter().map(ToJson::to_json_value).collect()).write(); + // Non-finite numbers are `null` in written JSON, as in JS. + assert_eq!(listed, json(loose).write(), "Edit::to_json_value"); + for text in TEXTS { + let result = apply_edits(text, typed); + assert_eq!(result.to_json(), wire_edits(text, loose), "{loose} {text:?}"); + assert_eq!(apply_edits_with(text, typed, &TracklistOptions::new()), result); + } + } +} + +#[test] +fn edit_results() { + let text = "00:00 Noisia - Stigma\n59:30 Phace - Psycho\n"; + let result = apply_edits( + text, + &[ + Edit::Shift { seconds: 45.0, lines: None, from: Some(2) }, + Edit::SetTime { line: 1, seconds: -3.0 }, + Edit::Delete { line: 7 }, + ], + ); + assert_eq!( + result, + EditResult { + text: "00:00 Noisia - Stigma\n01:00:15 Phace - Psycho\n".into(), + changed: vec![1, 2], + warnings: vec![ + EditWarning { code: EditWarningCode::StyleUpgraded, edit: 0, line: Some(2) }, + EditWarning { code: EditWarningCode::TimeClamped, edit: 1, line: Some(1) }, + EditWarning { code: EditWarningCode::EditInvalid, edit: 2, line: Some(7) }, + ], + } + ); + assert_eq!( + result.to_json(), + r#"{"text":"00:00 Noisia - Stigma\n01:00:15 Phace - Psycho\n","changed":[1,2],"warnings":[{"code":"style-upgraded","edit":0,"line":2},{"code":"time-clamped","edit":1,"line":1},{"code":"edit-invalid","edit":2,"line":7}]}"# + ); + // Half-up rounding at the written precision (R13.9.2), not banker's rounding. + let rounded = apply_edits("0:00.5 A - B", &[Edit::SetTime { line: 1, seconds: 2.25 }]); + assert_eq!(rounded.text, "0:02.3 A - B"); + // 100 hours cannot be written (R13.9.2). + let too_long = apply_edits("1:00:00 A - B", &[Edit::SetTime { line: 1, seconds: 360_000.0 }]); + assert_eq!(too_long.text, "1:00:00 A - B"); + assert_eq!(too_long.warnings[0].code, EditWarningCode::EditInvalid); +} + +#[test] +fn loose_edits_follow_js_number_rules() { + let text = "00:00 A - B\n01:00 C - D"; + let invalid = |edits: &str| { + let out = json(&wire_edits(text, edits)); + assert_eq!(out.get("text").unwrap().as_str(), Some(text), "{edits}"); + let warnings = out.get("warnings").unwrap().as_array().unwrap(); + assert_eq!(warnings.len(), 1, "{edits}"); + assert_eq!(warnings[0].get("code").unwrap().as_str(), Some("edit-invalid"), "{edits}"); + warnings[0].get("line").unwrap().write() + }; + assert_eq!(invalid(r#"[{"op":"set-time","line":true,"seconds":5}]"#), "null"); + assert_eq!(invalid(r#"[{"op":"set-time","line":1,"seconds":true}]"#), "1"); + assert_eq!(invalid(r#"[{"op":"set-time","line":1,"seconds":null}]"#), "1"); + assert_eq!(invalid(r#"[{"op":"set-time","line":1,"seconds":"5"}]"#), "1"); + assert_eq!(invalid(r#"[{"op":"set-time","line":1,"seconds":1e999}]"#), "1"); + assert_eq!(invalid(r#"[{"op":"set-time","line":1.5,"seconds":5}]"#), "null"); + assert_eq!(invalid(r#"[{"op":"shift","seconds":-1e999}]"#), "null"); + assert_eq!(invalid(r#"[{"op":"shift","seconds":1,"lines":null}]"#), "null"); + assert_eq!(invalid(r#"[{"op":"shift","seconds":1,"lines":[1,3]}]"#), "null"); + assert_eq!(invalid(r#"[{"op":"shift","seconds":1,"from":0}]"#), "null"); + assert_eq!(invalid(r#"[{"op":"shift","seconds":9007199254740992}]"#), "null"); + assert_eq!(invalid(r#"[{"op":"rename","line":-2}]"#), "-2"); + assert_eq!(invalid(r#"[{"op":"rename","line":"x","after":1e300}]"#), "1e+300"); + assert_eq!(invalid(r#"[{"op":"insert","after":3,"text":"x"}]"#), "3"); + assert_eq!(invalid(r#"[{"op":"insert","after":1,"text":"a\rb"}]"#), "1"); + assert_eq!(invalid(r#"[{"op":"delete"}]"#), "null"); + assert_eq!(invalid("[null]"), "null"); + assert_eq!(invalid("[[]]"), "null"); + // `lines` wins over `from`; not an array of edits: nothing to do. + assert_eq!( + wire_edits(text, r#"[{"op":"shift","seconds":1,"lines":[2],"from":"bad"}]"#), + r#"{"text":"00:00 A - B\n01:01 C - D","changed":[2],"warnings":[]}"# + ); + assert_eq!(wire_edits(text, r#"{"op":"sort-by-time"}"#), wire_edits(text, "[]")); +} + +#[test] +fn edit_warning_lines_are_usize() { + // The edit's own line comes back, as every other line number: a `usize`. + let result = apply_edits("00:00 a - b", &[Edit::delete(9), Edit::insert(usize::MAX, "x")]); + let lines: Vec> = result.warnings.iter().map(|w| w.line).collect(); + assert_eq!(lines, [Some(9), Some(usize::MAX)]); + // Edits run on JS numbers (R13.9): above 2^53 the line is the nearest double, and the JSON + // is what `JSON.stringify` writes for it. + let result = apply_edits("00:00 a - b", &[Edit::delete((1 << 53) + 1)]); + assert_eq!(result.warnings[0].line, Some(1 << 53)); + let result = apply_edits("00:00 a - b", &[Edit::delete(usize::MAX)]); + assert_eq!( + result.to_json(), + r#"{"text":"00:00 a - b","changed":[],"warnings":[{"code":"edit-invalid","edit":0,"line":18446744073709552000}]}"# + ); + assert_eq!( + result.to_json(), + wire_edits("00:00 a - b", &format!("[{}]", Edit::delete(usize::MAX).to_json())) + ); +} diff --git a/rust/tests/tracklist_properties.rs b/rust/tests/tracklist_properties.rs new file mode 100644 index 0000000..34b39b9 --- /dev/null +++ b/rust/tests/tracklist_properties.rs @@ -0,0 +1,579 @@ +//! SPEC R13.11 tracklist invariants, checked on generated texts. +//! +//! The generator is a small deterministic PRNG over fragments that exercise the line splitter, the +//! time scanner, emphasis and the line kinds (the same fragments as the JS property tests), so a +//! failure is reproducible from its case number. +#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::indexing_slicing)] + +use std::time::{Duration, Instant}; + +use trackparse::json::Json; +use trackparse::tracklist::{ + apply_edits, parse_tracklist, Edit, EditResult, EditWarningCode, EntryKind, Eol, Tracklist, +}; +use trackparse::{parse_with, wire, ModeOption, ParseOptions}; + +/// mulberry32. +struct Rng(u32); + +impl Rng { + fn next(&mut self) -> u32 { + self.0 = self.0.wrapping_add(0x6d2b_79f5); + let mut t = self.0; + t = (t ^ (t >> 15)).wrapping_mul(t | 1); + t ^= t.wrapping_add((t ^ (t >> 7)).wrapping_mul(t | 61)); + t ^ (t >> 14) + } + + fn below(&mut self, n: usize) -> usize { + self.next() as usize % n + } + + fn pick<'a>(&mut self, items: &[&'a str]) -> &'a str { + items[self.below(items.len())] + } + + fn chance(&mut self, percent: usize) -> bool { + self.below(100) < percent + } +} + +const FRAGMENTS: &[&str] = &[ + "\n", + "\r\n", + "\r", + "\n\r", + " ", + "\u{2028}", + "\u{85}", + "\u{a0}", + " ", + "\t", + "\u{3000}", + "00:00", + "0:00 ", + "04:37 ", + "1:02:03 ", + "01:02:03.5 ", + "125:30 ", + "12:34,250", + "1:75 ", + "0:61:00 ", + "1:2", + "[", + "]", + "(", + ")", + "[00:10] ", + "(1:00)", + " - ", + " – ", + "-", + "|", + ".", + ":", + "=> ", + "==>", + "1 ", + "2 ", + "01. ", + "3) ", + "Artist", + "Title", + "Noisia - Stigma", + "Intro", + "interview", + "Tracklist:", + "Part 2", + "https://x.y", + "www.", + "_-_", + "Ab-Cd", + "ID", + "(VIP)", + "**", + "*", + "__", + "_", + "***", + "* ", + "- ", + "• ", + "**[", + "]**", + "w/ ", + "W/", + "\u{200b}", + "𝄞", + "🎵", + "é", + "Кино", + "a", + "7", + "\u{0}", + "\"", + "\\", +]; + +fn noisy_text(rng: &mut Rng) -> String { + let n = rng.below(41); + (0..n).map(|_| rng.pick(FRAGMENTS)).collect() +} + +const STYLES: &[&str] = &["M:SS", "MM:SS", "H:MM:SS", "HH:MM:SS", "MM:SS.d", "M:SS,ddd"]; + +fn write_time(style: &str, seconds: u32, frac: u32) -> String { + let (h, m, s) = (seconds / 3600, (seconds % 3600) / 60, seconds % 60); + match style { + "M:SS" => format!("{}:{s:02}", seconds / 60), + "MM:SS" => format!("{:02}:{s:02}", seconds / 60), + "H:MM:SS" => format!("{h}:{m:02}:{s:02}"), + "HH:MM:SS" => format!("{h:02}:{m:02}:{s:02}"), + "MM:SS.d" => format!("{:02}:{s:02}.{}", seconds / 60, frac % 10), + _ => format!("{}:{s:02},{frac:03}", seconds / 60), + } +} + +const RESTS: &[&str] = &[ + "Noisia - Stigma", + "01. Phace - Plastic Acid", + "2 Unlimited - No Limit", + "Intro", + "Paperclip interview", + "Mefjus - Suicide Bassline (VIP)", + "", + "ID - ID", +]; + +fn list_line(rng: &mut Rng) -> String { + if rng.below(7) == 0 { + return rng.pick(&["", "Tracklist:", "a note", "https://example.com"]).to_string(); + } + let time = write_time(rng.pick(STYLES), rng.below(3600) as u32, rng.below(1000) as u32); + let gap = rng.pick(&[" ", " ", " - ", " | ", " => "]); + let rest = rng.pick(RESTS); + match rng.pick(&["", " ", "["]) { + "[" => format!("[{time}]{gap}{rest}"), + lead => format!("{lead}{time}{gap}{rest}"), + } +} + +/// A realistic timed list for the edit properties. +fn timed_list(rng: &mut Rng) -> String { + let n = 1 + rng.below(12); + let eol = rng.pick(&["\n", "\r\n"]); + let lines: Vec = (0..n).map(|_| list_line(rng)).collect(); + lines.join(eol) + if rng.chance(50) { eol } else { "" } +} + +fn any_text(rng: &mut Rng) -> String { + if rng.chance(30) { + timed_list(rng) + } else { + noisy_text(rng) + } +} + +fn raw_lines(list: &Tracklist) -> Vec { + list.entries.iter().map(|e| format!("{}{}", e.raw, e.eol)).collect() +} + +fn raws(text: &str) -> Vec { + parse_tracklist(text).entries.into_iter().map(|e| e.raw).collect() +} + +fn warned(result: &EditResult, codes: &[EditWarningCode]) -> bool { + result.warnings.iter().any(|w| codes.contains(&w.code)) +} + +fn shift(seconds: f64, from: Option) -> Edit { + Edit::Shift { seconds, lines: None, from } +} + +#[test] +fn lossless_and_parts_join_to_raw() { + let mut rng = Rng(1); + for case in 0..3000 { + let text = any_text(&mut rng); + let list = parse_tracklist(&text); + assert_eq!(raw_lines(&list).concat(), text, "case {case}: {text:?}"); + for e in &list.entries { + let p = &e.parts; + assert_eq!(format!("{}{}{}{}", p.lead, p.time, p.gap, p.rest), e.raw, "case {case}"); + // R13.1.3: without a time, `lead` holds at most a bullet; `time` and `gap` are empty. + assert_eq!(e.time.is_none(), p.time.is_empty(), "case {case}: {text:?}"); + if e.time.is_none() { + assert!(p.gap.is_empty(), "case {case}: {text:?}"); + } + assert_eq!(e.track.is_some(), matches!(e.kind, EntryKind::Track | EntryKind::Marker)); + assert!(!e.raw.contains(['\n', '\r'])); + } + assert_eq!(list.stats.lines, list.entries.len()); + let lines: Vec = list.entries.iter().map(|e| e.line).collect(); + assert_eq!(lines, (1..=list.entries.len()).collect::>()); + // Only the last line may lack a terminator. + let open = list.entries.iter().rev().skip(1).filter(|e| e.eol == Eol::None).count(); + assert_eq!(open, 0, "case {case}: {text:?}"); + } +} + +#[test] +fn only_lf_crlf_and_cr_break_lines() { + let count = |text: &str| parse_tracklist(text).entries.len(); + assert_eq!(count("a\u{2028}b\u{2029}c\u{85}d\u{b}e\u{c}f"), 1); + assert_eq!(count("a\r\nb\rc\nd\n"), 4); + assert_eq!(count("\n\r\r\n"), 3); + assert_eq!(count(""), 0); +} + +#[test] +fn any_edit_list_returns() { + // Loose edits through the JSON door: every field may be anything. + const FIELDS: &[&str] = &[ + "-3", + "0", + "1", + "2", + "5", + "15", + "1.5", + "-0.25", + "1e300", + "-1e300", + "1e999", + "-1e999", + "null", + "true", + "false", + "\"x\"", + "\"\"", + "[1,2]", + "{}", + "9007199254740993", + "359999.5", + ]; + const OPS: &[&str] = + &["set-time", "shift", "sort-by-time", "set-rest", "insert", "delete", "x"]; + const TEXTS: &[&str] = &["\"a\\nb\"", "\"c\\rd\"", "\"00:10 New - Line\"", "\"w/ x\"", "\"\""]; + let mut rng = Rng(2); + for case in 0..2000 { + let text = any_text(&mut rng); + let mut edits = Vec::new(); + for _ in 0..rng.below(7) { + if rng.chance(8) { + edits.push(rng.pick(&["null", "5", "\"shift\"", "[]", "{}"]).to_string()); + continue; + } + let mut fields = vec![format!("\"op\":\"{}\"", rng.pick(OPS))]; + for key in ["line", "seconds", "from", "after"] { + if rng.chance(60) { + fields.push(format!("\"{key}\":{}", rng.pick(FIELDS))); + } + } + if rng.chance(30) { + let items: Vec<&str> = (0..rng.below(4)).map(|_| rng.pick(FIELDS)).collect(); + fields.push(format!("\"lines\":[{}]", items.join(","))); + } + for key in ["rest", "text"] { + if rng.chance(60) { + let value = if rng.chance(80) { rng.pick(TEXTS) } else { rng.pick(FIELDS) }; + fields.push(format!("\"{key}\":{value}")); + } + } + edits.push(format!("{{{}}}", fields.join(","))); + } + let edits = Json::parse(&format!("[{}]", edits.join(","))).unwrap(); + let empty = Json::Obj(Vec::new()); + let out = wire::call("applyEdits", &text, &empty, &empty, &edits); + let new_text = out.get("text").and_then(Json::as_str).unwrap(); + let n = parse_tracklist(new_text).entries.len(); + let changed = out.get("changed").and_then(Json::as_array).unwrap(); + let numbers: Vec = changed + .iter() + .map(|c| match c { + Json::Num(n) => *n, + other => panic!("case {case}: changed holds {other:?}"), + }) + .collect(); + assert!(numbers.windows(2).all(|w| w[0] < w[1]), "case {case}: {numbers:?}"); + assert!(numbers.iter().all(|c| *c >= 1.0 && *c <= n as f64), "case {case}: {numbers:?}"); + // The work lines stay what a fresh split of the text gives (R13.9.5): applying nothing + // more to the result is the identity, and it parses losslessly. + assert_eq!(raw_lines(&parse_tracklist(new_text)).concat(), new_text, "case {case}"); + } +} + +#[test] +fn no_edits_is_the_identity() { + let mut rng = Rng(3); + for _ in 0..1000 { + let text = any_text(&mut rng); + let result = apply_edits(&text, &[]); + assert_eq!(result, EditResult { text, changed: vec![], warnings: vec![] }); + } +} + +#[test] +fn an_edit_on_one_line_leaves_the_others() { + let mut rng = Rng(4); + for case in 0..1500 { + let text = timed_list(&mut rng); + let before = raw_lines(&parse_tracklist(&text)); + if before.is_empty() { + continue; + } + let line = 1 + rng.below(before.len()); + let seconds = rng.below(8001) as f64 - 4000.0; + let edit = match rng.below(3) { + 0 => Edit::SetTime { line, seconds }, + 1 => Edit::SetRest { line, rest: "New - Rest".into() }, + _ => Edit::Shift { seconds, lines: Some(vec![line]), from: None }, + }; + let result = apply_edits(&text, std::slice::from_ref(&edit)); + let after = raw_lines(&parse_tracklist(&result.text)); + assert_eq!(after.len(), before.len(), "case {case}: {edit:?} on {text:?}"); + for (i, (a, b)) in after.iter().zip(&before).enumerate() { + if i != line - 1 { + assert_eq!(a, b, "case {case}: {edit:?} on {text:?}"); + } + } + assert!(result.changed.iter().all(|c| *c == line), "case {case}: {edit:?} on {text:?}"); + if warned(&result, &[EditWarningCode::EditInvalid]) { + assert_eq!(result.text, text, "case {case}"); + assert!(result.changed.is_empty(), "case {case}"); + } + } +} + +#[test] +fn insert_and_delete_keep_the_other_lines() { + let mut rng = Rng(5); + for case in 0..1500 { + let text = timed_list(&mut rng); + let before = raws(&text); + if before.is_empty() { + continue; + } + let at = rng.below(before.len() + 1); + let new_line = "00:00 New - Line"; + let ins = apply_edits(&text, &[Edit::Insert { after: at, text: new_line.into() }]); + let mut expected = before.clone(); + expected.insert(at, new_line.to_string()); + assert_eq!(raws(&ins.text), expected, "case {case}: insert after {at} in {text:?}"); + assert!(ins.changed.contains(&(at + 1)), "case {case}"); + + let line = 1 + rng.below(before.len()); + let del = apply_edits(&text, &[Edit::Delete { line }]); + let mut kept = before.clone(); + kept.remove(line - 1); + let got = raws(&del.text); + // Deleting the last line moves its eol ("" here) up: an empty line that becomes last + // without an eol is not a line (R13.9.5), so trailing empty lines may disappear. + while kept.last().is_some_and(String::is_empty) + && got.len() < kept.len() + && line == before.len() + { + kept.pop(); + } + assert_eq!(got, kept, "case {case}: delete {line} in {text:?}"); + } +} + +#[test] +fn shift_round_trip_restores_the_text() { + let lossy = [ + EditWarningCode::TimeClamped, + EditWarningCode::StyleUpgraded, + EditWarningCode::EditInvalid, + ]; + let widths = |text: &str| -> Vec> { + parse_tracklist(text).entries.iter().map(|e| e.time.as_ref().map(|t| t.raw.len())).collect() + }; + let mut rng = Rng(6); + let mut checked = 0; + for case in 0..2000 { + let text = timed_list(&mut rng); + let s = (1 + rng.below(5000)) as f64; + let n = parse_tracklist(&text).entries.len(); + let from = Some(1 + rng.below(12)).filter(|f| rng.chance(50) && *f <= n); + let up = apply_edits(&text, &[shift(s, from)]); + let down = apply_edits(&up.text, &[shift(-s, from)]); + // Widths are minimum widths (R13.9.2): `0:00` + 600 s is `10:00`, whose style then has two + // minute digits, so the way back writes `00:00`. A time whose digit count grew is outside + // the round trip (R13.9.7), like clamps and upgrades. + if warned(&up, &lossy) || warned(&down, &lossy) || widths(&up.text) != widths(&text) { + continue; + } + checked += 1; + assert_eq!(down.text, text, "case {case}: ±{s} from {from:?}"); + } + assert!(checked > 100, "only {checked} round trips were checked"); +} + +#[test] +fn sort_keeps_the_eol_slots_and_is_idempotent() { + let eols = + |text: &str| -> Vec { parse_tracklist(text).entries.iter().map(|e| e.eol).collect() }; + let mut rng = Rng(7); + for case in 0..1500 { + let text = timed_list(&mut rng); + let once = apply_edits(&text, &[Edit::SortByTime]); + // An empty line sorted into the last slot (eol "") is not a line any more (R13.1.1). + if eols(&once.text).len() == eols(&text).len() { + assert_eq!(eols(&once.text), eols(&text), "case {case}: {text:?}"); + } + let times: Vec = parse_tracklist(&once.text) + .entries + .iter() + .filter_map(|e| e.time.as_ref().map(|t| t.seconds)) + .collect(); + assert!(times.windows(2).all(|w| w[0] <= w[1]), "case {case}: {times:?}"); + assert_eq!(apply_edits(&once.text, &[Edit::SortByTime]).text, once.text, "case {case}"); + } +} + +#[test] +fn a_one_line_track_is_the_parse_of_its_line_text() { + // R13.4.1: the track part of a one-line text (no neighbours, so no bare position) is `rest` + // without its emphasis markers (R13.12) and a layered prefix (R13.13); the track's `input` + // is that text. + let options = ParseOptions::new().mode(ModeOption::Tracklist); + let mut rng = Rng(8); + let mut tracks = 0; + for case in 0..3000 { + let mut text = if rng.chance(50) { String::new() } else { list_line(&mut rng) }; + text.push_str(&noisy_text(&mut rng)); + let text = text.replace(['\r', '\n'], " "); + let list = parse_tracklist(&text); + let Some(entry) = list.entries.first() else { continue }; + assert_eq!(list.entries.len(), 1); + let Some(track) = &entry.track else { continue }; + tracks += 1; + assert_eq!(track, &parse_with(&track.input, &options), "case {case}: {text:?}"); + assert!( + track.position.is_none() || !track.input.starts_with(char::is_numeric) || { + // A position here is R4.2's own (`01. `, `3) `), never a bare one. + let raw = &track.position.as_ref().unwrap().raw; + track.input.trim_start().len() > raw.len() + } + ); + let plain = !entry.parts.rest.contains(['*', '_']) && !entry.layered; + if plain { + assert_eq!(track.input, entry.parts.rest, "case {case}: {text:?}"); + } + } + assert!(tracks > 500, "only {tracks} one-line tracks were checked"); +} + +#[test] +fn emphasis_changes_nothing() { + const RESTS: &[&str] = &[ + "Noisia - Stigma", + "01. Phace - Plastic Acid", + "Intro", + "Paperclip interview", + "Mefjus - Suicide Bassline (VIP)", + "ID - ID", + "Noisia feat. Foreign Beggars - Shellshock", + ]; + const TIME_WRAPS: &[(&str, &str)] = &[ + ("", ""), + ("**", "**"), + ("__", "__"), + ("*", "*"), + ("_", "_"), + ("**[", "]**"), + ("[**", "**]"), + ("**[**", "**]"), + ("_[", "]_"), + ]; + let mut rng = Rng(9); + for _ in 0..40 { + let t = write_time(rng.pick(STYLES), rng.below(3600) as u32, rng.below(1000) as u32); + for rest in RESTS { + let bare = parse_tracklist(&format!("{t} {rest}")).entries.remove(0); + for (open, close) in TIME_WRAPS { + for wrap in ["", "**", "__", "*", "_"] { + let decorated = format!("{open}{t}{close} {wrap}{rest}{wrap}"); + let e = parse_tracklist(&decorated).entries.remove(0); + assert_eq!( + e.time.as_ref().map(|t| t.seconds), + bare.time.as_ref().map(|t| t.seconds), + "{decorated:?}" + ); + assert_eq!(e.kind, bare.kind, "{decorated:?}"); + assert_eq!(e.track, bare.track, "{decorated:?}"); + } + } + } + } +} + +/// Best of three, so a busy CI worker does not fail the run; a super-linear blowup still would. +fn best(mut f: impl FnMut()) -> Duration { + (0..3) + .map(|_| { + let start = Instant::now(); + f(); + start.elapsed() + }) + .min() + .unwrap() +} + +fn hms(s: usize) -> String { + format!("{:02}:{:02}:{:02}", s / 3600, (s % 3600) / 60, s % 60) +} + +// R13.11.2: generous ceilings that catch super-linear blowups, not CI load. `cargo test` runs +// these in the dev profile, where the parser is several times slower than in a release build +// (10,000 lines: about 0.7 s optimised, 4 s unoptimised on the machine this was written on). +const SLOW_BUILD: u64 = if cfg!(debug_assertions) { 6 } else { 1 }; +const PARSE_CEILING: Duration = Duration::from_secs(3 * SLOW_BUILD); +const EDIT_CEILING: Duration = Duration::from_secs(SLOW_BUILD); + +#[test] +fn ten_thousand_lines_finish_under_the_ceiling() { + let lines: Vec = (0..10_000) + .map(|i| { + format!("{} {} Artist {i} & Other - Title {i} (VIP Mix)", hms((i * 37) % 7200), i % 100) + }) + .collect(); + let text = lines.join("\r\n"); + assert_eq!(parse_tracklist(&text).entries.len(), 10_000); + let parse = best(|| { + parse_tracklist(&text); + }); + let edits = [shift(5.0, None), Edit::SortByTime]; + let edit = best(|| { + apply_edits(&text, &edits); + }); + println!("10,000 lines: parse_tracklist {parse:?}, shift + sort {edit:?}"); + assert!(parse < PARSE_CEILING, "parse_tracklist took {parse:?}"); + assert!(edit < EDIT_CEILING, "apply_edits took {edit:?}"); +} + +#[test] +fn two_thousand_edits_on_five_thousand_lines_stay_linear() { + // R13.11.2: apply_edits costs lines plus edits, not their product. Each line's time is + // scanned once per write and the one-digit-hours test is kept up to date. + let lines: Vec = (0..5000).map(|i| format!("{} A {i} - T {i}", hms(i * 30))).collect(); + let text = lines.join("\n"); + let set_times: Vec = (0..2000) + .map(|k| Edit::SetTime { line: (k * 7) % 5000 + 1, seconds: (k * 10) as f64 }) + .collect(); + let inserts: Vec = (0..2000) + .map(|k| Edit::Insert { after: (k * 7) % 5000, text: "00:00 X - Y".into() }) + .collect(); + assert_eq!(apply_edits(&text, &set_times).changed.len(), 2000); + assert_eq!(apply_edits(&text, &inserts).changed.len(), 2000); + let set = best(|| { + apply_edits(&text, &set_times); + }); + let ins = best(|| { + apply_edits(&text, &inserts); + }); + println!("2,000 edits on 5,000 lines: set-time {set:?}, insert {ins:?}"); + assert!(set < EDIT_CEILING, "2,000 set-time edits took {set:?}"); + assert!(ins < EDIT_CEILING, "2,000 insert edits took {ins:?}"); +} diff --git a/scripts/compare-ports.mjs b/scripts/compare-ports.mjs index 9d58ce8..ceaddf5 100644 --- a/scripts/compare-ports.mjs +++ b/scripts/compare-ports.mjs @@ -1,11 +1,14 @@ #!/usr/bin/env node -// Cross-port byte check: runs every fixture case (spec/fixtures/**) through the built JS package -// and through the Python port, and diffs the FULL outputs (not the partial fixture expectations). +// Cross-port byte check: runs every fixture case (spec/fixtures/**) through the built JS package, +// the Python port and the Rust port, and diffs the FULL outputs (not the partial fixture +// expectations). JS is the reference; each other port is compared with it. // // Usage (from the repo root): // pnpm --filter trackparse build # builds js/dist -// node scripts/compare-ports.mjs # needs `uv`; runs scripts/dump_py.py in the python/ project +// node scripts/compare-ports.mjs # needs `uv` (Python) and `cargo` (Rust) +// node scripts/compare-ports.mjs --only=python # or --only=rust // +// Rust runs `cargo run --release --example dump` in rust/ (JSONL in, one JSON result per line). // Options are merged like js/test/runner.ts ({...defaults.options, ...case.options}, same for // formatOptions). Python gets one process for all cases (JSONL over stdin/stdout); dump_py.py maps // the camelCase options to snake_case kwargs and serialises with to_dict() (ParsedTrack, and the @@ -119,6 +122,38 @@ function runPython(all) { }); } +function runRust(all) { + return new Promise((resolveRs, reject) => { + const child = spawn("cargo", ["run", "--quiet", "--release", "--example", "dump"], { + cwd: join(root, "rust"), + stdio: ["pipe", "pipe", "inherit"], + }); + const chunks = []; + child.stdout.on("data", (chunk) => chunks.push(chunk)); + child.on("error", reject); + child.on("close", (code) => { + if (code !== 0) return reject(new Error(`the Rust dump example exited with code ${code}`)); + const lines = Buffer.concat(chunks).toString("utf8").split("\n"); + const byIndex = new Map(); + // One output line per input line, in order. Rust never throws: every line is a result. + all.forEach((c, k) => byIndex.set(c.i, lines[k] ? { ok: JSON.parse(lines[k]) } : undefined)); + resolveRs(byIndex); + }); + child.stdin.on("error", reject); + for (const c of all) { + const { fn, input, options, formatOptions, edits } = c; + // Non-finite numbers travel as 1e999 / -1e999, which the crate's JSON reader takes as infinity. + const line = JSON.stringify({ fn, input, options, formatOptions, edits }, (_k, v) => + typeof v === "number" && !Number.isFinite(v) ? `\u0000num:${v}` : v, + ) + .replaceAll('"\\u0000num:Infinity"', "1e999") + .replaceAll('"\\u0000num:-Infinity"', "-1e999"); + child.stdin.write(`${line}\n`); + } + child.stdin.end(); + }); +} + /** JSON with object keys sorted recursively, so key order never counts as a difference. */ function canonical(value) { return JSON.stringify(value, (_key, v) => @@ -151,35 +186,45 @@ function firstDiff(a, b, path = "$") { return `${path}: js=${show(a)} py=${show(b)}`; } -const py = await runPython(cases); +const only = process.argv.find((a) => a.startsWith("--only="))?.slice(7); +const ports = [ + { name: "Python", key: "py", run: runPython }, + { name: "Rust", key: "rs", run: runRust }, +].filter((p) => !only || p.name.toLowerCase() === only); -const diffs = []; -const byFn = {}; -let bothThrew = 0; -for (const c of cases) { - const j = runJs(c); - const p = py.get(c.i); - byFn[c.fn] ??= { total: 0, differ: 0 }; - byFn[c.fn].total++; - if (j.error && p?.error) bothThrew++; - if (comparable(j) === comparable(p)) continue; - byFn[c.fn].differ++; - let detail; - if (!p) detail = "python produced no output"; - else if (j.error || p.error) detail = `js ${j.error ?? "ok"} | py ${p.error ?? "ok"}`; - else detail = firstDiff(j.ok, p.ok); - diffs.push({ c, detail }); -} +const jsResults = cases.map(runJs); +let total = 0; +for (const port of ports) { + const other = await port.run(cases); + const diffs = []; + const byFn = {}; + let bothThrew = 0; + cases.forEach((c, k) => { + const j = jsResults[k]; + const p = other.get(c.i); + byFn[c.fn] ??= { total: 0, differ: 0 }; + byFn[c.fn].total++; + if (j.error && p?.error) bothThrew++; + if (comparable(j) === comparable(p)) return; + byFn[c.fn].differ++; + let detail; + if (!p) detail = `${port.name} produced no output`; + else if (j.error || p.error) detail = `js ${j.error ?? "ok"} | ${port.key} ${p.error ?? "ok"}`; + else detail = firstDiff(j.ok, p.ok).replace(" py=", ` ${port.key}=`); + diffs.push({ c, detail }); + }); -console.log(`compared ${cases.length} cases (JS dist vs Python)`); -for (const [fn, s] of Object.entries(byFn)) { - console.log(` ${fn.padEnd(15)} ${s.total - s.differ}/${s.total} identical`); -} -if (bothThrew) console.log(` (${bothThrew} cases threw in both ports)`); -console.log(`differences: ${diffs.length}`); -for (const { c, detail } of diffs.slice(0, MAX_SHOWN)) { - console.log(`\n- ${c.file} ${c.id} [${c.fn}] ${JSON.stringify(c.input)}`); - console.log(` ${detail}`); + console.log(`compared ${cases.length} cases (JS dist vs ${port.name})`); + for (const [fn, s] of Object.entries(byFn)) { + console.log(` ${fn.padEnd(15)} ${s.total - s.differ}/${s.total} identical`); + } + if (bothThrew) console.log(` (${bothThrew} cases threw in both ports)`); + console.log(`differences: ${diffs.length}`); + for (const { c, detail } of diffs.slice(0, MAX_SHOWN)) { + console.log(`\n- ${c.file} ${c.id} [${c.fn}] ${JSON.stringify(c.input)}`); + console.log(` ${detail}`); + } + if (diffs.length > MAX_SHOWN) console.log(`\n... and ${diffs.length - MAX_SHOWN} more`); + total += diffs.length; } -if (diffs.length > MAX_SHOWN) console.log(`\n... and ${diffs.length - MAX_SHOWN} more`); -process.exit(diffs.length ? 1 : 0); +process.exit(total ? 1 : 0); diff --git a/site/astro.config.mjs b/site/astro.config.mjs index f09d091..db8cf65 100644 --- a/site/astro.config.mjs +++ b/site/astro.config.mjs @@ -20,7 +20,7 @@ export default defineConfig({ title: "trackparse", disable404Route: true, description: - "Turn messy track names into structured data: artists, features, remixes, versions and the noise around them. JavaScript and Python, one spec.", + "Turn messy track names into structured data: artists, features, remixes, versions and the noise around them. JavaScript, Python and Rust, one spec.", logo: { light: "./src/assets/logo-light.svg", dark: "./src/assets/logo-dark.svg", replacesTitle: false }, favicon: "/favicon.svg", social: [ diff --git a/site/src/components/Install.astro b/site/src/components/Install.astro index 0a8929a..58dd715 100644 --- a/site/src/components/Install.astro +++ b/site/src/components/Install.astro @@ -1,14 +1,15 @@ --- -// One install line under the hero, switchable between npm and pip, with a copy button. +// One install line under the hero, switchable between npm, pip and cargo, with a copy button. import Copy from "@lucide/astro/icons/copy"; -const cmds = { npm: "npm install trackparse", pip: "pip install trackparse" }; +const cmds = { npm: "npm install trackparse", pip: "pip install trackparse", cargo: "cargo add trackparse" }; ---
+
{cmds.npm} @@ -72,6 +73,21 @@ const cmds = { npm: "npm install trackparse", pip: "pip install trackparse" }; .copy.done { color: var(--sl-color-white); } + /* Three package managers and a command don't fit one row on a phone: the switch gets its own. */ + @media (max-width: 26rem) { + .install { + flex-wrap: wrap; + } + .seg { + flex-basis: 100%; + border-right: 0; + border-bottom: 1px solid var(--tp-border); + } + code { + flex: 1; + padding-block: 0.8rem; + } + }