This commit is contained in:
zyronon
2023-12-03 23:40:24 +08:00
parent 20165db2f3
commit f839e54617
10 changed files with 100 additions and 71 deletions

View File

@@ -3,7 +3,7 @@
"title": "A private conversation!",
"titleTranslate": "私人谈话!",
"text": "Last week I went to the theatre. I had a very good seat. The play was very interesting. I did not enjoy it. A young man and a young woman were sitting behind me. They were talking loudly. I got very angry. I could not hear the actors. I turned round. I looked at the man and the woman angrily. They did not pay any attention. In the end, I could not bear it. I turned round again. 'I can't hear a word!' I said angrily.\n 'It's none of your business,' the young man said rudely. 'This is a private conversation!'",
"textCustomTranslate": "上星期我去看戏。\r\n我的座位很好\r\n戏很有意思\r\n但我却无法欣赏。\r\n一青年男子与一青年女子坐在我的身后\r\n大声地说着话。\r\n我非常生气\r\n因为我听不见演员在说什么。\r\n我回过头去\r\n怒视着那一男一女\r\n他们却毫不理会。\r\n最后我忍不住了\r\n又一次回过头去\r\n生气地说“我一个字也听不见了”\r\n\r\n“不关你的事”那男的毫不客气地说\r\n“这是私人间的谈话”",
"textCustomTranslate": "上星期我去看戏。\n我的座位很好\n戏很有意思\n但我却无法欣赏。\n一青年男子与一青年女子坐在我的身后\n大声地说着话。\n我非常生气\n因为我听不见演员在说什么。\n我回过头去\n怒视着那一男一女\n他们却毫不理会。\n最后我忍不住了\n又一次回过头去\n生气地说“我一个字也听不见了”\n\n“不关你的事”那男的毫不客气地说\n“这是私人间的谈话”",
"textNetworkTranslate": "",
"newWords": [],
"textCustomTranslateIsFormat": true,
@@ -14,8 +14,8 @@
"title": "Planning a share portfolio",
"titleTranslate": "规划股份投资",
"text": "How does the older investor differ in his approach to investment from the younger investor?\nThere is no shortage of tipsters around offering 'get-rich-quick' opportunities. But if you are a serious private investor, leave the Las Vegas mentality to those with money to fritter. The serious investor needs a proper 'portfolio' -- a well-planned selection of investments, with a definite structure and a clear aim. But exactly how does a newcomer to the stock market go about achieving that?\nWell, if you go to five reputable stock brokers and ask them what you should do with your money, you're likely to get five different answers, -- even if you give all the relevant information about your age age, family, finances and what you want from your investments. Moral? There is no one 'right' way to structure a portfolio. However, there are undoubtedly some wrong ways, and you can be sure that none of our five advisers would have suggested sinking all (or perhaps any) of your money into Periwigs*.\nSo what should you do? We'll assume that you have sorted out the basics -- like mortgages, pensions, insurance and access to sufficient cash reserves. You should then establish your own individual aims. These are partly a matter of personal circumstances, partly a matter of psychology.\nFor instance, if you are older you have less time to recover from any major losses, and you may well wish to boost your pension income. So preserving your capital and generating extra income are your main priorities. In this case, you'd probably construct a portfolio with some shares (but not high risk ones), along with gilts, cash deposits, and perhaps convertibles or the income shares of split capital investment trusts.\nIf you are younger, and in a solid financial position, you may decide to take an aggressive approach -- but only if you're blessed with a sanguine disposition and won't suffer sleepless nights over share prices. If portfolio, alongside your more pedestrian in vestments. Once you have decided on your investment aims, you can then decide where to put your money. The golden rule here is spread your risk -- if you put all of your money into Periwigs International, you're setting yourself up as a hostage to fortune.\n*'Periwigs' is the name of a fictitious company.\nINVESTOR'S CHRONICLE, March 23 1990",
"textCustomTranslate": "年长投资者与年轻投资者的投资方式有何不同?\r\n\r\n提供“快速致富”的机会不乏爆料者。\r\n但如果你是一个认真的私人投资者把拉斯维加斯的心态留给那些有钱挥霍的人。\r\n认真的投资者需要一个合适的“投资组合”——一个精心规划的投资选择有明确的结构和明确的目标。\r\n但一个新进入股市的人究竟是如何做到这一点的呢\r\n\r\n好吧如果你去找五位声誉良好的股票经纪人问他们你应该如何处理你的钱你很可能会得到五个不同的答案即使你提供了关于你的年龄、家庭、财务状况以及你想从投资中得到什么的所有相关信息。\r\n道德的\r\n没有一种“正确”的方式来构建投资组合。\r\n然而毫无疑问有一些错误的方法你可以肯定的是我们的五位顾问中没有一位会建议你把所有或任何钱都投入Periwigs*。\r\n\r\n那么你该怎么办呢\r\n我们假设你已经解决了基本问题比如抵押贷款、养老金、保险和获得足够的现金储备。\r\n然后你应该确立自己的个人目标。\r\n这些部分是个人情况的问题部分是心理的问题。\r\n\r\n例如如果你年纪较大你从任何重大损失中恢复的时间都会减少你很可能希望增加养老金收入。\r\n因此保护你的资本和创造额外收入是你的首要任务。\r\n在这种情况下你可能会构建一个投资组合其中包括一些股票但不是高风险股票以及金边债券、现金存款也许还有可转换债券或分割资本投资信托的收入份额。\r\n\r\n如果你更年轻财务状况稳定你可能会决定采取积极的方法——但前提是你有幸拥有乐观的性格不会因为股价而失眠。\r\n如果是投资组合与你更普通的投资组合在一起。\r\n一旦你决定了投资目标你就可以决定把钱放在哪里。\r\n这里的黄金法则是分散你的风险——如果你把所有的钱都投入到Periwigs International你就把自己当成了命运的人质。\r\n\r\n*“Periwigs”是一家虚构公司的名字。\r\n\r\n1990年3月23日《投资者纪事》",
"textNetworkTranslate": "年长投资者与年轻投资者的投资方式有何不同?\n\n提供“快速致富”的机会不乏爆料者。\n但如果你是一个认真的私人投资者把拉斯维加斯的心态留给那些有钱挥霍的人。\n认真的投资者需要一个合适的“投资组合”——一个精心规划的投资选择有明确的结构和明确的目标。\n但一个新进入股市的人究竟是如何做到这一点的呢\n\n好吧如果你去找五位声誉良好的股票经纪人问他们你应该如何处理你的钱你很可能会得到五个不同的答案即使你提供了关于你的年龄、家庭、财务状况以及你想从投资中得到什么的所有相关信息。\n道德的\n没有一种“正确”的方式来构建投资组合。\n然而毫无疑问有一些错误的方法你可以肯定的是我们的五位顾问中没有一位会建议你把所有或任何钱都投入Periwigs*。\n\n那么你该怎么办呢\n我们假设你已经解决了基本问题比如抵押贷款、养老金、保险和获得足够的现金储备。\n然后你应该确立自己的个人目标。\n这些部分是个人情况的问题部分是心理的问题。\n\n例如如果你年纪较大你从任何重大损失中恢复的时间都会减少你很可能希望增加养老金收入。\n因此保护你的资本和创造额外收入是你的首要任务。\n在这种情况下你可能会构建一个投资组合其中包括一些股票但不是高风险股票以及金边债券、现金存款也许还有可转换债券或分割资本投资信托的收入份额。\n\n如果你更年轻财务状况稳定你可能会决定采取积极的方法——但前提是你有幸拥有乐观的性格不会因为股价而失眠。\n如果是投资组合与你更普通的投资组合在一起。\n一旦你决定了投资目标你就可以决定把钱放在哪里。\n这里的黄金法则是分散你的风险——如果你把所有的钱都投入到Periwigs International你就把自己当成了命运的人质。\n\n*“Periwigs”是一家虚构公司的名字。\n\n1990年3月23日《投资者纪事》",
"textCustomTranslate": "年长投资者与年轻投资者的投资方式有何不同?\n\n提供“快速致富”的机会不乏爆料者。\n但如果你是一个认真的私人投资者把拉斯维加斯的心态留给那些有钱挥霍的人。\n认真的投资者需要一个合适的“投资组合”——一个精心规划的投资选择有明确的结构和明确的目标。\n但一个新进入股市的人究竟是如何做到这一点的呢\n\n好吧如果你去找五位声誉良好的股票经纪人问他们你应该如何处理你的钱你很可能会得到五个不同的答案即使你提供了关于你的年龄、家庭、财务状况以及你想从投资中得到什么的所有相关信息。\n道德的\n没有一种“正确”的方式来构建投资组合。\n然而毫无疑问有一些错误的方法你可以肯定的是我们的五位顾问中没有一位会建议你把所有或任何钱都投入Periwigs*。\n\n那么你该怎么办呢\n我们假设你已经解决了基本问题比如抵押贷款、养老金、保险和获得足够的现金储备。\n然后你应该确立自己的个人目标。\n这些部分是个人情况的问题部分是心理的问题。\n\n例如如果你年纪较大你从任何重大损失中恢复的时间都会减少你很可能希望增加养老金收入。\n因此保护你的资本和创造额外收入是你的首要任务。\n在这种情况下你可能会构建一个投资组合其中包括一些股票但不是高风险股票以及金边债券、现金存款也许还有可转换债券或分割资本投资信托的收入份额。\n\n如果你更年轻财务状况稳定你可能会决定采取积极的方法——但前提是你有幸拥有乐观的性格不会因为股价而失眠。\n如果是投资组合与你更普通的投资组合在一起。\n一旦你决定了投资目标你就可以决定把钱放在哪里。\n这里的黄金法则是分散你的风险——如果你把所有的钱都投入到Periwigs International你就把自己当成了命运的人质。\n\n*“Periwigs”是一家虚构公司的名字。\n\n1990年3月23日《投资者纪事》",
"textNetworkTranslate": "",
"newWords": [],
"textCustomTranslateIsFormat": true,
"useTranslateType": "custom",
@@ -26,7 +26,7 @@
"titleTranslate": "早餐还是午餐?",
"text": "It was Sunday. I never get up early on Sundays. I sometimes stay in bed until lunchtime. Last Sunday I got up very late. I looked out of the window. It was dark outside. 'What a day!' I thought. 'It's raining again.' Just then, the telephone rang. It was my aunt Lucy. 'I've just arrived by train,' she said. 'I'm coming to see you.'\n 'But I'm still having breakfast,' I said.\n 'What are you doing?' she asked.\n 'I'm having breakfast,' I repeated.\n 'Dear me,' she said. 'Do you always get up so late? It's one o'clock!'",
"textCustomTranslate": "那是个星期天,\n而在星期天我是从来不早起的\n有时我要一直躺到吃午饭的时候。\n上个星期天我起得很晚。\n我望望窗外外面一片昏暗。\n“鬼天气”\n我想“又下雨了。”\n正在这时电话铃响了。\n是我姑母露西打来的。\n“我刚下火车”她说\n“我这就来看你。”\n\n“但我还在吃早饭”我说。\n\n“你在干什么”她问道。\n\n“我正在吃早饭”我又说了一遍。\n\n“天啊”她说\n“你总是起得这么晚吗",
"textNetworkTranslate": "那是星期天。\n星期天我从不早起。\n我有时会一直躺在床上直到午餐时间。\n上周日我起得很晚。\n我望向窗外。\n外面很黑。\n“多么美好的一天”我想。\n“又下雨了。”就在这时电话铃响了。\n是我的姑姑露西。\n她说我刚坐火车到。\n“我是来看你的。”\n\n“但我还在吃早饭”我说。\n\n“你在干什么”她问道。\n\n“我正在吃早饭”我重复道。\n\n“亲爱的”她说。\n“你总是起得这么晚吗",
"textNetworkTranslate": "",
"textCustomTranslateIsFormat": true,
"useTranslateType": "custom",
"newWords": [],
@@ -102,7 +102,7 @@
"title": "A cold welcome",
"titleTranslate": "冷遇",
"text": "On Wednesday evening, we went to the Town Hall. It was the last day of the year and a large crowd of people had gathered under the Town Hall clock. It would strike twelve in twenty minutes' time. Fifteen minutes passed and then, at five to twelve, the clock stopped. The big minute hand did not move. We waited and waited, but nothing happened. Suddenly someone shouted. 'It's two minutes past twelve! The clock has stopped!' I looked at my watch. It was true. The big clock refused to welcome the New Year. At that moment, everybody began to laugh and sing.\n",
"textCustomTranslate": "星期三的晚上,我们去了市政厅。 那是一年的最后一天一大群人聚集在市政厅的大钟下面。再过20分钟大钟将敲响12下。15分钟过去了而就在11点55分时大钟停了。那根巨大的分针不动了。 我们等啊等啊可情况没有变化。突然有人喊道“已经12点零2分了那钟已经停了”我看了一下我的手表果真如此。那座大钟不愿意迎接新年。此时大家已经笑了起来同时唱起了歌。",
"textCustomTranslate": "星期三的晚上,我们去了市政厅。\n 那是一年的最后一天,一大群人聚集在市政厅的大钟下面。\n再过20分钟大钟将敲响12下。\n15分钟过去了而就在11点55分时大钟停了。\n那根巨大的分针不动了。\n 我们等啊等啊,可情况没有变化。\n突然有人喊道“已经12点零2分了\n那钟已经停了!”\n我看了一下我的手表,\n果真如此。\n那座大钟不愿意迎接新年。\n此时,大家已经笑了起来,同时唱起了歌。",
"textNetworkTranslate": "",
"textCustomTranslateIsFormat": false,
"useTranslateType": "custom",

