-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added clone methods to all implementations of the Marking interface. …
…Implementd a common behaviour regarding Set<String> attributes - the Set is always created during the construction and setUris or setTypes methods clear the existing internal Set and add all given Strings. Fixed two small issues inside a single JUnit test.
- Loading branch information
1 parent
a728b57
commit 1b11a41
Showing
16 changed files
with
1,120 additions
and
988 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
/** | ||
* This file is part of NIF transfer library for the General Entity Annotator Benchmark. | ||
* | ||
* NIF transfer library for the General Entity Annotator Benchmark is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* NIF transfer library for the General Entity Annotator Benchmark is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with NIF transfer library for the General Entity Annotator Benchmark. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.aksw.gerbil.transfer.nif; | ||
|
||
/** | ||
* A Marking belongs to a text and could mark a meaning inside the text or a | ||
* topic covered by the whole text. | ||
* | ||
* @author Michael Röder ([email protected]) | ||
* | ||
*/ | ||
public interface Marking { | ||
|
||
@Override | ||
public String toString(); | ||
} | ||
/** | ||
* This file is part of NIF transfer library for the General Entity Annotator Benchmark. | ||
* | ||
* NIF transfer library for the General Entity Annotator Benchmark is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* NIF transfer library for the General Entity Annotator Benchmark is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with NIF transfer library for the General Entity Annotator Benchmark. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.aksw.gerbil.transfer.nif; | ||
|
||
/** | ||
* A Marking belongs to a text and could mark a meaning inside the text or a | ||
* topic covered by the whole text. | ||
* | ||
* @author Michael Röder ([email protected]) | ||
* | ||
*/ | ||
public interface Marking extends Cloneable { | ||
|
||
@Override | ||
public String toString(); | ||
|
||
public Object clone() throws CloneNotSupportedException; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/org/aksw/gerbil/transfer/nif/ScoredSpan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
246 changes: 127 additions & 119 deletions
246
src/main/java/org/aksw/gerbil/transfer/nif/data/Annotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,127 @@ | ||
/** | ||
* This file is part of NIF transfer library for the General Entity Annotator Benchmark. | ||
* | ||
* NIF transfer library for the General Entity Annotator Benchmark is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* NIF transfer library for the General Entity Annotator Benchmark is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with NIF transfer library for the General Entity Annotator Benchmark. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.aksw.gerbil.transfer.nif.data; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.aksw.gerbil.transfer.nif.Meaning; | ||
import org.aksw.gerbil.transfer.nif.MeaningEqualityChecker; | ||
|
||
/** | ||
* An Annotation is a meaning which is added to a document. | ||
* | ||
* @author Michael Röder | ||
* | ||
*/ | ||
public class Annotation implements Meaning { | ||
|
||
@Deprecated | ||
protected String uri; | ||
protected Set<String> uris = new HashSet<String>(); | ||
|
||
public Annotation(String uri) { | ||
this.uri = uri; | ||
this.uris.add(uri); | ||
} | ||
|
||
public Annotation(Set<String> uris) { | ||
setUris(uris); | ||
} | ||
|
||
@Deprecated | ||
@Override | ||
public String getUri() { | ||
return uri; | ||
} | ||
|
||
@Deprecated | ||
@Override | ||
public void setUri(String uri) { | ||
this.uri = uri; | ||
this.uris.clear(); | ||
this.uris.add(uri); | ||
} | ||
|
||
@Override | ||
public Set<String> getUris() { | ||
return uris; | ||
} | ||
|
||
@Override | ||
public void setUris(Set<String> uris) { | ||
this.uris = uris; | ||
if (uris.size() > 0) { | ||
this.uri = uris.iterator().next(); | ||
} else { | ||
this.uri = null; | ||
} | ||
} | ||
|
||
@Override | ||
public void addUri(String uri) { | ||
this.uris.add(uri); | ||
if (this.uri == null) { | ||
this.uri = uri; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean containsUri(String uri) { | ||
return uris.contains(uri); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Annotation [uri=" + Arrays.toString(uris.toArray()) + "]"; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((uris == null) ? 0 : uris.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
Annotation other = (Annotation) obj; | ||
if (uris == null) { | ||
if (other.uris != null) | ||
return false; | ||
} else if (!MeaningEqualityChecker.overlaps(this, other)) | ||
return false; | ||
return true; | ||
} | ||
|
||
} | ||
/** | ||
* This file is part of NIF transfer library for the General Entity Annotator Benchmark. | ||
* | ||
* NIF transfer library for the General Entity Annotator Benchmark is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* NIF transfer library for the General Entity Annotator Benchmark is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with NIF transfer library for the General Entity Annotator Benchmark. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.aksw.gerbil.transfer.nif.data; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.aksw.gerbil.transfer.nif.Meaning; | ||
import org.aksw.gerbil.transfer.nif.MeaningEqualityChecker; | ||
|
||
/** | ||
* An Annotation is a meaning which is added to a document. | ||
* | ||
* @author Michael Röder | ||
* | ||
*/ | ||
public class Annotation implements Meaning { | ||
|
||
@Deprecated | ||
protected String uri; | ||
protected Set<String> uris = new HashSet<String>(); | ||
|
||
public Annotation(String uri) { | ||
this.uri = uri; | ||
this.uris.add(uri); | ||
} | ||
|
||
public Annotation(Set<String> uris) { | ||
setUris(uris); | ||
} | ||
|
||
public Annotation(Annotation annotation) { | ||
setUris(annotation.getUris()); | ||
} | ||
|
||
@Deprecated | ||
@Override | ||
public String getUri() { | ||
return uri; | ||
} | ||
|
||
@Deprecated | ||
@Override | ||
public void setUri(String uri) { | ||
this.uri = uri; | ||
this.uris.clear(); | ||
this.uris.add(uri); | ||
} | ||
|
||
@Override | ||
public Set<String> getUris() { | ||
return uris; | ||
} | ||
|
||
@Override | ||
public void setUris(Set<String> uris) { | ||
this.uris = uris; | ||
if (uris.size() > 0) { | ||
this.uri = uris.iterator().next(); | ||
} else { | ||
this.uri = null; | ||
} | ||
} | ||
|
||
@Override | ||
public void addUri(String uri) { | ||
this.uris.add(uri); | ||
if (this.uri == null) { | ||
this.uri = uri; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean containsUri(String uri) { | ||
return uris.contains(uri); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Annotation [uri=" + Arrays.toString(uris.toArray()) + "]"; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((uris == null) ? 0 : uris.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
Annotation other = (Annotation) obj; | ||
if (uris == null) { | ||
if (other.uris != null) | ||
return false; | ||
} else if (!MeaningEqualityChecker.overlaps(this, other)) | ||
return false; | ||
return true; | ||
} | ||
|
||
@Override | ||
public Object clone() throws CloneNotSupportedException { | ||
return new Annotation(this); | ||
} | ||
} |
Oops, something went wrong.