ridesoft/aiml

aiml文件解析库

0.1.0 2020-02-14 11:17 UTC

This package is auto-updated.

Last update: 2024-09-18 19:07:23 UTC


README

Build Status

Aiml Php库,适用于php,兼容Php 7.3以上。

AIML代表人工智能建模语言。AIML是一种基于XML的标记语言,旨在创建人工智能应用。

AIML参考

支持的语言标记

  • <pattern>
  • <template>
  • <star>
  • <srai>

如何安装

composer require ridesoft/aiml:~0.1.0

基本用法示例

您可以在robot.php文件中找到此示例。使用docker run -v ${PWD}:/var/www/html --rm -it php:7.4-fpm-alpine sh -c "php tests/robot.php"运行它。

<?php

require 'vendor/autoload.php';

$file = new \Ridesoft\AIML\File();

echo "Hello Aiml\n";
echo $file->setAimlFile(__DIR__ . '/files/simple.aiml')
        ->getCategory('Hello Aiml')
        ->getTemplate() . "\n";

$file2 = new \Ridesoft\AIML\File();
$category = $file2->setAimlFile(__DIR__ . '/files/srai.aiml')
    ->getCategory('Who Mauri is?');

echo "Who Mauri is? \n";
if ($category->isTemplateSrai()) {
    echo $file2->getCategory($category->getTemplate($category->getStars()))
        ->getTemplate(). "\n";
}

贡献

我在业余时间开发这个库:任何帮助都非常欢迎:无论如何,我希望遵循最佳实践使用TDD方法或至少为代码编写单元测试。

代码遵循PSR2标准。

检查编码标准

docker run -v ${PWD}:/var/www/html --rm -it php:7.4-fpm-alpine vendor/bin/phpcs --standard=PSR2 /var/www/html/src

运行单元测试(使用docker)

使用以下命令启动php7.4容器:

docker run -v ${PWD}:/var/www/html --rm -it php:7.4-fpm-alpine vendor/bin/phpunit