搜索算法 [英] searching algorithm
问题描述
大家好!
我有一个文本文件(英语 - 克罗地亚语字典),其中包含字母词汇
order。
此文件包含以下格式的179999个单词:
英语单词:croatian word
我想立即搜索我的gui
即时搜索,我的意思是我的程序搜索单词并向用户显示单词
用户类型字母。
是的,它需要快速
有人可以给我点数(方法)如何制作这个
我应该制作索引并使用file.seek
或者应该在和平中打破字典,并将以一个开头的单词和另一个单词中的b开头的单词...
?????
所以如果我有这个话
absinth:pelin
苦艾酒:pelin
绝对:apsolutan
绝对:apsolutni kod
绝对:apsolutno
绝对:čist
绝对:nesumnjiv
绝对值:potpun
绝对:savr?en
绝对坐标:apsolutne koordinate
绝对频率:apsolutnaučestalost
绝对差距:apsolutni jaz
绝对行间距:apsolutnimeđurazmaklinija
绝对多数:apsolutnavećina
绝对指向设备:apsolutnipokazivačkiuređaj
绝对数量: apsolutni udio
绝对值:apsolutna vrijednost
绝对零度:apsolutna nula
绝对:apsolutno
绝对:bezuvjetno
绝对:nezavisno
绝对:potpuno
绝对:samostalno
绝对:sasvim
赦免:odrje?enje
赦免:opro?taj
绝对主义:apsolutizam
赦免:odrije?iti
absolve:osloboditi
吸收:absorbirati
吸收:apsorbirati
吸收:crpsti
如果用户输入:" abs"程序应列出以上英语和克罗地亚语中的所有单词
如果用户输入:吸收比程序应该列出最后3个单词的英文和
克罗地亚
任何帮助都会很感激!
我为不好道歉英语
Hi all!
I have text file (english-croatian dictionary) with words in it in alphabetical
order.
This file contains 179999 words in this format:
english word: croatian word
I want to make instant search for my gui
Instant search, i mean that my program search words and show words to user as
user type letters.
yes, it needs to be fast
Can someone give me some points (approaches) how to make this
Should i make indexes and go with file.seek
or should breake dictionary in peaces and put words that start with a in one and
with b in another...
?????
So if i have this words
absinth:pelin
absinthe:pelin
absolute:apsolutan
absolute:apsolutni kod
absolute:apsolutno
absolute:čist
absolute:nesumnjiv
absolute:potpun
absolute:savr?en
absolute coordinates:apsolutne koordinate
absolute frequency:apsolutna učestalost
absolute gap:apsolutni jaz
absolute line spacing:apsolutni međurazmak linija
absolute majority:apsolutna većina
absolute pointing device:apsolutni pokazivački uređaj
absolute quantity:apsolutni udio
absolute value:apsolutna vrijednost
absolute zero:apsolutna nula
absolutely:apsolutno
absolutely:bezuvjetno
absolutely:nezavisno
absolutely:potpuno
absolutely:samostalno
absolutely:sasvim
absolution:odrje?enje
absolution:opro?taj
absolutism:apsolutizam
absolve:odrije?iti
absolve:osloboditi
absorb:absorbirati
absorb:apsorbirati
absorb:crpsti
if user type: "abs" program should list all words above in english and in croatian
if user type: "absorb" than program should list last 3 words in english and in
croatian
any help would be appreciate!
my apologies for bad english
推荐答案
我制作了一个基于ODS文件搜索字谜的脚本(调用
OSW英文,官方拼字游戏单词)
它加载一个包含369085个单词的文件(每行一个单词)
我创建一个dictionnary并使用其长度存储单词
单词为关键
示例:mydict [2]包含长度为2的单词列表
首先我选择正确的词典输入和第二次扫描这个
列表搜索正确的单词
我的文件包含369085并且它非常快
Seb
I have made a script that search anagram based on the ODS file ( call
OSW in english, Official Scrabble Words)
it load a file that contain 369085 words (one word per line)
I create a dictionnary and store word into using the length of the
word as key
example : mydict[2] contain a list of word with length = 2
first I select the correct dict entry and in a second time I scan this
list searching correct word
my file contains 369085 and it''s pretty fast
Seb
2007-05-10,Gigs_< gi ** @ hi.t-com.hrwrote:
On 2007-05-10, Gigs_ <gi**@hi.t-com.hrwrote:
大家好!
我有文本文件(英文-croatian字典)里面有单词
按字母顺序排列。这个文件包含这个
格式的179999个单词:英文单词:croatian word
我想立即搜索我的gui即时搜索,我的意思是
我的程序搜索单词并以用户身份向用户显示单词
类型字母。是的,它需要快速
有人可以给我一些分数(方法)如何制作这个
我应该制作索引并使用file.seek
或者应该在和平中打破字典并将单词和/或b中的单词放在一起开始
...
>
所以如果我有这个话
[下面的删节词典]
苦艾酒:pelin
苦艾酒:pelin
绝对:apsolutan
绝对:apsolutni kod
absolve:odrije?iti
absolve:osloboditi
吸收:absorbirati
吸收:apsorbirati
吸收:crpsti
如果用户输入:" abs"程序应列出上面的所有单词
english和克罗地亚语如果用户输入:吸收程序
应该列出英文和克罗地亚语中的最后3个单词
Hi all!
I have text file (english-croatian dictionary) with words in it
in alphabetical order. This file contains 179999 words in this
format: english word: croatian word
I want to make instant search for my gui Instant search, i mean
that my program search words and show words to user as user
type letters. yes, it needs to be fast
Can someone give me some points (approaches) how to make this
Should i make indexes and go with file.seek
or should breake dictionary in peaces and put words that start
with a in one and with b in another...
So if i have this words
[abridged dictionary below]
absinth:pelin
absinthe:pelin
absolute:apsolutan
absolute:apsolutni kod
absolve:odrije?iti
absolve:osloboditi
absorb:absorbirati
absorb:apsorbirati
absorb:crpsti
if user type: "abs" program should list all words above in
english and in croatian if user type: "absorb" than program
should list last 3 words in english and in croatian
解决数据结构问题的解决方案可能是
a多树。
每个节点都指向一组以下字母和一组
克罗地亚语翻译,其中任何一个可能是空的,使
节点成为一片叶子。
对于上面的(abrideged)字典,你会生成(使用
固定宽度的程序员字体,所以树看起来不错):
a
|
b
|
s
/ \
io
/ / \
nlr
/ / \ \
tuv b->(absorbirati,crpisti)
/ | |
(pelin)< -h t e->(odrije?iti,osloboditi)
| |
(pelin)< -e e->(apsolutan,apsolutni kod)
当用户输入字母时,你只需沿着树行进,打印
当前节点中保存的叶子节点中保存的所有单词。
-
Neil Cerutti >
我们将获得越来越大的成就。 --Richard J.
Daley
A solution that solves the problem with a data structure might be
a multi-tree.
Each node points at a set of following letters, and a set of
croatian translations, either of which might be empty, making the
node a leaf.
For the above (abrideged) dictionary, you would generate (use a
fixed-width "programmers" font so the tree looks good):
a
|
b
|
s
/ \
i o
/ / \
n l r
/ / \ \
t u v b->(absorbirati, crpisti)
/ | |
(pelin)<-h t e->(odrije?iti, osloboditi)
| |
(pelin)<-e e->(apsolutan, apsolutni kod)
As the user enter letters, you just march down the tree, printing
all the words held in leaf nodes held in the current node.
--
Neil Cerutti
We shall reach greater and greater platitudes of achievement. --Richard J.
Daley
" Neil Cerutti" < ho ***** @ yahoo.com写了留言
news:sl ******************** @ FIAD06.norwich。 edu ...
|在2007-05-10,Gigs_< gi ** @ hi.t-com.hrwrote:
|如果用户输入:" abs"程序应列出上面的所有单词
|英语和克罗地亚语如果用户输入:吸收比计划
|应该列出英文和克罗地亚语中的最后3个单词
|
|解决数据结构问题的解决方案可能是
|一个多树。
特定的计算机科学术语是前缀树或trie(来自reTRIEval)。
http://en.wikipedia.org/wiki/Trie
给出了介绍。
|每个节点都指向一组以下字母,以及一组
|克罗地亚语翻译,其中任何一个都可能是空的,使得
|节点一片叶子。
|
|对于上面的(abrideged)字典,你会生成(使用
|固定宽度的程序员字体,这样树看起来很好):
|
| a
| |
| b
| |
| s
| / \
|我是
| / / \
| n l r
| / / \\ \\ \\
| t u v b->(absorbirati,crpisti)
| / | |
| (pelin)< -h t e->(odrije?iti,osloboditi)
| | |
| (pelin)< -e e->(apsolutan,apsolutni kod)
|
|当用户输入字母时,你只需沿树下行,打印
|在当前节点中保存的叶节点中保存的所有单词。
tjr
|
"Neil Cerutti" <ho*****@yahoo.comwrote in message
news:sl********************@FIAD06.norwich.edu...
| On 2007-05-10, Gigs_ <gi**@hi.t-com.hrwrote:
| if user type: "abs" program should list all words above in
| english and in croatian if user type: "absorb" than program
| should list last 3 words in english and in croatian
|
| A solution that solves the problem with a data structure might be
| a multi-tree.
Specific computer science terms are prefix tree or trie (from reTRIEval).
http://en.wikipedia.org/wiki/Trie
gives an introduction.
| Each node points at a set of following letters, and a set of
| croatian translations, either of which might be empty, making the
| node a leaf.
|
| For the above (abrideged) dictionary, you would generate (use a
| fixed-width "programmers" font so the tree looks good):
|
| a
| |
| b
| |
| s
| / \
| i o
| / / \
| n l r
| / / \ \
| t u v b->(absorbirati, crpisti)
| / | |
| (pelin)<-h t e->(odrije?iti, osloboditi)
| | |
| (pelin)<-e e->(apsolutan, apsolutni kod)
|
| As the user enter letters, you just march down the tree, printing
| all the words held in leaf nodes held in the current node.
tjr
|
>
这篇关于搜索算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!