View File

@@ -2,7 +2,7 @@
import {onMounted, watch} from "vue";
import {BaseState, useBaseStore} from "@/stores/base.ts";
import {DictType, SaveConfig, SaveDict} from "@/types.ts"
import {Dict, DictType, SaveConfig, SaveDict} from "@/types.ts"
import Practice from "@/pages/practice/index.vue"
import {useRuntimeStore} from "@/stores/runtime.ts";
import {useSettingStore} from "@/stores/setting.ts";
@@ -21,11 +21,19 @@ const {setTheme} = useTheme()
watch(store.$state, (n: BaseState) => {
let data: BaseState = cloneDeep(n)
data.myDictList.map((v: any) => {
if (v.type === DictType.word) v.originWords = []
if (v.type === DictType.article) v.articles = []
v.words = []
v.chapterWords = []
data.myDictList.map((v: Dict) => {
if (v.isCustom) {
if (v.type === DictType.article) {
v.articles.map(s => {
delete s.sections
})
}
} else {
if (v.type === DictType.word) v.originWords = []
if (v.type === DictType.article) v.articles = []
v.words = []
v.chapterWords = []
}
})
localforage.setItem(SaveDict.key, JSON.stringify({val: data, version: SaveDict.version}))
})

View File

@@ -70,14 +70,13 @@ watch(() => props.article, val => {
function renewSections() {
if (editArticle.text.trim()) {
renewSectionTexts(editArticle)
editArticle.sections = []
return
if (editArticle.useTranslateType === TranslateType.custom) {
failCount = renewSectionTranslates(editArticle, editArticle.textCustomTranslate)
}
if (editArticle.useTranslateType === TranslateType.network) {
failCount = renewSectionTranslates(editArticle, editArticle.textNetworkTranslate)
}
console.log('failCount',failCount)
} else {
editArticle.sections = []
}
@@ -165,6 +164,7 @@ function saveSentenceText(sentence: Sentence, val: string) {
}
function save(option: 'save' | 'saveAndNext') {
// return console.log(cloneDeep(editArticle))
return new Promise((resolve: Function) => {
// console.log('article', article)
// copy(JSON.stringify(article))

View File

@@ -46,7 +46,7 @@ export function splitEnArticle(text: string): { sections: Sentence[][], newText:
let doc = nlp.tokenize(rowSection)
let sentences = doc.json()
// console.log('--')
console.log('ss', sentences)
// console.log('ss', sentences)
sentences.map(sentenceRow => {
let sentence: Sentence = {
//他没有空格,导致修改一行一行的数据时,汇总时全没有空格了,库无法正常断句
@@ -138,15 +138,20 @@ export function splitEnArticle(text: string): { sections: Sentence[][], newText:
break
//类似于这种的“' -- ”的。需要保留空格用了一个占位符才处理因为每个符号都会把前面的那个字符的nextSpace改为false
case ' ':
console.log('sentence', sentence)
sentence.words[sentence.words.length - 1].nextSpace = true
let word3 = cloneDeep({
...DefaultArticleWord,
name: 'placeholder',
isSymbol: true,
nextSpace: false,
});
sentence.words.push(word3)
// console.log('sentence', sentence)
//遇到“The clock has stopped!' I looked at my watch.”
//检测到stopped!' 的'时如果前引号不在当前句会把当前句的word合并到前一句。那么当前句的word就为空了会报错
//所以需要检测一下
if (sentence.words.length) {
sentence.words[sentence.words.length - 1].nextSpace = true
let word3 = cloneDeep({
...DefaultArticleWord,
name: 'placeholder',
isSymbol: true,
nextSpace: false,
});
sentence.words.push(word3)
}
break
default:
// console.log('post', post)
@@ -183,11 +188,7 @@ export function splitEnArticle(text: string): { sections: Sentence[][], newText:
let post: string = v.post
//判断是不是等于空,因为正常的词后面都会有个空格。这种不需要处理。
if (post && post !== ' ') {
try {
checkSymbol(post)
} catch (e) {
console.log('err', v)
}
checkSymbol(post)
}
}
})
@@ -197,19 +198,19 @@ export function splitEnArticle(text: string): { sections: Sentence[][], newText:
})
})
// sections = sections.filter(sectionItem => sectionItem.length)
// sections.map((sectionItem, a) => {
// sectionItem.map((sentenceItem, b) => {
// sentenceItem.text = sentenceItem.words.reduce((previousValue: string, currentValue) => {
// previousValue += currentValue.name + (currentValue.nextSpace ? ' ' : '')
// return previousValue
// }, '')
// })
// })
sections = sections.filter(sectionItem => sectionItem.length)
sections.map((sectionItem, a) => {
sectionItem.map((sentenceItem, b) => {
sentenceItem.text = sentenceItem.words.reduce((previousValue: string, currentValue) => {
previousValue += currentValue.name + (currentValue.nextSpace ? ' ' : '')
return previousValue
}, '')
})
})
// console.log(sections)
// console.timeEnd()
console.log('sections', sections)
// console.log('sections', sections)
return {
newText: text,
sections
@@ -278,11 +279,12 @@ export function isArticle(type: DictType): boolean {
export function getTranslateText(article: Article) {
if (article.useTranslateType === TranslateType.custom) {
return article.textCustomTranslate
.split('\r\n\r\n').filter(v => v)
.split('\n\n').filter(v => v)
} else if (article.useTranslateType === TranslateType.network) {
return article.textNetworkTranslate
.split('\r\n\r\n').filter(v => v)
.split('\n\n').filter(v => v)
} else {
return []
}

View File

@@ -6,29 +6,29 @@ import {Translator} from "@opentranslate/translator/src/translator.ts";
export function renewSectionTranslates(article: Article, translate: string) {
let failCount = 0
let articleTranslate = translate.split('\n')
// console.log('articleTranslate', articleTranslate)
// console.log('articleTranslate', articleTranslate)
let count = 0
for (let i = 0; i < article.sections.length; i++) {
let v = article.sections[i]
for (let j = 0; j < v.length; j++) {
let sentence = v[j]
try {
let trans = articleTranslate[count]
if (trans) {
sentence.translate = trans
} else {
failCount++
}
} catch (e) {
failCount++
// console.log('没有对应的翻译', sentence.text)
}
count++
let articleTranslate = translate.split('\n')
// console.log('articleTranslate', articleTranslate)
// console.log('articleTranslate', articleTranslate)
let count = 0
for (let i = 0; i < article.sections.length; i++) {
let v = article.sections[i]
for (let j = 0; j < v.length; j++) {
let sentence = v[j]
try {
let trans = articleTranslate[count]
if (trans.trim()) {
sentence.translate = trans
} else {
failCount++
}
count++
} catch (e) {
failCount++
// console.log('没有对应的翻译', sentence.text)
}
count++
}
count++
}
return failCount
}

View File

@@ -252,6 +252,13 @@ function add() {
emitter.emit(EventKey.openArticleListModal)
}
function back() {
emit('back')
setTimeout(() => {
isEditDict = false
}, 500)
}
defineExpose({getDictDetail, add, editDict})
@@ -260,7 +267,7 @@ defineExpose({getDictDetail, add, editDict})
<template>
<div class="article-detail">
<header>
<div class="back" @click.stop="emit('back')">
<div class="back" @click.stop="back">
<Icon icon="octicon:arrow-left-24" width="20"/>
</div>
<div class="left">

View File

@@ -425,7 +425,7 @@ function resetChapterList(num?: number, sync?: boolean) {
runtimeStore.editDict.chapterWords = chunk(runtimeStore.editDict.words, runtimeStore.editDict.chapterWordNumber)
runtimeStore.editDict.length = runtimeStore.editDict.words.length
chapterList2 = runtimeStore.editDict.chapterWords.map((v, i) => ({id: i}))
if (sync!==undefined){
if (sync !== undefined) {
syncMyDictList(runtimeStore.editDict)
}
}
@@ -544,6 +544,13 @@ function s() {
}
}
function back() {
emit('back')
setTimeout(() => {
isEditDict = false
}, 500)
}
defineExpose({getDictDetail, add: addWord, editDict})
</script>
@@ -551,7 +558,7 @@ defineExpose({getDictDetail, add: addWord, editDict})
<template>
<div class="dict-detail">
<header>
<div class="back" @click.stop="emit('back')">
<div class="back" @click.stop="back">
<Icon icon="octicon:arrow-left-24" width="20"/>
</div>
<div class="left">

View File

@@ -35,7 +35,7 @@ onUnmounted(() => {
<template>
<div class="footer " :class="!settingStore.showToolbar && 'hide'">
<div class="bottom anim">
<div class="bottom ">
<el-progress
:percentage="progress"
:stroke-width="8"
@@ -82,7 +82,7 @@ onUnmounted(() => {
.footer {
width: var(--toolbar-width);
margin-bottom: 10rem;
transition: all .3s;
transition: all var(--anim-time);
position: relative;
margin-top: 15rem;
@@ -91,7 +91,7 @@ onUnmounted(() => {
margin-top: 50rem;
.progress {
bottom: calc(100% + 20rem);
bottom: calc(100% + 25rem);
}
}

View File

@@ -193,16 +193,21 @@ export const useBaseStore = defineStore('base', {
let configStr: string = await localforage.getItem(SaveDict.key)
// console.log(configStr)
// console.log('s', new Blob([configStr]).size)
// configStr = ''
configStr = ''
if (configStr) {
let data = JSON.parse(configStr)
let state: BaseState = data.val
let version = Number(data.version)
// console.log('state', state)
state.load = false
if (data.version === SaveDict.version) {
if (version === SaveDict.version) {
this.setState(state)
} else {
this.setState(state)
if (version === 2) {
}
// this.setState(state)
}
}
} catch (e) {

View File

@@ -148,7 +148,7 @@ export const ShortcutKeyMap = {
export const SaveDict = {
key: 'typing-word-dict',
version: 2
version: 3
}
export const SaveConfig = {
key: 'typing-word-config',