generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Proficient Search Help

Previous Thread :: Next Thread 
dansk is not online. dansk
Joined: 24 Dec 2008
Total Posts: 548
06 May 2015 12:00 PM
Alright so first of all believe it or not I have a script in my workspace that globalized an array encoded with the entire english language. What I'm trying to make is an autocorrect script. First of all, I realize just looping through this normal using a for loop would take way too many iterations. My first step is to find a word in the array using a binary search algorithm. I can write it in java using integers but strings I'm not so comfortable with. Anybody know how I would accomplish this?
Report Abuse
dansk is not online. dansk
Joined: 24 Dec 2008
Total Posts: 548
06 May 2015 12:11 PM
Bump
Report Abuse
Intern33t is not online. Intern33t
Joined: 19 Nov 2010
Total Posts: 1530
06 May 2015 12:17 PM
according to lua-usersputadothereorg/wiki/BinarySearch there is "table.binsearch"
Report Abuse
dansk is not online. dansk
Joined: 24 Dec 2008
Total Posts: 548
06 May 2015 12:19 PM
The link isn't working
Report Abuse
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
06 May 2015 01:05 PM
http://lua-users.org/wiki/BinarySearch
Report Abuse
dansk is not online. dansk
Joined: 24 Dec 2008
Total Posts: 548
06 May 2015 01:25 PM
So I checked the link but wouldn't that work with Integers? How would I use it to compare strings alphabetically?
Report Abuse
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
06 May 2015 02:30 PM
You could've organised everything alphabetically:

Dictionary = {
A={"All letters beginning with A"},
B = {"You get the idea"}
}

Then,
for _,a in pairs(Dictionary[string:sub(1,1):Upper()]) do
-- Do stuff
end

---------------

Dictionary[string:sub(1,1):Upper()]

"Dictionary" is the "main" table.
"string" is the word
:sub(1,1) gets the first letter.
:Upper() turns it upper-case.

So, it's the same as this (str == string):

str = "Hello"
Dictionary["H":Upper()]
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
06 May 2015 02:48 PM
table.concat(yourArray, '||'):find("wordyou'relookingfor")

If you're looking for something that finds the correction based on a search, I'd suggest you either start making a dictionary of common mispellings and searching each typed word as a key, or use a fuzzy match for the words in your array. It could help if you did organise them into letters, though

Thing = {
A = {
A = {
"Aa lava"
}
};
B = {
A = {
N = {
A = {
-- Yeah you get the idea dude
}
}
}
}
}

That can totally help you by cutting out large amounts of things.
Report Abuse
dansk is not online. dansk
Joined: 24 Dec 2008
Total Posts: 548
06 May 2015 02:57 PM
Thanks guys. (Btw the dictionary is already organized alphabetically)
Report Abuse
darkwisp is not online. darkwisp
Joined: 07 Apr 2010
Total Posts: 22653
06 May 2015 03:34 PM
I think what the mean by alphabetically is separating each set of words into tables of alphabets.
Report Abuse
dansk is not online. dansk
Joined: 24 Dec 2008
Total Posts: 548
06 May 2015 03:45 PM
Well Instead of that I just took the indexs of where each letter starts and ends so I can jump to them quicker
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image