dthree / wat

Instant, central, community-built docs
MIT License
495 stars 25 forks source link

"Language?", or some sort of clarity engine #12

Closed Qix- closed 9 years ago

Qix- commented 9 years ago

I could see this having a huge impact on other languages, such as C (for instance). Yes, man pages help, but are sometimes much more than what you need (i.e. the common example you use of argument order, etc.).


If I do wat printf, I'm going to get a few different results for a few different languages. Likewise, if I do wat println, I might get a few different options for clarification.

What would be cool to see in Wat is an engine for determining what result the user is most likely looking for, and filling in any missing pieces through continued prompt(s).

For instance, when I do type printf and there are are a few languages - c and php, namely - wat would ask Language?, in which I could respond c.

Further, for the REPL version, it might even be useful to specify what language(s) you're looking for. If I'm a C/JS developer, I will literally never be looking for PHP information. lang c, js or some similar command would be a hint to the clarity engine that I'm going to be looking for language results in either c or js (javascript).

This would be an incredible tool in my arsenal.

dthree commented 9 years ago

Great idea!

This should be pretty straightforward: Wat already tracks your command history, and, for example, if you've recently asked for 3 or more commands from a particular language or lib, it'll download all the markdown locally for that language in the background so there's no latency in future commands.

How about this:

When a user types in invalid command, I parse the index, find all partial matches, scoring them based on two-word matches, etc. etc.

I then weight the scoring by a priority scoring on the languages you use most. Any language you've never searched for gets a negative scoring. Then it'll do something like:

? printf

Did you mean:

  1. c printf
  2. ...
  3. ...

Maybe languages that have never been queried get omitted entirely.

Then the user can type:

? 1

And then it will pull up the first option: c printf.

I can also highlight the string matches in yellow background-highlighter or something.

Qix- commented 9 years ago

I wouldn't omit entirely. I probably haven't ever looked up Ruby stuff, though if I wanted to learn one day not seeing anything in Wat about Ruby would be discouraging. Score negatively, but include if there are empty spots.

Also, as far as the 1, 2, 3 menu pattern goes, I would discourage it for languages in particular. My reflexes are going to be quicker than to look at a menu when I see Language - my brain is going to realize it's asking for a language disambiguation and type in the language I'm looking for before my eyes even see the menu. :)

dthree commented 9 years ago

Ok no probs.

Almost done with this feature.

BTW, try this:

npm install -g wat wat stackoverflow array concat

:fire:

Qix- commented 9 years ago

First one was a mistake. Second one should have worked :X

screen shot 2015-08-28 at 12 47 09 am
dthree commented 9 years ago

Did you re-install? The version I published 2 hours ago should have it. But wait anyway - I finished the other thing. Let me republish.

Btw you can also type so array concat or stack array concat.

dthree commented 9 years ago

Ok try to install again.

So on this search implementation:

I need more content in order to try out more conflicts, but it's a start.

dthree commented 9 years ago

@Qix- Did that so command ever work for you? If you run another install now, I've got a ton of updates, including the actual topic of this issue :)

Qix- commented 9 years ago

@dthree

screen shot 2015-08-28 at 10 53 06 pm
dthree commented 9 years ago

Ahhhh 1 sec. Not doing another thing on this project until I write tests haha.

dthree commented 9 years ago

@Qix- Ok fixed.

dthree commented 9 years ago

This is handled now. To see how it works now, do;

$ npm install -g wat
$ wat tour