B4A Library GiLoWordsGamesUtils

GiLoWordsGamesUtils 1.0

Library useful to create word game apps, for any languages. Actually only English and Italian but I will add VERY SOON a method to import simple CSV file for any language

  • Initialize
  • SetItalian
To use the internal Italian vocabulary.​
  • SetEnglish
To use the internal English vocabulary.​
  • GetRandomWord(WordLength As Int) As String
Returns a WordLenght long random word pass -1 for any long​
  • WordExists(WordToSearch As String) As Boolean
Checks if a word exists (in the db, of course)​
  • FindAnagrams(Word As String) As List
Returns a list of anagrams of the given Word​
  • GetWordsFromLetters(Letters As String) As List
Returns a list of words containig the given Letters​
  • GetFilteredWords(filtro As String) As List
Returns a list of words using the given Filter.
Filter should include SQLite wildcards:
% represents zero, one, or multiple numbers or characters;
_ (underscore) represents a single character.
Example:
%a__l% returns example and other 2399 words
__a__le returns example and other 27 words​
  • Size(FirstLetter As String) As Long
Returns a count of words starting with FirstLetter
Pass empty string for all words


_______________________________________________________________

Upgrade to version 1.1
I'm added new features


  • AddingWordsFromList(wordlist As List)
To adding words in current DB from a List, one word for row
if you are using the internal dictionary this is changed​
  • SetCustomVocabulary(name As String)
To set the name for create a vocabulary, name is a DB name​

  • LoadCSVVocabulary(dir As String,fil As String,ForceNew As Boolean)
To fill the vocabulary from a csv file, one word for row, if ForceNew is True the previous dictionary words Will be deleted​

  • DeleteWords(FilterType As String, FilterValue As String) As Int
Delete Words WHIT SQL Filter
Filter Type as "=", "LENGHT", "LIKE"
Filter Value as numeric or letteral example
type value
= example delete 1 word
LENGHT >10 delete any words whit lenght>10 letters
LENGHT <9 delete any words whit lenghta<9 letters
LENGHT =7 delete any words whit lenght=7 letters
LIKE a% delete any words start whit a
return number of delete words​
  • RestoreDBIT
restore the original ITalian DB​

  • RestoreDBENG
restore the original ENGlish DB​


_______________________________________________________________

Upgrade to version 1.3
I'm added new features and dictionary


  • Levenshtein_distance(x As String, y As String) As Int
return Levenshtein distance, for more information see Wikipedia

  • SetSpanish
To use the external spanish dictionary, this dictionary is downloaded at first use​

  • SuggestsCorrection(word As String) As List
for a mistaken word suggests a list of possible corrections​



donate at least 15€ and I will send you this library
 
Last edited:

Star-Dust

Expert
Licensed User
Good job ;)
 

LucaMs

Expert
Licensed User
Longtime User
Last edited:

Star-Dust

Expert
Licensed User
But your app does not show the main and most powerful feature of your library:

(almost instantly)
what is the secret? :p
 

LordZenzo

Well-Known Member
Licensed User
Longtime User
But your app does not show the main and most powerful feature of your library:
  • FindAnagrams(Word As String) As List
Returns a list of anagrams of the given Word
(almost instantly)
false
if you play at level two you have to find the word between a series of anagrams
 

Star-Dust

Expert
Licensed User
I ask forgiveness at @LordZenzo, in my post on Code Snipped i wrongly attributed the library to UDG, but I corrected the post and I apologize.
 

Smee

Well-Known Member
Licensed User
Longtime User
Looks good, can you provide a small demo code?
 

LordZenzo

Well-Known Member
Licensed User
Longtime User
this code

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim mydb As Words
End Sub

Sub globals
  
End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    mydb.Initialize
    mydb.SetItalian
    Dim a As Long=DateTime.Now
    Log(mydb.GetRandomWord(10))
    Log(DateTime.Now-a)
    Dim a As Long=DateTime.Now
    Log(mydb.FindAnagrams("digitale"))
    Log(DateTime.Now-a)
    Dim a As Long=DateTime.Now
    Log(mydb.GetFilteredWords("__gi%le"))
    Log(DateTime.Now-a)
    Dim a As Long=DateTime.Now
    Log(mydb.GetWordsFromLetters("digitale"))
    Log(DateTime.Now-a)
  

    ExitApplication
End Sub

generate this logs
time in Milliseconds

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
total words 244836
merendando
507
(ArrayList) [digitale, gelidita]
124
(ArrayList) [aggiustabile, argille, cagionevole, digitale, ingiungendole, ingiunzionale, ingiuriandole, ingiustificabile, magistrale, magistratuale, pigionale, pugile, ragionevole, regionale, registrabile, registrarle, sagittale, vagile, vaginale, vigile]
193
(ArrayList) [digitale, gelidita, ditegli, edilita, dategli, lidite, gelidi, litiga, ialite, italie, gelati, legati, taglie, teglia, dilati, ditali, digita, algidi, lagidi, ditale, ideati, tediai, ideali, iliade, algide, gelida, lagide, tigli, etili, lieti, liegi, ligie, tildi, digli, tilde, editi, edili, degli, gilde, aliti, itali, tagli, agiti, agili, ligia, alite, itale, lieta, telai, agile, gelai, legai, aditi, tiadi, alidi, laidi, lidia, dagli, gilda, gladi, delta, taled, deita, diate, dieta, edita, taide, tedia, tiade, alide, dalie, laide, leida, egida, giade, liti, ligi, lite, teli, ilei, geti, gite, egli, geli, gile, glie, lige, diti, lidi, dite, tedi, ledi, lied, idei, alti, ital, lati, lita, tali, iati, gita, agli, gila, glia, liga, alte, late, tale, tela, aite, atei, elia, gate, tega, gale, gela, lega, gaie, dati, dita, laid, lida, diga, date, teda, leda, aedi, idea, iti, ili, lii, gli, ite, tie, eli, ile, lei, lie, gel, idi, del, led, dei, die, alt, tal, ita, tai, ali, ila, lai, gal, agi, gai, gia, eta, tea, lea, aie, eia, gea, dal, dai, dia, ida, dea, it, il, ii, gi, et, el, ei, di, de, al, ai, ad]
106
 

Star-Dust

Expert
Licensed User
Velocissimo
 

LucaMs

Expert
Licensed User
Longtime User
words.gif


Real time (it takes more time to fill the Listview than to find the words ;)).
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Do you (all members) have dictionaries files (text format, like CSV)?

Thank you
 

Star-Dust

Expert
Licensed User
Have dictionaries files text format, English and Itaglian (coreggiut format)
 

Star-Dust

Expert
Licensed User
I offered a dictionary to LucaMs , He as he had asked for a dictionary

LucaMs said:
Doyou (all members) have dictionaries files (text format, like CSV)?
 
Top