Repository navigation
Conversation
NormalizeText keeps punctuation by default, so "product." and "again." were looked up with the trailing period and weren't found in the SSWE model, which has "product" and "again". Pass keepPunctuations: false, as dotnet#7961 did for ApplyCustomWordEmbedding. The expected-output comment also didn't match what the sample prints, so it's updated. It shows the first 10 of the 150 values, which are minimums that this change doesn't affect. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the sample’s punctuation-normalization and expected-output comment updates.
No open issues 🎉
What changed in this PR
Updates the ML.NET ApplyWordEmbedding sample to remove punctuation before tokenization, allowing sentence-ending words to match the pretrained embedding vocabulary. This follows the custom-model sample fix in #7961.
Changes:
- Passes
keepPunctuations: falsetoNormalizeText. - Corrects the expected-output comment for the first 10 feature values; those minimum values are unaffected by punctuation removal.
| File | Description |
|---|---|
docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/Text/ApplyWordEmbedding.cs |
Removes punctuation during normalization and corrects the expected-output comment. |
Review effort: Balanced
| // Expected output: | ||
| // Number of Features: 150 | ||
| // Features: -1.2489 0.2384 -1.3034 -0.9135 -3.4978 -0.1784 -1.3823 -0.3863 -2.5262 -0.8950 ... | ||
| // Features: -1.2489 -0.6884 -1.3034 -0.9135 -3.4978 -0.1784 -1.3823 -2.1131 -2.5262 -1.6288 ... |
There was a problem hiding this comment.
For context on why the old Expected output comment differed: when ApplyWordEmbedding.cs was added in #3142, the initial commit (15be23ce2c) had a typo in the input text ("greate" instead of "great"), so "greate" was ignored as out-of-vocabulary when generating the comment. A review commit (58e2d4be07) fixed the typo to "great" without updating the expected output comment.
Note
This change and description were written by GitHub Copilot (AI) on my behalf.
ApplyWordEmbeddinguses the same sentence asApplyCustomWordEmbedding, andNormalizeTextkeeps punctuation by default. Soproduct.andagain.were looked up with the trailing period and weren't found in the SSWE model, which hasproductandagain. This passeskeepPunctuations: false, like #7961 did for the custom-model sample.The expected-output comment also didn't match what the sample prints today, so it's updated. It shows the first 10 of the 150 feature values. They're minimums that this change doesn't affect, so the new line only fixes the old mismatch.
Follow-up to #7961.