如何获取英语中所有4个字母的单词的列表 [英] How to get the list of all 4 letter words in the English language

查看:212
本文介绍了如何获取英语中所有4个字母的单词的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Folks,

我是一个初学者,一直在玩C#.我最近为非常流行的牛与牛"文字游戏编写了代码.它适用于2个玩家,即;一个玩家想到一个单词,而另一个人则猜到它.我只给了10个猜测的机会.

我现在想为单个玩家制作游戏(计算机对人类).我想知道是否有英语单词中的所有4个字母单词都无需重复字母的情况(我将游戏限制为仅4个字母单词).我知道我可以使用枚举并将所有4个字母的单词写下来.但这很难对单词进行编码.那将是我的最后选择.

任何帮助将不胜感激.

Hello Folks,

I am a beginner and have been playing around with C#. I have recently written the code for the very popular ''Cows and Bulls'' word game. Its working for 2 players i.e; One player thinks of a word and the other person has to guess it. I am giving only 10 chances for guessing.

I now want to make the game for a single player(Computer v Human). I was wondering if there was anyway of getting all the 4 letter words in the English Language without Letter repetition(I have limited the game to 4 Letter words only). I know I can use an Enumeration and write down all the 4 letter words. But that''s Hard Coding the Words. That would be my last option.

Any help would be appreciated.

推荐答案



您可以将单词的信息存储在数据库中.并在排名中再增加一列.当计算机使用特定单词时,将等级标记为+1.

每次您选择单词use order by子句以进行排序.因此最低的排名将排在首位,请使用单词并增加单词.

您可以使用len SQL函数过滤单词.因此您的查询就像是
Hi,

You can store the information of the words in the database. and add one more column with the rank. When computer use particular word, mark the rank as +1.

Everytime you choose the word use order by clause to order with rank. so the lowest rank will come first, Use the word and increment the word.

You can filter the word using len SQL function. So your query would be like,
select top 1 * from dictionary where len(word)=4 order by rank;


希望这对您有帮助,

谢谢.


Hope this helps you ,

Thanks.


正如AmitGajjar所说,您应该将单词存储在某个地方,尽管我只会存储符合条件的单词(4个字母,非重复字符).如果使用合理大小的字典,则单词列表将会很大,因此,如果性能较差,则可以考虑对第一个字符(例如"a"表,"b"表)进行分区.

使您的任务更轻松的一件事是使用Linux的字典 ^ ].您可以轻松地编写一个perl脚本来处理该文件,并将所有符合条件的单词发送到一个新文件中(如果要按首字母分隔,则将这些文件分隔开).然后,您所要做的就是将单词输入到后备存储中,尽管您可以将文本文件用作后备存储.
As AmitGajjar said, you should store the words somewhere, though I''d only store the eligible words (4 letters, non-repeating characters). The list of words is going to be large if you use a reasonable size dictionary, so you might consider partitioning on the first character (e.g. an "a" table, "b" table) etc if performance is bad.

One thing you can do to make your task easier is to use Linux''s dictionary see here for the file location[^]. You can easily write a perl script to process the file and emit all the eligible words into a new file (or files if you want to segregate by first letter). Then all you need do is get the words into your backing store, though you could use the text file(s) as your backing store.


这篇关于如何获取英语中所有4个字母的单词的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