gt-bot_PHPBot-PHP Bot可以帮助您更快地查找文档吗?

gt-bot

I came across PHPBot the other day (not to be confused with Botman or Fondbot) – a “chatbot” which helps you look up PHP manual entries and generates example code for them.

几天 ,我碰到了PHPBot (不要与BotmanFondbot混淆)–一个“聊天机器人”,可以帮助您查找PHP手册条目并为其生成示例代码。

If you follow me on Twitter, you know I don’t believe in chatbots being chatbots – as someone who’s built some for both commercial purposes and personal ones, and as someone who was around in the age of IRC auto-responding scripts, I see chatbots as a little more than a marketing fad designed to impress today’s Snapchat generation. However, every now and then one will appear that’s actually useful. Could this be the one? Let’s take a look.

如果您在Twitter上关注我,您会知道我不相信聊天机器人是聊天机器人–作为为商业目的和个人目的而构建的聊天机器人,以及大约在IRC自动响应脚本时代使用的聊天机器人,聊天机器人只不过是一种旨在打动当今Snapchat一代的营销时尚。 但是,偶尔会出现一个实际上有用的信息。 可以是那个吗? 让我们来看看。

Bot welcoming image

概念 (Concept)

The idea is that you use the text input on the page to enter a PHP related term (like “ksort”) and the application will reply with an explanation and some example code, like so:

这个想法是,您可以使用页面上的文本输入来输入与PHP相关的术语(例如“ ksort”),然后应用程序将给出解释和一些示例代码,例如:

PHPBot reply to ksort input

Different queries will produce different responses. So, if you ask it for echo:

不同的查询将产生不同的响应。 因此,如果您要求它echo

PHPBot's reply to echo

用处 (Usefulness)

While this sounds interesting in theory, in practice it’s a bit off.

尽管从理论上讲这听起来很有趣,但在实践中还是有些偏离。

知识库和错误 (Knowledgebase and Bugs)

The knowledge the bot can provide is limited at best. For example, asking it for preg_split copies the first example from the manual entry, but fails to recognize the newline and messes things up:

机器人可以提供的知识最多是有限的。 例如,要求它preg_split复制了手动输入中的第一个示例,但无法识别换行符并弄乱了内容:

Preg split PHPBot response

Magic methods don’t seem to be supported:

似乎不支持魔术方法:

PHPBot's response to __toString

And some queries will just fail, purely because there’s no example in the manual that the bot can find:

而且某些查询只会失败,这纯粹是因为机器人没有找到可以在该手册中找到的示例:

PHPBot's response to exec

自动完成/建议 (Autocompletion / Suggestion)

For the queries it doesn’t recognize, or for those a user had just started typing, it would be nice to have some kind of autocomplete or autocorrect dropdown – or at the very least, when asking for the wrong thing, the bot should be able to infer what we meant and suggest that. For example, preg_split which is identical to explode only it uses regex to split a string is quite stupidly named, and the bot recognizing this when we ask for preg_explode would be a great feature addition.

对于无法识别的查询,或者对于刚刚开始输入用户的查询,最好具有某种自动完成或自动更正的下拉菜单-至少,在要求输入错误内容时,机器人应能够推断出我们的意思并提出建议。 例如, preg_splitexplode完全相同,只是它使用正则表达式来拆分字符串而被愚蠢地命名,并且当我们要求preg_explode时,识别该错误的机器人将是一个很好的功能。

preg_explode produces nothing useful in PHPBot

复制/粘贴友好 (Copy / Paste Friendliness)

The snippets the bot returns are just code-highlighted blocks of text, but they’re not very copy-paste friendly. The lines don’t wrap either, so you’re never sure what you’re copying, and the bot sometimes misformats an example and messes up new lines, making it even less paste-friendly:

机器人返回的代码片段只是代码突出显示的文本块,但它们对复制粘贴并不友好。 这些行也不会换行,因此您永远不确定要复制的内容,并且该漫游器有时会错误格式化示例并弄乱新行,从而使其对粘贴的友好程度降低:

Broken newlines in returned example

A standardized shape of returned data would benefit the project considerably. A PSR-2 formatted plain-text output comes to mind as something cross-platform friendly which could then be consumed by any custom-made client (see API below).

返回数据的标准化形状将使项目受益匪浅。 考虑到PSR-2格式的纯文本输出是跨平台友好的,任何定制的客户端都可以使用它(请参阅下面的API)。

API (API)

The app as-is provides no API access, so it can only be used in a separate tab / browser. In an era where we all have over 20 tabs open at any one given time while working, yet another one isn’t exactly too useful – it’d work much better as a browser extension, really, but even better if it had an API.

应用程序原样不提供API访问权限,因此只能在单独的标签/浏览器中使用。 在这个时代,我们每个人在工作时都会在任何时候打开20多个标签,而另一个标签并不是完全有用–它确实可以作为浏览器扩展更好地工作,但是如果拥有一个API,效果会更好。

Being able to implement it with any third party tool, client, or IDE would actually be quite exciting, and would significantly augment tools like class templates and code snippets in IDEs like PhpStorm!

能够使用任何第三方工具,客户端或IDE实施它实际上会非常令人兴奋,并且将大大增强诸如PhpStorm之类的IDE中的类模板和代码段之类的工具!

源代码 (Source Code)

Right now, PHPBot is closed source. I assume this is because it was quickly hacked up and is little more than a crawler which grabs the relevant example from a queried method, if it can find one. That’s understandable, but I would encourage the author to clean up the code and open source it as soon as possible so that we as a community can dig in and make it do things the author didn’t think of.

目前,PHPBot是封闭源。 我认为这是因为它很快就被黑客入侵,并且只不过是一个爬网程序,它可以从查询的方法中获取相关示例,如果可以找到的话。 这是可以理解的,但是我鼓励作者清理代码并尽快将其开源,以使我们作为一个社区能够进行挖掘,并使它做作者未曾想到的事情。

结论 (Conclusion)

PHPBot, while less a bot and more an “interactive” search field for the PHP manual with examples, has a limited scope of use. Right now, its knowledgebase is minute, and the examples within are less than useful. It’s a cute experiment, but little more than that.

PHPBot虽然不是bot,而是带有示例PHP手册的“交互式”搜索字段,但其使用范围有限。 现在,它的知识库很小,而且其中的示例还没有用。 这是一个可爱的实验,但仅此而已。

At this point in time, I’d sooner recommend a thing like DevDocs which contains the full manual and works offline, thus being extra fast. PHPBot does show potential as an interesting tool / experiment, but won’t realize that potential until it opens up its source code and allows people to contribute example code to generate, and APIs to implement its responses in traditional chatbots that can be integrated with CLI tools, IDEs, and maybe even IM application clients – then, having an interactive, responsive, user-upgradeable manual that can be fully integrated with one’s local tool will become a game-changer.

在这个时候,我会尽快推荐像DevDocs这样的东西,它包含完整的手册并且可以脱机工作,因此速度更快。 PHPBot确实显示了作为一种有趣的工具/实验的潜力,但是直到它开放其源代码并允许人们贡献示例代码来生成,并且API可以在可与CLI集成的传统聊天机器人中实现其响应之前,PHPBot才意识到这种潜力。工具,IDE,甚至IM应用程序客户端,然后具有交互式,响应式,用户可升级的手册,可以与自己的本地工具完全集成,将改变游戏规则。

It should be noted that the app is in beta right now, and that the author intends to take it much further. I had spoken to him on Twitter, where he’s very open to feature requests and feedback, so go give him some!

应当指出,该应用程序目前处于测试阶段,作者打算将其进一步扩展。 我已经在Twitter上与他交谈过,他很开放以接受功能请求和反馈,所以请给他一些!

Did you check it out? What did you think?

你检查了吗? 你觉得呢?

翻译自: https://www.sitepoint.com/phpbot-can-php-bot-help-look-documentation-faster/

gt-bot

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值