Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
factchecksnlp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Himadri Kumari
factchecksnlp
Commits
c4597bd1
There was an error fetching the commit references. Please try again later.
Commit
c4597bd1
authored
Jan 16, 2020
by
anirudhash
Browse files
Options
Downloads
Patches
Plain Diff
Working
parent
772f673c
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
SNLP2019_test.tsv
+1
-1
1 addition, 1 deletion
SNLP2019_test.tsv
pom.xml
+24
-1
24 additions, 1 deletion
pom.xml
src/main/java/Annotator.java
+388
-9
388 additions, 9 deletions
src/main/java/Annotator.java
src/main/java/Main.java
+16
-15
16 additions, 15 deletions
src/main/java/Main.java
with
429 additions
and
26 deletions
SNLP2019_test.tsv
+
1
−
1
View file @
c4597bd1
This diff is collapsed.
Click to expand it.
pom.xml
+
24
−
1
View file @
c4597bd1
...
...
@@ -7,6 +7,18 @@
<groupId>
snlp
</groupId>
<artifactId>
factchecker
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
6
</source>
<target>
6
</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
...
...
@@ -14,6 +26,17 @@
<version>
4.3.6
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bytedeco.javacpp-presets/cpython-platform -->
<dependency>
<groupId>
org.bytedeco.javacpp-presets
</groupId>
<artifactId>
cpython-platform
</artifactId>
<version>
3.6-1.4.3
</version>
</dependency>
<dependency>
<groupId>
org.json
</groupId>
<artifactId>
json
</artifactId>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/Annotator.java
+
388
−
9
View file @
c4597bd1
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
//import net.guides.springboot.springbootasyncexample.model.User;
public
class
Annotator
{
Implementation
impl
=
new
Implementation
();
/*
public String getAnnotations(String input) throws IOException {
String endpoint = "https://labs.tib.eu/falcon/api?mode=long";
String endpoint1 = "https://labs.tib.eu/falcon/falcon2/api?mode=long";
...
...
@@ -98,18 +93,35 @@ public class Annotator {
String url = impl.getURL(y);
String content = impl.getPageContent(url);
if(content.equals(""))
{
System.out.println("Content is empty");
}
if(realArr.size() == 0)
{
if(content.contains(relations.toString()))
{
res = "true";
//
}
else {
res = "false";
//
}
}
for(int a=0; a<realArr.size(); a++)
{
String
out
[]
=
content
.
split
(
"\\n"
);
content
=
ifKeyword
(
out
,
relations
.
toString
());
if(content.contains(realArr.get(a)))
{
res = "true";
//
}
else {
res = "false";
//
}
}
...
...
@@ -120,6 +132,15 @@ public class Annotator {
}
else if(y.equals("") && relations.length() == 0)
{
System.out.println("String y is empty and relation is empty false returned");
}
else if(y.equals("") && relations.length() != 0)
{
System.out.println("String y is empty and relation is not empty false returned");
}
...
...
@@ -127,6 +148,7 @@ public class Annotator {
if (res.equals(""))
{
res = "false";
System.out.println("Input is" +input);
}
...
...
@@ -183,5 +205,362 @@ public class Annotator {
// }
// return annotations;
// }
*/
public
String
getAnnotations
(
String
input
)
throws
IOException
{
input
=
input
.
replace
(
":"
,
""
);
input
=
input
.
replace
(
"'s"
,
""
);
input
=
input
.
replace
(
","
,
""
);
input
=
input
.
replace
(
"'"
,
""
);
if
(
input
.
contains
(
"place "
))
{
if
(
input
.
contains
(
"death"
)
)
{
String
[]
spl
=
input
.
split
(
"death place is"
);
String
rtr
=
impl
.
getURL
(
spl
[
0
]);
String
content
=
impl
.
getPageContent
(
rtr
);
String
find
=
spl
[
1
].
replace
(
"."
,
""
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
find
))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"birth"
)
)
{
String
[]
spl
=
input
.
split
(
"birth place is"
);
String
rtr
=
impl
.
getURL
(
spl
[
0
]);
String
content
=
impl
.
getPageContent
(
rtr
);
String
find
=
spl
[
1
].
replace
(
"."
,
""
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
find
))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"last"
)
)
{
String
[]
spl
=
input
.
split
(
"last place is"
);
String
rtr
=
impl
.
getURL
(
spl
[
0
]);
String
content
=
impl
.
getPageContent
(
rtr
);
String
find
=
spl
[
1
].
replace
(
"."
,
""
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
find
))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"foundation"
)
)
{
String
[]
spl
=
input
.
split
(
"foundation place is"
);
String
rtr
=
impl
.
getURL
(
spl
[
0
]);
String
content
=
impl
.
getPageContent
(
rtr
);
String
find
=
spl
[
1
].
replace
(
"."
,
""
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
find
))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"innovation"
)
)
{
String
[]
spl
=
input
.
split
(
"innovation place is"
);
String
rtr
=
impl
.
getURL
(
spl
[
0
]);
String
content
=
impl
.
getPageContent
(
rtr
);
String
find
=
spl
[
1
].
replace
(
"."
,
""
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
find
))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"nascence"
)
)
{
String
[]
spl
=
input
.
split
(
"nascence place is"
);
String
rtr
=
impl
.
getURL
(
spl
[
0
]);
String
content
=
impl
.
getPageContent
(
rtr
);
String
find
=
spl
[
1
].
replace
(
"."
,
""
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
find
))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
}
else
if
(
input
.
contains
(
"place."
))
{
if
(
input
.
contains
(
"place"
))
{
if
(
input
.
contains
(
"death"
)
)
{
input
=
input
.
replace
(
"death place."
,
""
);
String
[]
spl
=
input
.
split
(
" is "
);
String
rtr
=
impl
.
getURL
(
spl
[
1
]);
String
content
=
impl
.
getPageContent
(
rtr
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
spl
[
0
]))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"birth"
)
)
{
input
=
input
.
replace
(
" birth place."
,
""
);
String
[]
spl
=
input
.
split
(
" is "
);
String
rtr
=
impl
.
getURL
(
spl
[
1
]);
String
content
=
impl
.
getPageContent
(
rtr
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
spl
[
0
]))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"last"
)
)
{
input
=
input
.
replace
(
" last place."
,
""
);
String
[]
spl
=
input
.
split
(
" is "
);
String
rtr
=
impl
.
getURL
(
spl
[
1
]);
String
content
=
impl
.
getPageContent
(
rtr
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
spl
[
0
]))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"foundation"
)
)
{
input
=
input
.
replace
(
" foundation place."
,
""
);
String
[]
spl
=
input
.
split
(
" is "
);
String
rtr
=
impl
.
getURL
(
spl
[
1
]);
String
content
=
impl
.
getPageContent
(
rtr
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
spl
[
0
]))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"innovation"
)
)
{
input
=
input
.
replace
(
" innovation place."
,
""
);
String
[]
spl
=
input
.
split
(
" is "
);
String
rtr
=
impl
.
getURL
(
spl
[
1
]);
String
content
=
impl
.
getPageContent
(
rtr
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
spl
[
0
]))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"nascence"
)
)
{
input
=
input
.
replace
(
" nascence place."
,
""
);
String
[]
spl
=
input
.
split
(
" is "
);
String
rtr
=
impl
.
getURL
(
spl
[
1
]);
String
content
=
impl
.
getPageContent
(
rtr
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
spl
[
0
]))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
}
}
else
if
(
input
.
contains
(
"stars is"
))
{
input
=
input
.
replace
(
"."
,
""
);
String
[]
spl
=
input
.
split
(
" stars "
);
String
rtr
=
impl
.
getURL
(
spl
[
0
]);
String
content
=
impl
.
getPageContent
(
rtr
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
spl
[
1
]))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"team is"
))
{
input
=
input
.
replace
(
"."
,
""
);
String
[]
spl
=
input
.
split
(
" team is "
);
String
rtr
=
impl
.
getURL
(
spl
[
0
]);
String
content
=
impl
.
getPageContent
(
rtr
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
spl
[
1
]))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"award is"
))
{
input
=
input
.
replace
(
"."
,
""
);
String
[]
spl
=
input
.
split
(
" award is "
);
String
rtr
=
impl
.
getURL
(
spl
[
0
]);
String
content
=
impl
.
getPageContent
(
rtr
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
spl
[
1
]))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"subsidiary is"
))
{
input
=
input
.
replace
(
"."
,
""
);
String
[]
spl
=
input
.
split
(
" subsidiary is "
);
String
rtr
=
impl
.
getURL
(
spl
[
0
]);
String
content
=
impl
.
getPageContent
(
rtr
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
spl
[
1
]))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
if
(
input
.
contains
(
"spouse is"
))
{
input
=
input
.
replace
(
"."
,
""
);
String
[]
spl
=
input
.
split
(
" spouse is "
);
String
rtr
=
impl
.
getURL
(
spl
[
0
]);
String
content
=
impl
.
getPageContent
(
rtr
);
content
=
content
.
replaceAll
(
"[^aA-zZ\\s]"
,
""
);
content
=
content
.
replace
(
"["
,
""
);
content
=
content
.
replace
(
"]"
,
""
);
if
(
content
.
contains
(
spl
[
1
]))
{
return
"true"
;
}
else
{
return
"false"
;
}
}
else
{
return
"false"
;
}
return
""
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/Main.java
+
16
−
15
View file @
c4597bd1
import
java.io.*
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Path
;
...
...
@@ -9,11 +8,13 @@ public class Main {
public
static
void
main
(
String
args
[])
throws
IOException
{
BufferedWriter
out
;
System
.
out
.
println
(
"Hi"
);
Path
currentPath
=
Paths
.
get
(
""
);
String
filepath
=
currentPath
.
toAbsolutePath
().
toString
();
filepath
=
filepath
+
File
.
separator
+
"result.ttl"
;
filepath
=
filepath
+
File
.
separator
+
"result
6
.ttl"
;
File
file1
=
new
File
(
filepath
);
file1
.
getParentFile
().
mkdirs
();
file1
.
createNewFile
();
...
...
@@ -21,7 +22,6 @@ public class Main {
Writer
writer
=
new
BufferedWriter
(
new
OutputStreamWriter
(
new
FileOutputStream
(
filepath
),
StandardCharsets
.
UTF_8
));
Annotator
at
=
new
Annotator
();
//at.getAnnotations();
File
file
=
new
File
(
"SNLP2019_test.tsv"
);
BufferedReader
br
=
new
BufferedReader
(
new
FileReader
(
file
));
...
...
@@ -36,26 +36,27 @@ public class Main {
id
.
add
(
inp
[
0
]);
}
for
(
int
i
=
1
;
i
<
input
.
size
();
i
++)
{
for
(
int
i
=
1
;
i
<
input
.
size
();
i
++)
{
String
res
=
at
.
getAnnotations
(
input
.
get
(
i
));
System
.
out
.
println
(
"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"
+
res
);
if
(
res
==
"true"
)
{
if
(
res
==
"true"
)
{
//writer1.write(id.get(y) + "\t" + input.get(y) + "\t" + 1.0 + "\n");
String
str
=
"<http://swc2017.aksw.org/task2/dataset/"
+
id
.
get
(
i
)
+
"><http://swc2017.aksw.org/hasTruthValue>\"1.0\"^^<http://www.w3.org/2001/XMLSchema#double> ."
+
"\n"
;
writer
.
write
(
"<http://swc2017.aksw.org/task2/dataset/"
+
id
.
get
(
i
)
+
"><http://swc2017.aksw.org/hasTruthValue>\"1.0\"^^<http://www.w3.org/2001/XMLSchema#double> ."
+
"\n"
);
}
else
{
String
str1
=
"<http://swc2017.aksw.org/task2/dataset/"
+
id
.
get
(
i
)
+
"><http://swc2017.aksw.org/hasTruthValue>\"1.0\"^^<http://www.w3.org/2001/XMLSchema#double> ."
+
"\n"
;
}
else
{
String
str1
=
"<http://swc2017.aksw.org/task2/dataset/"
+
id
.
get
(
i
)
+
"><http://swc2017.aksw.org/hasTruthValue>\"0.0\"^^<http://www.w3.org/2001/XMLSchema#double> ."
+
"\n"
;
writer
.
write
(
"<http://swc2017.aksw.org/task2/dataset/"
+
id
.
get
(
i
)
+
"><http://swc2017.aksw.org/hasTruthValue>\"0.0\"^^<http://www.w3.org/2001/XMLSchema#double> ."
+
"\n"
);
}
}
writer
.
close
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment