作者:风情万种791008 | 来源:互联网 | 2023-02-05 09:06
Ihaveasimpleapplicationthataskstheuserforasearchterm,andthenperformsasearchfortha
I have a simple application that asks the user for a search term, and then performs a search for that term.
我有一个简单的应用程序,要求用户提供搜索词,然后搜索该词。
I want to give it the ability to "auto correct" the entered term. This is just for a few terms, that are easy to enter incorrectly. For example, if someone searches for "BestBuy", and what I have in my array to be searched is "Best Buy", I want to automatically convert "BestBuy" into "Best Buy" before the search. I intend to have a list of these in a text file.
我想让它能够“自动更正”输入的术语。这只是几个术语,很容易输入错误。例如,如果有人搜索“BestBuy”,并且我在我的阵列中搜索的是“Best Buy”,我想在搜索之前自动将“BestBuy”转换为“Best Buy”。我打算在文本文件中列出这些列表。
What's the best way to do this? Can I have in my text file, every line be something like bestbuy, Best Buy
the first item being the entered term and the second one being what it gets autocorrected into? What should I use to store this data? A hashmap?
最好的方法是什么?我可以在我的文本文件中,每行都是bestbuy,Best Buy第一项是输入的术语,第二项是自动修正的内容吗?我应该用什么来存储这些数据?一个hashmap?
Edit: Just to clarify, I'm not trying to make an actual auto-correct system. That's way, way beyond the scope of this project. This is just to simply replace certain inputs with "corrected" versions to match what is in the array being searched.
编辑:只是为了澄清,我不打算制作一个真正的自动纠正系统。这是超出本项目范围的方式。这只是简单地用“已更正”版本替换某些输入以匹配正在搜索的数组中的内容。
3 个解决方案