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应用程序部署到生产环境之前,需要进行的准备工作和最佳实践,包括心态调整、代码审查、测试覆盖率提升、配置文件优化、日志记录完... 目录部署前夜:从开发到生产的心理准备与检查清单环境搭建:打造稳固的应用运行平台自动化流水线:让部署像

Linux中Curl参数详解实践应用

《Linux中Curl参数详解实践应用》在现代网络开发和运维工作中,curl命令是一个不可或缺的工具,它是一个利用URL语法在命令行下工作的文件传输工具,支持多种协议,如HTTP、HTTPS、FTP等... 目录引言一、基础请求参数1. -X 或 --request2. -d 或 --data3. -H 或

在Ubuntu上部署SpringBoot应用的操作步骤

《在Ubuntu上部署SpringBoot应用的操作步骤》随着云计算和容器化技术的普及,Linux服务器已成为部署Web应用程序的主流平台之一,Java作为一种跨平台的编程语言,具有广泛的应用场景,本... 目录一、部署准备二、安装 Java 环境1. 安装 JDK2. 验证 Java 安装三、安装 mys

Python中构建终端应用界面利器Blessed模块的使用

《Python中构建终端应用界面利器Blessed模块的使用》Blessed库作为一个轻量级且功能强大的解决方案,开始在开发者中赢得口碑,今天,我们就一起来探索一下它是如何让终端UI开发变得轻松而高... 目录一、安装与配置:简单、快速、无障碍二、基本功能:从彩色文本到动态交互1. 显示基本内容2. 创建链

Node.js 中 http 模块的深度剖析与实战应用小结

《Node.js中http模块的深度剖析与实战应用小结》本文详细介绍了Node.js中的http模块,从创建HTTP服务器、处理请求与响应,到获取请求参数,每个环节都通过代码示例进行解析,旨在帮... 目录Node.js 中 http 模块的深度剖析与实战应用一、引言二、创建 HTTP 服务器:基石搭建(一

java中VO PO DTO POJO BO DO对象的应用场景及使用方式

《java中VOPODTOPOJOBODO对象的应用场景及使用方式》文章介绍了Java开发中常用的几种对象类型及其应用场景,包括VO、PO、DTO、POJO、BO和DO等,并通过示例说明了它... 目录Java中VO PO DTO POJO BO DO对象的应用VO (View Object) - 视图对象

Go信号处理如何优雅地关闭你的应用

《Go信号处理如何优雅地关闭你的应用》Go中的优雅关闭机制使得在应用程序接收到终止信号时,能够进行平滑的资源清理,通过使用context来管理goroutine的生命周期,结合signal... 目录1. 什么是信号处理?2. 如何优雅地关闭 Go 应用?3. 代码实现3.1 基本的信号捕获和优雅关闭3.2

正则表达式高级应用与性能优化记录

《正则表达式高级应用与性能优化记录》本文介绍了正则表达式的高级应用和性能优化技巧,包括文本拆分、合并、XML/HTML解析、数据分析、以及性能优化方法,通过这些技巧,可以更高效地利用正则表达式进行复杂... 目录第6章:正则表达式的高级应用6.1 模式匹配与文本处理6.1.1 文本拆分6.1.2 文本合并6

python中的与时间相关的模块应用场景分析

《python中的与时间相关的模块应用场景分析》本文介绍了Python中与时间相关的几个重要模块:`time`、`datetime`、`calendar`、`timeit`、`pytz`和`dateu... 目录1. time 模块2. datetime 模块3. calendar 模块4. timeit

HarmonyOS学习(七)——UI(五)常用布局总结

自适应布局 1.1、线性布局(LinearLayout) 通过线性容器Row和Column实现线性布局。Column容器内的子组件按照垂直方向排列,Row组件中的子组件按照水平方向排列。 属性说明space通过space参数设置主轴上子组件的间距,达到各子组件在排列上的等间距效果alignItems设置子组件在交叉轴上的对齐方式,且在各类尺寸屏幕上表现一致,其中交叉轴为垂直时,取值为Vert