Initial commit
This commit is contained in:
commit
6e104cc08f
263
.gitignore
vendored
Normal file
263
.gitignore
vendored
Normal file
@ -0,0 +1,263 @@
|
||||
main.pdf
|
||||
ustcthesis-doc.pdf
|
||||
*.hd
|
||||
|
||||
## test files:
|
||||
build/
|
||||
test/**/*.pdf
|
||||
|
||||
## Core latex/pdflatex auxiliary files:
|
||||
*.aux
|
||||
*.lof
|
||||
*.log
|
||||
*.lot
|
||||
*.fls
|
||||
*.out
|
||||
*.toc
|
||||
*.fmt
|
||||
*.fot
|
||||
*.cb
|
||||
*.cb2
|
||||
.*.lb
|
||||
|
||||
## Intermediate documents:
|
||||
*.dvi
|
||||
*.xdv
|
||||
*-converted-to.*
|
||||
# these rules might exclude image files for figures etc.
|
||||
# *.ps
|
||||
# *.eps
|
||||
# *.pdf
|
||||
|
||||
## Generated if empty string is given at "Please type another file name for output:"
|
||||
.pdf
|
||||
|
||||
## Bibliography auxiliary files (bibtex/biblatex/biber):
|
||||
*.bbl
|
||||
*.bcf
|
||||
*.blg
|
||||
*-blx.aux
|
||||
*-blx.bib
|
||||
*.run.xml
|
||||
|
||||
## Build tool auxiliary files:
|
||||
*.fdb_latexmk
|
||||
*.synctex
|
||||
*.synctex(busy)
|
||||
*.synctex.gz
|
||||
*.synctex.gz(busy)
|
||||
*.pdfsync
|
||||
|
||||
## Build tool directories for auxiliary files
|
||||
# latexrun
|
||||
latex.out/
|
||||
|
||||
## Auxiliary and intermediate files from other packages:
|
||||
# algorithms
|
||||
*.alg
|
||||
*.loa
|
||||
|
||||
# achemso
|
||||
acs-*.bib
|
||||
|
||||
# amsthm
|
||||
*.thm
|
||||
|
||||
# beamer
|
||||
*.nav
|
||||
*.pre
|
||||
*.snm
|
||||
*.vrb
|
||||
|
||||
# changes
|
||||
*.soc
|
||||
|
||||
# comment
|
||||
*.cut
|
||||
|
||||
# cprotect
|
||||
*.cpt
|
||||
|
||||
# elsarticle (documentclass of Elsevier journals)
|
||||
*.spl
|
||||
|
||||
# endnotes
|
||||
*.ent
|
||||
|
||||
# fixme
|
||||
*.lox
|
||||
|
||||
# feynmf/feynmp
|
||||
*.mf
|
||||
*.mp
|
||||
*.t[1-9]
|
||||
*.t[1-9][0-9]
|
||||
*.tfm
|
||||
|
||||
#(r)(e)ledmac/(r)(e)ledpar
|
||||
*.end
|
||||
*.?end
|
||||
*.[1-9]
|
||||
*.[1-9][0-9]
|
||||
*.[1-9][0-9][0-9]
|
||||
*.[1-9]R
|
||||
*.[1-9][0-9]R
|
||||
*.[1-9][0-9][0-9]R
|
||||
*.eledsec[1-9]
|
||||
*.eledsec[1-9]R
|
||||
*.eledsec[1-9][0-9]
|
||||
*.eledsec[1-9][0-9]R
|
||||
*.eledsec[1-9][0-9][0-9]
|
||||
*.eledsec[1-9][0-9][0-9]R
|
||||
|
||||
# glossaries
|
||||
*.acn
|
||||
*.acr
|
||||
*.glg
|
||||
*.glo
|
||||
*.gls
|
||||
*.glsdefs
|
||||
|
||||
# gnuplottex
|
||||
*-gnuplottex-*
|
||||
|
||||
# gregoriotex
|
||||
*.gaux
|
||||
*.gtex
|
||||
|
||||
# htlatex
|
||||
*.4ct
|
||||
*.4tc
|
||||
*.idv
|
||||
*.lg
|
||||
*.trc
|
||||
*.xref
|
||||
|
||||
# hyperref
|
||||
*.brf
|
||||
|
||||
# knitr
|
||||
*-concordance.tex
|
||||
# TODO Comment the next line if you want to keep your tikz graphics files
|
||||
*.tikz
|
||||
*-tikzDictionary
|
||||
|
||||
# listings
|
||||
*.lol
|
||||
|
||||
# makeidx
|
||||
*.idx
|
||||
*.ilg
|
||||
*.ind
|
||||
*.ist
|
||||
|
||||
# minitoc
|
||||
*.maf
|
||||
*.mlf
|
||||
*.mlt
|
||||
*.mtc[0-9]*
|
||||
*.slf[0-9]*
|
||||
*.slt[0-9]*
|
||||
*.stc[0-9]*
|
||||
|
||||
# minted
|
||||
_minted*
|
||||
*.pyg
|
||||
|
||||
# morewrites
|
||||
*.mw
|
||||
|
||||
# nomencl
|
||||
*.nlg
|
||||
*.nlo
|
||||
*.nls
|
||||
|
||||
# pax
|
||||
*.pax
|
||||
|
||||
# pdfpcnotes
|
||||
*.pdfpc
|
||||
|
||||
# sagetex
|
||||
*.sagetex.sage
|
||||
*.sagetex.py
|
||||
*.sagetex.scmd
|
||||
|
||||
# scrwfile
|
||||
*.wrt
|
||||
|
||||
# sympy
|
||||
*.sout
|
||||
*.sympy
|
||||
sympy-plots-for-*.tex/
|
||||
|
||||
# pdfcomment
|
||||
*.upa
|
||||
*.upb
|
||||
|
||||
# pythontex
|
||||
*.pytxcode
|
||||
pythontex-files-*/
|
||||
|
||||
# tcolorbox
|
||||
*.listing
|
||||
|
||||
# thmtools
|
||||
*.loe
|
||||
|
||||
# TikZ & PGF
|
||||
*.dpth
|
||||
*.md5
|
||||
*.auxlock
|
||||
|
||||
# todonotes
|
||||
*.tdo
|
||||
|
||||
# easy-todo
|
||||
*.lod
|
||||
|
||||
# xcolor
|
||||
*.xcp
|
||||
|
||||
# xmpincl
|
||||
*.xmpi
|
||||
|
||||
# xindy
|
||||
*.xdy
|
||||
|
||||
# xypic precompiled matrices
|
||||
*.xyc
|
||||
|
||||
# endfloat
|
||||
*.ttt
|
||||
*.fff
|
||||
|
||||
# Latexian
|
||||
TSWLatexianTemp*
|
||||
|
||||
## Editors:
|
||||
# WinEdt
|
||||
*.bak
|
||||
*.sav
|
||||
|
||||
# Texpad
|
||||
.texpadtmp
|
||||
|
||||
# LyX
|
||||
*.lyx~
|
||||
|
||||
# Kile
|
||||
*.backup
|
||||
|
||||
# KBibTeX
|
||||
*~[0-9]*
|
||||
|
||||
# auto folder when using emacs and auctex
|
||||
./auto/*
|
||||
*.el
|
||||
|
||||
# expex forward references with \gathertags
|
||||
*-tags.tex
|
||||
|
||||
# standalone packages
|
||||
*.sta
|
45
.vscode/settings.json
vendored
Normal file
45
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"latex-workshop.intellisense.unimathsymbols.enabled": true,
|
||||
"latex-workshop.latex.recipes": [
|
||||
{
|
||||
"name": "latexmk (xelatex)",
|
||||
"tools": [
|
||||
"xelatexmk"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "latexmk (lualatex)",
|
||||
"tools": [
|
||||
"lualatexmk"
|
||||
]
|
||||
}
|
||||
],
|
||||
"latex-workshop.latex.tools": [
|
||||
{
|
||||
"name": "xelatexmk",
|
||||
"command": "latexmk",
|
||||
"args": [
|
||||
"-synctex=1",
|
||||
"-interaction=nonstopmode",
|
||||
"-file-line-error",
|
||||
"-xelatex",
|
||||
"-outdir=%OUTDIR%",
|
||||
"%DOC%"
|
||||
],
|
||||
"env": {}
|
||||
},
|
||||
{
|
||||
"name": "lualatexmk",
|
||||
"command": "latexmk",
|
||||
"args": [
|
||||
"-synctex=1",
|
||||
"-interaction=nonstopmode",
|
||||
"-file-line-error",
|
||||
"-lualatex",
|
||||
"-outdir=%OUTDIR%",
|
||||
"%DOC%"
|
||||
],
|
||||
"env": {}
|
||||
},
|
||||
]
|
||||
}
|
5
README.md
Normal file
5
README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# 合肥市第八中学 LaTeX 论文模板
|
||||
|
||||
Fork from [ustcthesis](https://github.com/ustctug/ustcthesis).
|
||||
|
||||
本项目是合肥市第八中学论文 LaTeX 模板 ustcthesis,按照 《研究生学位论文撰写手册》(最近在修订中) 和 《中国科学技术大学本科毕业论文(设计)格式》 的要求编写,兼容最新版的 TeX Live、MacTeX 、MiKTeX 发行版,支持跨平台使用。
|
9
chapters/acknowledgements.tex
Normal file
9
chapters/acknowledgements.tex
Normal file
@ -0,0 +1,9 @@
|
||||
% !TeX root = ../main.tex
|
||||
|
||||
\begin{acknowledgements}
|
||||
在研究性学习期间,我们有幸得到了户雨老师的教导。户老师不仅耐心地为我指出课题立项中的不足之处,还对课题研究报告提出宝贵的建议,她在整个过程中都给予了我充分的帮助和支持。
|
||||
|
||||
感谢董子豪同学,他参与了项目的测试与文字稿的编写工作,还在学校给予了我诸多建议,可以说在本项目中董子豪同学起到了“一个顶俩”的重要作用。
|
||||
|
||||
感谢开源软件及自由软件运动,本项目为开源软件,更是基于开源软件。本人深受自由软件运动精神感召,没有开源软件就没有现在的互联网,现代生活的一切可能都会完全不存在了,在此特感谢开源社区中无私奉献的开发者。
|
||||
\end{acknowledgements}
|
36
chapters/deploy.tex
Normal file
36
chapters/deploy.tex
Normal file
@ -0,0 +1,36 @@
|
||||
\chapter{部署}
|
||||
|
||||
\section{Clone(克隆)Git 仓库}
|
||||
|
||||
使用 git clone 命令,如下:
|
||||
|
||||
\lstset{language = bash, style = lgeneral}
|
||||
|
||||
\begin{lstlisting}
|
||||
$ git clone https://git.thehrz.net/thehrz/yigedinglia.git && cd yigedinglia
|
||||
\end{lstlisting}
|
||||
|
||||
由于于网络原因,此步骤可能十分缓慢或失败。
|
||||
|
||||
\section{Docker Compose 部署}
|
||||
|
||||
\lstset{language = bash, style = lgeneral}
|
||||
|
||||
\begin{lstlisting}
|
||||
$ docker compose up --build -d
|
||||
\end{lstlisting}
|
||||
|
||||
由于于网络原因,此步骤可能十分缓慢或失败。
|
||||
|
||||
\section{测试服务器}
|
||||
|
||||
本项目也提供一个测试服务器,包含所有功能,欢迎使用。由于部署于中国香港,在中国大陆访问响应时间较长。如图 \ref{fig:ping}。
|
||||
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=8cm]{ping.png}
|
||||
\caption{}
|
||||
\label{fig:ping}
|
||||
\end{figure}
|
||||
|
||||
地址: \href{https://yigedinglia.thehrz.net/}{https://yigedinglia.thehrz.net/}
|
60
chapters/frontend.tex
Normal file
60
chapters/frontend.tex
Normal file
@ -0,0 +1,60 @@
|
||||
% !TeX root = ../main.tex
|
||||
|
||||
\chapter{前端展示}
|
||||
|
||||
\section{简介}
|
||||
|
||||
基于 TypeScript 的 Vite + Vue.js 3 项目,使用 Navie UI 组件库。
|
||||
|
||||
\section{路由列表}
|
||||
|
||||
\begin{itemize}
|
||||
\item /
|
||||
\item /idioms/solitaire
|
||||
\item /idioms/:idiom
|
||||
\item /data
|
||||
\end{itemize}
|
||||
|
||||
\section{主界面 / 查询界面}
|
||||
|
||||
主界面即成语成语界面,输入一个成语并选择,转到成语详细页面。如图\ref{fig:index-page}。
|
||||
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=13cm]{index-page.png}
|
||||
\caption{}
|
||||
\label{fig:index-page}
|
||||
\end{figure}
|
||||
|
||||
\subsection{成语输入}
|
||||
|
||||
支持自动补全。如图\ref{fig:index-input}。
|
||||
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=13cm]{index-input.png}
|
||||
\caption{}
|
||||
\label{fig:index-input}
|
||||
\end{figure}
|
||||
|
||||
\subsection{成语信息}
|
||||
|
||||
包含成语含义、出处、例句。如图\ref{fig:idiom-detail}。
|
||||
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=13cm]{idiom-detail.png}
|
||||
\caption{}
|
||||
\label{fig:idiom-detail}
|
||||
\end{figure}
|
||||
|
||||
\section{成语接龙}
|
||||
|
||||
输入一个成语或点击“随机”按钮,自动查询成语,展示接龙。如图\ref{fig:soliaire}。
|
||||
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=13cm]{soliaire.png}
|
||||
\caption{}
|
||||
\label{fig:soliaire}
|
||||
\end{figure}
|
52
chapters/intro.tex
Normal file
52
chapters/intro.tex
Normal file
@ -0,0 +1,52 @@
|
||||
% !TeX root = ../main.tex
|
||||
|
||||
\chapter{简介}
|
||||
|
||||
\section{研究背景}
|
||||
|
||||
部分高中生缺乏成语储量,语言表达能力弱,而传统记背成语方法缺乏枯燥,使得高中生反感成语。
|
||||
|
||||
我们意识到成语作为中国文化的精华之一,逐渐成为在我们身边却又被忽视的语言资源。
|
||||
|
||||
\section{研究目的}
|
||||
|
||||
为用户提供成语学习相关资源,提高效率,发挥个人主观能动性。
|
||||
|
||||
\section{研究意义}
|
||||
|
||||
成语是我国汉语词汇里浓墨重彩的一笔,本应用有利于增添成语学习的趣味性,激发使用者对文学和语言的兴趣,提升使用者对成语典故的理解和运用能力,使其通过成语了解和传承中华民族的民族心理、民族文化和历史走向。
|
||||
|
||||
整个研发过程让开发者的创造性思维得以展现,从分析研究成语的特点,到开发成语接龙的高效算法,我们注重思维的碰撞,小组成员进行了大量研究。同时,小组成员通过该项活动把日常学习生活中的所思所感融会贯通,展示了自己的想法和风格,实现了自我表达。
|
||||
|
||||
\section{关于“一个顶俩”}
|
||||
|
||||
我们选取“一个顶俩”作为项目名,有以下原因:
|
||||
|
||||
\begin{itemize}
|
||||
\item “一个顶俩”末拼音为“lia”,没有成语以“lia”为首拼音,即“一个顶俩”可以作为成语接龙的“终点”。
|
||||
\item “一个顶俩”十分具有震慑力而不失幽默,十分符合本项目组长的气质。
|
||||
\item “一个顶俩”意为“一个人做事有效果,一个人能代替两个人”,十分符合小组成员董子豪的能力。
|
||||
\end{itemize}
|
||||
|
||||
|
||||
\section{技术栈}
|
||||
|
||||
\subsection{后端}
|
||||
|
||||
基于 \href{https://go.dev/}{Golang},使用高性能Web框架Echo开发后端服务器。
|
||||
|
||||
基于 \href{https://github.com/hashicorp/go-memdb}{go-memdb} 内存数据库项目,我们能够将30895条成语数据在内存数据库中索引并高效查询。
|
||||
|
||||
\subsection{前端}
|
||||
|
||||
基于 \href{https://cn.vuejs.org/}{Vue.js 3} JavaScript 框架,使用TypeScript语言进行动态内容展示、用户交互体验、数据处理等操作。
|
||||
|
||||
基于 \href{https://www.naiveui.com/zh-CN/os-theme}{Naive UI} 前端框架,使用部分组件,提高开发效率,美化UI。
|
||||
|
||||
使用 \href{https://unocss.dev/}{UnoCSS} 原子化 CSS 框架,便于样式调整,提升代码可读性与开发效率。
|
||||
|
||||
使用 \href{https://cn.vitejs.dev/}{Vite 5} 构建项目,打包前端代码。
|
||||
|
||||
\subsection{部署}
|
||||
|
||||
基于 \href{https://www.docker.com/}{Docker} 容器化技术,构建前端与后端项目的镜像后,使用 \href{https://github.com/docker/compose}{Docker Compose} 技术管理容器并部署。
|
224
chapters/process.tex
Normal file
224
chapters/process.tex
Normal file
@ -0,0 +1,224 @@
|
||||
% !TeX root = ../main.tex
|
||||
|
||||
\lstdefinestyle{lfonts}{
|
||||
basicstyle = \scriptsize\ttfamily,
|
||||
stringstyle = \color{purple},
|
||||
keywordstyle = \color{blue!60!black}\bfseries,
|
||||
commentstyle = \color{olive}\scshape,
|
||||
}
|
||||
\lstdefinestyle{lnumbers}{
|
||||
numbers = left,
|
||||
numberstyle = \tiny,
|
||||
numbersep = 1em,
|
||||
firstnumber = 1,
|
||||
stepnumber = 1,
|
||||
}
|
||||
\lstdefinestyle{llayout}{
|
||||
breaklines = true,
|
||||
tabsize = 2,
|
||||
% columns = spacefixed,
|
||||
}
|
||||
\lstdefinestyle{lgeometry}{
|
||||
xleftmargin = 20pt,
|
||||
xrightmargin = 0pt,
|
||||
frame = tb,
|
||||
framesep = \fboxsep,
|
||||
framexleftmargin = 20pt,
|
||||
}
|
||||
|
||||
\lstdefinestyle{lgeneral}{
|
||||
style = lfonts,
|
||||
style = lnumbers,
|
||||
style = llayout,
|
||||
style = lgeometry,
|
||||
}
|
||||
|
||||
\lstdefinelanguage{JavaScript}{
|
||||
keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break, import, const, from},
|
||||
keywordstyle=\color{blue}\bfseries,
|
||||
ndkeywords={class, export, boolean, throw, implements, import, this},
|
||||
ndkeywordstyle=\color{darkgray}\bfseries,
|
||||
identifierstyle=\color{black},
|
||||
sensitive=false,
|
||||
comment=[l]{//},
|
||||
morecomment=[s]{/*}{*/},
|
||||
commentstyle=\color{purple}\ttfamily,
|
||||
stringstyle=\color{red}\ttfamily,
|
||||
morestring=[b]',
|
||||
morestring=[b]"
|
||||
}
|
||||
|
||||
|
||||
\chapter{成语接龙算法流程}
|
||||
|
||||
\section{成语词库}
|
||||
|
||||
我们站在巨人的肩膀上,前人已经收集了足够的成语词库。成语词库来源于 \href{https://github.com/pwxcoo/chinese-xinhua}{chinese-xinhua},此项目以 MIT 协议开源。
|
||||
|
||||
以下是其中一个成语的数据结构:
|
||||
|
||||
\lstset{language = JavaScript, style = lgeneral}
|
||||
|
||||
\begin{lstlisting}
|
||||
{
|
||||
"derivation": "语出《法华经·法师功德品》下至阿鼻地狱。”",
|
||||
"example": "但也有少数意志薄弱的……逐步上当,终至堕入~。★《上饶集中营·炼狱杂记》",
|
||||
"explanation": "阿鼻梵语的译音,意译为无间”,即痛苦无有间断之意。常用来比喻黑暗的社会和严酷的牢狱。又比喻无法摆脱的极其痛苦的境地。",
|
||||
"pinyin": "ā bí dì yù",
|
||||
"word": "阿鼻地狱",
|
||||
"abbreviation": "abdy",
|
||||
"id": 0
|
||||
},
|
||||
\end{lstlisting}
|
||||
|
||||
经统计,共收录了 30895 个成语,但其中还包括了非四字成语。我们使用如下 JavaScript 代码剔除:
|
||||
|
||||
\lstset{language = JavaScript, style = lgeneral}
|
||||
|
||||
\begin{lstlisting}
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import idioms from './idiom.json' assert { type: 'json' }
|
||||
|
||||
const new_idioms = idioms.filter(value => value.word.length === 4)
|
||||
|
||||
console.log(new_idioms.length)
|
||||
|
||||
const idioms_json = JSON.stringify(new_idioms)
|
||||
|
||||
fs.writeFile('./four_letter_idioms.json', idioms_json, (err) => {
|
||||
if (err)
|
||||
throw err
|
||||
})
|
||||
\end{lstlisting}
|
||||
|
||||
\section{后端}
|
||||
|
||||
\subsection{索引}
|
||||
为便于查询成语,首先为每个成语以其首拼音和末拼音索引。
|
||||
|
||||
再采用递推法,以成语“一个顶俩”的“yi”为初始值,遍历末拼音为“yi”的成语,以第一次循环为“第一层”,为每个成语添加层级属性。
|
||||
|
||||
以下为核心代码:
|
||||
|
||||
\lstset{language = Go, style = lgeneral}
|
||||
|
||||
\begin{lstlisting}
|
||||
func initIdiomsDB() {
|
||||
lastPinyins := mapset.NewSet[string]()
|
||||
|
||||
lastPinyins.Add("yi") // 初始化,以“yi”为起点递推
|
||||
|
||||
level := 1
|
||||
for lastPinyins.Cardinality() > 0 { // 直到无需要遍历的拼音结束循环
|
||||
firstPinyins := mapset.NewSet[string]()
|
||||
|
||||
for pinyin := range lastPinyins.Iter() {
|
||||
err := func() error {
|
||||
txn := IdiomsDB.Txn(true)
|
||||
defer txn.Abort()
|
||||
|
||||
result, err := txn.Get("lastPinyin", "pinyin", pinyin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for item := result.Next(); item != nil; item = result.Next() {
|
||||
lastPinyin := item.(*models.LastPinyin)
|
||||
if lastPinyin != nil && level > 0 {
|
||||
if lastPinyin.Idiom.Level == 0 {
|
||||
lastPinyin.Idiom.Level = level
|
||||
err := txn.Insert("idioms", lastPinyin.Idiom)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
firstPinyins.Add(utils.GetFirstPinyin(lastPinyin.Idiom.Pinyin))
|
||||
}
|
||||
}
|
||||
}
|
||||
txn.Commit()
|
||||
return nil
|
||||
}()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
lastPinyins = firstPinyins // 以在下一次循环查询成语
|
||||
level++
|
||||
}
|
||||
}
|
||||
\end{lstlisting}
|
||||
|
||||
本算法实际上是递推思想的应用。算法前期对成语索引,为每个成语添加Level属性,以便于之后的正向查询成语接龙。
|
||||
|
||||
以下为流程图:
|
||||
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=12cm]{index.pdf}
|
||||
\caption{}
|
||||
\label{fig:index}
|
||||
\end{figure}
|
||||
|
||||
\subsection{遍历查询}
|
||||
|
||||
得到这些成语后再分别遍历以每个成语首拼音为末拼音的成语。
|
||||
|
||||
以下为核心代码:
|
||||
\lstset{language = Go, style = lgeneral}
|
||||
|
||||
\begin{lstlisting}
|
||||
func Solitaire(c echo.Context) error {
|
||||
var r *solitaireRequest
|
||||
err := c.Bind(&r)
|
||||
if err != nil {
|
||||
return c.String(http.StatusBadRequest, "")
|
||||
}
|
||||
idiom, err := db.GetIdiom(r.Word)
|
||||
if err != nil {
|
||||
return c.String(http.StatusBadRequest, "")
|
||||
}
|
||||
|
||||
idioms := linkedhashset.New()
|
||||
|
||||
for idiom != nil {
|
||||
idioms.Add(idiom)
|
||||
level := idiom.Level
|
||||
if level > 1 {
|
||||
pinyinIdioms, err := db.GetFirstPinyinIdioms(utils.GetLastPinyin(idiom.Pinyin))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
filtered := utils.Filter(pinyinIdioms, func(i *models.Idiom) bool {
|
||||
return i.Level < idiom.Level
|
||||
}) // 检出比当前成语低Level的成语
|
||||
idiom = utils.RandomItem(filtered) // 成语可能不止一个,随机取一个
|
||||
} else if utils.GetLastPinyin(idiom.Pinyin) == "yi" {
|
||||
idioms.Add(&models.Idiom{ // 遍历结束,加一个顶俩
|
||||
Data: models.Data{
|
||||
Id: 29502,
|
||||
Derivation: "无",
|
||||
Example: "董同学在项目中起到了~的效果。",
|
||||
Explanation: "形容一个人做事有效果,一个人能代替两个人。",
|
||||
Pinyin: "yī gè dǐng liǎ",
|
||||
Word: "一个顶俩",
|
||||
Abbreviation: "无",
|
||||
},
|
||||
})
|
||||
break
|
||||
} else {
|
||||
return c.String(http.StatusNoContent, "") // 找不到成语
|
||||
}
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, idioms) // 成功,输出
|
||||
}
|
||||
\end{lstlisting}
|
||||
|
||||
经过测试,循环遍历5次后需要遍历的成语列表为空,即最多4个成语就能到达“一个顶俩”这一成语。
|
||||
|
||||
每个成语的Level属性接龙到成语“一个顶俩”的“距离”。
|
||||
|
||||
在得到目标成语后,只需查询首拼音与该成语末拼音相同的成语中比该成语层级属性更低的成语,就能保证查询的方向是在步步逼近成语“一个顶俩”。
|
32
chapters/test.tex
Normal file
32
chapters/test.tex
Normal file
@ -0,0 +1,32 @@
|
||||
\chapter{基准测试}
|
||||
|
||||
\section{Go Test}
|
||||
|
||||
我们使用 Go Test 工具对成语接龙算法进行基准测试,结果如下:
|
||||
|
||||
\lstset{language = Bash, style = lgeneral}
|
||||
|
||||
\begin{lstlisting}
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: yigedinglia-backend
|
||||
cpu: 13th Gen Intel(R) Core(TM) i5-13400F
|
||||
BenchmarkSolitaire
|
||||
BenchmarkSolitaire-16 114219 8939 ns/op
|
||||
PASS
|
||||
\end{lstlisting}
|
||||
|
||||
结果十分喜人,代表在最理想情况下,一次接龙操作耗时 8939 ns。
|
||||
|
||||
\section{Postman}
|
||||
|
||||
实际的生产环境不总是最理想的,以下为 Postman 的压力测试报告:
|
||||
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=12cm]{postman.pdf}
|
||||
\caption{}
|
||||
\label{fig:postman}
|
||||
\end{figure}
|
||||
|
||||
报告显示,每秒能处理20.16个请求,平均每个请求耗时3ms。
|
1676
figures/hfbz-icon.pdf
Executable file
1676
figures/hfbz-icon.pdf
Executable file
File diff suppressed because one or more lines are too long
BIN
figures/idiom-detail.png
Normal file
BIN
figures/idiom-detail.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 165 KiB |
BIN
figures/index-input.png
Normal file
BIN
figures/index-input.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 125 KiB |
BIN
figures/index-page.png
Normal file
BIN
figures/index-page.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 110 KiB |
BIN
figures/index.pdf
Normal file
BIN
figures/index.pdf
Normal file
Binary file not shown.
BIN
figures/logo-left.png
Executable file
BIN
figures/logo-left.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
BIN
figures/ping.png
Normal file
BIN
figures/ping.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 63 KiB |
BIN
figures/postman.pdf
Normal file
BIN
figures/postman.pdf
Normal file
Binary file not shown.
BIN
figures/soliaire.png
Normal file
BIN
figures/soliaire.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 128 KiB |
17
main.tex
Normal file
17
main.tex
Normal file
@ -0,0 +1,17 @@
|
||||
\documentclass{thesis}
|
||||
\input{setup.tex}
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
\tableofcontents
|
||||
|
||||
\mainmatter
|
||||
\input{chapters/intro.tex}
|
||||
\input{chapters/process.tex}
|
||||
\input{chapters/frontend.tex}
|
||||
\input{chapters/deploy.tex}
|
||||
\input{chapters/test.tex}
|
||||
|
||||
\backmatter
|
||||
\input{chapters/acknowledgements.tex}
|
||||
\end{document}
|
85
setup.tex
Normal file
85
setup.tex
Normal file
@ -0,0 +1,85 @@
|
||||
% !TeX root = ./main.tex
|
||||
|
||||
\ustcsetup{
|
||||
title = {“一个顶俩”——基于Golang+Vue3的成语学习Web应用},
|
||||
class = {高一(12)班},
|
||||
author = {何锐哲\ 董子豪},
|
||||
supervisor = {户雨},
|
||||
date = {2024-03-01},
|
||||
math-font = xits,
|
||||
}
|
||||
|
||||
% 加载宏包
|
||||
\usepackage{float}
|
||||
|
||||
\usepackage{xcolor}
|
||||
|
||||
\usepackage{listings}
|
||||
|
||||
\usepackage{markdown}
|
||||
|
||||
|
||||
% 定理类环境宏包
|
||||
\usepackage{amsthm}
|
||||
|
||||
% 插图
|
||||
\usepackage{graphicx}
|
||||
|
||||
% 三线表
|
||||
\usepackage{booktabs}
|
||||
|
||||
% 跨页表格
|
||||
\usepackage{longtable}
|
||||
|
||||
% 算法
|
||||
\usepackage[ruled,linesnumbered]{algorithm2e}
|
||||
|
||||
% SI 量和单位
|
||||
\usepackage{siunitx}
|
||||
|
||||
% 参考文献使用 BibTeX + natbib 宏包
|
||||
% 顺序编码制
|
||||
\usepackage[sort]{natbib}
|
||||
\bibliographystyle{ustcthesis-numerical}
|
||||
|
||||
% 著者-出版年制
|
||||
% \usepackage{natbib}
|
||||
% \bibliographystyle{ustcthesis-authoryear}
|
||||
|
||||
% 本科生参考文献的著录格式
|
||||
% \usepackage[sort]{natbib}
|
||||
% \bibliographystyle{ustcthesis-bachelor}
|
||||
|
||||
% 参考文献使用 BibLaTeX 宏包
|
||||
% \usepackage[style=ustcthesis-numeric]{biblatex}
|
||||
% \usepackage[bibstyle=ustcthesis-numeric,citestyle=ustcthesis-inline]{biblatex}
|
||||
% \usepackage[style=ustcthesis-authoryear]{biblatex}
|
||||
% \usepackage[style=ustcthesis-bachelor]{biblatex}
|
||||
% 声明 BibLaTeX 的数据库
|
||||
% \addbibresource{bib/ustc.bib}
|
||||
|
||||
% 配置图片的默认目录
|
||||
\graphicspath{{figures/}}
|
||||
|
||||
% 数学命令
|
||||
\makeatletter
|
||||
\newcommand\dif{% % 微分符号
|
||||
\mathop{}\!%
|
||||
\ifustc@math@style@TeX
|
||||
d%
|
||||
\else
|
||||
\mathrm{d}%
|
||||
\fi
|
||||
}
|
||||
\makeatother
|
||||
\newcommand\eu{{\symup{e}}}
|
||||
\newcommand\iu{{\symup{i}}}
|
||||
|
||||
% 用于写文档的命令
|
||||
\DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}}
|
||||
\DeclareRobustCommand\env[1]{\texttt{#1}}
|
||||
\DeclareRobustCommand\pkg[1]{\textsf{#1}}
|
||||
\DeclareRobustCommand\file[1]{\nolinkurl{#1}}
|
||||
|
||||
% hyperref 宏包在最后调用
|
||||
\usepackage{hyperref}
|
3144
thesis.cls
Normal file
3144
thesis.cls
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user