crossminer / scava

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

More StackOverFlow posts / recommendations #432

Open phkrief opened 4 years ago

phkrief commented 4 years ago

Hi, Would it be possible to list more SOF posts? For example, we could specify in the preference the max amount of results.

Thanks

creat89 commented 4 years ago

Which recommender are you using?

phkrief commented 4 years ago

Actually, I realize that I don't get the same posts depending on the code. You will say, "Of course!" Unfortunately, for our example, it is a shame.

For example if I ask recommendations on this code:

package openweather.json_simple;

import java.io.IOException;

import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException;

public class App {

static String OpenWeathermapAPI = "http://api.openweathermap.org/data/2.5/weather?q={city}&appid=abbcea2020f75409af198b98de40e3a6";
public static void main(String[] args) throws IOException, ParseException {
    // Parsing of the API result
    JSONParser parser = new JSONParser();
}

}

I don't get the same posts if I add before the code about the URL access:

============= package openweather.json_simple;

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL;

import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException;

public class App {

static String OpenWeathermapAPI = "http://api.openweathermap.org/data/2.5/weather?q={city}&appid=abbcea2020f75409af198b98de40e3a6";

public static void main(String[] args) throws IOException, ParseException {
    // Creation of the REST API
    String city = (args.length != 0)? args[0]:"Toulouse";
    String restAPI = OpenWeathermapAPI.replace("{city}", city);
    URL url = new URL(restAPI);
    // Access to the  REST API
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    con.setRequestMethod("GET");
    con.setConnectTimeout(5000);
    con.setReadTimeout(5000);
    int status = con.getResponseCode();
    if (status == HttpURLConnection.HTTP_OK) {
        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
        try {
            // Parsing of the API result
            JSONParser parser = new JSONParser();
            JSONObject jsonObject = (JSONObject) parser.parse(in);
        } finally {
            in.close();
        }
    }
}

}

creat89 commented 4 years ago

Yes, I got it. But which recommender are you using? The KB has multiple recommenders and only four are created by us, all of them called CROSSIndex (there is one for Java, C, PHP and JavaScript). If you're using other recommenders, those are created by UDA and they are not connected to the Indexes that we generate. UDA decided to create their own indexes with specific dumps of data.

phkrief commented 4 years ago

Oh?! In the present case, I'm calling the recommender used by the Eclipse Plugin when you select the item: "Request API documentation and Q&A posts". Thx

creat89 commented 4 years ago

That's a UDA recommender, so I cannot help you. I'll put Juri as the assigned to the issue.

davidediruscio commented 4 years ago

Yes, that is how SORec works. The import statements also have a role in the selection of SO posts.

Sent with something mobile


From: Philippe Krief notifications@github.com Sent: Saturday, November 23, 2019 8:50:27 PM To: crossminer/scava scava@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: Re: [crossminer/scava] More StackOverFlow posts / recommendations (#432)

Actually, I realize that I don't get the same posts depending on the code. You will say, "Of course!" Unfortunately, for our example, it is a shame.

For example if I ask recommendations on this code:

package openweather.json_simple;

import java.io.IOException;

import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException;

public class App {

static String OpenWeathermapAPI = "http://api.openweathermap.org/data/2.5/weather?q={city}&appid=abbcea2020f75409af198b98de40e3a6"; public static void main(String[] args) throws IOException, ParseException { // Parsing of the API result JSONParser parser = new JSONParser(); }

}

I don't get the same posts if I add before the code about the URL access:

============= package openweather.json_simple;

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL;

import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException;

public class App {

static String OpenWeathermapAPI = "http://api.openweathermap.org/data/2.5/weather?q={city}&appid=abbcea2020f75409af198b98de40e3a6";

public static void main(String[] args) throws IOException, ParseException { // Creation of the REST API String city = (args.length != 0)? args[0]:"Toulouse"; String restAPI = OpenWeathermapAPI.replace("{city}", city); URL url = new URL(restAPI); // Access to the REST API HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); con.setConnectTimeout(5000); con.setReadTimeout(5000); int status = con.getResponseCode(); if (status == HttpURLConnection.HTTP_OK) { BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); try { // Parsing of the API result JSONParser parser = new JSONParser(); JSONObject jsonObject = (JSONObject) parser.parse(in); } finally { in.close(); } } }

}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/crossminer/scava/issues/432?email_source=notifications&email_token=AAPPAEARDLVOWWZ2QHZYQZDQVGCQHA5CNFSM4JQ3SEBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE74NDY#issuecomment-557827727, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAPPAEDU66Z6UMMRWMCZVATQVGCQHANCNFSM4JQ3SEBA.

phkrief commented 4 years ago

@davidediruscio do you mean that StackOverFlow API provides only the 5 first posts of a request? Thanks

creat89 commented 4 years ago

None of the recommenders is connected to StackOverflow API. All, including ours, make use of dumps. I'm sure Davide was referring to other stuff.

phkrief commented 4 years ago

Hi @creat89 , do you mean that the StackOverFlow posts we get come from our KB? If not fro where do they come from if they don't come from a StackOverFlow API? I don't understand what you mean by "dumps"

creat89 commented 4 years ago

Yes, the SO posts come from files that have been processed and indexed by the KB. The KB doesn't connect itself to StackOverflow servers.

And I refer to dumps to the file that every three months more or less the owners of Stack Overflow publish (a huge XML file that contains all the information from SO https://archive.org/details/stackexchange).

davidediruscio commented 4 years ago

Hi Philippe, If you interested in how SORec works internally to produce recommendations, you can refer to chap 7 of D6.5.

phkrief commented 4 years ago

Thx a lot @davidediruscio. I should have done that first, you are right. So I check out the chapter 7 and discovered the Figure 23: The SOrec architecture. I didn't realize/understand that we were filtering, analysing and indexing StackOverFlow. Thx a lot for pointing that. It clarifies things

phkrief commented 4 years ago

So, let's come back to my initial demand. With this information, I don't understand your comment "Yes, that is how SORec works. The import statements also have a role in the selection of SO posts." Are we limited by the number of results? Thx

davidediruscio commented 4 years ago

Hi @phkrief we intentionally limited the results to the most 5 relevant posts. Indeed, we could add more in the results. However, let's keep the possibility of specifying the size of the results as a nice to have feature for the moment. Does it make sense?

jdirocco commented 4 years ago

The number of so results can be set in the configuration file. please have a look at https://github.com/crossminer/scava-deployment/blob/c4e9501f8758ebd47773fce552b487819eaa3d2c/KB/application.properties#L23

davidediruscio commented 4 years ago

@md2manoppello sure I know, but to allow end-users to change that parameter from the Eclipse IDE some more work is needed, which is in my opinion of not high priority for now.

phkrief commented 4 years ago

yes, @davidediruscio and @md2manoppello , it works for me. And I already identified as an enhancement. For me an 'enhancement" means 'nice to have'. Are you OK with that?