Skip to content

Commit

Permalink
completed wiki and dbpedia endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
mithun96 committed May 31, 2018
1 parent 69c4fe7 commit 5f4c7a3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 27,14 @@ public enum ENDPOINT_TYPE
public EndPoint(String data, ENDPOINT_TYPE type_) {
this.setTriples(new ArrayList<Triple>());
this.type = type_;
if (type == ENDPOINT_TYPE.library || type == ENDPOINT_TYPE.dbpedia) {
if (type == ENDPOINT_TYPE.library ) {
try {
this.parser(data);
} catch (Exception e) {
e.printStackTrace();
}
}
else if (type == ENDPOINT_TYPE.lcongress || type == ENDPOINT_TYPE.oclc || type == ENDPOINT_TYPE.wiki ) {
else if (type == ENDPOINT_TYPE.lcongress || type == ENDPOINT_TYPE.oclc || type == ENDPOINT_TYPE.wiki || type == ENDPOINT_TYPE.dbpedia ) {
try {
this.parserText(data);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 43,8 @@ public static String parserDBpedia(String input) throws IOException {

try {
String url = Helper.generate_dbpedia_query(input);
String rawJSON = Helper.query2(url);

Data data = new Data(rawJSON, ENDPOINT_TYPE.dbpedia);
Data data = new Data(url, ENDPOINT_TYPE.dbpedia);
jsonObject = data.constructJSON(input);
}
catch(Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 42,6 @@ public static String query(String url) throws IOException {
return resp.toString();
}

public static String query2(String url) throws IOException {
URL link = new URL(url);

// HttpURLConnection httpLink = (HttpURLConnection) link.openConnection();
// httpLink.setRequestMethod("GET");

// String disposition = httpLink.getHeaderField("Content-Disposition");
// String contentType = httpLink.getContentType();

// StringBuffer resp = new StringBuffer();
// InputStream inputStream = httpLink.getInputStream();


// BufferedReader in = new BufferedReader(new InputStreamReader(httpLink.getInputStream()));
// String inputLine;

// while ((inputLine = in.readLine()) != null) {
// resp.append(inputLine);
// }

// System.out.println("Raw Output: " resp);
// System.out.println();

return "";
}


/* NOTE:
- Generates JSON list of reconciler IDs and author
- Query on the LOC ID
Expand Down Expand Up @@ -119,7 92,7 @@ public static String generate_dbpedia_query(String id) throws IOException {
System.out.println("---- name from DBpedia ------ " name);

/* STEP 2 - get n-triples dataset from foaf:name literal */
return "dbpedia.org/data/" name ".ntriples ";
return "http://dbpedia.org/data/" name ".ntriples ";
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 44,7 @@ public static String parserWiki(String input) throws IOException {
String url = Helper.generate_wiki_query(input);
String url2 = Helper.generate_wikidbpedia_query(input);

String rawJSON = Helper.query2(url);
String rawJSON2 = Helper.query2(url2);

Data data = new Data(url, ENDPOINT_TYPE.wiki);
Data data = new Data(url2, ENDPOINT_TYPE.wiki);
data.addEndPoint(new EndPoint(url2, ENDPOINT_TYPE.wiki));

jsonObject = data.constructJSON(input);
Expand Down

0 comments on commit 5f4c7a3

Please sign in to comment.