W801学习笔记二十一:英语背单词学习应用——上

2024-05-08 03:36

本文主要是介绍W801学习笔记二十一:英语背单词学习应用——上,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

英语背单词是比较常见的学习APP,参考唐诗宋词应用,本章做一个类似的应用。

一、单词数据清洗及格式转换

        诗词数据的获取渠道很多,一般可以按照年级来分文件。如一到九年级,四六级,雅思等等。

       1、先从网上某某地方下载单词数据。包含英文,中文,音标。

       2、相对唐诗数据,这回我们做复杂一点。包含一个文件头:

文件描述用ENGDC表示 

3、同样方法,也可以整理短语数据。

短语不需要音标,且英文部分比较长,所以直接把英语部分扩为32字节

 

 文件描述用ENGCZ表示

 

4、这样,可以通过宏定位数据位置了

#define dataDC(idx) ((const char*)DataBuff+((idx) * 128) + 64)
#define dataZY(idx) ((const char*)DataBuff+((idx) * 128) + 96)
#define dataCN(idx) ((const char*)DataBuff+((idx) * 128) + 128)

二、增加菜单项

[{"t": "三分钟限时挑战","i": "-","d": 0,"g": {},"s": [{"t": "语文","i": "menu/yuwen.png","d": 0,"g": {},"s": [{"t": "唐诗三百首","i": "-","d": 302,"g": {"w":1, "m":1},"s": []},{"t": "宋词三百首","i": "-","d": 302,"g": {"w":1, "m":2},"s": []}]},{"t": "英语","i": "menu/eng.png","d": 0,"g": {},"s": [{"t": "根据拼写猜词意","i": "-","d": 301,"g": {"w":1, "m":1, "f":"project/english8danci.txt"},"s": []},{"t": "根据词义猜拼写","i": "-","d": 301,"g": {"w":1, "m":2, "f":"project/english8danci.txt"},"s": []},{"t": "猜拼写完全正确","i": "-","d": 301,"g": {"w":1, "m":3, "f":"project/english8danci.txt"},"s": []},{"t": "猜短语意思","i": "-","d": 301,"g": {"w":1, "m":4, "f":"project/english8cizu.txt"},"s": []},{"t": "猜短语拼写","i": "-","d": 301,"g": {"w":1, "m":5, "f":"project/english8cizu.txt"},"s": []}]}]},{"t": "五十题竞速挑战","i": "-","d": 0,"g": {},"s": [{"t": "语文","i": "menu/yuwen.png","d": 0,"g": {},"s": [{"t": "唐诗三百首","i": "-","d": 302,"g": {"w":2, "m":1},"s": []},{"t": "宋词三百首","i": "-","d": 302,"g": {"w":2, "m":2},"s": []}]},{"t": "英语","i": "menu/eng.png","d": 0,"g": {},"s": [{"t": "根据拼写猜词意","i": "-","d": 301,"g": {"w":2, "m":1, "f":"project/english8danci.txt"},"s": []},{"t": "根据词义猜拼写","i": "-","d": 301,"g": {"w":2, "m":2, "f":"project/english8danci.txt"},"s": []},{"t": "猜拼写完全正确","i": "-","d": 301,"g": {"w":2, "m":3, "f":"project/english8danci.txt"},"s": []},{"t": "猜短语意思","i": "-","d": 301,"g": {"w":2, "m":4, "f":"project/english8cizu.txt"},"s": []},{"t": "猜短语拼写","i": "-","d": 301,"g": {"w":2, "m":5, "f":"project/english8cizu.txt"},"s": []}]}]},{"t": "零错误闯关挑战","i": "-","d": 0,"g": {},"s": [{"t": "语文","i": "menu/yuwen.png","d": 0,"g": {},"s": [{"t": "唐诗三百首","i": "-","d": 302,"g": {"w":3, "m":1},"s": []},{"t": "宋词三百首","i": "-","d": 302,"g": {"w":3, "m":2},"s": []}]},{"t": "英语","i": "menu/eng.png","d": 0,"g": {},"s": [{"t": "根据拼写猜词意","i": "-","d": 301,"g": {"w":3, "m":1, "f":"project/english8danci.txt"},"s": []},{"t": "根据词义猜拼写","i": "-","d": 301,"g": {"w":3, "m":2, "f":"project/english8danci.txt"},"s": []},{"t": "猜拼写完全正确","i": "-","d": 301,"g": {"w":3, "m":3, "f":"project/english8danci.txt"},"s": []},{"t": "猜短语意思","i": "-","d": 301,"g": {"w":3, "m":4, "f":"project/english8cizu.txt"},"s": []},{"t": "猜短语拼写","i": "-","d": 301,"g": {"w":3, "m":5, "f":"project/english8cizu.txt"},"s": []}]}]},{"t": "关于","i": "menu/test16.png","d": 102,"g": {},"s": []}
]

