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/08/24 10:36:07 UTC
svn commit: r1161001 - in
/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools:
chunker/ cmdline/parser/ coref/ coref/mention/ dictionary/ lang/english/
namefind/ ngram/ parser/lang/en/ parser/treeinsert/ postag/ sentdetect/
tokenize/ uti...
Author: joern
Date: Wed Aug 24 08:36:06 2011
New Revision: 1161001
URL: http://svn.apache.org/viewvc?rev=1161001&view=rev
Log:
OPENNLP-264 Code Cleanup: Remove unnecessary casts
Modified:
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/ChunkerME.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTool.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/coref/DiscourseElement.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/dictionary/Dictionary.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/dictionary/Index.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/lang/english/TreebankLinker.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/DictionaryNameFinder.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderEventStream.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameSampleSequenceStream.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/RegexNameFinder.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/ngram/NGramModel.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/lang/en/HeadRules.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/AttachContextGenerator.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/BuildContextGenerator.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/CheckContextGenerator.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/Parser.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/ParserEventStream.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/postag/DefaultPOSContextGenerator.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/postag/POSSampleSequenceStream.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/tokenize/SimpleTokenizer.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/tokenize/TokenSample.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/BeamSearch.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/CountedSet.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/CharacterNgramFeatureGenerator.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/PreviousMapFeatureGenerator.java
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/ChunkerME.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/ChunkerME.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/ChunkerME.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/ChunkerME.java Wed Aug 24 08:36:06 2011
@@ -146,7 +146,7 @@ public class ChunkerME implements Chunke
@Deprecated
public List<String> chunk(List<String> toks, List<String> tags) {
bestSequence =
- beam.bestSequence(toks.toArray(new String[toks.size()]), new Object[] { (String[]) tags.toArray(new String[tags.size()]) });
+ beam.bestSequence(toks.toArray(new String[toks.size()]), new Object[] { tags.toArray(new String[tags.size()]) });
return bestSequence.getOutcomes();
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTool.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTool.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTool.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTool.java Wed Aug 24 08:36:06 2011
@@ -75,7 +75,7 @@ public final class ParserTool implements
int start = 0;
int i=0;
for (Iterator<String> ti = tokens.iterator(); ti.hasNext();i++) {
- String tok = (String) ti.next();
+ String tok = ti.next();
p.insert(new Parse(text, new Span(start, start + tok.length()), AbstractBottomUpParser.TOK_NODE, 0,i));
start += tok.length() + 1;
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/coref/DiscourseElement.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/coref/DiscourseElement.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/coref/DiscourseElement.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/coref/DiscourseElement.java Wed Aug 24 08:36:06 2011
@@ -111,11 +111,11 @@ public abstract class DiscourseElement {
public String toString() {
Iterator<MentionContext> ei = extents.iterator();
- MentionContext ex = (MentionContext) ei.next();
+ MentionContext ex = ei.next();
StringBuffer de = new StringBuffer();
de.append("[ ").append(ex.toText());//.append("<").append(ex.getHeadText()).append(">");
while (ei.hasNext()) {
- ex = (MentionContext) ei.next();
+ ex = ei.next();
de.append(", ").append(ex.toText());//.append("<").append(ex.getHeadText()).append(">");
}
de.append(" ]");
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java Wed Aug 24 08:36:06 2011
@@ -141,7 +141,7 @@ public abstract class AbstractMentionFin
//exclude nps with UCPs inside.
List<Parse> sc = np.getSyntacticChildren();
for (Iterator<Parse> sci = sc.iterator();sci.hasNext();) {
- Parse scp = (Parse) sci.next();
+ Parse scp = sci.next();
if (scp.getSyntacticType().equals("UCP") || scp.getSyntacticType().equals("NX")) {
return;
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/dictionary/Dictionary.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/dictionary/Dictionary.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/dictionary/Dictionary.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/dictionary/Dictionary.java Wed Aug 24 08:36:06 2011
@@ -201,8 +201,7 @@ public class Dictionary implements Itera
public Entry next() {
- StringList tokens = (StringList)
- dictionaryIterator.next();
+ StringList tokens = dictionaryIterator.next();
return new Entry(tokens, new Attributes());
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/dictionary/Index.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/dictionary/Index.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/dictionary/Index.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/dictionary/Index.java Wed Aug 24 08:36:06 2011
@@ -42,7 +42,7 @@ public class Index {
while (tokenLists.hasNext()) {
- StringList tokens = (StringList) tokenLists.next();
+ StringList tokens = tokenLists.next();
for (int i = 0; i < tokens.size(); i++) {
this.tokens.add(tokens.getToken(i));
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/lang/english/TreebankLinker.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/lang/english/TreebankLinker.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/lang/english/TreebankLinker.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/lang/english/TreebankLinker.java Wed Aug 24 08:36:06 2011
@@ -96,7 +96,7 @@ public class TreebankLinker extends Defa
List<Parse> parses = new ArrayList<Parse>();
for (String line=in.readLine();null != line;line = in.readLine()) {
if (line.equals("")) {
- DiscourseEntity[] entities = treebankLinker.getEntities((Mention[]) document.toArray(new Mention[document.size()]));
+ DiscourseEntity[] entities = treebankLinker.getEntities(document.toArray(new Mention[document.size()]));
//showEntities(entities);
new CorefParse(parses,entities).show();
sentenceNumber=0;
@@ -124,7 +124,7 @@ public class TreebankLinker extends Defa
}
}
if (document.size() > 0) {
- DiscourseEntity[] entities = treebankLinker.getEntities((Mention[]) document.toArray(new Mention[document.size()]));
+ DiscourseEntity[] entities = treebankLinker.getEntities(document.toArray(new Mention[document.size()]));
//showEntities(entities);
(new CorefParse(parses,entities)).show();
}
@@ -142,7 +142,7 @@ class CorefParse {
for (int ei=0,en=entities.length;ei<en;ei++) {
if (entities[ei].getNumMentions() > 1) {
for (Iterator<MentionContext> mi = entities[ei].getMentions(); mi.hasNext();) {
- MentionContext mc = (MentionContext) mi.next();
+ MentionContext mc = mi.next();
Parse mentionParse = ((DefaultParse) mc.getParse()).getParse();
parseMap.put(mentionParse,ei+1);
//System.err.println("CorefParse: "+mc.getParse().hashCode()+" -> "+ (ei+1));
@@ -153,7 +153,7 @@ class CorefParse {
public void show() {
for (int pi=0,pn=parses.size();pi<pn;pi++) {
- Parse p = (Parse) parses.get(pi);
+ Parse p = parses.get(pi);
show(p);
System.out.println();
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/DictionaryNameFinder.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/DictionaryNameFinder.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/DictionaryNameFinder.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/DictionaryNameFinder.java Wed Aug 24 08:36:06 2011
@@ -83,7 +83,7 @@ public class DictionaryNameFinder implem
}
}
- return (Span[]) foundNames.toArray(new Span[foundNames.size()]);
+ return foundNames.toArray(new Span[foundNames.size()]);
}
public void clearAdaptiveData() {
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderEventStream.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderEventStream.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderEventStream.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderEventStream.java Wed Aug 24 08:36:06 2011
@@ -102,7 +102,7 @@ public class NameFinderEventStream exten
public static List<Event> generateEvents(String[] sentence, String[] outcomes, NameContextGenerator cg) {
List<Event> events = new ArrayList<Event>(outcomes.length);
for (int i = 0; i < outcomes.length; i++) {
- events.add(new Event((String) outcomes[i], cg.getContext(i, sentence, outcomes,null)));
+ events.add(new Event(outcomes[i], cg.getContext(i, sentence, outcomes,null)));
}
cg.updateAdaptiveData(sentence, outcomes);
@@ -138,7 +138,7 @@ public class NameFinderEventStream exten
public static String[][] additionalContext(String[] tokens, Map<String, String> prevMap) {
String[][] ac = new String[tokens.length][1];
for (int ti=0;ti<tokens.length;ti++) {
- String pt = (String) prevMap.get(tokens[ti]);
+ String pt = prevMap.get(tokens[ti]);
ac[ti][0]="pd="+pt;
}
return ac;
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java Wed Aug 24 08:36:06 2011
@@ -220,13 +220,13 @@ public class NameFinderME implements Tok
List<String> c = bestSequence.getOutcomes();
- contextGenerator.updateAdaptiveData(tokens, (String[]) c.toArray(new String[c.size()]));
+ contextGenerator.updateAdaptiveData(tokens, c.toArray(new String[c.size()]));
int start = -1;
int end = -1;
List<Span> spans = new ArrayList<Span>(tokens.length);
for (int li = 0; li < c.size(); li++) {
- String chunkTag = (String) c.get(li);
+ String chunkTag = c.get(li);
if (chunkTag.endsWith(NameFinderME.START)) {
if (start != -1) {
spans.add(new Span(start, end, extractNameType(chunkTag)));
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameSampleSequenceStream.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameSampleSequenceStream.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameSampleSequenceStream.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameSampleSequenceStream.java Wed Aug 24 08:36:06 2011
@@ -61,7 +61,7 @@ public class NameSampleSequenceStream im
@SuppressWarnings("unchecked")
public Event[] updateContext(Sequence sequence, AbstractModel model) {
- Sequence<NameSample> pss = (Sequence<NameSample>) sequence;
+ Sequence<NameSample> pss = sequence;
TokenNameFinder tagger = new NameFinderME(new TokenNameFinderModel("x-unspecified", model, Collections.<String, Object>emptyMap(), null));
String[] sentence = pss.getSource().getSentence();
String[] tags = NameFinderEventStream.generateOutcomes(tagger.find(sentence), null, sentence.length);
@@ -94,7 +94,7 @@ class NameSampleSequenceIterator impleme
}
public Sequence<NameSample> next() {
- NameSample sample = (NameSample) psi.next();
+ NameSample sample = psi.next();
String sentence[] = sample.getSentence();
String tags[] = NameFinderEventStream.generateOutcomes(sample.getNames(), null, sentence.length);
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/RegexNameFinder.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/RegexNameFinder.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/RegexNameFinder.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/RegexNameFinder.java Wed Aug 24 08:36:06 2011
@@ -70,9 +70,9 @@ public final class RegexNameFinder imple
while (matcher.find()) {
Integer tokenStartIndex =
- (Integer) sentencePosTokenMap.get(matcher.start());
+ sentencePosTokenMap.get(matcher.start());
Integer tokenEndIndex =
- (Integer) sentencePosTokenMap.get(matcher.end());
+ sentencePosTokenMap.get(matcher.end());
if (tokenStartIndex != null && tokenEndIndex != null) {
Span annotation = new Span(tokenStartIndex.intValue(),
@@ -83,7 +83,7 @@ public final class RegexNameFinder imple
}
}
- return (Span[]) annotations.toArray(
+ return annotations.toArray(
new Span[annotations.size()]);
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/ngram/NGramModel.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/ngram/NGramModel.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/ngram/NGramModel.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/ngram/NGramModel.java Wed Aug 24 08:36:06 2011
@@ -94,7 +94,7 @@ public class NGramModel implements Itera
*/
public int getCount(StringList ngram) {
- Integer count = (Integer) mNGrams.get(ngram);
+ Integer count = mNGrams.get(ngram);
if (count == null) {
return 0;
@@ -111,7 +111,7 @@ public class NGramModel implements Itera
*/
public void setCount(StringList ngram, int count) {
- Integer oldCount = (Integer) mNGrams.put(ngram, count);
+ Integer oldCount = mNGrams.put(ngram, count);
if (oldCount == null) {
mNGrams.remove(ngram);
@@ -256,7 +256,7 @@ public class NGramModel implements Itera
for (Iterator<StringList> it = iterator(); it.hasNext();) {
- StringList ngram = (StringList) it.next();
+ StringList ngram = it.next();
int count = getCount(ngram);
@@ -295,7 +295,7 @@ public class NGramModel implements Itera
Dictionary dict = new Dictionary(caseSensitive);
for (Iterator<StringList> it = iterator(); it.hasNext();) {
- dict.put((StringList)it.next());
+ dict.put(it.next());
}
return dict;
@@ -319,7 +319,7 @@ public class NGramModel implements Itera
public Entry next() {
- StringList tokens = (StringList) mDictionaryIterator.next();
+ StringList tokens = mDictionaryIterator.next();
Attributes attributes = new Attributes();
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/lang/en/HeadRules.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/lang/en/HeadRules.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/lang/en/HeadRules.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/lang/en/HeadRules.java Wed Aug 24 08:36:06 2011
@@ -147,7 +147,7 @@ public class HeadRules implements opennl
}
return constituents[constituents.length - 1].getHead();
}
- else if ((hr = (HeadRule) headRules.get(type)) != null) {
+ else if ((hr = headRules.get(type)) != null) {
String[] tags = hr.tags;
int cl = constituents.length;
int tl = tags.length;
@@ -196,10 +196,10 @@ public class HeadRules implements opennl
public void labelGaps(Stack<Constituent> stack) {
if (stack.size() > 4) {
//Constituent con0 = (Constituent) stack.get(stack.size()-1);
- Constituent con1 = (Constituent) stack.get(stack.size()-2);
- Constituent con2 = (Constituent) stack.get(stack.size()-3);
- Constituent con3 = (Constituent) stack.get(stack.size()-4);
- Constituent con4 = (Constituent) stack.get(stack.size()-5);
+ Constituent con1 = stack.get(stack.size()-2);
+ Constituent con2 = stack.get(stack.size()-3);
+ Constituent con3 = stack.get(stack.size()-4);
+ Constituent con4 = stack.get(stack.size()-5);
//System.err.println("con0="+con0.label+" con1="+con1.label+" con2="+con2.label+" con3="+con3.label+" con4="+con4.label);
//subject extraction
if (con1.getLabel().equals("NP") && con2.getLabel().equals("S") && con3.getLabel().equals("SBAR")) {
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/AttachContextGenerator.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/AttachContextGenerator.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/AttachContextGenerator.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/AttachContextGenerator.java Wed Aug 24 08:36:06 2011
@@ -43,7 +43,7 @@ public class AttachContextGenerator exte
private boolean containsPunct(Collection<Parse> puncts, String punct){
if (puncts != null){
for (Iterator<Parse> pi=puncts.iterator();pi.hasNext();) {
- Parse p = (Parse) pi.next();
+ Parse p = pi.next();
if (p.getType().equals(punct)) {
return true;
}
@@ -62,14 +62,14 @@ public class AttachContextGenerator exte
public String[] getContext(Parse[] constituents, int index, List<Parse> rightFrontier, int rfi) {
List<String> features = new ArrayList<String>(100);
int nodeDistance = rfi;
- Parse fn = (Parse) rightFrontier.get(rfi);
+ Parse fn = rightFrontier.get(rfi);
Parse fp = null;
if (rfi+1 < rightFrontier.size()) {
- fp = (Parse) rightFrontier.get(rfi+1);
+ fp = rightFrontier.get(rfi+1);
}
Parse p_1 = null;
if (rightFrontier.size() > 0) {
- p_1 = (Parse) rightFrontier.get(0);
+ p_1 = rightFrontier.get(0);
}
Parse p0 = constituents[index];
Parse p1 = null;
@@ -165,6 +165,6 @@ public class AttachContextGenerator exte
//features.add("noquotematch");
}
}
- return ((String[]) features.toArray(new String[features.size()]));
+ return features.toArray(new String[features.size()]);
}
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/BuildContextGenerator.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/BuildContextGenerator.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/BuildContextGenerator.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/BuildContextGenerator.java Wed Aug 24 08:36:06 2011
@@ -146,7 +146,7 @@ public class BuildContextGenerator exten
features.add(EOS+","+consbop0);
}
- return (String[]) features.toArray(new String[features.size()]);
+ return features.toArray(new String[features.size()]);
}
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/CheckContextGenerator.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/CheckContextGenerator.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/CheckContextGenerator.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/CheckContextGenerator.java Wed Aug 24 08:36:06 2011
@@ -104,7 +104,7 @@ public class CheckContextGenerator exten
surround(p1, 1, type, p1s, features);
surround(p2, 2, type, p2s, features);
- return ((String[]) features.toArray(new String[features.size()]));
+ return features.toArray(new String[features.size()]);
}
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/Parser.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/Parser.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/Parser.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/Parser.java Wed Aug 24 08:36:06 2011
@@ -345,7 +345,7 @@ public class Parser extends AbstractBott
else {
List<Parse> rf = getRightFrontier(p,punctSet);
for (int fi=0,fs=rf.size();fi<fs;fi++) {
- Parse fn = (Parse) rf.get(fi);
+ Parse fn = rf.get(fi);
attachModel.eval(attachContextGenerator.getContext(children, advanceNodeIndex,rf,fi), aprobs);
if (debugOn) {
//List cs = java.util.Arrays.asList(attachContextGenerator.getContext(children, advanceNodeIndex,rf,fi,punctSet));
@@ -371,13 +371,13 @@ public class Parser extends AbstractBott
List<Parse> crf = getRightFrontier(newParse2,punctSet);
Parse updatedNode;
if (attachments[ai] == daughterAttachIndex) {//attach daughter
- updatedNode = (Parse) crf.get(fi);
+ updatedNode = crf.get(fi);
updatedNode.add(advanceNode,headRules);
}
else { //attach sister
Parse psite;
if (fi+1 < crf.size()) {
- psite = (Parse) crf.get(fi+1);
+ psite = crf.get(fi+1);
updatedNode = psite.adjoin(advanceNode,headRules);
}
else {
@@ -388,7 +388,7 @@ public class Parser extends AbstractBott
}
//update spans affected by attachment
for (int ni=fi+1;ni<crf.size();ni++) {
- Parse node = (Parse) crf.get(ni);
+ Parse node = crf.get(ni);
node.updateSpan();
}
//if (debugOn) {System.out.print(ai+"-result: ");newParse2.show();System.out.println();}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/ParserEventStream.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/ParserEventStream.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/ParserEventStream.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/parser/treeinsert/ParserEventStream.java Wed Aug 24 08:36:06 2011
@@ -213,10 +213,10 @@ public class ParserEventStream extends A
Map<Parse, Integer> parents = getNonAdjoinedParent(chunks[ci]);
//try daughters first.
for (int cfi=0;cfi<currentRightFrontier.size();cfi++) {
- Parse frontierNode = (Parse) rightFrontier.get(cfi);
- Parse cfn = (Parse) currentRightFrontier.get(cfi);
+ Parse frontierNode = rightFrontier.get(cfi);
+ Parse cfn = currentRightFrontier.get(cfi);
if (!Parser.checkComplete || !Parser.COMPLETE.equals(cfn.getLabel())) {
- Integer i = (Integer) parents.get(frontierNode);
+ Integer i = parents.get(frontierNode);
if (debug) System.err.println("Looking at attachment site ("+cfi+"): "+cfn.getType()+" ci="+i+" cs="+nonPunctChildCount(cfn)+", "+cfn+" :for "+currentChunks[ci].getType()+" "+currentChunks[ci]+" -> "+parents);
if (attachNode == null && i != null && i.intValue() == nonPunctChildCount(cfn)) {
attachType = Parser.ATTACH_DAUGHTER;
@@ -239,8 +239,8 @@ public class ParserEventStream extends A
}
//try sisters, and generate non-attach events.
for (int cfi=0;cfi<currentRightFrontier.size();cfi++) {
- Parse frontierNode = (Parse) rightFrontier.get(cfi);
- Parse cfn = (Parse) currentRightFrontier.get(cfi);
+ Parse frontierNode = rightFrontier.get(cfi);
+ Parse cfn = currentRightFrontier.get(cfi);
if (attachNode == null && parents.containsKey(frontierNode.getParent())
&& frontierNode.getType().equals(frontierNode.getParent().getType())
){ //&& frontierNode.getParent().getLabel() == null) {
@@ -271,10 +271,10 @@ public class ParserEventStream extends A
if (attachNode != null) {
if (attachType == Parser.ATTACH_DAUGHTER) {
Parse daughter = currentChunks[ci];
- if (debug) System.err.println("daughter attach a="+attachNode.getType()+":"+attachNode+" d="+daughter+" com="+lastChild(chunks[ci], (Parse) rightFrontier.get(attachNodeIndex)));
+ if (debug) System.err.println("daughter attach a="+attachNode.getType()+":"+attachNode+" d="+daughter+" com="+lastChild(chunks[ci], rightFrontier.get(attachNodeIndex)));
attachNode.add(daughter,rules);
daughter.setParent(attachNode);
- if (lastChild(chunks[ci], (Parse) rightFrontier.get(attachNodeIndex))) {
+ if (lastChild(chunks[ci], rightFrontier.get(attachNodeIndex))) {
if (etype == ParserEventTypeEnum.CHECK) {
parseEvents.add(new Event(Parser.COMPLETE, checkContextGenerator.getContext(attachNode,currentChunks,ci,true)));
}
@@ -287,10 +287,10 @@ public class ParserEventStream extends A
}
}
else if (attachType == Parser.ATTACH_SISTER) {
- Parse frontierNode = (Parse) rightFrontier.get(attachNodeIndex);
+ Parse frontierNode = rightFrontier.get(attachNodeIndex);
rightFrontier.set(attachNodeIndex,frontierNode.getParent());
Parse sister = currentChunks[ci];
- if (debug) System.err.println("sister attach a="+attachNode.getType()+":"+attachNode+" s="+sister+" ap="+attachNode.getParent()+" com="+lastChild(chunks[ci], (Parse) rightFrontier.get(attachNodeIndex)));
+ if (debug) System.err.println("sister attach a="+attachNode.getType()+":"+attachNode+" s="+sister+" ap="+attachNode.getParent()+" com="+lastChild(chunks[ci], rightFrontier.get(attachNodeIndex)));
Parse newParent = attachNode.getParent().adjoin(sister,rules);
newParent.setParent(attachNode.getParent());
@@ -299,7 +299,7 @@ public class ParserEventStream extends A
if (attachNode == currentChunks[0]) {
currentChunks[0]= newParent;
}
- if (lastChild(chunks[ci], (Parse) rightFrontier.get(attachNodeIndex))) {
+ if (lastChild(chunks[ci], rightFrontier.get(attachNodeIndex))) {
if (etype == ParserEventTypeEnum.CHECK) {
parseEvents.add(new Event(Parser.COMPLETE, checkContextGenerator.getContext(newParent,currentChunks,ci,true)));
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/postag/DefaultPOSContextGenerator.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/postag/DefaultPOSContextGenerator.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/postag/DefaultPOSContextGenerator.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/postag/DefaultPOSContextGenerator.java Wed Aug 24 08:36:06 2011
@@ -190,7 +190,7 @@ public class DefaultPOSContextGenerator
e.add("nn=" + nextnext);
}
}
- String[] contexts = (String[]) e.toArray(new String[e.size()]);
+ String[] contexts = e.toArray(new String[e.size()]);
if (contextsCache != null) {
contextsCache.put(cacheKey,contexts);
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/postag/POSSampleSequenceStream.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/postag/POSSampleSequenceStream.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/postag/POSSampleSequenceStream.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/postag/POSSampleSequenceStream.java Wed Aug 24 08:36:06 2011
@@ -52,7 +52,7 @@ public class POSSampleSequenceStream imp
@SuppressWarnings("unchecked")
public Event[] updateContext(Sequence sequence, AbstractModel model) {
- Sequence<POSSample> pss = (Sequence<POSSample>) sequence;
+ Sequence<POSSample> pss = sequence;
POSTagger tagger = new POSTaggerME(new POSModel("x-unspecified", model, null, null));
String[] sentence = pss.getSource().getSentence();
String[] tags = tagger.tag(pss.getSource().getSentence());
@@ -83,7 +83,7 @@ class POSSampleSequenceIterator implemen
}
public Sequence<POSSample> next() {
- POSSample sample = (POSSample) psi.next();
+ POSSample sample = psi.next();
String sentence[] = sample.getSentence();
String tags[] = sample.getTags();
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java Wed Aug 24 08:36:06 2011
@@ -148,7 +148,7 @@ public class DefaultSDContextGenerator i
collectFeatures(prefix,suffix,previous,next);
String[] context = new String[collectFeats.size()];
- context = (String[]) collectFeats.toArray(context);
+ context = collectFeats.toArray(context);
collectFeats.clear();
return context;
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java Wed Aug 24 08:36:06 2011
@@ -244,7 +244,7 @@ public class SentenceDetectorME implemen
public double[] getSentenceProbabilities() {
double[] sentProbArray = new double[sentProbs.size()];
for (int i = 0; i < sentProbArray.length; i++) {
- sentProbArray[i] = ((Double) sentProbs.get(i)).doubleValue();
+ sentProbArray[i] = sentProbs.get(i).doubleValue();
}
return sentProbArray;
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/tokenize/SimpleTokenizer.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/tokenize/SimpleTokenizer.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/tokenize/SimpleTokenizer.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/tokenize/SimpleTokenizer.java Wed Aug 24 08:36:06 2011
@@ -83,7 +83,7 @@ public class SimpleTokenizer extends Abs
if (charType != CharacterEnum.WHITESPACE) {
tokens.add(new Span(start, sl));
}
- return (Span[]) tokens.toArray(new Span[tokens.size()]);
+ return tokens.toArray(new Span[tokens.size()]);
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/tokenize/TokenSample.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/tokenize/TokenSample.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/tokenize/TokenSample.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/tokenize/TokenSample.java Wed Aug 24 08:36:06 2011
@@ -193,7 +193,7 @@ public class TokenSample {
}
}
- return new TokenSample(untaggedSampleString.toString(), (Span[]) realTokenSpans.toArray(
+ return new TokenSample(untaggedSampleString.toString(), realTokenSpans.toArray(
new Span[realTokenSpans.size()]));
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/BeamSearch.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/BeamSearch.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/BeamSearch.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/BeamSearch.java Wed Aug 24 08:36:06 2011
@@ -119,9 +119,9 @@ public class BeamSearch<T> {
int sz = Math.min(size, prev.size());
for (int sc = 0; prev.size() > 0 && sc < sz; sc++) {
- Sequence top = (Sequence) prev.extract();
+ Sequence top = prev.extract();
List<String> tmpOutcomes = top.getOutcomes();
- String[] outcomes = (String[]) tmpOutcomes.toArray(new String[tmpOutcomes.size()]);
+ String[] outcomes = tmpOutcomes.toArray(new String[tmpOutcomes.size()]);
String[] contexts = cg.getContext(i, sequence, outcomes, additionalContext);
double[] scores;
if (contextsCache != null) {
@@ -180,7 +180,7 @@ public class BeamSearch<T> {
Sequence[] topSequences = new Sequence[numSeq];
for (int seqIndex = 0; seqIndex < numSeq; seqIndex++) {
- topSequences[seqIndex] = (Sequence) prev.extract();
+ topSequences[seqIndex] = prev.extract();
}
return topSequences;
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/CountedSet.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/CountedSet.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/CountedSet.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/CountedSet.java Wed Aug 24 08:36:06 2011
@@ -55,7 +55,7 @@ public class CountedSet<E> implements Se
}
public boolean add(E o) {
- Integer count = (Integer) cset.get(o);
+ Integer count = cset.get(o);
if ( count == null ) {
cset.put(o, 1);
return true;
@@ -102,7 +102,7 @@ public class CountedSet<E> implements Se
* @return the count of the specified object.
*/
public int getCount(E o) {
- Integer count = (Integer) cset.get(o);
+ Integer count = cset.get(o);
if ( count == null ) {
return 0;
}
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/CharacterNgramFeatureGenerator.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/CharacterNgramFeatureGenerator.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/CharacterNgramFeatureGenerator.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/CharacterNgramFeatureGenerator.java Wed Aug 24 08:36:06 2011
@@ -52,7 +52,7 @@ public class CharacterNgramFeatureGenera
for (Iterator<StringList> it = model.iterator(); it.hasNext();) {
- StringList tokenList = (StringList) it.next();
+ StringList tokenList = it.next();
if (tokenList.size() > 0) {
features.add("ng=" + tokenList.getToken(0).toLowerCase());
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/PreviousMapFeatureGenerator.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/PreviousMapFeatureGenerator.java?rev=1161001&r1=1161000&r2=1161001&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/PreviousMapFeatureGenerator.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/PreviousMapFeatureGenerator.java Wed Aug 24 08:36:06 2011
@@ -29,7 +29,7 @@ public class PreviousMapFeatureGenerator
private Map<String, String> previousMap = new HashMap<String, String>();
public void createFeatures(List<String> features, String[] tokens, int index, String[] preds) {
- features.add("pd=" + (String) previousMap.get(tokens[index]));
+ features.add("pd=" + previousMap.get(tokens[index]));
}
/**