如何在 python aiml 中以 img 的形式获得响应
how to get response in the form of img in python aiml
所以我试图用 https://github.com/paulovn/python-aiml
制作一个聊天机器人
<?xml version="1.0" encoding="ISO-8859-1"?>
<aiml version="1.0">
<!-- -->
<!-- Free software (c) 2011 ALICE A.I. Foundation. -->
<!-- This program is open source code released under -->
<!-- the terms of the GNU General Public License -->
<!-- as published by the Free Software Foundation. -->
<!-- Complies with AIML 1.0 Tag Set Specification -->
<!-- as adopted by the ALICE A.I. Foundation. -->
<!-- Last modified 10/5/2011 -->
<!-- -->
<category><pattern>HAVE YOU READ THE COMMUNIST *</pattern>
<template>Yes, Marx had made some interesting observations.</template>
</category>
<category><pattern>WHAT IS A GOVERNMENT</pattern>
<template>Ideally it is a representative of the people.</template>
</category>
<category><pattern>WHAT IS GREENPEACE</pattern>
<template>Global organization promoting enviornmental activism.</template>
</category>
<category><pattern>WHAT IS THE GOVERNMENT</pattern>
<template><srai>WHAT IS GOVERNMENT </srai></template>
</category>
<category><pattern>WHAT IS CAPITALISM</pattern>
<template>The economic system in which all or most of the means of production and distribution, as land, factories, railroads, etc., are privately owned and operated for profit, originally under fully competitive conditions. It has been generally characterized by a tendency toward concentration of wealth, and, in its later phase, by the growth of great corporations, increased governmental control, etc. Its is also known as the principles, methods, interests, power, influence, etc. of capitalists, especially of those with large holdings.</template>
</category>
<category><pattern>WHAT IS SOCIALISM</pattern>
<template><random> <li>Communism from people who want to keep their Volvos.</li> <li>Any of various theories or systems of the ownership and operation of the means of production and distribution by society or the community rather than by private individuals, with all members of society or the community sharing in the work and the products.</li> </random></template>
</category>
<category><pattern>WHAT IS GOVERNMENT</pattern>
<template>An established system of political administration by which a nation, state, district, etc. is governed.</template>
</category>
<category><pattern>WHAT IS COMMUNISM</pattern>
<template>A sociopolitical movement advocating the common ownership of the means of production and the resolution of class conflict by bringing about a classless society. </template>
</category>
<category><pattern>WHAT IS IMPEACHED</pattern>
<template>When a person's honor or reputation has been challenged or discredited.</template>
</category>
<category><pattern>WHAT IS IMPEACHMENT</pattern>
<template>Charge against a public official of improper conduct.<think> <set name="it"> <set name="topic">IMPEACHMENT</set> </set> </think></template>
</category>
<category><pattern>I DO NOT LIKE GUNS</pattern>
<template>That is perfectly understandable.</template>
</category>
<category><pattern>I DO NOT LIKE GUNS *</pattern>
<template>What about the second Amendemnt?</template>
</category>
<category><pattern>IS CAPITALISM *</pattern>
<template><srai>WHAT IS CAPITALISM </srai></template>
</category>
<category><pattern>DO YOU LIKE GUNS</pattern>
<template>Not especially. I am not into violence. </template>
</category>
<category><pattern>WHY GUNS</pattern>
<template>I support the 2nd Amendment.</template>
</category>
<category><pattern>WHO WAS THE FIRST IMPEACHED PRESIDENT *</pattern>
<template>Andrew Jackson.</template>
</category>
<category><pattern>WHO WAS THE FIRST IMPEACHED *</pattern>
<template>Andrew Jackson.</template>
</category>
<category><pattern>WHO IS THE GOVERNOR OF TEXAS</pattern>
<template><set name="he">Rick Perry</set> is Rick Perry.</template>
</category>
<category><pattern>WHO IS THE GOVERNOR OF *</pattern>
<template>That changes every few years.</template>
</category>
<category><pattern>WHO IS THE GOVERNOR OF CALIFORNIA</pattern>
<template>Jerry Brown.</template>
</category>
<category><pattern>WHO IS THE GOVERNOR *</pattern>
<template>It changes every few years.</template>
</category>
<category><pattern>GUNS</pattern>
<template>Some people like guns.</template>
</category>
<category><pattern>GUNS *</pattern>
<template>I believe in the Right to Bear Arms.</template>
</category>
<category><pattern>TELL ME ABOUT GUNS</pattern>
<template><srai>WHAT IS A GUN</srai></template>
</category>
</aiml>
这是示例代码,它非常简单,但我找不到一个 link 告诉如何让机器人以图像的形式发送响应,就像我想要的模式一样是谁是马克思,它以马克思的形象回应
您执行此操作的方式取决于您的解释器以及您如何使用它。如果您的解释器仅支持 AIML 1,您可以使用 HTML 标签显示图像。
<category>
<pattern>WHO WAS MARX</pattern>
<template>
A historical figure who wrote about communism.
<P ALIGN="CENTER"><img src="https://upload.wikimedia.org/wikipedia/commons/d/d4/Karl_Marx_001.jpg"></img></P>
</template>
</category>
如果您的解释器支持 AIML 2,您可以像这样使用 <image>
标签
<category>
<pattern>WHO WAS MARX</pattern>
<template>
A historical figure who wrote about communism.
<image>https://upload.wikimedia.org/wikipedia/commons/d/d4/Karl_Marx_001.jpg</image>
</template>
</category>
这将产生以下输出。
所以我试图用 https://github.com/paulovn/python-aiml
制作一个聊天机器人<?xml version="1.0" encoding="ISO-8859-1"?>
<aiml version="1.0">
<!-- -->
<!-- Free software (c) 2011 ALICE A.I. Foundation. -->
<!-- This program is open source code released under -->
<!-- the terms of the GNU General Public License -->
<!-- as published by the Free Software Foundation. -->
<!-- Complies with AIML 1.0 Tag Set Specification -->
<!-- as adopted by the ALICE A.I. Foundation. -->
<!-- Last modified 10/5/2011 -->
<!-- -->
<category><pattern>HAVE YOU READ THE COMMUNIST *</pattern>
<template>Yes, Marx had made some interesting observations.</template>
</category>
<category><pattern>WHAT IS A GOVERNMENT</pattern>
<template>Ideally it is a representative of the people.</template>
</category>
<category><pattern>WHAT IS GREENPEACE</pattern>
<template>Global organization promoting enviornmental activism.</template>
</category>
<category><pattern>WHAT IS THE GOVERNMENT</pattern>
<template><srai>WHAT IS GOVERNMENT </srai></template>
</category>
<category><pattern>WHAT IS CAPITALISM</pattern>
<template>The economic system in which all or most of the means of production and distribution, as land, factories, railroads, etc., are privately owned and operated for profit, originally under fully competitive conditions. It has been generally characterized by a tendency toward concentration of wealth, and, in its later phase, by the growth of great corporations, increased governmental control, etc. Its is also known as the principles, methods, interests, power, influence, etc. of capitalists, especially of those with large holdings.</template>
</category>
<category><pattern>WHAT IS SOCIALISM</pattern>
<template><random> <li>Communism from people who want to keep their Volvos.</li> <li>Any of various theories or systems of the ownership and operation of the means of production and distribution by society or the community rather than by private individuals, with all members of society or the community sharing in the work and the products.</li> </random></template>
</category>
<category><pattern>WHAT IS GOVERNMENT</pattern>
<template>An established system of political administration by which a nation, state, district, etc. is governed.</template>
</category>
<category><pattern>WHAT IS COMMUNISM</pattern>
<template>A sociopolitical movement advocating the common ownership of the means of production and the resolution of class conflict by bringing about a classless society. </template>
</category>
<category><pattern>WHAT IS IMPEACHED</pattern>
<template>When a person's honor or reputation has been challenged or discredited.</template>
</category>
<category><pattern>WHAT IS IMPEACHMENT</pattern>
<template>Charge against a public official of improper conduct.<think> <set name="it"> <set name="topic">IMPEACHMENT</set> </set> </think></template>
</category>
<category><pattern>I DO NOT LIKE GUNS</pattern>
<template>That is perfectly understandable.</template>
</category>
<category><pattern>I DO NOT LIKE GUNS *</pattern>
<template>What about the second Amendemnt?</template>
</category>
<category><pattern>IS CAPITALISM *</pattern>
<template><srai>WHAT IS CAPITALISM </srai></template>
</category>
<category><pattern>DO YOU LIKE GUNS</pattern>
<template>Not especially. I am not into violence. </template>
</category>
<category><pattern>WHY GUNS</pattern>
<template>I support the 2nd Amendment.</template>
</category>
<category><pattern>WHO WAS THE FIRST IMPEACHED PRESIDENT *</pattern>
<template>Andrew Jackson.</template>
</category>
<category><pattern>WHO WAS THE FIRST IMPEACHED *</pattern>
<template>Andrew Jackson.</template>
</category>
<category><pattern>WHO IS THE GOVERNOR OF TEXAS</pattern>
<template><set name="he">Rick Perry</set> is Rick Perry.</template>
</category>
<category><pattern>WHO IS THE GOVERNOR OF *</pattern>
<template>That changes every few years.</template>
</category>
<category><pattern>WHO IS THE GOVERNOR OF CALIFORNIA</pattern>
<template>Jerry Brown.</template>
</category>
<category><pattern>WHO IS THE GOVERNOR *</pattern>
<template>It changes every few years.</template>
</category>
<category><pattern>GUNS</pattern>
<template>Some people like guns.</template>
</category>
<category><pattern>GUNS *</pattern>
<template>I believe in the Right to Bear Arms.</template>
</category>
<category><pattern>TELL ME ABOUT GUNS</pattern>
<template><srai>WHAT IS A GUN</srai></template>
</category>
</aiml>
这是示例代码,它非常简单,但我找不到一个 link 告诉如何让机器人以图像的形式发送响应,就像我想要的模式一样是谁是马克思,它以马克思的形象回应
您执行此操作的方式取决于您的解释器以及您如何使用它。如果您的解释器仅支持 AIML 1,您可以使用 HTML 标签显示图像。
<category>
<pattern>WHO WAS MARX</pattern>
<template>
A historical figure who wrote about communism.
<P ALIGN="CENTER"><img src="https://upload.wikimedia.org/wikipedia/commons/d/d4/Karl_Marx_001.jpg"></img></P>
</template>
</category>
如果您的解释器支持 AIML 2,您可以像这样使用 <image>
标签
<category>
<pattern>WHO WAS MARX</pattern>
<template>
A historical figure who wrote about communism.
<image>https://upload.wikimedia.org/wikipedia/commons/d/d4/Karl_Marx_001.jpg</image>
</template>
</category>
这将产生以下输出。