Skip to content

Commit

Permalink
添加查询单字与词条重码的词条
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleBing committed Oct 6, 2024
1 parent 7d96504 commit 044af82
Show file tree
Hide file tree
Showing 16 changed files with 269 additions and 310 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v1.29 `2024-10-06`
- 添加查询单字与词条重码的词条

## v1.28 `2024-07-30`
- 优化暗黑模式下词条分组分配的显示
- 暗黑模式下 分组上下移动样式优化
Expand Down
9 changes: 1 addition & 8 deletions assets/img/delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 1 addition & 7 deletions assets/img/down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/img/down_alt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
430 changes: 159 additions & 271 deletions assets/img/icons.ai

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions assets/img/up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/img/up_alt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion assets/scss/_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ $height-checkbox: 14px;
$border-color-checkbox: #d6d6d6;

.word-item{
@extend .unselectable;
height: $height-word-item;
align-items: center;
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion assets/scss/wubi.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
transform: translateY(2px);
}

.unselectable, .schema-list .schema-list-item, .config-file-list .config-file-list-item, .file-list .file-list-item, .catalog-list .catalog-item, .footer .footer-left .link-list .link, .btn, .word-item .operation, .word-item {
.unselectable, .schema-list .schema-list-item, .config-file-list .config-file-list-item, .file-list .file-list-item, .catalog-list .catalog-item, .footer .footer-left .link-list .link, .btn, .word-item .operation {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
Expand Down
56 changes: 54 additions & 2 deletions js/Dict.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,12 @@ class Dict {
console.log(`Sort 用时 ${new Date().getTime() - startPoint} ms`)
}

// 查重,返回重复定义的字词
// includeCharacter 当包含单字时
/**
* 查重,返回重复定义的字词,非编码
* @param filterSingleCharacter 当包含单字时
* @param isWithAllRepeatWord
* @returns {*[]}
*/
getRepetitionWords(filterSingleCharacter, isWithAllRepeatWord){
let startPoint = new Date().getTime()
let wordMap = new Map()
Expand Down Expand Up @@ -257,6 +261,54 @@ class Dict {
return repetitionWords
}


/**
* 获取与单字重码的词条
* @returns {*[]}
*/
getRepeatedWordsWithSameCode(){
let startPoint = new Date().getTime()
let codeMap = new Map()
let repetitionWords = []

// 生成单字 code map
this.wordsOrigin
.filter(word => getUnicodeStringLength(word.word) === 1)
.forEach(word => {
codeMap.set(word.code, word)
})

this.wordsOrigin.forEach(word => {
if (codeMap.has(word.code) && getUnicodeStringLength(word.word) > 1){
repetitionWords.push(word) // 添加词条
let matchedWord = codeMap.get(word.code)
if (matchedWord) repetitionWords.push(matchedWord) // 同时添加跟这个词条相同编码的单字
}
})

// 排序
repetitionWords.sort((a, b) => {
// console.log(a.word + a.code, b.word + b.code)
return (a.isPriorityAbove(b)) ? -1 : 1
})
for (let i = 0; i < repetitionWords.length - 1; i++) {
if (repetitionWords[i].id === repetitionWords[i + 1].id ) {
repetitionWords.splice(i,1)
i = i - 1
}
}

console.log('重复词条数量:未去重之前 ', repetitionWords.length)

console.log(`查重完成,用时 ${new Date().getTime() - startPoint} ms`)
console.log('词条字典数量: ', codeMap.size)
console.log('重复词条数量: ', repetitionWords.length)
console.log('重复 + 词条字典 = ', repetitionWords.length + codeMap.size)
console.log('处理之后的:', repetitionWords)
return repetitionWords
}


/**
* 给所有词条添加权重
* 添加规则:
Expand Down
4 changes: 2 additions & 2 deletions js/Global.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const IS_IN_DEVELOP = false // 生产
// const IS_IN_DEVELOP = true // 开发
// const IS_IN_DEVELOP = false // 生产
const IS_IN_DEVELOP = true // 开发

const DEFAULT_BASE_URL = 'http://kylebing.cn/portal/'
// const BASE_URL = 'http://localhost:3000/'
Expand Down
18 changes: 18 additions & 0 deletions js/Word.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ class Word{
this.note = note || ''
this.indicator = indicator
}
toCodeComparableString(){
return this.code + '\t' + this.priority + '\t' + this.note
}

/**
* 判断词条优先级是否高于另一个词条
* @param word
*/
isPriorityAbove(word){
if (this.code < word.code){
return true
} else if (this.code === word.code) {
return this.priority > word.priority // code 一样时,权重大的优先
} else {
return false
}
}

toComparableString(){
return this.word + '\t' + this.code + '\t' + this.id + '\t' + this.priority + '\t' + this.note
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wubi-dict-editor",
"version": "1.2.8",
"version": "1.2.9",
"private": true,
"author": {
"name": "KyleBing",
Expand Down Expand Up @@ -34,7 +34,7 @@
"config": {
"forge": {
"packagerConfig": {
"appVersion": "1.2.8",
"appVersion": "1.2.9",
"name": "五笔码表助手",
"appCopyright": "[email protected]",
"icon": "./assets/img/appIcon/appicon",
Expand Down
9 changes: 7 additions & 2 deletions view/index/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,14 @@ const app = {
},

// 查重
checkRepetition(includeCharacter, isWithAllRepeatWord){
checkRepetition(includeCharacter, isWithAllRepeatWord, isWithAllType){
this.setGroupId(-1) // 高亮分组定位到 【全部】
this.words = this.dict.getRepetitionWords(includeCharacter, isWithAllRepeatWord)
this.words = this.dict.getRepetitionWords(includeCharacter, isWithAllRepeatWord, isWithAllType)
},

// 查询所有与单字重复的词条
checkRepeatedWordWithSameCode(){
this.words = this.dict.getRepeatedWordsWithSameCode()
},

// 词组编码查错
Expand Down
23 changes: 17 additions & 6 deletions view/index/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@
<img src="../../assets/img/up_white.svg" alt="调换权重上移">
</div>
<div v-else class="up" @click.stop="moveUp(item.id, true)" title="调换权重上移">
<img src="../../assets/img/up.svg" alt="调换权重上移">
<img src="../../assets/img/up_alt.svg" alt="调换权重上移">
</div>
<div v-if="config.theme === 'black'" class="down"
@click.stop="moveDown(item.id, true)" title="调换权重下移">
<img src="../../assets/img/down_white.svg" alt="调换权重下移">
</div>
<div v-else class="down" @click.stop="moveDown(item.id, true)" title="调换权重下移">
<img src="../../assets/img/down.svg" alt="调换权重下移">
<img src="../../assets/img/down_alt.svg" alt="调换权重下移">
</div>

<div v-if="config.theme === 'black'" class="up" @click.stop="editWord(item)">
Expand Down Expand Up @@ -317,13 +317,13 @@
<img src="../../assets/img/up_white.svg" alt="调换权重上移" >
</div>
<div v-else class="up" @click.stop="moveUp(item.id, true)" title="调换权重上移">
<img src="../../assets/img/up.svg" alt="调换权重上移" >
<img src="../../assets/img/up_alt.svg" alt="调换权重上移" >
</div>
<div v-if="config.theme === 'black'" class="down" @click.stop="moveDown(item.id, true)" title="调换权重下移">
<img src="../../assets/img/down_white.svg" alt="调换权重下移" >
</div>
<div v-else class="down" @click.stop="moveDown(item.id, true)" title="调换权重下移">
<img src="../../assets/img/down.svg" alt="调换权重下移" >
<img src="../../assets/img/down_alt.svg" alt="调换权重下移" >
</div>


Expand Down Expand Up @@ -422,7 +422,7 @@
</section>

<section>
<div class="title">查重 - 全部</div>
<div class="title">词条查重 - 全部</div>
<div class="content">
<div class="btn-list">
<div class="btn-item">
Expand All @@ -435,7 +435,7 @@
</div>
</section>
<section>
<div class="title">查重 - 多余部分</div>
<div class="title">词条查重 - 多余部分</div>
<div class="content">
<div class="btn-list">
<div class="btn-item">
Expand All @@ -447,6 +447,17 @@
</div>
</div>
</section>
<section>
<div class="title">编码查重 - 与单字重码的词条</div>
<div class="content">
<div class="btn-list">
<div class="btn-item">
<div class="btn btn-primary" @click="checkRepeatedWordWithSameCode()">查重</div>
</div>
</div>
</div>
</section>

<section>
<div class="title">查错</div>
<div class="content">
Expand Down

0 comments on commit 044af82

Please sign in to comment.