Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Huang Xin
xx
Commits
40296faa
Commit
40296faa
authored
Jan 28, 2020
by
XHG3
Browse files
first commit
parents
Changes
6
Hide whitespace changes
Inline
Side-by-side
.classpath
0 → 100644
View file @
40296faa
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-13"
>
<attributes>
<attribute
name=
"module"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
path=
"src"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
.gitignore
0 → 100644
View file @
40296faa
/bin/
.project
0 → 100644
View file @
40296faa
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
OpenData
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.jdt.core.javanature
</nature>
</natures>
</projectDescription>
.settings/org.eclipse.jdt.core.prefs
0 → 100644
View file @
40296faa
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=13
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=13
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=13
src/keyword/dbpedia/lookupTest.java
0 → 100644
View file @
40296faa
package
keyword.dbpedia
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URLEncoder
;
import
java.util.List
;
import
java.util.Map
;
public
class
lookupTest
{
public
static
String
sendGet
(
String
url
,
String
param
)
{
String
result
=
""
;
BufferedReader
in
=
null
;
try
{
String
urlNameString
=
url
+
"?"
+
param
;
URL
realUrl
=
new
URL
(
urlNameString
);
// open url link
URLConnection
connection
=
realUrl
.
openConnection
();
// link setting
connection
.
setRequestProperty
(
"accept"
,
"*/*"
);
connection
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"user-agent"
,
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
);
// connect
connection
.
connect
();
// get connect header
Map
<
String
,
List
<
String
>>
map
=
connection
.
getHeaderFields
();
// printer header list
for
(
String
key
:
map
.
keySet
())
{
System
.
out
.
println
(
key
+
"--->"
+
map
.
get
(
key
));
}
// BufferedReader for get URL
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
result
+=
line
+
"\n"
;
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"get exception!"
+
e
);
e
.
printStackTrace
();
}
// close connection
finally
{
try
{
if
(
in
!=
null
)
{
in
.
close
();
}
}
catch
(
Exception
e2
)
{
e2
.
printStackTrace
();
}
}
return
result
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
lookupTest
httpTest
=
new
lookupTest
();
// String query="query="+URLEncoder.encode("select * where { ?s ?p ?o .} LIMIT 100","UTF-8");
String
QueryString
=
"QueryString="
+
URLEncoder
.
encode
(
"Unmanned vehicle"
,
"UTF-8"
);
// System.out.println(query);
System
.
out
.
println
(
httpTest
.
sendGet
(
"http://lookup.dbpedia.org/api/search.asmx/KeywordSearch"
,
QueryString
));
//System.out.println(URLEncoder.encode("query= select distinct ?Concept where {[] a ?Concept} LIMIT 100","UTF-8"));
}
}
\ No newline at end of file
src/keyword/dbpedia/sparqlTest.java
0 → 100644
View file @
40296faa
package
keyword.dbpedia
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URLEncoder
;
import
java.util.List
;
import
java.util.Map
;
public
class
sparqlTest
{
public
static
String
sendGet
(
String
url
,
String
param
)
{
String
result
=
""
;
BufferedReader
in
=
null
;
try
{
String
urlNameString
=
url
+
"?"
+
param
;
URL
realUrl
=
new
URL
(
urlNameString
);
// open url link
URLConnection
connection
=
realUrl
.
openConnection
();
// link setting
connection
.
setRequestProperty
(
"accept"
,
"*/*"
);
connection
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"user-agent"
,
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
);
// connect
connection
.
connect
();
// get connect header
Map
<
String
,
List
<
String
>>
map
=
connection
.
getHeaderFields
();
// printer header list
for
(
String
key
:
map
.
keySet
())
{
System
.
out
.
println
(
key
+
"--->"
+
map
.
get
(
key
));
}
// BufferedReader for get URL
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
result
+=
line
+
"\n"
;
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"get exception!"
+
e
);
e
.
printStackTrace
();
}
// close connection
finally
{
try
{
if
(
in
!=
null
)
{
in
.
close
();
}
}
catch
(
Exception
e2
)
{
e2
.
printStackTrace
();
}
}
return
result
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
sparqlTest
httpTest
=
new
sparqlTest
();
// String query="query="+URLEncoder.encode("select * where { ?s ?p ?o .} LIMIT 100","UTF-8");
String
query
=
"query="
+
URLEncoder
.
encode
(
"SELECT DISTINCT ?s WHERE {?s ?p ?o. FILTER(REGEX(str(?s), \"MRO\", \"i\"))}"
,
"UTF-8"
);
// System.out.println(query);
System
.
out
.
println
(
httpTest
.
sendGet
(
"http://dbpedia.org/sparql"
,
query
+
"&timeout=30000"
));
//System.out.println(URLEncoder.encode("query= select distinct ?Concept where {[] a ?Concept} LIMIT 100","UTF-8"));
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment