gleitz / howdoi

instant coding answers via the command line
http://blog.gleitzman.com/post/43330157197/howdoi-instant-coding-answers-via-the-command-line
MIT License
10.61k stars 869 forks source link

Add method to detect symbols like +, /, etc. in the queries #485

Open SudhakarKuma opened 1 year ago

SudhakarKuma commented 1 year ago

Description

Add some method to detect symbols in the query. Let us say, we want to know how to use + sign to concatenate two strings. To know this, one can pass queries, like

At present, the outputs for these two are as shown below:

> howdoi use + concat strings
+
> howdoi use plus concat strings
public class Concat {
    String cat(String a, String b) {
        a += b;
        return a;
    }
}

Additional Comments (if any)

Similarly, the results vary significantly for queries like howdoi a divide b, howdoi a / b, etc.

Have you read the Contributing Guidelines on Pull Requests on mkdocs?

Yes

SudhakarKuma commented 1 year ago

I can take this up and submit a PR, if the developers feel that this issue has some merit. @gleitz

gleitz commented 1 year ago

This is interesting. It looks like the search engine gives different results.

~ » howdoi use + concat strings --link
https://stackoverflow.com/questions/30154541/how-do-i-concatenate-strings
~ » howdoi use plus concat strings --link
https://stackoverflow.com/questions/47605/string-concatenation-concat-vs-operator

How are you thinking of solving the issue?

SudhakarKuma commented 1 year ago

Hi @gleitz , Thank you for your response! From the results, it seems that use plus concat strings fetches better results as compared to use + concat strings. So, I was thinking whether we should replace the symbols by their suitable meanings (in words) at the back end and then, we run the query.

I would be happy to know your take on this.

gleitz commented 1 year ago

This would be the first time we're rewriting queries. I don't know if the impact will be worth the risk of "tampering" with the request.

SudhakarKuma commented 1 year ago

Oh, I see! Any other suggestions by which we can detect symbols in the queries?

gleitz commented 1 year ago

Try playing around with the Google query and see if you can use quotes or something like that to handle it?

SudhakarKuma commented 1 year ago

Sure, I will give it a try and share the findings here.