Skip to content

Commit

Permalink
🐞fix: fix random index selection for prefix and suffix words
Browse files Browse the repository at this point in the history
Corrected the random index selection logic
for prefix and suffix wordsin the function
`getJrps` in `Generator`.
This ensures the correct word lists are used
for generating random words.
  • Loading branch information
yanosea committed Oct 10, 2024
1 parent 61c5c20 commit 8aad9f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/library/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,19 @@ func (g *Generator) getJrps(num int,
argSuffix = ""
case WithPrefix:
// get random number for suffix
randomIndexSuffix := g.RandProxy.Intn(len(allAVWords))
randomIndexSuffix := g.RandProxy.Intn(len(allNWords))
// get random prefix word
randomSuffix := allAVWords[randomIndexSuffix]
randomSuffix := allNWords[randomIndexSuffix]
// set prefix word and suffix word
prefixWord = argPrefix
suffixWord = randomSuffix.Lemma.FieldNullString.String
// set argSuffix to empty string
argSuffix = ""
case WithSuffix:
// get random number for argPrefix
randomIndexPrefix := g.RandProxy.Intn(len(allNWords))
randomIndexPrefix := g.RandProxy.Intn(len(allAVWords))
// get random prefix word
randomPrefix := allNWords[randomIndexPrefix]
randomPrefix := allAVWords[randomIndexPrefix]
// set prefix word and suffix word
prefixWord = randomPrefix.Lemma.FieldNullString.String
suffixWord = argSuffix
Expand Down

0 comments on commit 8aad9f9

Please sign in to comment.