which-dialect 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/translate.js +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ Every language's data defines its words in English, so English is the bridge bet
|
|
|
88
88
|
|
|
89
89
|
**Hand-picked words** come before all of these for the meanings that have them (see below).
|
|
90
90
|
|
|
91
|
-
Meanings are ordered by `meaning` (if given), then by being tagged for `fromRegion`, then the dictionary's own order, which lists main meanings first. That order is a guess when a word has several parts of speech: English *just* is listed as an adjective ("fair") before the adverb. Pass `pos` or `meaning` when you know which one you want.
|
|
91
|
+
Meanings are ordered by `meaning` (if given), then by being tagged for `fromRegion`, then the dictionary's own order, which lists main meanings first. **Specialist and sexual meanings come last:** the English data labels later meanings `technical` (physics, chemistry, geometry… from Wiktionary's topics) or `sexual` (by definition, since Wiktionary seldom labels them), so "excited" lists *enthusiastic* and "to stir the emotions" before "in a state of higher energy", "having an erection" and "sexually aroused", for every target language. A word's first meaning is never labelled, so *gold* stays the metal and *circle* the shape (`senseLabels` in `languages/en.ts`). That order is a guess when a word has several parts of speech: English *just* is listed as an adjective ("fair") before the adverb. Pass `pos` or `meaning` when you know which one you want.
|
|
92
92
|
|
|
93
93
|
### Hand-picked words
|
|
94
94
|
|
package/dist/translate.js
CHANGED
|
@@ -130,6 +130,10 @@ const INFLECTION_VIA = /\b(?:past|participle|plural|singular|present|third-perso
|
|
|
130
130
|
// Everyday speech, not slang: a form's own colloquial meaning ("got": "Have/has.") isn't marginal.
|
|
131
131
|
const EVERYDAY_LABELS = new Set(['informal', 'colloquial']);
|
|
132
132
|
const LABEL_PENALTY = new Set(['slang', 'Internet', 'humorous', 'literary', 'dialectal', 'uncommon', 'rare', 'euphemistic']);
|
|
133
|
+
// Senses with any of these labels (added by the data build, LanguageConfig.senseLabels) rank after
|
|
134
|
+
// everyday and marginal ones: specialist ("excited": "in a state of higher energy", physics) and sexual
|
|
135
|
+
// meanings, which a learner rarely means and shouldn't see first.
|
|
136
|
+
const LATER_LABELS = new Set(['technical', 'sexual']);
|
|
133
137
|
// A target gloss that lists the bridge term itself as an equivalent ("muốn": "to want"; "má": "mother;
|
|
134
138
|
// mom") is a plain translation, but a short gloss can't earn definition overlap, since the term's own
|
|
135
139
|
// words don't count. Wordier glosses did ("mắc": "to want to (go to the bathroom, laugh, etc.); to have
|
|
@@ -859,13 +863,15 @@ export function createTranslator(options = {}) {
|
|
|
859
863
|
}
|
|
860
864
|
return marginal ? -1 : 0;
|
|
861
865
|
};
|
|
866
|
+
const later = (g) => (g.source.labels.some((l) => LATER_LABELS.has(l)) ? 2 : 0);
|
|
862
867
|
const relevance = (g) => (meaningWords
|
|
863
868
|
? 10 * meaningOverlap(meaningWords, g.source.glosses.join(' ')) + 5 * meaningOverlap(meaningWords, g.translations[0]?.gloss ?? '')
|
|
864
869
|
: 0) -
|
|
865
870
|
(ownSenses && g.source.via && SPELLING_VIA.test(g.source.via) ? 2 : 0) +
|
|
866
871
|
(fromRegion && g.source.regionTagged ? 3 : 0) +
|
|
867
872
|
pronounRelevance(g) +
|
|
868
|
-
labelRelevance(g)
|
|
873
|
+
labelRelevance(g) -
|
|
874
|
+
later(g) +
|
|
869
875
|
(!meaning && pickedFirst.has(g.source) ? 5 : 0);
|
|
870
876
|
// A sense with no translations says nothing, so it goes after the ones that do ("got": "Expressing
|
|
871
877
|
// obligation; used with have." finds nothing; "Must; have/has (to)." gives "phải").
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "which-dialect",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "Translate words between languages and dialects, meaning by meaning, starting with Vietnamese (Northern, Central, Southern) and English, with Wiktionary data loaded on demand. More languages are planned.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|