定制 refactor73/autotextgen 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

refactor73/autotextgen

Composer 安装命令:

composer require refactor73/autotextgen

包简介

A simple document driven text generation written in PHP

README 文档

README

A simple document driven text composer.

Description

Writing natural language text blocks based on context and decisions parsed from a JSON document. The context contains the properties of the JSON document itself and can be added to the text as ${variables}, while the decision table contains bool values based on pre executed custom conditions and are used in [IF $decision] control structures.

Example

$context = Context::fromArray([
    'trend' => 10,
    'total' => 90,
]);

$decisionTable = DecisionTable::fromArray([
    'isNegative' => false,
]);

$textComposer = new TextComposer($decisionTable, $context);

$result = $textComposer->compose(
    '{In dieser Woche|Aktuell} ist der Wert um ${trend} auf ${total} Punkte ' .
    '[IF $isNegative] gefallen [ELSE] gestiegen [ENDIF].'
);

Possible result are:

In dieser Woche ist der Wert um 10 auf 90 Punkte gestiegen.

or

Aktuell ist der Wert um 10 auf 90 Punkte gestiegen.

Manipulators

Syntax Description
{synonym1|synonym2|synonym3} Random choose a synonym out of list
${var} Variable name from context
[IF $decision] ... [ENDIF] if control structure
[IF $decision] ... [ELSE] ... [ENDIF] if else control structure

Use case

Generating varied text for a customer metric report based on a JSON document.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固