B4A Library GiLoWordsGamesUtils

GiLoWordsGamesUtils updated to version 1.8

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(CallBack As Object,EventName As String, logs As Boolean)

  • SetLanguage(asLang As String)
    if you want to create multiple languages you can use this property before loading the corresponding csv with the LoadCSVVocabulary command

  • 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.

  • GetFilteredWords2(filtro As List, notfiltro As List) As List
    Returns a list of words using the specified filter. and excluding the words corresponding to the second filter
    Filter should include SQLite wildcards:
    % represents zero, one, or multiple numbers or characters;
    _ (underscore) represents a single character.

  • GetFilteredWordFromList(filtro As String,Parole As List) As List
    Returns a list of words using the given Filter, the filter is applied to the list
    Filter should include SQLite wildcards:
    % represents zero, one, or multiple numbers or characters;
    _ (underscore) represents a single character.

  • CountWords(FirstLetter As String) As Long
    Returns a count of words starting with FirstLetter
    Pass empty string for all words (size of dictionary)

  • AddingWordsFromList(wordlist As List)
    To adding words in current DB from a List, one word for row

  • 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
    this is the first command to use, possibly after assigning a name to the vocabulary, ForceNew = False prevents the vocabulary from being created at each start, losing any changes made to the vocabulary itself

  • 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
    DeleteWords("=","example") delete 1 word
    DeleteWords("LENGHT", ">10") delete any words whit lenght >10 letters
    DeleteWords("LENGHT","<9") delete any words whit lenght <9 letters
    DeleteWords("LENGHT", "=7") delete any words whit lenght =7 letters
    DeleteWords("LIKE", "a%") delete any words start whit a
    return number of delete words

  • DeleteWordsFromList(ListWord As List) As Int
    Deletes the words in the list
    example of list: ('example','word','amb%')
    eliminates the words example, word, and all words that begin with amb from the dictionary

  • SetTimeOut(t As Long)
    the GetWordsFromLetters function can be very demanding and long if many letters are passed, with this property we avoid excessive waiting but obtain partial results

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

  • SuggestsCorrection(word As String) As List
    for a mistaken word suggests a list of possible corrections
llink for 3 csv files corresponding to Italian, English, and Spanish

https://drive.google.com/file/d/10laSFgzSak_XkjUEqkrwHNH0frSIxM-Q/view?usp=drive_link
donate at least 15€ and I will send you this library
 

Attachments

  • Word.rar
    35.7 KB · Views: 124
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Good job ;)
 

LucaMs

Expert
Licensed User
Longtime User
Last edited:

Star-Dust

Expert
Licensed User
Longtime 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
Longtime 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
Longtime 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:

Star-Dust

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

Star-Dust

Expert
Licensed User
Longtime 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