This commit is contained in:
wysha-object 2026-04-26 12:47:26 +08:00
parent af4033e5bd
commit 7768e77a39
No known key found for this signature in database
GPG Key ID: 258E47C92BB45228
2 changed files with 9 additions and 7 deletions

View File

@ -50,7 +50,7 @@ const posList = computed<{ pos: string; totalFreq?: number; trans: { pos: string
<div class="flex gap-3 flex-wrap items-end">
<span v-for="tran in pos.trans">
<span v-if="tran.frequency != undefined" :class="['rare', 'uncommon', 'common'][tran.frequency]">{{ tran.cn }}</span>
<SentenceHightLightWord :text="tran.cn" :word="word.word" :dictation="!props.showFull" :high-light="false" />
<SentenceHightLightWord v-else :text="tran.cn" :word="word.word" :dictation="!props.showFull" :high-light="false" />
</span>
</div>
</div>

View File

@ -16,18 +16,20 @@ function getTrans(word: Word): { cn: string, freq: number }[] {
return Array.from(rsMap.values());
}
function getCommonCount(str1: string, str2: string): number {
function calCommon(str1: string, str2: string): number {
str1 = str1.toLowerCase();
str2 = str2.toLowerCase();
let count = 0;
let rs = 0;
let set1 = new Set(str1.split(''));
let set2 = new Set(str2.split(''));
for (let char of set1) {
if (set2.has(char)) {
count++;
rs += 1 << 2;
} else {
rs--;
}
}
return count;
return rs;
}
function calSimilarity(word1: Word, word2: Word): number {
@ -48,8 +50,8 @@ function calSimilarity(word1: Word, word2: Word): number {
}
})
similarity += getCommonCount(word1Trans.map(item => item.cn).join(''), word2Trans.map((item) => item.cn).join(''));
similarity += getCommonCount(word1.word, word2.word) << 16;
similarity += calCommon(word1Trans.map(item => item.cn).join(''), word2Trans.map((item) => item.cn).join(''));
similarity += calCommon(word1.word, word2.word) << 16;
return similarity;
}