code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public BeanId getFirstReference(final String propertyName) {
List<BeanId> refrences = getReference(propertyName);
if (refrences == null || refrences.size() < 1) {
return null;
}
return refrences.get(0);
} | java |
public static Optional<CacheManager> lookup() {
CacheManager manager = lookup.lookup(CacheManager.class);
if (manager != null) {
return Optional.of(manager);
} else {
return Optional.absent();
}
} | java |
public static String percentEncode(String source) throws AuthException {
try {
return URLEncoder.encode(source, "UTF-8")
.replace("+", "%20")
.replace("*", "%2A")
.replace("%7E", "~");
} catch (UnsupportedEncodingException ex) {
throw new AuthException("cannot encode va... | java |
public static String percentDecode(String source) throws AuthException {
try {
return URLDecoder.decode(source, "UTF-8");
} catch (java.io.UnsupportedEncodingException ex) {
throw new AuthException("cannot decode value '" + source + "'", ex);
}
} | java |
public static <T> T wrapTempFileList(T original, com.aoindustries.io.TempFileList tempFileList, Wrapper<T> wrapper) {
if(tempFileList != null) {
return wrapper.call(original, tempFileList);
} else {
// Warn once
synchronized(tempFileWarningLock) {
if(!tempFileWarned) {
if(logger.isLoggable(Level.W... | java |
public List<Method> listMethods( final Class<?> classObj,
final String methodName )
{
//
// Get the array of methods for my classname.
//
Method[] methods = classObj.getMethods();
List<Method> methodSignatures = new ArrayList<M... | java |
private Map<Integer, Double> predict(final double[] x) {
Map<Integer, Double> result = new HashMap<>();
for (int i = 0; i < model.weights.length; i++) {
double y = VectorUtils.dotProduct(x, model.weights[i]);
y += model.bias[i];
result.put(i, y);
}
re... | java |
public void onlineTrain(final double[] x, final int labelIndex) {
Map<Integer, Double> result = predict(x);
Map.Entry<Integer, Double> maxResult = result.entrySet().stream().max((e1, e2) -> e1.getValue().compareTo(e2.getValue())).orElse(null);
if (maxResult.getKey() != labelIndex) {
... | java |
@Override
public Map<String, Double> predict(Tuple predict) {
Map<Integer, Double> indexResult = predict(predict.vector.getVector());
return indexResult.entrySet().stream()
.map(e -> new ImmutablePair<>(model.labelIndexer.getLabel(e.getKey()), VectorUtils.sigmoid.apply(e.getValue()))... | java |
private boolean isTrimEnabled() {
String contentType = response.getContentType();
// If the contentType is the same string (by identity), return the previously determined value.
// This assumes the same string instance is returned by the response when content type not changed between calls.
if(contentType!=isTr... | java |
private boolean processChar(char c) {
if(inTextArea) {
if(
c==TrimFilterWriter.textarea_close[readCharMatchCount]
|| c==TrimFilterWriter.TEXTAREA_CLOSE[readCharMatchCount]
) {
readCharMatchCount++;
if(readCharMatchCount>=TrimFilterWriter.textarea_close.length) {
inTextArea=false;
readC... | java |
public int set( final int flags )
{
for (;;)
{
int current = _flags.get();
int newValue = current | flags;
if ( _flags.compareAndSet( current, newValue ) )
{
return current;
}
}
} | java |
public int unset( final int flags )
{
for (;;)
{
int current = _flags.get();
int newValue = current & ~flags;
if ( _flags.compareAndSet( current, newValue ) )
{
return current;
}
}
} | java |
public int change( final int add,
final int remove )
{
for (;;)
{
int current = _flags.get();
int newValue = ( current | add ) & ~remove;
if ( _flags.compareAndSet( current, newValue ) )
{
return curr... | java |
public static <E> String message(Response<E> response) {
return Optional.ofNullable(response).map(Response::getMessage).orElse(StringUtils.EMPTY);
} | java |
public static DTree convertTreeBankToCoNLLX(final String constituentTree) {
Tree tree = Tree.valueOf(constituentTree);
SemanticHeadFinder headFinder = new SemanticHeadFinder(false); // keep copula verbs as head
Collection<TypedDependency> dependencies = new EnglishGrammaticalStructure(tree, str... | java |
private String addLocale(Locale locale, String url, String encodedParamName, String encoding) {
// Split the anchor
int poundPos = url.lastIndexOf('#');
String beforeAnchor;
String anchor;
if(poundPos==-1) {
beforeAnchor = url;
anchor = null;
} else {
anchor = url.substring(poundPos);
beforeAnch... | java |
public static Map<String,Locale> getEnabledLocales(ServletRequest request) {
@SuppressWarnings("unchecked")
Map<String,Locale> enabledLocales = (Map<String,Locale>)request.getAttribute(ENABLED_LOCALES_REQUEST_ATTRIBUTE_KEY);
if(enabledLocales==null) throw new IllegalStateException("Not in request filtered by Loca... | java |
protected boolean isLocalizedPath(String url) {
int questionPos = url.lastIndexOf('?');
String lowerPath = (questionPos==-1 ? url : url.substring(0, questionPos)).toLowerCase(Locale.ROOT);
return
// Matches SessionResponseWrapper
// Matches NoSessionFilter
!lowerPath.endsWith(".bmp")
&& !lowerPath.end... | java |
protected String toLocaleString(Locale locale) {
String language = locale.getLanguage();
if(language.isEmpty()) return "";
String country = locale.getCountry();
if(country.isEmpty()) return language;
String variant = locale.getVariant();
if(variant.isEmpty()) {
return language + '-' + country;
} else... | java |
@Override
public void loadModel(InputStream modelIs) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
IOUtils.copy(modelIs, baos);
} catch (IOException e) {
LOG.error("Load model err.", e);
}
InputStream isForSVMLoad = new ByteArrayI... | java |
static String getJavaScriptUnicodeEscapeString(char ch) {
int chInt = (int)ch;
if(chInt>=ENCODE_RANGE_1_START && chInt<ENCODE_RANGE_1_END) {
return javaScriptUnicodeEscapeStrings1[chInt - ENCODE_RANGE_1_START];
}
if(chInt>=ENCODE_RANGE_2_START && chInt<ENCODE_RANGE_2_END) {
return javaScriptUnicodeEscapeS... | java |
@Override
public Map<String, Double> predict(Tuple predict) {
Map<Integer, Double> labelProb = new HashMap<>();
for (Integer labelIndex : model.labelIndexer.getIndexSet()) {
double likelihood = 1.0D;
for (int i = 0; i < predict.vector.getVector().length; i++) {
... | java |
public static void splitData(final String originalTrainingDataFile) {
List<Tuple> trainingData = NaiveBayesClassifier.readTrainingData(originalTrainingDataFile, "\\s");
List<Tuple> wrongData = new ArrayList<>();
int lastTrainingDataSize;
int iterCount = 0;
do {
Syste... | java |
public void addFilePart(final String fieldName, final InputStream stream, final String contentType)
throws IOException
{
addFilePart(fieldName, stream, null, contentType);
} | java |
public void addFilePart(final String fieldName, final URL urlToUploadFile)
throws IOException
{
//
// Maybe try and extract a filename from the last part of the url?
// Or have the user pass it in?
// Or just leave it blank as I have already done?
//
addFilePa... | java |
public void addHeaderField(final String name, final String value)
{
writer.append(name + ": " + value).append(LINE_FEED);
writer.flush();
} | java |
public HttpResponse finish() throws IOException
{
writer.append("--" + boundary + "--").append(LINE_FEED);
writer.flush();
try {
return doFinish();
} finally {
writer.close();
}
} | java |
public double update(final double units) {
final double speed;
lock.lock();
try {
final long currentTime = System.nanoTime();
final long timeDifference = (currentTime - lastUpdateTime) / C1; // nanoseconds to micros
if (timeDifference >= averagingPeriod) {
speed = units / averaging... | java |
public static <T> Optional<T> toBean(String json, Class<T> clazz) {
if (StringUtils.isBlank(json)) {
log.warn("json is blank. ");
return Optional.empty();
}
try {
OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
re... | java |
public static <T> String toJson(T t) {
if (Objects.isNull(t)) {
log.warn("t is blank. ");
return "";
}
try {
return OBJECT_MAPPER.writeValueAsString(t);
} catch (Exception e) {
log.error(e.getMessage(), e);
return "";
}
... | java |
@RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE, value = "/parse", method = RequestMethod.GET)
public String parse(@RequestParam("sentence") String sentence, HttpServletRequest request) {
if (sentence == null || sentence.trim().isEmpty()) {
return StringUtils.EMPTY;
}
sentence = sentenc... | java |
public static <T> T resolveValue(ValueExpression expression, Class<T> type, ELContext elContext) {
if(expression == null) {
return null;
} else {
return type.cast(expression.getValue(elContext));
}
} | java |
public static <T> T resolveValue(Object value, Class<T> type, ELContext elContext) {
if(value == null) {
return null;
} else if(value instanceof ValueExpression) {
return resolveValue((ValueExpression)value, type, elContext);
} else {
return type.cast(value);
}
} | java |
public static MediaValidator getMediaValidator(MediaType contentType, Writer out) throws MediaException {
// If the existing out is already validating for this type, use it.
// This occurs when one validation validates to a set of characters that are a subset of the requested validator.
// For example, a URL is a... | java |
@Override
public boolean getAllowRobots(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page) {
return false;
} | java |
public Map<String, Double> convertMapKey(Map<Integer, Double> probs) {
Map<String, Double> stringKeyProb = new HashMap<>();
probs.entrySet().forEach(e -> stringKeyProb.put(getLabel(e.getKey()), e.getValue()));
return stringKeyProb;
} | java |
public static List<ValidationMessage> validateMediaType(TagData data, List<ValidationMessage> messages) {
Object o = data.getAttribute("type");
if(
o != null
&& o != TagData.REQUEST_TIME_VALUE
&& !(o instanceof MediaType)
) {
String type = Coercion.toString(o);
try {
// First allow shortcuts (m... | java |
public static List<ValidationMessage> validateScope(TagData data, List<ValidationMessage> messages) {
Object o = data.getAttribute("scope");
if(
o != null
&& o != TagData.REQUEST_TIME_VALUE
) {
String scope = Coercion.toString(o);
try {
Scope.getScopeId(scope);
// Value is OK
} catch(JspTag... | java |
public static double distanceKms(BigDecimal lat1, BigDecimal lng1, BigDecimal lat2, BigDecimal lng2 ){
return new GeoCoordinate(lat1, lng1).distanceTo(new GeoCoordinate(lat2, lng2));
} | java |
public static <K, V> MapBuilder<K, V> map(Map<K, V> instance) {
return new MapBuilder<>(instance);
} | java |
public void run(final List<Tuple> data) {
List<Tuple> dataCopy = new ArrayList<>(data);
this.labels = data.parallelStream().map(x -> x.label).collect(Collectors.toSet());
if (shuffleData) {
Collections.shuffle(dataCopy);
}
int chunkSize = data.size() / nfold;
... | java |
private void eval(List<Tuple> training, List<Tuple> testing, int nfold) {
classifier.train(training);
for (Tuple tuple : testing) {
String actual = classifier.predict(tuple).entrySet().stream()
.max((e1, e2) -> e1.getValue().compareTo(e2.getValue()))
... | java |
private static String filter(String s) {
int len = s.length();
StringBuilder filtered = new StringBuilder(len);
int pos = 0;
while(pos < len) {
char ch1 = s.charAt(pos++);
if(Character.isHighSurrogate(ch1)) {
// Handle surrogates
if(pos < len) {
char ch2 = s.charAt(pos++);
if(Character.i... | java |
protected void doTag(Writer out) throws JspException, IOException {
JspFragment body = getJspBody();
if(body!=null) {
// Check for JspWriter to avoid a JspWriter wrapping a JspWriter
body.invoke(
(out instanceof JspWriter)
? null
: out
);
}
} | java |
private static BinRelation extractPolar(DTree tree) {
// TODO: HERE.
DNode rootVerb = tree.getRoots().get(0);
// rootVerb.getChildren().
BinRelation binRelation = new BinRelation();
return binRelation;
} | java |
private Event createEvent(String obs) {
int lastSpace = obs.lastIndexOf(StringUtils.SPACE);
Event event = null;
if (lastSpace != -1) {
String label = obs.substring(lastSpace + 1);
String[] contexts = obs.substring(0, lastSpace).split("\\s+");
// Split name an... | java |
public static List<CoreLabel> stanfordTokenize(String str) {
TokenizerFactory<? extends HasWord> tf = PTBTokenizer.coreLabelFactory();
// ptb3Escaping=false -> '(' not converted as '-LRB-', Dont use it, it will cause Dependency resolution err.
Tokenizer<? extends HasWord> originalWordTokenizer ... | java |
public void tagPOS(List<CoreLabel> tokens) {
if (posTagger == null) {
if (POS_TAGGER_MODEL_PATH == null) {
LOG.warn("Default POS Tagger model");
POS_TAGGER_MODEL_PATH = StanfordConst.STANFORD_DEFAULT_POS_EN_MODEL;
}
posTagger = new MaxentTagger... | java |
public static void tagLemma(List<CoreLabel> tokens) {
// Not sure if this can be static.
Morphology morpha = new Morphology();
for (CoreLabel token : tokens) {
String lemma;
String pos = token.tag();
if (pos.equals(LangLib.POS_NNPS)) {
pos = L... | java |
public synchronized void tagNamedEntity(List<CoreLabel> tokens) {
boolean isPOSTagged = tokens.parallelStream().filter(x -> x.tag() == null).count() == 0;
if (!isPOSTagged) {
throw new RuntimeException("Please Run POS Tagger before Named Entity tagger.");
}
if (ners != null) ... | java |
private Tuple<String,String> getOverrideEntry( final String key )
{
for ( String prefix : _overrides )
{
String override = prefix + "." + key;
String value = getPropertyValue( override );
if ( value != null )
{
return ne... | java |
private Tuple<String,String> getEntry( final String key )
{
Tuple<String,String> override = getOverrideEntry( key );
if ( override == null )
{
String value = getPropertyValue( key );
if ( value != null )
{
return new Tuple<String... | java |
private Tuple<String,String> getEntry( final String key,
final Collection<String> prefixes )
{
if ( CollectionUtils.isEmpty( prefixes ) )
{
return getEntry( key );
}
for( String prefix : prefixes )
{... | java |
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
jpaVendorAdapter.setDatabase(Database.H2);
jpaVendorAdapter.setGenerateDdl(true);
LocalContainerEntityManagerFactoryBean entityManagerFactory = ne... | java |
@Bean
public ServletRegistrationBean h2servletRegistration() {
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new WebServlet());
servletRegistrationBean.addUrlMappings("/h2/*");
return servletRegistrationBean;
} | java |
public static void setAttribute(PageContext pageContext, String scope, String name, Object value) throws JspTagException {
pageContext.setAttribute(name, value, Scope.getScopeId(scope));
} | java |
public static Object findObject(PageContext pageContext, String scope, String name, String property, boolean beanRequired, boolean valueRequired) throws JspTagException {
try {
// Check the name
if(name==null) throw new AttributeRequiredException("name");
// Find the bean
Object bean;
if(scope==null) ... | java |
public static int getScopeId(String scope) throws JspTagException {
if(scope==null || PAGE.equals(scope)) return PageContext.PAGE_SCOPE;
else if(REQUEST.equals(scope)) return PageContext.REQUEST_SCOPE;
else if(SESSION.equals(scope)) return PageContext.SESSION_SCOPE;
else if(APPLICATION.equals(scope)) return Pag... | java |
public static Map<String,String> bundleToStringMap( final ResourceBundle bundle,
final String suffix )
{
if ( bundle == null )
{
return Collections.<String,String>emptyMap();
}
String theSuffix;
... | java |
@Override
public Map<String, Double> predict(Tuple predict) {
KNNEngine engine = new KNNEngine(predict, trainingData, k);
if (mode == 1) {
engine.getDistance(engine.chebyshevDistance);
} else if (mode == 2) {
engine.getDistance(engine.manhattanDistance);
... | java |
public void purge()
{
WeakElement<?> element;
while( ( element = (WeakElement<?>) _queue.poll() ) != null )
{
_set.remove( element );
}
} | java |
@Override
public ISeqClassifier train(List<SequenceTuple> trainingData) {
if (trainingData == null || trainingData.size() == 0) {
LOG.warn("Training data is empty.");
return this;
}
if (modelPath == null) {
try {
modelPath = Files.createTe... | java |
public static String getSignatureBaseString(String requestMethod, String requestUrl,
Map<String, String> protocolParameters) throws AuthException {
StringBuilder sb = new StringBuilder();
sb.append(requestMethod.toUpperCase()).append("&")
.append(AuthUtils.percentEncode(normalizeUrl(requestUrl))).... | java |
public static List<Tuple> createBalancedTrainingData(final List<Tuple> trainingData) {
Map<String, Long> tagCount = trainingData.parallelStream()
.map(x -> new AbstractMap.SimpleImmutableEntry<>(x.label, 1))
.collect(Collectors.groupingBy(Map.Entry::getKey, Collectors.counting())... | java |
public static Pair<List<Tuple>, List<Tuple>> splitData(final List<Tuple> trainingData, double proportion) {
if (proportion < 0 || proportion > 1) {
throw new RuntimeException("Proportion should between 0.0 - 1.0");
}
if (proportion > 0.5) {
proportion = 1 - proportion;
... | java |
public void calculateLabelPrior() {
double prior = 1D / model.labelIndexer.getLabelSize();
model.labelIndexer.getIndexSet().forEach(labelIndex -> model.labelPrior.put(labelIndex, prior));
} | java |
public static void writeWithMarkup(Object value, MarkupType markupType, MediaEncoder encoder, Writer out) throws IOException {
if(encoder==null) {
writeWithMarkup(value, markupType, out);
} else {
if(value!=null) {
if(
value instanceof Writable
&& !((Writable)value).isFastToString()
) {
... | java |
public void buildModel(String wordFileName) throws IOException {
BufferedReader br = new BufferedReader(new FileReader(new File(wordFileName)));
String str;
while ((str = br.readLine()) != null) {
List<String> tokens = StanfordParser.stanfordTokenize(str).stream().map(CoreLabel::ori... | java |
public static int ipv4ToInt( final Inet4Address addr )
{
int value = 0;
for( byte chunk : addr.getAddress() )
{
value <<= 8;
value |= chunk & 0xff;
}
return value;
} | java |
public static <E> List<E> empty(List<E> list) {
return Optional.ofNullable(list).orElse(newArrayList());
} | java |
public static <E> List<E> clean(List<E> list) {
if (iterable(list)) {
return list.stream().filter(e -> {
if (Objects.isNull(e)) {
return false;
}
if (e instanceof Nullable) {
return !((Nullable) e).isNull();
... | java |
public ChainWriter encodeJavaScriptStringInXmlAttribute(Object value) throws IOException {
// Two stage encoding:
// 1) Text -> JavaScript (with quotes added)
// 2) JavaScript -> XML Attribute
if(
value instanceof Writable
&& !((Writable)value).isFastToString()
) {
// Avoid unnecessary toString c... | java |
@Deprecated
public ChainWriter printEU(String value) {
int len = value.length();
for (int c = 0; c < len; c++) {
char ch = value.charAt(c);
if (ch == ' ') out.print('+');
else {
if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) out.print(ch);
else {
out.pri... | java |
public static void writeHtmlImagePreloadJavaScript(String url, Appendable out) throws IOException {
out.append("<script type='text/javascript'>\n"
+ " var img=new Image();\n"
+ " img.src=\"");
// Escape for javascript
StringBuilder javascript = new StringBuilder(url.length());
encodeTextInJavaScript(u... | java |
public Map<String, String> split(final CharSequence source) {
java.util.Objects.requireNonNull(source, "source");
Map<String, String> parameters = new HashMap<>();
Iterator<String> i = new StringIterator(source, pairSeparator);
while (i.hasNext()) {
String keyValue = i.next();
int keyValueS... | java |
public Splitter trim(char c) {
Matcher matcher = new CharMatcher(c);
return new Splitter(pairSeparator, keyValueSeparator, matcher, matcher);
} | java |
public Splitter trim(char[] chars) {
Matcher matcher = new CharsMatcher(chars);
return new Splitter(pairSeparator, keyValueSeparator, matcher, matcher);
} | java |
public void close() {
super.clear();
if (indexMap != null){
indexMap.clear();
indexMap = null;
}
if (this.indexStore != null){
getIndexStore().close();
this.indexStore = null ;
}
if (this.cacheStore != null){
getCacheStore().close();
this.cacheStore = null ;
}
} | java |
private double gaussianUpdate(int predicate, int oid, double correctionConstant) {
double param = params[predicate].getParameters()[oid];
double x0 = 0.0;
double modelValue = modelExpects[0][predicate].getParameters()[oid];
double observedValue = observedExpects[predicate].getParameters(... | java |
@Override
final public void writeSuffixTo(Appendable out) throws IOException {
writeSuffix(buffer, out);
buffer.setLength(0);
} | java |
public static <T> T nullIfEmpty(T value) throws IOException {
return isEmpty(value) ? null : value;
} | java |
public static String toCapCase( final String string )
{
if ( string == null )
{
return null;
}
if( string.length() == 1 )
{
return string.toUpperCase();
}
return Character.toUpperCase( string.charAt( 0 ) ) + string.substring( 1 ).toLo... | java |
public static void appendToBuffer( final StringBuffer buffer,
final String string,
final String delimiter )
{
if ( string == null )
{
return;
}
//
// Only append th... | java |
@SafeVarargs
public static <T> T coalesce( final T ... things )
{
if( things == null || things.length == 0 )
{
return null;
}
for( T thing : things )
{
if( thing != null )
{
return thing;
}
}
... | java |
@SafeVarargs
public static <T> T coalesceNonEmpty( final T ... things )
{
if( things == null || things.length == 0 )
{
return null;
}
for( T thing : things )
{
if( thing instanceof CharSequence )
{
if( ! StringUtils.... | java |
@Override
public BeanInfo[] getAdditionalBeanInfo() {
try {
return new BeanInfo[] {
Introspector.getBeanInfo(InputTag.class.getSuperclass())
};
} catch(IntrospectionException err) {
throw new AssertionError(err);
}
} | java |
public static String fileNameFromString( final String text )
{
String value = text.replace( ' ', '_' );
if ( value.length() < 48 )
{
return value;
}
return value.substring( 0, 47 );
} | java |
public static int executeToFile( final String[] command,
final File file )
throws
IOException,
InterruptedException
{
return executeToFile( command, file, System.err );
} | java |
public static int executeToFile( final String[] command,
final File file,
final OutputStream stderr )
throws
IOException,
InterruptedException
{
return executeToStreams( command,... | java |
public static void makeSecurityCheck( final File file,
final File base )
{
if( ! file.getAbsolutePath().startsWith( base.getAbsolutePath() ) )
{
throw new IllegalArgumentException( "Illegal file path [" + file + "]" );
}
} | java |
public void setLink(Link link) {
setHref(link.getHref());
setHrefAbsolute(link.getHrefAbsolute());
HttpParameters linkParams = link.getParams();
if(linkParams != null) {
for(Map.Entry<String,List<String>> entry : linkParams.getParameterMap().entrySet()) {
String paramName = entry.getKey();
for(String... | java |
protected static void update(String[] ec, Set<String> predicateSet, Map<String, Integer> counter, int cutoff) {
for (String s : ec) {
Integer val = counter.get(s);
val = val == null ? 1 : val + 1;
counter.put(s, val);
if (!predicateSet.contains(s) && counter.get(... | java |
private GrammaticalStructure tagDependencies(List<? extends HasWord> taggedWords) {
GrammaticalStructure gs = nndepParser.predict(taggedWords);
return gs;
} | java |
public String[] getFeatNames() {
String[] namesArray = new String[nameIndexMap.size()];
for (Map.Entry<String, Integer> entry : nameIndexMap.entrySet()) {
namesArray[entry.getValue()] = entry.getKey();
}
return namesArray;
} | java |
public void tagPOS(List<CoreLabel> tokens, Tree tree) {
try {
List<TaggedWord> posList = tree.getChild(0).taggedYield();
for (int i = 0; i < tokens.size(); i++) {
String pos = posList.get(i).tag();
tokens.get(i).setTag(pos);
}
} catch (... | java |
public Pair<CoreMap, GrammaticalStructure> parseForCoref(String sentence) {
List<CoreLabel> tokens = stanfordTokenize(sentence);
Tree tree = parser.parse(tokens);
GrammaticalStructure gs = tagDependencies(tree, true);
tagPOS(tokens);
tagLemma(tokens);
tagNamedEntity(token... | java |
public static boolean causedBy( final Throwable ex,
final Class<? extends Throwable> exceptionClass )
{
Throwable cause = ex;
while( cause != null && ! exceptionClass.isInstance( cause ) )
{
cause = cause.getCause();
... | java |
public static <T extends Throwable> T getCause( final Throwable ex,
final Class<T> exceptionClass )
{
Throwable cause = ex;
while( cause != null && ! exceptionClass.isInstance( cause ) )
{
cause = cause.getCause();
... | java |
public static String getMessage( final Throwable ex )
{
String message = ex.getMessage();
//
// It *appears* as though the SQLException hasn't been
// converted to nest? It seems like it has it's own
// method of nesting, not sure why. I don't know
... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.