1. Go to this page and download the library: Download tuxonice/words library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tuxonice / words example snippets
lab\WordGenerator\WordGeneratorFacade;
// Create a generator with standard Portuguese patterns (default language)
$generator = WordGeneratorFacade::standard();
// Generate a single word
$word = $generator->generateWord(6); // 6 is the maximum word length
echo $word . PHP_EOL;
// Generate multiple words
$words = $generator->generateWords(5, 8); // 5 words with maximum length of 8
foreach ($words as $word) {
echo $word . PHP_EOL;
}
// Use easy mode for simpler words
$easyGenerator = WordGeneratorFacade::easyMode();
$easyWords = $easyGenerator->generateWords(3, 5); // 3 words with maximum length of 5
// Easy mode for Spanish
$easySpanishGenerator = WordGeneratorFacade::easyMode('spanish');
$easySpanishWords = $easySpanishGenerator->generateWords(3, 5); // 3 words with maximum length of 5
// Generate Spanish words
$spanishGenerator = WordGeneratorFacade::standard('spanish');
$spanishWord = $spanishGenerator->generateWord(7);
echo "Spanish word: $spanishWord" . PHP_EOL;
// Use language codes
$ptGenerator = new WordGeneratorFacade('pt'); // Portuguese
$esGenerator = new WordGeneratorFacade('es'); // Spanish
namespace Tlab\WordGenerator\Matrix;
class FrenchMatrix extends LanguageMatrix
{
public function getLanguageCode(): string
{
return 'fr';
}
public function getLanguageName(): string
{
return 'French';
}
public static function createStandard(): self
{
// Define French-specific transition matrix
$matrix = [
// French vowels and consonants with their transitions
// ...
];
// Common French word endings
$commonEndings = ['e', 'es', 'ent', 'ais', 'ait', 'er', 'ez', 'eur', 'euse', 'ion', 'tion'];
return new self($matrix, $commonEndings);
}
public static function createEasyMode(): self
{
// Define simplified French transition matrix
// ...
return new self($easyMatrix, $easyEndings);
}
}
protected function createMatrixForLanguage(string $language, bool $easyMode): LanguageMatrix
{
switch ($language) {
case 'portuguese':
case 'pt':
return $easyMode ? PortugueseMatrix::createEasyMode() : PortugueseMatrix::createStandard();
case 'spanish':
case 'es':
return $easyMode ? SpanishMatrix::createEasyMode() : SpanishMatrix::createStandard();
case 'french':
case 'fr':
return $easyMode ? FrenchMatrix::createEasyMode() : FrenchMatrix::createStandard();
default:
// Default to Portuguese if the language is not supported
return $easyMode ? PortugueseMatrix::createEasyMode() : PortugueseMatrix::createStandard();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.