直接在g属性下面添加一个f属性,表示对应的数据文件。

这里没有分年级,如果分的话,需要再添加一级菜单。

三、生成问题选项

通过菜单,可以看到计划做5种答题模式

        1、根据拼写猜词意

        2、根据词义猜拼写

        3、猜拼写完全正确

        4、猜短语意思

        5、猜短语拼写

其中第3种模式比较特殊。方法为:

        i。挑出两个字母,如 a b

        ii。四个选项分别为 ab Ab aB AB

上代码:

void YingYu::createQuestion()
{currentQuestion->question = ran_max(YingYuCount);currentQuestion->ans = ran_max(4);for(u8 i=0;i<4;i++){if(i == currentQuestion->ans){currentQuestion->answer[i] = currentQuestion->question;}else{currentQuestion->answer[i] = ran_max(YingYuCount);}}if(gameMode == 3){createQuestionMode3();}}void YingYu::createQuestionMode3()
{uint8_t i,e1,e2;char ne1,ne2;u8 len = strlen(dataDC(currentQuestion->question));for(i=0; i<4; i++) {memset(errEngWord[i], 0, 40);memcpy(errEngWord[i],  dataDC(currentQuestion->question), len);}e1 = ran_max(len);while(errEngWord[0][e1] < 97 || errEngWord[0][e1] > 122) {e1 = ran_max(len);}e2 = e1;while(e2 == e1 || errEngWord[0][e2] < 97 || errEngWord[0][e2] > 122) {e2 = ran_max(len);}ne1 = errEngWord[0][e1] - ran_max(25) -1;if(ne1 < 97) {ne1 =ne1 + 26;}ne2 = errEngWord[0][e2] - ran_max(25) -1;if(ne2 < 97) {ne2 =ne2 + 26;}errEngWord[(currentQuestion->ans + 1) % 4][e1] = ne1;errEngWord[(currentQuestion->ans + 2) % 4][e1] = ne1;errEngWord[(currentQuestion->ans + 2) % 4][e2] = ne2;errEngWord[(currentQuestion->ans + 3) % 4][e2] = ne2;}

四、显示问题选项

几种模式的显示内容是不一样的。需要分别处理

void YingYu::showQuetion()
{u8 i;for(i=0;i<4;i++)Display_Fill_Rectangle2(Eng_Answer_LOC_X, Eng_Answer_LOC_Y[i]-2, 440, 21 ,answerBGColor[i]);Display_Fill_Rectangle2(0,100, 480, 80, BLACK);printf("q=%d, a=%d, a1=%d, a2=%d, a3=%d, a4=%d\n",currentQuestion->question,currentQuestion->ans,currentQuestion->answer[0]
,currentQuestion->answer[1]
,currentQuestion->answer[2]
,currentQuestion->answer[3] );switch (gameMode) {case 1:Display_String(Eng_Quetion_LOC_A, &optionQuetion, dataDC(currentQuestion->question));Display_String2(Eng_Quetion_LOC_B, &optionZY, "[%s]", dataZY(currentQuestion->question));for(i=0;i<4;i++)Display_String2(Eng_Answer_LOC_X, Eng_Answer_LOC_Y[i], &optionAnswer[i], (const char *)answerTitle[i], dataCN(currentQuestion->answer[i]));break;case 2:Display_String(Eng_Quetion_LOC_A, &optionQuetion, dataCN(currentQuestion->question));Display_String2(Eng_Quetion_LOC_B, &optionZY, "[%s]", dataZY(currentQuestion->question));for(i=0;i<4;i++)Display_String2(Eng_Answer_LOC_X, Eng_Answer_LOC_Y[i], &optionAnswer[i], (const char *)answerTitle[i], dataDC(currentQuestion->answer[i]));break;case 3:Display_String(Eng_Quetion_LOC_A, &optionQuetion, dataCN(currentQuestion->question));Display_String2(Eng_Quetion_LOC_B, &optionZY, "[%s]", dataZY(currentQuestion->question));for(i=0;i<4;i++)Display_String2(Eng_Answer_LOC_X, Eng_Answer_LOC_Y[i], &optionAnswer[i], (const char *)answerTitle[i], errEngWord[i]);break;case 4:Display_String(Eng_Quetion_LOC_A, &optionQuetion, dataDC(currentQuestion->question));for(i=0;i<4;i++)Display_String2(Eng_Answer_LOC_X, Eng_Answer_LOC_Y[i], &optionAnswer[i], (const char *)answerTitle[i], dataCN(currentQuestion->answer[i]));break;case 5:Display_String(Eng_Quetion_LOC_A, &optionQuetion, dataCN(currentQuestion->question));for(i=0;i<4;i++)Display_String2(Eng_Answer_LOC_X, Eng_Answer_LOC_Y[i], &optionAnswer[i], (const char *)answerTitle[i], dataDC(currentQuestion->answer[i]));break;}
}

这篇关于W801学习笔记二十一:英语背单词学习应用——上的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/969196

相关文章

Python中随机休眠技术原理与应用详解

《Python中随机休眠技术原理与应用详解》在编程中,让程序暂停执行特定时间是常见需求,当需要引入不确定性时,随机休眠就成为关键技巧,下面我们就来看看Python中随机休眠技术的具体实现与应用吧... 目录引言一、实现原理与基础方法1.1 核心函数解析1.2 基础实现模板1.3 整数版实现二、典型应用场景2

Python Dash框架在数据可视化仪表板中的应用与实践记录

《PythonDash框架在数据可视化仪表板中的应用与实践记录》Python的PlotlyDash库提供了一种简便且强大的方式来构建和展示互动式数据仪表板,本篇文章将深入探讨如何使用Dash设计一... 目录python Dash框架在数据可视化仪表板中的应用与实践1. 什么是Plotly Dash?1.1

Android Kotlin 高阶函数详解及其在协程中的应用小结

《AndroidKotlin高阶函数详解及其在协程中的应用小结》高阶函数是Kotlin中的一个重要特性,它能够将函数作为一等公民(First-ClassCitizen),使得代码更加简洁、灵活和可... 目录1. 引言2. 什么是高阶函数?3. 高阶函数的基础用法3.1 传递函数作为参数3.2 Lambda

Java中&和&&以及|和||的区别、应用场景和代码示例

《Java中&和&&以及|和||的区别、应用场景和代码示例》:本文主要介绍Java中的逻辑运算符&、&&、|和||的区别,包括它们在布尔和整数类型上的应用,文中通过代码介绍的非常详细,需要的朋友可... 目录前言1. & 和 &&代码示例2. | 和 ||代码示例3. 为什么要使用 & 和 | 而不是总是使

Python循环缓冲区的应用详解

《Python循环缓冲区的应用详解》循环缓冲区是一个线性缓冲区,逻辑上被视为一个循环的结构,本文主要为大家介绍了Python中循环缓冲区的相关应用,有兴趣的小伙伴可以了解一下... 目录什么是循环缓冲区循环缓冲区的结构python中的循环缓冲区实现运行循环缓冲区循环缓冲区的优势应用案例Python中的实现库

SpringBoot整合MybatisPlus的基本应用指南

《SpringBoot整合MybatisPlus的基本应用指南》MyBatis-Plus,简称MP,是一个MyBatis的增强工具,在MyBatis的基础上只做增强不做改变,下面小编就来和大家介绍一下... 目录一、MyBATisPlus简介二、SpringBoot整合MybatisPlus1、创建数据库和

python中time模块的常用方法及应用详解

《python中time模块的常用方法及应用详解》在Python开发中,时间处理是绕不开的刚需场景,从性能计时到定时任务,从日志记录到数据同步,时间模块始终是开发者最得力的工具之一,本文将通过真实案例... 目录一、时间基石:time.time()典型场景:程序性能分析进阶技巧:结合上下文管理器实现自动计时

Java进阶学习之如何开启远程调式

《Java进阶学习之如何开启远程调式》Java开发中的远程调试是一项至关重要的技能,特别是在处理生产环境的问题或者协作开发时,:本文主要介绍Java进阶学习之如何开启远程调式的相关资料,需要的朋友... 目录概述Java远程调试的开启与底层原理开启Java远程调试底层原理JVM参数总结&nbsMbKKXJx

Java逻辑运算符之&&、|| 与&、 |的区别及应用

《Java逻辑运算符之&&、||与&、|的区别及应用》:本文主要介绍Java逻辑运算符之&&、||与&、|的区别及应用的相关资料,分别是&&、||与&、|,并探讨了它们在不同应用场景中... 目录前言一、基本概念与运算符介绍二、短路与与非短路与:&& 与 & 的区别1. &&:短路与(AND)2. &:非短

Spring AI集成DeepSeek三步搞定Java智能应用的详细过程

《SpringAI集成DeepSeek三步搞定Java智能应用的详细过程》本文介绍了如何使用SpringAI集成DeepSeek,一个国内顶尖的多模态大模型,SpringAI提供了一套统一的接口,简... 目录DeepSeek 介绍Spring AI 是什么?Spring AI 的主要功能包括1、环境准备2