suilven/random-english

生成随机可信的英语,用于测试搜索引擎

1.0.2 2020-07-06 22:59 UTC

This package is auto-updated.

Last update: 2024-09-07 08:30:16 UTC


README

Build Status Scrutinizer Code Quality codecov.io

Latest Stable Version Latest Unstable Version Total Downloads License Monthly Downloads Daily Downloads composer.lock

GitHub Code Size GitHub Repo Size GitHub Last Commit GitHub Activity GitHub Issues

codecov.io

生成看似可信的英语文本,尽管它在语义上可能不正确。

入门指南

首先,无需在实时系统上安装此软件,它纯粹是为了创建测试数据,如固定数据。

先决条件

需要PHP 7.2

Give examples

安装

composer require --dev suilven/random-english

用法

脚本

随机句子

参数4是返回的句子数量

> bin/randomEnglish sentences 4
Shut in, however, by nine, it was terrible to sun his piano, which we had observed with the sorry house.
Foresting at night is more fun than seconding during the day.
Try!! You cannot wire here.
The minute is colour kenyan copper.

随机段落

参数2是随机段落数量

> bin/randomEnglish paragraphs  2
Cat juices are best eaten with propers.  The spread in Pakistan is healthy.  The down is a storm of an female flog and is gold in the voice for his stomach and the mildness of his die.  Wait!! You cannot add here.  The park is colour cornflower blue.  Thea opened the tall and found that it led into a cheap fever, not much larger than a through.  The inside weather was paning on the across bank.  The further great double into the beer.  How slowly the hide passes here, encompassed as I am by fly and fit?  Among these were a couple of countrys, a toeing catch I employed sometimes, a sick hurting a skill, Gregg the butcher and his little boy, and two or three loafers and golf caddies who were accustomed to hang about the railway station.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Wish!! You cannot second here.  This is a random string from 1 to 4 two.  Tom's younger brother (or rather half-brother) Sid was already through with his part of the work (picking up chips), for he was a quiet boy, and had no adventurous, trouble-some ways.  The something gold ladder round the comb.  The decrease is a pull of an try were and is garden in the brush for his coin and the mildness of his come.  It was piano in the line, there star was sound.  Reminding at night is more fun than answering during the day.  Shut in, however, by road, it was through to fruit his cost, which we had observed with the model taste.  Were it not for the works, the south clean would not be out.  The salt film was snowing on the close bank.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

PHP

使用以下配置初始化生成器,或者留空以从 config/sentence-structure.cfg 中选择随机结构

$generator = new RandomEnglishGenerator();
$generator->setConfig('It was [adjective] in the [noun], [contraction] [noun] was [adjective]');

$generator->sentence(); // generate a random sentence
$generator->title(); // generate a random sentence in Title Case
$generator->paragraph(10); // generate a random paragraph of up to a max of 10 sentences

配置

句子结构定义在 config/sentence-structure.cfg 中,如下所示

The [noun] was [verb_ing] [adverb]
The [noun] in [country] is [adjective]
The [noun] is colour [colour]
This is a random string from 1 to 4 [one|two|three|four]

随机生成的工作方式如下

  • 从配置文件中选择随机行。
  • 方括号外的任何单词都按原样输出。
  • 形式为 [one|two|three|four] 的字符串代表随机单词的选择,可以是 onetwothreefour,并将附加到句子中。
  • words 目录包含各种文本文件,其中包含以文件名为代表的单词列表。指令 [noun] 将导致加载文件 words/english_nouns.txt 并从文件中选择随机单词。
  • 异常
    • [country] 将加载 words/english_countries.txt,仅仅是一个语义问题
    • [verb_ing] 将获取一个动词并将其转换为以 ing 结尾的形式
    • [plural_noun] 将从文件 words/english_countable_nouns.txt 中获取一个名词,并用屈折变化器将其变为复数形式
  • 以下是对 Faker 运行的命令以生成随机条目,例如 [lastName] 将生成一个姓氏。
'address',
        'name',
        'randomDigit',
        'randomLetter',
        'randomNumber',
        'title',
        'titleMale',
        'titleFemale',
        'firstNameMale',
        'firstNameFemale',
        'lastName',

        'catchPhrase',
        'bs',
        'company',
        'companySuffix',
        'jobTitle',

        'realText',

        'dayOfWeek',
        'monthName',

运行测试

  1. 构建Docker镜像并进入bash shell
sudo docker-compse up -d phpcli
sudo docker-compose exec phpcli /bin/bash

请注意,如果之前未构建,则第一步可能需要几分钟。

bash提示符将如下所示

> sdc exec phpcli /bin/bash
 ____                 _                   _____             _ _     _     
|  _ \ __ _ _ __   __| | ___  _ __ ___   | ____|_ __   __ _| (_)___| |__  
| |_) / _` | '_ \ / _` |/ _ \| '_ ` _ \  |  _| | '_ \ / _` | | / __| '_ \ 
|  _ < (_| | | | | (_| | (_) | | | | | | | |___| | | | (_| | | \__ \ | | |
|_| \_\__,_|_| |_|\__,_|\___/|_| |_| |_| |_____|_| |_|\__, |_|_|___/_| |_|
                                                      |___/               
root@randomenglish.test:/var/www> 

版本控制

我们使用 SemVer 进行版本控制。有关可用的版本,请参阅此存储库的标签

作者

许可

本项目采用MIT许可证 - 有关详细信息,请参阅LICENSE.md 文件

数据来源