我搜索了谷歌并实施了此代码,但它给出了 警告:DOMDocument :: loadXML():打开和结束标记不匹配:链接第2行和头部在实体中,第94行/home/etplpm/public_html/netsamningar/wp-content/themes/thestory/template-login.php on第36行。 我根据我的文档更改了Url和密钥,但找不到任何合适的解决方案。
def reply(input)
# you load this from a storage, so that when you add new keywords,
# your code doesn't have to be touched.
knowledge = [
{ keyword: 'how are you', response: 'Good, how about yourself, %{name}?' },
{ keyword: 'bye', response: 'Ciao!' },
]
response = knowledge.detect do |pair|
input.downcase.include?(pair[:keyword].downcase)
end
response && response[:response]
end
reply('How are you doing, machine?') # => "Good, how about yourself, %{name}?"
reply('gotta go, bye') # => "Ciao!"