Skip to content

[AI] Optimize word scoring normalization#32

Merged
sochalewski merged 1 commit into
mainfrom
points
Jul 5, 2026
Merged

[AI] Optimize word scoring normalization#32
sochalewski merged 1 commit into
mainfrom
points

Conversation

@sochalewski

Copy link
Copy Markdown
Owner

Summary

Optimizes Language.points(for:) by scoring lowercased Unicode scalars against precomputed scalar point tables and only applying canonical precomposition when decomposed combining marks are detected.

Also precomposes sanitized word queries, adds scoring normalization coverage, tightens DAWG validator expectations to include scored Word ordering, and introduces a Scripts/points-performance benchmark with PR CI reporting for scoring changes.

Why

Word scoring runs on search results and needs to stay correct for composed and decomposed Unicode input without paying unnecessary normalization cost for common already-composed or ASCII words.

Impact

Scoring behavior is preserved for existing words while decomposed French and Polish characters now score consistently with their composed equivalents. Future changes to Language.points(for:) get a dedicated benchmark script and automated PR performance comment when the scoring implementation changes.

Validation

Adds unit tests for canonical precomposition in Language.points(for:) and sanitizedWordQuery, updates DAWG validator tests to assert scored Word results, and adds the standalone Scripts/points-performance benchmark plus CI integration.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Points performance

Results

PointsPerformance comparison

Base Compare Build Iterations Samples
924f9e0 63b0ab4 swiftc -O -whole-module-optimization 200000 5

Language.points(for:) Time

Median ns/word, lower is better.

Workload Base Compare Delta Change Samples
English ASCII 354.36 72.14 -282.22 -79.64% 5/5
Polish composed 584.49 136.58 -447.91 -76.63% 5/5
Polish decomposed 2018.40 780.89 -1237.51 -61.31% 5/5
Mixed result-like 364.82 41.78 -323.04 -88.55% 5/5
Geomean -78.57%

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.70%. Comparing base (924f9e0) to head (63b0ab4).

Files with missing lines Patch % Lines
Scrabbdict/Extensions/Language+Extension.swift 92.68% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #32      +/-   ##
==========================================
- Coverage   93.75%   93.70%   -0.05%     
==========================================
  Files          35       35              
  Lines        1840     1875      +35     
==========================================
+ Hits         1725     1757      +32     
- Misses        115      118       +3     
Flag Coverage Δ
ios 93.70% <92.85%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Scrabbdict/Extensions/String+Extension.swift 100.00% <100.00%> (ø)
Scrabbdict/Extensions/Language+Extension.swift 93.02% <92.68%> (-6.98%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sochalewski sochalewski merged commit 9e36e2d into main Jul 5, 2026
9 checks passed
@sochalewski sochalewski deleted the points branch July 5, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant