Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: At the request of #593 #635

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import edu.illinois.cs.cogcomp.core.datastructures.QueryableList;
import edu.illinois.cs.cogcomp.core.datastructures.ViewNames;
import edu.illinois.cs.cogcomp.core.datastructures.textannotation.*;
import edu.illinois.cs.cogcomp.core.utilities.StringUtils;
// import edu.illinois.cs.cogcomp.core.utilities.StringUtils;
import org.apache.commons.lang3.StringUtils;
import edu.illinois.cs.cogcomp.nlp.utilities.POSUtils;
import edu.illinois.cs.cogcomp.nlp.utilities.ParseTreeProperties;
import edu.illinois.cs.cogcomp.nlp.utilities.ParseUtils;
Expand Down Expand Up @@ -581,15 +582,15 @@ public String[] getParentSiblingPhraseNgrams() {

public String getAnnotatedText() {
List<String> tokens = Arrays.asList(s.ta.getTokens());
return StringUtils.join(" ", tokens.subList(0, commaPosition + 1)) + "["
+ StringUtils.join(",", labels) + "] "
+ StringUtils.join(" ", tokens.subList(commaPosition + 1, tokens.size()));
return StringUtils.join(tokens.subList(0, commaPosition + 1), " ") + "["
+ StringUtils.join(labels, ",") + "] "
+ StringUtils.join(tokens.subList(commaPosition + 1, tokens.size()), " ");
}

public String getBayraktarAnnotatedText() {
List<String> tokens = Arrays.asList(s.ta.getTokens());
return StringUtils.join(" ", tokens.subList(0, commaPosition + 1)) + "["
return StringUtils.join(tokens.subList(0, commaPosition + 1), " ") + "["
+ getBayraktarLabel() + "] "
+ StringUtils.join(" ", tokens.subList(commaPosition + 1, tokens.size()));
+ StringUtils.join(tokens.subList(commaPosition + 1, tokens.size()), " ");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import edu.illinois.cs.cogcomp.core.datastructures.textannotation.PredicateArgumentView;
import edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation;
import edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotationUtilities;
import edu.illinois.cs.cogcomp.core.utilities.StringUtils;
// import edu.illinois.cs.cogcomp.core.utilities.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
* Used to group all the commas in a sentence. The commas can then be accessed based on positional
Expand Down Expand Up @@ -238,7 +239,7 @@ public String getAnnotatedText() {
annotatedText += " " + tokens[tokenIdx];
String commaAnnotation = "";
while (commaNum < commas.size() && commas.get(commaNum).commaPosition == tokenIdx) {
commaAnnotation += StringUtils.join(",", commas.get(commaNum).getLabels());
commaAnnotation += StringUtils.join(commas.get(commaNum).getLabels(), ",");
commaNum++;
}
if (commaAnnotation.length() > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,31 @@ public static String now() {

}

public static String join(String separator, Object... objects) {
StringBuilder sb = new StringBuilder();
// public static String join(String separator, Object... objects) {
// StringBuilder sb = new StringBuilder();

for (Object o : objects) {
sb.append(o.toString()).append(separator);
}
return sb.toString().trim();
}
// for (Object o : objects) {
// sb.append(o.toString()).append(separator);
// }
// return sb.toString().trim();
// }

public static String join(String separator, List<String> tokens) {
if (tokens.size() == 1)
return tokens.get(0);
// public static String join(String separator, List<String> tokens) {
// if (tokens.size() == 1)
// return tokens.get(0);

StringBuilder sb = new StringBuilder();
// StringBuilder sb = new StringBuilder();

for (String token : tokens) {
sb.append(token).append(separator);
}
// for (String token : tokens) {
// sb.append(token).append(separator);
// }

return sb.toString().trim();
}
// return sb.toString().trim();
// }

public static String join(String separator, String[] tokens) {
return join(separator, Arrays.asList(tokens));
}
// public static String join(String separator, String[] tokens) {
// return join(separator, Arrays.asList(tokens));
// }

public static String generateUniqueString() {
return UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
package edu.illinois.cs.cogcomp.nlp.corpusreaders.corpusutils;

import edu.illinois.cs.cogcomp.core.datastructures.ViewNames;
import edu.illinois.cs.cogcomp.core.utilities.StringUtils;
// import edu.illinois.cs.cogcomp.core.utilities.StringUtils;
import org.apache.commons.lang3.StringUtils;
import edu.illinois.cs.cogcomp.core.utilities.configuration.Configurator;
import edu.illinois.cs.cogcomp.core.utilities.configuration.Property;
import edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager;
Expand All @@ -24,7 +25,7 @@ public class CorpusSplitConfigurator extends Configurator {
public static final Property DEV_FRACTION = new Property("devFraction", "0.1");
public static final Property TEST_FRACTION = new Property("testFraction", "0.2");
public static final Property VIEWS_TO_CONSIDER = new Property("viewsToConsider",
StringUtils.join(",", new String[]{ViewNames.EVENT_ERE,ViewNames.MENTION_ERE}));
StringUtils.join(new String[]{ViewNames.EVENT_ERE,ViewNames.MENTION_ERE}, ","));


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

import edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent;
import edu.illinois.cs.cogcomp.core.transformers.ITransformer;
import edu.illinois.cs.cogcomp.core.utilities.StringUtils;
// import edu.illinois.cs.cogcomp.core.utilities.StringUtils;
import org.apache.commons.lang3.StringUtils;
import edu.illinois.cs.cogcomp.edison.features.DiscreteFeature;
import edu.illinois.cs.cogcomp.edison.features.Feature;

Expand Down Expand Up @@ -52,7 +53,7 @@ public static <T> Set<Feature> getNgramsOrdered(List<T> list, int ngramLength,
}

}
features.add(DiscreteFeature.create(i + ":" + StringUtils.join("-", strings)));
features.add(DiscreteFeature.create(i + ":" + StringUtils.join(strings, "-")));
}
return features;
}
Expand All @@ -77,7 +78,7 @@ public static <T> Set<Feature> getNgramsUnordered(List<T> list, int ngramLength,
}

}
features.add(DiscreteFeature.create(StringUtils.join("-", strings)));
features.add(DiscreteFeature.create(StringUtils.join(strings, "-")));
}
return features;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

import edu.illinois.cs.cogcomp.core.datastructures.ViewNames;
import edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation;
import edu.illinois.cs.cogcomp.core.utilities.StringUtils;
// import edu.illinois.cs.cogcomp.core.utilities.StringUtils;
import org.apache.commons.lang3.StringUtils;
import edu.illinois.cs.cogcomp.edison.features.Feature;
import edu.illinois.cs.cogcomp.edison.features.factory.BrownClusterFeatureExtractor;
import edu.illinois.cs.cogcomp.edison.utilities.EdisonException;
Expand Down Expand Up @@ -109,7 +110,7 @@ public final void test() {
featArray[i++] = f.toString();

Arrays.sort(featArray);
String actualOutput = StringUtils.join(",", featArray);
String actualOutput = StringUtils.join(featArray, ",");
assertEquals(expectedOutput, actualOutput);
}
}