Revision: 27d414e37781
Branch: default
Author: Sebastian Hellmann <
kur...@googlemail.com>
Date: Tue Feb 12 08:59:01 2013
Log: new implementations
http://code.google.com/p/nlp2rdf/source/detail?r=27d414e37781
Added:
/core/nif/src/main/java/org/nlp2rdf/core/urischemes/ContextHashBasedString.java
/core/nif/src/main/java/org/nlp2rdf/core/urischemes/NIFParserException.java
/core/nif/src/main/java/org/nlp2rdf/core/urischemes/OffsetBasedString.java
/core/nif/src/main/java/org/nlp2rdf/core/urischemes/RFC5147String.java
/core/nif/src/main/java/org/nlp2rdf/core/urischemes/URIGeneratorHelper.java
/core/nif/src/main/java/org/nlp2rdf/core/urischemes/URIScheme.java
Deleted:
/core/nif/src/main/java/org/nlp2rdf/core/util/URIGeneratorHelper.java
Modified:
/core/nif/src/main/java/org/nlp2rdf/core/impl/MD5Based.java
/core/nif/src/main/java/org/nlp2rdf/core/impl/OffsetBased.java
/implementation/lexo/lexo-webservice/src/main/java/org/nlp2rdf/implementation/lexo/NIFLexo.java
/implementation/lexo/lexo-wrapper/src/main/java/org/nlp2rdf/implementation/lexo/LExOAdditions.java
/implementation/opennlp/opennlp-webservice/src/main/java/org/nlp2rdf/implementation/opennlp/NIFOpenNLP.java
/implementation/opennlp/opennlp-wrapper/src/main/java/org/nlp2rdf/implementation/opennlp/OpenNLPWrapper.java
/implementation/snowball/snowball-webservice/src/main/java/org/nlp2rdf/implementation/snowball/NIFStemmer.java
/implementation/snowball/snowball-wrapper/src/main/java/org/nlp2rdf/implementation/snowball/SnowballStemmer.java
/implementation/stanford-core/stanford-core-webservice/src/main/java/org/nlp2rdf/implementation/stanfordcore/NIFStanfordCore.java
/implementation/stanford-core/stanford-core-wrapper/src/main/java/org/nlp2rdf/implementation/stanfordcore/StanfordCoreNLPWrapper.java
/implementation/stanford-core/stanford-core-wrapper/src/test/java/org/nlp2rdf/implementation/stanfordcore/StanfordTest.java
=======================================
--- /dev/null
+++
/core/nif/src/main/java/org/nlp2rdf/core/urischemes/ContextHashBasedString.java
Tue Feb 12 08:59:01 2013
@@ -0,0 +1,178 @@
+package org.nlp2rdf.core.urischemes;
+
+import com.jamonapi.Monitor;
+import com.jamonapi.MonitorFactory;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.nlp2rdf.core.Span;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * User: hellmann
+ * Date: 12.02.13
+ */
+public class ContextHashBasedString implements URIScheme {
+
+ private static final Logger log =
LoggerFactory.getLogger(ContextHashBasedString.class);
+ public static final int firstCharLength = 20;
+ public static final int defaultContextLength = 10;
+ public static final String IDENTIFIER = "hash";
+ public static final String BRA = "(";
+ public static final String KET = ")";
+
+ @Override
+ public String getOWLClassURI() {
+ //TODO
+
return "
http://nlp2rdf.lod2.eu/schema/string/ContextHashBasedString";
+ }
+
+ @Override
+ public Span[] parse(String prefix, String uri, String context) throws
NIFParserException {
+ String[] st = uri.substring(prefix.length()).split("_");
+
+ if (st.length < 5) {
+ throw new NIFParserException("Too few parameters in " + uri
+ " expected 5");
+ }
+
+ if (!IDENTIFIER.equals(st[0])) {
+ throw new NIFParserException("Wrong identifier for " +
getOWLClassURI() + " expected " + IDENTIFIER + " found " + st[0] + " in " +
uri);
+ }
+
+ int contextLength = 0;
+ int anchoredPartLength = 0;
+ String digest = null;
+
+ try {
+
+ contextLength = Integer.parseInt(st[1]);
+ anchoredPartLength = Integer.parseInt(st[2]);
+ digest = st[3];
+
+ } catch (NumberFormatException npe) {
+ throw new NIFParserException("The span could not be recognized
correctly for scheme " + getOWLClassURI() + " expected int_int_MD5 ,
found " + st[1] + "_" + st[2] + "_" + st[3], npe);
+ }
+
+ StringBuilder addressedString = new StringBuilder();
+ addressedString.append(st[4]);
+ for (int x = 4; x < st.length; x++) {
+ addressedString.append(st[x]).append("_");
+ }
+
+
+ int offset = 0;
+ int index;
+ ArrayList<Span> spans = new ArrayList<Span>();
+ while ((index = context.indexOf(addressedString.toString(),
offset)) != -1) {
+ StringBuilder message = new StringBuilder();
+
+ Span spanCandidate = new Span(index, index +
anchoredPartLength);
+ //calculate the context boundaries
+
message.append(URIGeneratorHelper.getContextBefore(spanCandidate, context,
contextLength));
+ message.append(BRA);
+ message.append(spanCandidate.getCoveredText(context));
+ message.append(KET);
+
message.append(URIGeneratorHelper.getContextAfter(spanCandidate, context,
contextLength));
+
+ String digestNew = DigestUtils.md5Hex(message.toString());
+ if (digest.equals(digestNew)) {
+ spans.add(spanCandidate);
+ } else {
+ //try the next one
+ offset = index;
+ }
+ }
+ if (spans.isEmpty()) {
+ throw new NIFParserException("Could not calculate spans for
uri " + uri + " of scheme " + getOWLClassURI() + " string not found in
context");
+ }
+ return spans.toArray(new Span[spans.size()]);
+ }
+
+ @Override
+ public String generate(String prefix, String context, Span[] spans) {
+ return generate(prefix, context, spans, defaultContextLength);
+ }
+
+ public String generate(String prefix, String context, Span[] spans,
int contextLength) {
+ if (spans.length != 1) {
+ log.debug(getOWLClassURI() + " scheme only takes the first
span for generation of URIs, but the array contains " + spans.length);
+ }
+ Span span = spans[0];
+ //the substring
+ String anchoredPart = span.getCoveredText(context).toString();
+ StringBuilder message = new StringBuilder();
+ //calculate the context boundaries
+ message.append(URIGeneratorHelper.getContextBefore(span, context,
contextLength));
+ message.append(BRA);
+ message.append(anchoredPart);
+ message.append(KET);
+ message.append(URIGeneratorHelper.getContextAfter(span, context,
contextLength));
+
+ String digest = DigestUtils.md5Hex(message.toString());
+ String firstChars =
URIGeneratorHelper.getFirstCharacters(anchoredPart, firstCharLength);
+ StringBuilder uri = new StringBuilder();
+ uri.append(prefix);
+ uri.append(IDENTIFIER).append("_");
+ uri.append(contextLength).append("_");
+ uri.append(anchoredPart.length()).append("_");
+ uri.append(digest).append("_");
+ uri.append(firstChars);
+
+ if (log.isTraceEnabled()) {
+ log.trace("Text (" + context.length() + " chars): " + context);
+ log.trace("Word (" + span.getCoveredText(context).length() + "
chars): " + span.getCoveredText(context));
+ log.trace("Span: " + span.getStart() + "|" + span.getEnd());
+ //log.trace("Before|After: " + before + "|" + after);
+ log.trace("Context (" + contextLength + ") before: |" +
URIGeneratorHelper.getContextBefore(span, context, contextLength));
+ log.trace("Context (" + contextLength + ") after: |" +
URIGeneratorHelper.getContextAfter(span, context, contextLength) + "|");
+ log.trace("Message: |" + message.toString() + "|");
+ log.trace("URI: " + uri.toString());
+ }
+
+ return uri.toString();
+ }
+
+
+ @Override
+ public boolean validate(String prefix, String uri, String context) {
+ Span[] span = null;
+ try {
+ span = parse(prefix, uri, context);
+ } catch (NIFParserException npe) {
+ return false;
+ }
+
+ if (span.length > 1) {
+ log.warn(uri + "this uri addresses several strings in the
context, validation failed, not unique");
+ return false;
+ }
+
+ return true;
+
+ }
+
+
+ public int calculateMinimalContextLength(String text, Set<Span> spans)
{
+ Monitor mon =
MonitorFactory.getTimeMonitor(this.getClass().getSimpleName()
+ "init").start();
+ int contextLength = 0;
+ contextLength = repeat(text, spans, contextLength);
+
log.info("Minimal context calculated: " + contextLength + "
needed: " + mon.stop().getLastValue() + " ms. ");
+ return contextLength;
+ }
+
+ private int repeat(String text, Set<Span> allSpans, int contextLength)
{
+ Set<String> collision = new HashSet<String>();
+ for (Span span : allSpans) {
+ if (false == collision.add(generate("", text, new
Span[]{span}))) {
+ contextLength++;
+ return repeat(text, allSpans, contextLength);
+ }
+ }
+ return contextLength;
+ }
+
+
+}
=======================================
--- /dev/null
+++
/core/nif/src/main/java/org/nlp2rdf/core/urischemes/NIFParserException.java
Tue Feb 12 08:59:01 2013
@@ -0,0 +1,15 @@
+package org.nlp2rdf.core.urischemes;
+
+/**
+ * User: hellmann
+ * Date: 12.02.13
+ */
+public class NIFParserException extends Exception {
+ public NIFParserException(String message) {
+ super(message);
+ }
+
+ public NIFParserException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
=======================================
--- /dev/null
+++
/core/nif/src/main/java/org/nlp2rdf/core/urischemes/OffsetBasedString.java
Tue Feb 12 08:59:01 2013
@@ -0,0 +1,89 @@
+package org.nlp2rdf.core.urischemes;
+
+import org.nlp2rdf.core.Span;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ */
+public class OffsetBasedString implements URIScheme {
+
+ private static Logger log =
LoggerFactory.getLogger(OffsetBasedString.class);
+ public static final int firstCharLength = 20;
+ public static final String IDENTIFIER = "offset";
+
+ @Override
+ public String getOWLClassURI() {
+ //TODO
+ return "
http://nlp2rdf.lod2.eu/schema/string/OffsetBasedString";
+ }
+
+
+ public String generate(String prefix, String context, Span[] spans) {
+ return generate(prefix, context, spans, false);
+ }
+
+ public String generate(String prefix, String context, Span[] spans,
boolean appendString) {
+ if (spans.length != 1) {
+ log.warn(getOWLClassURI() + " scheme only supports exactly one
span, but the array contains " + spans.length);
+ }
+ //just using the first
+ Span span = spans[0];
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(prefix);
+ sb.append(IDENTIFIER);
+ sb.append("_");
+ sb.append(span.getStart());
+ sb.append("_");
+ sb.append(span.getEnd());
+ if (appendString) {
+ sb.append("_");
+
sb.append(URIGeneratorHelper.getFirstCharacters(span.getCoveredText(context).toString(),
firstCharLength));
+ }
+ log.trace(sb.toString());
+ return sb.toString();
+ }
+
+ @Override
+ public Span[] parse(String prefix, String uri, String context) throws
NIFParserException {
+ String[] st = uri.substring(prefix.length()).split("_");
+ if (!IDENTIFIER.equals(st[0])) {
+ throw new NIFParserException("Wrong identifier for " +
getOWLClassURI() + " expected " + IDENTIFIER + " found " + st[0] + " in " +
uri);
+ }
+ try {
+ return new Span[]{new Span(Integer.parseInt(st[1]),
Integer.parseInt(st[2]))};
+ } catch (NumberFormatException npe) {
+ throw new NIFParserException("The span could not be recognized
correctly for scheme " + getOWLClassURI() + " expected int_int , found " +
st[1] + "_" + st[2]);
+ }
+
+ }
+
+ @Override
+ public boolean validate(String prefix, String uri, String context) {
+ Span span = null;
+ try {
+ span = parse(prefix, uri, context)[0];
+ } catch (NIFParserException npe) {
+ return false;
+ }
+
+ if(context==null){
+ return true;
+ }
+
+ String[] st = uri.substring(prefix.length()).split("_");
+ if (3 <= st.length ) {
+ return true;
+ } else {
+ StringBuilder tmp = new StringBuilder();
+ tmp.append(st[3]);
+ for (int x = 4; x < st.length; x++) {
+ tmp.append(st[x]).append("_");
+ }
+ return tmp.toString().equals(span.getCoveredText(context));
+ }
+
+ }
+
+}
=======================================
--- /dev/null
+++ /core/nif/src/main/java/org/nlp2rdf/core/urischemes/RFC5147String.java
Tue Feb 12 08:59:01 2013
@@ -0,0 +1,99 @@
+package org.nlp2rdf.core.urischemes;
+
+import org.nlp2rdf.core.Span;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * User: hellmann
+ * Date: 12.02.13
+ * RFC 5147:
+ *
http://tools.ietf.org/html/rfc5147#section-3
+ * <p/>
+ * text-fragment = text-scheme 0*( ";" integrity-check )
+ * text-scheme = ( char-scheme / line-scheme )
+ * char-scheme = "char=" ( position / range )
+ * line-scheme = "line=" ( position / range )
+ * integrity-check = ( length-scheme / md5-scheme )
+ * [ "," mime-charset ]
+ * position = number
+ * range = ( position "," [ position ] ) / ( "," position )
+ * number = 1*( DIGIT )
+ * length-scheme = "length=" number
+ * md5-scheme = "md5=" md5-value
+ * md5-value = 32HEXDIG
+ */
+public class RFC5147String implements URIScheme {
+ private static Logger log =
LoggerFactory.getLogger(RFC5147String.class);
+ public static final String charIdentifier = "char=";
+ public static final String lineIdentifier = "line=";
+
+ @Override
+ public String getOWLClassURI() {
+ //TODO
+ return null;
+ }
+
+ @Override
+ public Span[] parse(String prefix, String uri, String context) throws
NIFParserException {
+ //separate the integrity check
+ String[] st = uri.substring(prefix.length()).split(";");
+ String text_scheme = st[0];
+ if (text_scheme.startsWith(charIdentifier)) {
+ try {
+ return new
Span[]{getSpan(text_scheme.substring(charIdentifier.length()), context)};
+ } catch (NumberFormatException nfe) {
+ throw new NIFParserException("URI violates syntax of
scheme " + getOWLClassURI(), nfe);
+ }
+ } else if (text_scheme.startsWith(lineIdentifier)) {
+ //TODO
+ throw new NIFParserException("not implemented yet");
+ } else {
+ throw new NIFParserException("URI violates syntax of scheme "
+ getOWLClassURI());
+ }
+ }
+
+ private Span getSpan(String range, String context) {
+ String[] pos = range.split(",");
+ if (pos[0].isEmpty()) {
+ return new Span(0, Integer.parseInt(pos[1]));
+ } else if (pos[1].isEmpty()) {
+ return new Span(Integer.parseInt(pos[0]), context.length());
+ } else {
+ return new Span(Integer.parseInt(pos[0]),
Integer.parseInt(pos[1]));
+ }
+ }
+
+ @Override
+ public boolean validate(String prefix, String uri, String context) {
+ Span[] span = null;
+ try {
+ span = parse(prefix, uri, context);
+ } catch (NIFParserException npe) {
+ return false;
+ }
+
+ String[] st = uri.substring(prefix.length()).split(";");
+ if (st.length <= 1) {
+ return true;
+ }
+
+ String integrity_check = st[1];
+ //TODO
+ return true;
+
+ }
+
+ @Override
+ public String generate(String prefix, String context, Span[] spans) {
+ if (spans.length != 1) {
+ log.debug(getOWLClassURI() + " scheme only takes the first
span for generation of URIs, but the array contains " + spans.length);
+ }
+ StringBuilder sb = new StringBuilder(prefix);
+ sb.append(charIdentifier);
+ sb.append(spans[0].getStart());
+ sb.append(",");
+ sb.append(spans[0].getEnd());
+ return sb.toString();
+ }
+}
=======================================
--- /dev/null
+++
/core/nif/src/main/java/org/nlp2rdf/core/urischemes/URIGeneratorHelper.java
Tue Feb 12 08:59:01 2013
@@ -0,0 +1,93 @@
+/***************************************************************************/
+/* Copyright (C) 2010-2011, Sebastian Hellmann
*/
+/* Note: If you need parts of NLP2RDF in another licence due to licence
*/
+/* incompatibility, please mail
hell...@informatik.uni-leipzig.de
*/
+/*
*/
+/* This file is part of NLP2RDF.
*/
+/*
*/
+/* NLP2RDF is free software; you can redistribute it and/or modify
*/
+/* it under the terms of the GNU General Public License as published by
*/
+/* the Free Software Foundation; either version 3 of the License, or
*/
+/* (at your option) any later version.
*/
+/*
*/
+/* NLP2RDF 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 General Public License for more details.
*/
+/*
*/
+/* You should have received a copy of the GNU General Public License
*/
+/* along with this program. If not, see <
http://www.gnu.org/licenses/>.
*/
+/***************************************************************************/
+
+package org.nlp2rdf.core.urischemes;
+
+import org.nlp2rdf.core.Span;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+/**
+ * @author Sebastian Hellmann
+ * Created: 29.06.11
+ * <p/>
+ * This class contains static helper methods for handling and
validating a model
+ */
+public class URIGeneratorHelper {
+ private static final Logger log =
LoggerFactory.getLogger(URIGeneratorHelper.class);
+
+
+ public static String join(String[] s, String glue) {
+ int k = s.length;
+ if (k == 0) {
+ return null;
+ }
+ StringBuilder out = new StringBuilder();
+ out.append(s[0]);
+ for (int x = 1; x < k; ++x)
+ out.append(glue).append(s[x]);
+ return out.toString();
+ }
+
+ /**
+ * @param span the span of the addressed String
+ * @param text
+ * @param contextLength
+ * @return
+ */
+ public static String getContextBefore(Span span, String text, int
contextLength) {
+ int before = (span.getStart() - contextLength < 0) ? 0 :
span.getStart() - contextLength;
+ return text.substring(before, span.getStart());
+ }
+
+ /**
+ * @param span the span of the addressed String
+ * @param text
+ * @param contextLength
+ * @return
+ */
+ public static String getContextAfter(Span span, String text, int
contextLength) {
+ int after = (span.getEnd() + contextLength > text.length()) ?
text.length() : span.getEnd() + contextLength;
+ return text.substring(span.getEnd(), after);
+ }
+
+
+ /**
+ * return the first characters of the anchored part urlencoded
+ *
+ * @param anchoredPart
+ * @param firstCharLength
+ * @return
+ */
+ public static String getFirstCharacters(String anchoredPart, int
firstCharLength) {
+ String firstChars = (anchoredPart.length() > firstCharLength) ?
anchoredPart.substring(0, firstCharLength) : anchoredPart;
+ try {
+ firstChars =
URLEncoder.encode(firstChars, "UTF-8").replaceAll("\\+", "%20");
+ } catch (UnsupportedEncodingException e) {
+ log.error("", e);
+ }
+ return firstChars;
+ }
+
+}
=======================================
--- /dev/null
+++ /core/nif/src/main/java/org/nlp2rdf/core/urischemes/URIScheme.java Tue
Feb 12 08:59:01 2013
@@ -0,0 +1,20 @@
+package org.nlp2rdf.core.urischemes;
+
+import org.nlp2rdf.core.Span;
+
+/**
+ * User: hellmann
+ * Date: 12.02.13
+ */
+public interface URIScheme {
+
+ public abstract String getOWLClassURI();
+
+
+ public Span[] parse(String prefix, String uri, String context) throws
NIFParserException;
+
+ public boolean validate(String prefix, String uri, String context);
+
+ public String generate(String prefix, String context, Span[] spans);
+
+}
=======================================
--- /core/nif/src/main/java/org/nlp2rdf/core/util/URIGeneratorHelper.java
Mon Nov 28 00:21:18 2011
+++ /dev/null
@@ -1,128 +0,0 @@
-/***************************************************************************/
-/* Copyright (C) 2010-2011, Sebastian Hellmann
*/
-/* Note: If you need parts of NLP2RDF in another licence due to licence
*/
-/* incompatibility, please mail
hell...@informatik.uni-leipzig.de
*/
-/*
*/
-/* This file is part of NLP2RDF.
*/
-/*
*/
-/* NLP2RDF is free software; you can redistribute it and/or modify
*/
-/* it under the terms of the GNU General Public License as published by
*/
-/* the Free Software Foundation; either version 3 of the License, or
*/
-/* (at your option) any later version.
*/
-/*
*/
-/* NLP2RDF 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 General Public License for more details.
*/
-/*
*/
-/* You should have received a copy of the GNU General Public License
*/
-/* along with this program. If not, see <
http://www.gnu.org/licenses/>.
*/
-/***************************************************************************/
-
-package org.nlp2rdf.core.util;
-
-import com.hp.hpl.jena.ontology.OntModel;
-import eu.lod2.nlp2rdf.schema.str.ContextHashBasedString;
-import eu.lod2.nlp2rdf.schema.str.OffsetBasedString;
-import org.nlp2rdf.core.Span;
-import org.nlp2rdf.core.URIGenerator;
-import org.nlp2rdf.core.impl.MD5Based;
-import org.nlp2rdf.core.impl.OffsetBased;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.security.InvalidParameterException;
-import java.util.*;
-
-/**
- * @author Sebastian Hellmann
- * Created: 29.06.11
- * <p/>
- * This class contains static helper methods for handling and
validating a model
- */
-public class URIGeneratorHelper {
- private static Logger log =
LoggerFactory.getLogger(URIGeneratorHelper.class);
-
-
- @Deprecated
- private static URIGenerator initURIGenerator(String text,
TreeMap<Span, List<Span>> tokenizedText, String uriRecipe) {
- /* URIGenerator uriGenerator =
URIGeneratorHelper.determineGenerator(uriRecipe);
- //calculate the minimal contextlength
- if (uriGenerator instanceof MD5Based) {
- Set<Span> allSpans = new HashSet<Span>();
- //document span
- allSpans.add(new Span(0, text.length()));
- allSpans.addAll(tokenizedText.keySet());
- for (Span key : tokenizedText.keySet()) {
- allSpans.addAll(tokenizedText.get(key));
- }
- //uriGenerator.init(text, allSpans);
- }
- return uriGenerator;
- */
- return null;
- }
-
-
- /**
- * Based on the recipe string as sepicfied the method returns an
urigenerator object
- * default for contextlength should be 10 if client did not provide
anything else
- * @param recipe
- * @param contextLength default is 10 and it is legal to put it here
as a "Magic Number"
- * @return
- */
- public static URIGenerator determineGenerator(String recipe, int
contextLength) {
-
- if (recipe.equalsIgnoreCase("context-hash")) {
- return new MD5Based(contextLength);
- } else if (recipe.equalsIgnoreCase("offset")) {
- return new OffsetBased();
- }
- throw new InvalidParameterException(recipe + " <- recipe not
known ");
-
- }
-
-
- /**
- * @param span the span of the addressed String
- * @param text
- * @param contextLength
- * @return
- */
- public static String getContextBefore(Span span, String text, int
contextLength) {
- int before = (span.getStart() - contextLength < 0) ? 0 :
span.getStart() - contextLength;
- return text.substring(before, span.getStart());
- }
-
- /**
- * @param span the span of the addressed String
- * @param text
- * @param contextLength
- * @return
- */
- public static String getContextAfter(Span span, String text, int
contextLength) {
- int after = (span.getEnd() + contextLength > text.length()) ?
text.length() : span.getEnd() + contextLength;
- return text.substring(span.getEnd(), after);
- }
-
-
- /**
- * return the first characters of the anchored part urlencoded
- *
- * @param anchoredPart
- * @param firstCharLength
- * @return
- */
- public static String getFirstCharacters(String anchoredPart, int
firstCharLength) {
- String firstChars = (anchoredPart.length() > firstCharLength) ?
anchoredPart.substring(0, firstCharLength) : anchoredPart;
- try {
- firstChars =
URLEncoder.encode(firstChars, "UTF-8").replaceAll("\\+", "%20");
- } catch (UnsupportedEncodingException e) {
- log.error("", e);
- }
- return firstChars;
- }
-
-}
=======================================
--- /core/nif/src/main/java/org/nlp2rdf/core/impl/MD5Based.java Tue Aug 7
04:52:52 2012
+++ /core/nif/src/main/java/org/nlp2rdf/core/impl/MD5Based.java Tue Feb 12
08:59:01 2013
@@ -22,7 +22,6 @@
package org.nlp2rdf.core.impl;
import com.hp.hpl.jena.ontology.OntModel;
-import com.hp.hpl.jena.rdf.model.Model;
import com.jamonapi.Monitor;
import com.jamonapi.MonitorFactory;
import eu.lod2.nlp2rdf.schema.str.ContextHashBasedString;
@@ -31,7 +30,7 @@
import org.apache.commons.codec.digest.DigestUtils;
import org.nlp2rdf.core.Span;
import org.nlp2rdf.core.URIGenerator;
-import org.nlp2rdf.core.util.URIGeneratorHelper;
+import org.nlp2rdf.core.urischemes.URIGeneratorHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
=======================================
--- /core/nif/src/main/java/org/nlp2rdf/core/impl/OffsetBased.java Tue Aug
7 04:52:52 2012
+++ /core/nif/src/main/java/org/nlp2rdf/core/impl/OffsetBased.java Tue Feb
12 08:59:01 2013
@@ -22,21 +22,18 @@
package org.nlp2rdf.core.impl;
import com.hp.hpl.jena.ontology.OntModel;
-import eu.lod2.nlp2rdf.schema.str.*;
import org.nlp2rdf.core.Span;
import org.nlp2rdf.core.URIGenerator;
-import org.nlp2rdf.core.util.URIGeneratorHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.String;
import java.security.InvalidParameterException;
-import java.util.Set;
import java.util.StringTokenizer;
/**
* @author Sebastian Hellmann
- * This class implements the NIF Offset URI Scheme.
+ * This class implements the NIF OffsetBasedString URI Scheme.
*
http://nlp2rdf.org/nif-1-0#toc-nif-recipe-offset-based-uris
* calling init() is not necessary
*/
=======================================
---
/implementation/lexo/lexo-webservice/src/main/java/org/nlp2rdf/implementation/lexo/NIFLexo.java
Sat Jan 7 08:23:05 2012
+++
/implementation/lexo/lexo-webservice/src/main/java/org/nlp2rdf/implementation/lexo/NIFLexo.java
Tue Feb 12 08:59:01 2013
@@ -24,8 +24,7 @@
import com.hp.hpl.jena.ontology.OntModel;
import org.nlp2rdf.core.ErrorHandling;
import org.nlp2rdf.core.URIGenerator;
-import org.nlp2rdf.core.util.URIGeneratorHelper;
-import org.nlp2rdf.implementation.stanfordcore.StanfordCoreNLPWrapper;
+import org.nlp2rdf.core.urischemes.URIGeneratorHelper;
import org.nlp2rdf.ontology.ClasspathLoader;
import org.nlp2rdf.ontology.olia.OLiAManager;
import org.nlp2rdf.webservice.NIFParameters;
=======================================
---
/implementation/lexo/lexo-wrapper/src/main/java/org/nlp2rdf/implementation/lexo/LExOAdditions.java
Sun Feb 19 00:59:20 2012
+++
/implementation/lexo/lexo-wrapper/src/main/java/org/nlp2rdf/implementation/lexo/LExOAdditions.java
Tue Feb 12 08:59:01 2013
@@ -25,22 +25,16 @@
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.ModelFactory;
-import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.vocabulary.OWL;
-import edu.stanford.nlp.ling.CoreAnnotations;
import eu.lod2.nlp2rdf.schema.IThing;
import eu.lod2.nlp2rdf.schema.sso.IPhrase;
import eu.lod2.nlp2rdf.schema.sso.IWord;
import eu.lod2.nlp2rdf.schema.sso.Phrase;
import eu.lod2.nlp2rdf.schema.sso.Word;
-import eu.lod2.nlp2rdf.schema.str.IOffsetBasedString;
-import eu.lod2.nlp2rdf.schema.str.IString;
import eu.lod2.nlp2rdf.schema.tools.Factory;
-import org.mindswap.pellet.Individual;
import org.nlp2rdf.core.URIGenerator;
-import org.nlp2rdf.core.impl.OffsetBased;
import org.nlp2rdf.core.util.URIComparator;
-import org.nlp2rdf.core.util.URIGeneratorHelper;
+import org.nlp2rdf.core.urischemes.URIGeneratorHelper;
import org.nlp2rdf.implementation.stanfordcore.StanfordCoreNLPWrapper;
import org.nlp2rdf.ontology.olia.OLiAManager;
import org.slf4j.Logger;
=======================================
---
/implementation/opennlp/opennlp-webservice/src/main/java/org/nlp2rdf/implementation/opennlp/NIFOpenNLP.java
Sun Nov 27 01:46:39 2011
+++
/implementation/opennlp/opennlp-webservice/src/main/java/org/nlp2rdf/implementation/opennlp/NIFOpenNLP.java
Tue Feb 12 08:59:01 2013
@@ -24,7 +24,7 @@
import com.hp.hpl.jena.ontology.OntModel;
import org.nlp2rdf.core.ErrorHandling;
import org.nlp2rdf.core.URIGenerator;
-import org.nlp2rdf.core.util.URIGeneratorHelper;
+import org.nlp2rdf.core.urischemes.URIGeneratorHelper;
import org.nlp2rdf.ontology.ClasspathLoader;
import org.nlp2rdf.ontology.olia.OLiAManager;
import org.nlp2rdf.webservice.NIFParameters;
=======================================
---
/implementation/opennlp/opennlp-wrapper/src/main/java/org/nlp2rdf/implementation/opennlp/OpenNLPWrapper.java
Mon Aug 6 06:55:28 2012
+++
/implementation/opennlp/opennlp-wrapper/src/main/java/org/nlp2rdf/implementation/opennlp/OpenNLPWrapper.java
Tue Feb 12 08:59:01 2013
@@ -28,7 +28,6 @@
import eu.lod2.nlp2rdf.schema.Thing;
import eu.lod2.nlp2rdf.schema.sso.Sentence;
import eu.lod2.nlp2rdf.schema.sso.Word;
-import eu.lod2.nlp2rdf.schema.str.Document;
import eu.lod2.nlp2rdf.schema.tools.Factory;
import opennlp.tools.postag.POSModel;
import opennlp.tools.postag.POSTaggerME;
@@ -36,7 +35,7 @@
import org.nlp2rdf.core.Text2RDF;
import org.nlp2rdf.core.URIGenerator;
import org.nlp2rdf.core.util.URIComparator;
-import org.nlp2rdf.core.util.URIGeneratorHelper;
+import org.nlp2rdf.core.urischemes.URIGeneratorHelper;
import org.nlp2rdf.ontology.olia.OLiAManager;
import org.nlp2rdf.ontology.olia.OLiAOntology;
import org.slf4j.Logger;
=======================================
---
/implementation/snowball/snowball-webservice/src/main/java/org/nlp2rdf/implementation/snowball/NIFStemmer.java
Fri Nov 25 02:12:37 2011
+++
/implementation/snowball/snowball-webservice/src/main/java/org/nlp2rdf/implementation/snowball/NIFStemmer.java
Tue Feb 12 08:59:01 2013
@@ -24,7 +24,7 @@
import com.hp.hpl.jena.ontology.OntModel;
import org.nlp2rdf.core.ErrorHandling;
import org.nlp2rdf.core.URIGenerator;
-import org.nlp2rdf.core.util.URIGeneratorHelper;
+import org.nlp2rdf.core.urischemes.URIGeneratorHelper;
import org.nlp2rdf.webservice.NIFParameters;
import org.nlp2rdf.webservice.NIFServlet;
import org.slf4j.Logger;
=======================================
---
/implementation/snowball/snowball-wrapper/src/main/java/org/nlp2rdf/implementation/snowball/SnowballStemmer.java
Mon Aug 6 06:55:28 2012
+++
/implementation/snowball/snowball-wrapper/src/main/java/org/nlp2rdf/implementation/snowball/SnowballStemmer.java
Tue Feb 12 08:59:01 2013
@@ -25,11 +25,9 @@
import com.hp.hpl.jena.ontology.OntModel;
import eu.lod2.nlp2rdf.schema.sso.StopWord;
import eu.lod2.nlp2rdf.schema.sso.Word;
-import eu.lod2.nlp2rdf.schema.str.Document;
import org.nlp2rdf.core.Span;
import org.nlp2rdf.core.Text2RDF;
import org.nlp2rdf.core.URIGenerator;
-import org.nlp2rdf.core.util.URIGeneratorHelper;
import org.nlp2rdf.implementation.opennlp.OpenNLPTokenizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
=======================================
---
/implementation/stanford-core/stanford-core-webservice/src/main/java/org/nlp2rdf/implementation/stanfordcore/NIFStanfordCore.java
Sun Nov 27 01:46:39 2011
+++
/implementation/stanford-core/stanford-core-webservice/src/main/java/org/nlp2rdf/implementation/stanfordcore/NIFStanfordCore.java
Tue Feb 12 08:59:01 2013
@@ -24,14 +24,12 @@
import com.hp.hpl.jena.ontology.OntModel;
import org.nlp2rdf.core.ErrorHandling;
import org.nlp2rdf.core.URIGenerator;
-import org.nlp2rdf.core.util.URIGeneratorHelper;
+import org.nlp2rdf.core.urischemes.URIGeneratorHelper;
import org.nlp2rdf.ontology.ClasspathLoader;
import org.nlp2rdf.ontology.olia.OLiAManager;
import org.nlp2rdf.webservice.NIFParameters;
import org.nlp2rdf.webservice.NIFServlet;
-import java.security.InvalidParameterException;
-
/**
* @author Sebastian Hellmann
* Created: 29.05.11
=======================================
---
/implementation/stanford-core/stanford-core-wrapper/src/main/java/org/nlp2rdf/implementation/stanfordcore/StanfordCoreNLPWrapper.java
Tue Aug 7 04:52:52 2012
+++
/implementation/stanford-core/stanford-core-wrapper/src/main/java/org/nlp2rdf/implementation/stanfordcore/StanfordCoreNLPWrapper.java
Tue Feb 12 08:59:01 2013
@@ -22,7 +22,6 @@
package org.nlp2rdf.implementation.stanfordcore;
import com.hp.hpl.jena.ontology.*;
-import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
import edu.stanford.nlp.ling.CoreAnnotations.*;
import edu.stanford.nlp.ling.CoreLabel;
@@ -36,12 +35,10 @@
import eu.lod2.nlp2rdf.schema.Thing;
import eu.lod2.nlp2rdf.schema.sso.Phrase;
import eu.lod2.nlp2rdf.schema.sso.Word;
-import eu.lod2.nlp2rdf.schema.str.Document;
import eu.lod2.nlp2rdf.schema.tools.Factory;
import org.nlp2rdf.core.Span;
import org.nlp2rdf.core.Text2RDF;
import org.nlp2rdf.core.URIGenerator;
-import org.nlp2rdf.core.util.URIGeneratorHelper;
import org.nlp2rdf.ontology.olia.OLiAManager;
import org.nlp2rdf.ontology.olia.OLiAOntology;
import org.slf4j.Logger;
=======================================
---
/implementation/stanford-core/stanford-core-wrapper/src/test/java/org/nlp2rdf/implementation/stanfordcore/StanfordTest.java
Sun Nov 27 01:46:39 2011
+++
/implementation/stanford-core/stanford-core-wrapper/src/test/java/org/nlp2rdf/implementation/stanfordcore/StanfordTest.java
Tue Feb 12 08:59:01 2013
@@ -26,8 +26,7 @@
import com.hp.hpl.jena.rdf.model.ModelFactory;
import org.junit.Test;
import org.nlp2rdf.core.URIGenerator;
-import org.nlp2rdf.core.util.URIGeneratorHelper;
-import org.nlp2rdf.implementation.stanfordcore.StanfordCoreNLPWrapper;
+import org.nlp2rdf.core.urischemes.URIGeneratorHelper;
import org.nlp2rdf.ontology.olia.OLiAManager;
/**