crossminer / scava

https://eclipse.org/scava/
Eclipse Public License 2.0
18 stars 13 forks source link

Question about API documentation and Q&A posts #340

Closed phkrief closed 5 years ago

phkrief commented 5 years ago

I try to understand how this menu item works. When I select the code: "JSONParser parser = new JSONParser();" I would expect to receive the same list of posts from StackOverflow as if I was searching directly from StackOverflow. It is not really the case. So How should I use this item if I look for example on JSONParser ?

Actually, if I only select JSONParser and ask for "API documentation and Q&A posts" and get the famous error: ;-) image

Any help is welcome Thanks

jdirocco commented 5 years ago

Hi Philippe, The server properly replies with a list of SO ids. The KB deployed to ci3 works: For instance, your request

curl -X POST "http://ci4.castalia.camp:8080/api/recommendation/recommended_API_documentation" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"compilationUnit\": \"JSONParser parser = new JSONParser();\" }"

produces

{
  "recommendationItems": [
    {
      "apiDocumentationLink": "13722549",
      "apiCallRecommendation": null,
      "significance": 9.851954460144043,
      "recommendationType": null,
      "apiFunctionCallFOCUS": null
    },
    {
      "apiDocumentationLink": "10275326",
      "apiCallRecommendation": null,
      "significance": 9.851954460144043,
      "recommendationType": null,
      "apiFunctionCallFOCUS": null
    },
    {
      "apiDocumentationLink": "17729475",
      "apiCallRecommendation": null,
      "significance": 9.851954460144043,
      "recommendationType": null,
      "apiFunctionCallFOCUS": null
    },
    {
      "apiDocumentationLink": "22141521",
      "apiCallRecommendation": null,
      "significance": 9.851954460144043,
      "recommendationType": null,
      "apiFunctionCallFOCUS": null
    },
    {
      "apiDocumentationLink": "272803",
      "apiCallRecommendation": null,
      "significance": 9.657296180725098,
      "recommendationType": null,
      "apiFunctionCallFOCUS": null
    }
  ]
}

SO recommendation results.

ENHANCEMENT: I suggest selecting all the code in the compilation unit (all class code) to get better results: the KB query-builder uses the import section of the class to generate a good query.

phkrief commented 5 years ago

Indeed ! I just tried taking the whole initial code including the import and the results are much more accurate. thx a lot