andydixon/pornolize

该包已被废弃,不再维护。未建议替代包。

PHP翻译器用于pornolize.com以使文本粗俗化

1.1.0 2019-03-04 21:33 UTC

This package is auto-updated.

Last update: 2022-01-05 13:53:23 UTC


README

此代码源自The Pornolizer的原后端代码,但已被重新开发为一个兼容composer的模块,可免费使用和滥用。

安装

composer require "andydixon/pornolize 1.*"

使用

文本粗俗化过程分为两部分 - 名称粗俗化和文本粗俗化。以下示例将粗俗化存储在$text中的文本


require_once __DIR__ . '/vendor/autoload.php';

$text = "The domestic goat or simply goat (Capra aegagrus hircus) is a subspecies of C. aegagrus domesticated from the wild goat of Southwest Asia and Eastern Europe. The goat is a member of the animal family Bovidae and the goat—antelope subfamily Caprinae, meaning it is closely related to the sheep. There are over 300 distinct breeds of goat. Goats are one of the oldest domesticated species of animal, and have been used for milk, meat, fur, and skins across much of the world. Milk from goats is often turned into goat cheese.";

$language = "en"; // can be one of 'dk', 'de', 'en', 'es', 'hr', 'hu', 'no', 'se'

try {

	// Pornolize any names that may exist
	$translator = Pornolize\NameTranslator::make($text, $language, 50);
	$text=$translator->translate()->__toString();

	// Pornolize main content
	$translator = Pornolize\ProseTranslator::make($text, $language, 50);
	$text = $translator->translate()->__toString();

	echo $text;

} catch (PornolizerDictionaryException $e) {    // Thrown if a dictionary file cant be found
	echo $lang . "'s dictionary does not exist";
} catch (PornolizerSwearabilityException $e) {  // Thrown if you make it outside of 0-100
    echo $e->getMessage();
}

上面的代码相当直观(我不是很擅长为普通人编写文档),然而对于任何翻译器对象,最后的选项改变了文本的侮辱程度,添加的词汇越多,越好

欢迎提出更改和改进,只需向我发送审阅的pull request。

有任何问题可以通过电子邮件向我咨询 - ajdixon0283 at outlook dot com,但你会得到你给予的 - 无礼将招致愤怒,对于那些将大脑卡在直肠里的人,可以免费提供额外的愤怒。