You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2011/01/25 14:39:48 UTC
svn commit: r1063274 - in
/incubator/opennlp/trunk/opennlp-uima/src/main/java/opennlp/uima:
parser/Parser.java tokenize/TokenizerModelResource.java
Author: joern
Date: Tue Jan 25 13:39:48 2011
New Revision: 1063274
URL: http://svn.apache.org/viewvc?rev=1063274&view=rev
Log:
OPENLP-24 Formated code to comply with conventions
Modified:
incubator/opennlp/trunk/opennlp-uima/src/main/java/opennlp/uima/parser/Parser.java
incubator/opennlp/trunk/opennlp-uima/src/main/java/opennlp/uima/tokenize/TokenizerModelResource.java
Modified: incubator/opennlp/trunk/opennlp-uima/src/main/java/opennlp/uima/parser/Parser.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-uima/src/main/java/opennlp/uima/parser/Parser.java?rev=1063274&r1=1063273&r2=1063274&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-uima/src/main/java/opennlp/uima/parser/Parser.java (original)
+++ incubator/opennlp/trunk/opennlp-uima/src/main/java/opennlp/uima/parser/Parser.java Tue Jan 25 13:39:48 2011
@@ -88,21 +88,21 @@ public class Parser extends CasAnnotator
String tokenList[] = new String[tokens.length];
for (int i = 0; i < tokens.length; i++) {
- String tokenString = tokens[i].getCoveredText(sentence).toString();
- String escapedToken = escape(tokenString);
- tokenList[i] = escapedToken;
-
- int escapedStart = sentenceStringBuilder.length();
- int start = tokens[i].getStart();
- mIndexMap.put(new Integer(escapedStart), new Integer(start));
-
- int escapedEnd = escapedStart + escapedToken.length();
- int end = tokens[i].getEnd();
- mIndexMap.put(new Integer(escapedEnd), new Integer(end));
-
- sentenceStringBuilder.append(tokenList[i]);
-
- sentenceStringBuilder.append(' ');
+ String tokenString = tokens[i].getCoveredText(sentence).toString();
+ String escapedToken = escape(tokenString);
+ tokenList[i] = escapedToken;
+
+ int escapedStart = sentenceStringBuilder.length();
+ int start = tokens[i].getStart();
+ mIndexMap.put(new Integer(escapedStart), new Integer(start));
+
+ int escapedEnd = escapedStart + escapedToken.length();
+ int end = tokens[i].getEnd();
+ mIndexMap.put(new Integer(escapedEnd), new Integer(end));
+
+ sentenceStringBuilder.append(tokenList[i]);
+
+ sentenceStringBuilder.append(' ');
}
// remove last space
@@ -116,12 +116,12 @@ public class Parser extends CasAnnotator
int start = 0;
for (int i = 0; i < tokenList.length; i++) {
-
- mParseForTagger.insert(new Parse(tokenizedSentence, new Span(start,
- start + tokenList[i].length()),
- opennlp.tools.parser.chunking.Parser.TOK_NODE, 0f, 0));
-
- start += tokenList[i].length() + 1;
+
+ mParseForTagger.insert(new Parse(tokenizedSentence, new Span(start,
+ start + tokenList[i].length()),
+ opennlp.tools.parser.chunking.Parser.TOK_NODE, 0f, 0));
+
+ start += tokenList[i].length() + 1;
}
}
@@ -210,27 +210,26 @@ public class Parser extends CasAnnotator
throws ResourceInitializationException {
super.initialize(context);
-
- this.context = context;
-
+
+ this.context = context;
+
mLogger = context.getLogger();
-
+
if (mLogger.isLoggable(Level.INFO)) {
mLogger.log(Level.INFO, "Initializing the OpenNLP Parser.");
- }
-
+ }
+
ParserModel model;
-
+
try {
- ParserModelResource modelResource =
- (ParserModelResource) context.getResourceObject(UimaUtil.MODEL_PARAMETER);
-
- model = modelResource.getModel();
- }
- catch (ResourceAccessException e) {
- throw new ResourceInitializationException(e);
+ ParserModelResource modelResource = (ParserModelResource) context
+ .getResourceObject(UimaUtil.MODEL_PARAMETER);
+
+ model = modelResource.getModel();
+ } catch (ResourceAccessException e) {
+ throw new ResourceInitializationException(e);
}
-
+
mParser = ParserFactory.create(model);
}
@@ -239,18 +238,18 @@ public class Parser extends CasAnnotator
*/
public void typeSystemInit(TypeSystem typeSystem)
throws AnalysisEngineProcessException {
-
- mSentenceType = AnnotatorUtil.getRequiredTypeParameter(context, typeSystem,
+
+ mSentenceType = AnnotatorUtil.getRequiredTypeParameter(context, typeSystem,
UimaUtil.SENTENCE_TYPE_PARAMETER);
- mTokenType = AnnotatorUtil.getRequiredTypeParameter(context, typeSystem,
+ mTokenType = AnnotatorUtil.getRequiredTypeParameter(context, typeSystem,
UimaUtil.TOKEN_TYPE_PARAMETER);
- mParseType = AnnotatorUtil.getRequiredTypeParameter(context, typeSystem,
+ mParseType = AnnotatorUtil.getRequiredTypeParameter(context, typeSystem,
PARSE_TYPE_PARAMETER);
- mTypeFeature = AnnotatorUtil.getRequiredFeatureParameter(context, mParseType, TYPE_FEATURE_PARAMETER,
- CAS.TYPE_NAME_STRING);
+ mTypeFeature = AnnotatorUtil.getRequiredFeatureParameter(context,
+ mParseType, TYPE_FEATURE_PARAMETER, CAS.TYPE_NAME_STRING);
}
/**
@@ -279,14 +278,13 @@ public class Parser extends CasAnnotator
StringBuilder sentenceStringBuilder = new StringBuilder();
- while (containingTokens.hasNext())
- {
- AnnotationFS token = (AnnotationFS) containingTokens.next();
-
- sentenceStringBuilder.append(token.getCoveredText());
-
- // attention the offsets moves inside the sentence...
- sentenceStringBuilder.append(' ');
+ while (containingTokens.hasNext()) {
+ AnnotationFS token = (AnnotationFS) containingTokens.next();
+
+ sentenceStringBuilder.append(token.getCoveredText());
+
+ // attention the offsets moves inside the sentence...
+ sentenceStringBuilder.append(' ');
}
String sentence = sentenceStringBuilder.toString();
@@ -338,7 +336,7 @@ public class Parser extends CasAnnotator
cas.getIndexRepository().addFS(parseAnnotation);
}
-
+
/**
* Releases allocated resources.
*/
Modified: incubator/opennlp/trunk/opennlp-uima/src/main/java/opennlp/uima/tokenize/TokenizerModelResource.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-uima/src/main/java/opennlp/uima/tokenize/TokenizerModelResource.java?rev=1063274&r1=1063273&r2=1063274&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-uima/src/main/java/opennlp/uima/tokenize/TokenizerModelResource.java (original)
+++ incubator/opennlp/trunk/opennlp-uima/src/main/java/opennlp/uima/tokenize/TokenizerModelResource.java Tue Jan 25 13:39:48 2011
@@ -27,10 +27,10 @@ import org.apache.uima.analysis_engine.A
*/
public interface TokenizerModelResource {
- /**
- * Retrieves the shared model instance.
- *
- * @return
- */
- TokenizerModel getModel();
+ /**
+ * Retrieves the shared model instance.
+ *
+ * @return
+ */
+ TokenizerModel getModel();
}