merged mode: rewrite term frequency (use score)
This commit is contained in:
parent
04def64521
commit
f54f909701
@ -318,21 +318,24 @@ function dictTagsSort(tags) {
|
||||
});
|
||||
}
|
||||
|
||||
function dictJmdictTermTagsRare(tags) {
|
||||
const rareTags = [
|
||||
'ik',
|
||||
'iK',
|
||||
'ok',
|
||||
'oK',
|
||||
'io',
|
||||
'oik'
|
||||
];
|
||||
function dictTermTagScore(tags) {
|
||||
let score = 0;
|
||||
|
||||
const tagScores = {
|
||||
'ik': -5,
|
||||
'iK': -5,
|
||||
'ok': -5,
|
||||
'oK': -5,
|
||||
'io': -5,
|
||||
'oik': -5,
|
||||
'P': 10
|
||||
};
|
||||
|
||||
for (const tag of tags) {
|
||||
if (rareTags.includes(tag)) {
|
||||
return true;
|
||||
}
|
||||
score += tagScores[tag] || 0;
|
||||
}
|
||||
return false;
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
function dictFieldSplit(field) {
|
||||
|
@ -313,7 +313,7 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia
|
||||
},"29":function(container,depth0,helpers,partials,data,blockParams,depths) {
|
||||
var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", buffer =
|
||||
" <div class=\"expression\">\n <span class=\"expression-"
|
||||
+ container.escapeExpression(((helper = (helper = helpers.jmdictTermFrequency || (depth0 != null ? depth0.jmdictTermFrequency : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"jmdictTermFrequency","hash":{},"data":data}) : helper)))
|
||||
+ container.escapeExpression(((helper = (helper = helpers.termFrequency || (depth0 != null ? depth0.termFrequency : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"termFrequency","hash":{},"data":data}) : helper)))
|
||||
+ "\">";
|
||||
stack1 = ((helper = (helper = helpers.kanjiLinks || (depth0 != null ? depth0.kanjiLinks : depth0)) != null ? helper : alias2),(options={"name":"kanjiLinks","hash":{},"fn":container.program(30, data, 0, blockParams, depths),"inverse":container.noop,"data":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper));
|
||||
if (!helpers.kanjiLinks) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
|
||||
|
@ -113,15 +113,15 @@ class Translator {
|
||||
expression: expression,
|
||||
reading: reading,
|
||||
termTags: dictTagsSort(tags),
|
||||
jmdictTermFrequency: (tags => {
|
||||
if (tags.has('P')) {
|
||||
termFrequency: (score => {
|
||||
if (score > 0) {
|
||||
return 'popular';
|
||||
} else if (dictJmdictTermTagsRare(tags)) {
|
||||
} else if (score < 0) {
|
||||
return 'rare';
|
||||
} else {
|
||||
return 'normal';
|
||||
}
|
||||
})(result.expressions.get(expression).get(reading))
|
||||
})(dictTermTagScore(result.expressions.get(expression).get(reading)))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@
|
||||
{{#if merged}}
|
||||
{{#each expressions}}
|
||||
<div class="expression">
|
||||
<span class="expression-{{jmdictTermFrequency}}">{{#kanjiLinks}}{{#furigana}}{{{.}}}{{/furigana}}{{/kanjiLinks}}</span><!--
|
||||
<span class="expression-{{termFrequency}}">{{#kanjiLinks}}{{#furigana}}{{{.}}}{{/furigana}}{{/kanjiLinks}}</span><!--
|
||||
--><div class="peek-wrapper">
|
||||
{{~#if ../playback~}}
|
||||
<a href="#" class="action-play-audio"><img src="/mixed/img/play-audio.png" title="Play audio" alt></a>
|
||||
|
Loading…
Reference in New Issue
Block a user