repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
cpollet/jixture
core/src/main/java/net/cpollet/jixture/fixtures/capacities/cleaning/CleanableFixtureProxy.java
CleanableFixtureProxy.getClassesToDeleteIterator
@Override public Iterator<Class> getClassesToDeleteIterator() { if (fixture instanceof CleanableFixture) { return cleanableFixture().getClassesToDeleteIterator(); } return Collections.<Class>emptyList().iterator(); }
java
@Override public Iterator<Class> getClassesToDeleteIterator() { if (fixture instanceof CleanableFixture) { return cleanableFixture().getClassesToDeleteIterator(); } return Collections.<Class>emptyList().iterator(); }
[ "@", "Override", "public", "Iterator", "<", "Class", ">", "getClassesToDeleteIterator", "(", ")", "{", "if", "(", "fixture", "instanceof", "CleanableFixture", ")", "{", "return", "cleanableFixture", "(", ")", ".", "getClassesToDeleteIterator", "(", ")", ";", "}"...
Returns an ordered iterator of mapping classes to delete from database. @return an ordered iterator of mapping classes to delete from database.
[ "Returns", "an", "ordered", "iterator", "of", "mapping", "classes", "to", "delete", "from", "database", "." ]
faef0d4991f81c2cdb5be3ba24176636ef0cc433
https://github.com/cpollet/jixture/blob/faef0d4991f81c2cdb5be3ba24176636ef0cc433/core/src/main/java/net/cpollet/jixture/fixtures/capacities/cleaning/CleanableFixtureProxy.java#L53-L60
train
GoodforGod/dummymaker
src/main/java/io/dummymaker/export/impl/CsvExporter.java
CsvExporter.buildCsvValue
private String buildCsvValue(final Field field, final String fieldValue) { return (areTextValuesWrapped && field.getType().equals(String.class) || isValueWrappable.test(fieldValue)) ? wrapWithQuotes(fieldValue) : fieldValue; }
java
private String buildCsvValue(final Field field, final String fieldValue) { return (areTextValuesWrapped && field.getType().equals(String.class) || isValueWrappable.test(fieldValue)) ? wrapWithQuotes(fieldValue) : fieldValue; }
[ "private", "String", "buildCsvValue", "(", "final", "Field", "field", ",", "final", "String", "fieldValue", ")", "{", "return", "(", "areTextValuesWrapped", "&&", "field", ".", "getType", "(", ")", ".", "equals", "(", "String", ".", "class", ")", "||", "is...
Build correct final export field value in CSV format Check for wrap option for field value @param field export field @param fieldValue export field value @return final export field value
[ "Build", "correct", "final", "export", "field", "value", "in", "CSV", "format", "Check", "for", "wrap", "option", "for", "field", "value" ]
a4809c0a8139ab9cdb42814a3e37772717a313b4
https://github.com/GoodforGod/dummymaker/blob/a4809c0a8139ab9cdb42814a3e37772717a313b4/src/main/java/io/dummymaker/export/impl/CsvExporter.java#L127-L135
train
GoodforGod/dummymaker
src/main/java/io/dummymaker/export/impl/CsvExporter.java
CsvExporter.generateCsvHeader
private String generateCsvHeader(final IClassContainer container) { final String separatorAsStr = String.valueOf(separator); return container.getFormatSupported(Format.CSV).entrySet().stream() .map(e -> e.getValue().getExportName()) .collect(Collectors.joining(separatorAsStr)); }
java
private String generateCsvHeader(final IClassContainer container) { final String separatorAsStr = String.valueOf(separator); return container.getFormatSupported(Format.CSV).entrySet().stream() .map(e -> e.getValue().getExportName()) .collect(Collectors.joining(separatorAsStr)); }
[ "private", "String", "generateCsvHeader", "(", "final", "IClassContainer", "container", ")", "{", "final", "String", "separatorAsStr", "=", "String", ".", "valueOf", "(", "separator", ")", ";", "return", "container", ".", "getFormatSupported", "(", "Format", ".", ...
Generates header for CSV file @return csv header
[ "Generates", "header", "for", "CSV", "file" ]
a4809c0a8139ab9cdb42814a3e37772717a313b4
https://github.com/GoodforGod/dummymaker/blob/a4809c0a8139ab9cdb42814a3e37772717a313b4/src/main/java/io/dummymaker/export/impl/CsvExporter.java#L142-L147
train
jayantk/jklol
src/com/jayantkrish/jklol/ccg/SyntacticCategory.java
SyntacticCategory.assignFeatures
public SyntacticCategory assignFeatures(Map<Integer, String> assignedFeatures, Map<Integer, Integer> relabeledFeatures) { String newFeatureValue = featureValue; int newFeatureVariable = featureVariable; if (assignedFeatures.containsKey(featureVariable)) { newFeatureValue = assignedFeatures.get(featureVariable); newFeatureVariable = -1; } else if (relabeledFeatures.containsKey(featureVariable)) { newFeatureVariable = relabeledFeatures.get(newFeatureVariable); } if (isAtomic()) { return SyntacticCategory.createAtomic(value, newFeatureValue, newFeatureVariable); } else { SyntacticCategory assignedReturn = returnType.assignFeatures(assignedFeatures, relabeledFeatures); SyntacticCategory assignedArgument = argumentType.assignFeatures(assignedFeatures, relabeledFeatures); return SyntacticCategory.createFunctional(direction, assignedReturn, assignedArgument, newFeatureValue, newFeatureVariable); } }
java
public SyntacticCategory assignFeatures(Map<Integer, String> assignedFeatures, Map<Integer, Integer> relabeledFeatures) { String newFeatureValue = featureValue; int newFeatureVariable = featureVariable; if (assignedFeatures.containsKey(featureVariable)) { newFeatureValue = assignedFeatures.get(featureVariable); newFeatureVariable = -1; } else if (relabeledFeatures.containsKey(featureVariable)) { newFeatureVariable = relabeledFeatures.get(newFeatureVariable); } if (isAtomic()) { return SyntacticCategory.createAtomic(value, newFeatureValue, newFeatureVariable); } else { SyntacticCategory assignedReturn = returnType.assignFeatures(assignedFeatures, relabeledFeatures); SyntacticCategory assignedArgument = argumentType.assignFeatures(assignedFeatures, relabeledFeatures); return SyntacticCategory.createFunctional(direction, assignedReturn, assignedArgument, newFeatureValue, newFeatureVariable); } }
[ "public", "SyntacticCategory", "assignFeatures", "(", "Map", "<", "Integer", ",", "String", ">", "assignedFeatures", ",", "Map", "<", "Integer", ",", "Integer", ">", "relabeledFeatures", ")", "{", "String", "newFeatureValue", "=", "featureValue", ";", "int", "ne...
Assigns values to or relabels feature variables in this category. @param assignedFeatures @param relabeledFeatures @return
[ "Assigns", "values", "to", "or", "relabels", "feature", "variables", "in", "this", "category", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/SyntacticCategory.java#L273-L291
train
jayantk/jklol
src/com/jayantkrish/jklol/ccg/SyntacticCategory.java
SyntacticCategory.assignAllFeatures
public SyntacticCategory assignAllFeatures(String value) { Set<Integer> featureVars = Sets.newHashSet(); getAllFeatureVariables(featureVars); Map<Integer, String> valueMap = Maps.newHashMap(); for (Integer var : featureVars) { valueMap.put(var, value); } return assignFeatures(valueMap, Collections.<Integer, Integer>emptyMap()); }
java
public SyntacticCategory assignAllFeatures(String value) { Set<Integer> featureVars = Sets.newHashSet(); getAllFeatureVariables(featureVars); Map<Integer, String> valueMap = Maps.newHashMap(); for (Integer var : featureVars) { valueMap.put(var, value); } return assignFeatures(valueMap, Collections.<Integer, Integer>emptyMap()); }
[ "public", "SyntacticCategory", "assignAllFeatures", "(", "String", "value", ")", "{", "Set", "<", "Integer", ">", "featureVars", "=", "Sets", ".", "newHashSet", "(", ")", ";", "getAllFeatureVariables", "(", "featureVars", ")", ";", "Map", "<", "Integer", ",", ...
Assigns value to all unfilled feature variables. @param value @return
[ "Assigns", "value", "to", "all", "unfilled", "feature", "variables", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/SyntacticCategory.java#L299-L308
train
jayantk/jklol
src/com/jayantkrish/jklol/ccg/SyntacticCategory.java
SyntacticCategory.getWithoutFeatures
public SyntacticCategory getWithoutFeatures() { if (isAtomic()) { return createAtomic(value, DEFAULT_FEATURE_VALUE, -1); } else { return createFunctional(getDirection(), returnType.getWithoutFeatures(), argumentType.getWithoutFeatures()); } }
java
public SyntacticCategory getWithoutFeatures() { if (isAtomic()) { return createAtomic(value, DEFAULT_FEATURE_VALUE, -1); } else { return createFunctional(getDirection(), returnType.getWithoutFeatures(), argumentType.getWithoutFeatures()); } }
[ "public", "SyntacticCategory", "getWithoutFeatures", "(", ")", "{", "if", "(", "isAtomic", "(", ")", ")", "{", "return", "createAtomic", "(", "value", ",", "DEFAULT_FEATURE_VALUE", ",", "-", "1", ")", ";", "}", "else", "{", "return", "createFunctional", "(",...
Get a syntactic category identical to this one except with all feature values replaced by the default value. @return
[ "Get", "a", "syntactic", "category", "identical", "to", "this", "one", "except", "with", "all", "feature", "values", "replaced", "by", "the", "default", "value", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/SyntacticCategory.java#L369-L376
train
jayantk/jklol
src/com/jayantkrish/jklol/ccg/SyntacticCategory.java
SyntacticCategory.getArgumentList
public List<SyntacticCategory> getArgumentList() { if (isAtomic()) { return Lists.newArrayList(); } else { List<SyntacticCategory> args = getReturn().getArgumentList(); args.add(getArgument()); return args; } }
java
public List<SyntacticCategory> getArgumentList() { if (isAtomic()) { return Lists.newArrayList(); } else { List<SyntacticCategory> args = getReturn().getArgumentList(); args.add(getArgument()); return args; } }
[ "public", "List", "<", "SyntacticCategory", ">", "getArgumentList", "(", ")", "{", "if", "(", "isAtomic", "(", ")", ")", "{", "return", "Lists", ".", "newArrayList", "(", ")", ";", "}", "else", "{", "List", "<", "SyntacticCategory", ">", "args", "=", "...
Gets the sequence of arguments that this category accepts. Note that the returned arguments themselves may be functional types. The sequence is returned with the first required argument at the end of the list. @return
[ "Gets", "the", "sequence", "of", "arguments", "that", "this", "category", "accepts", ".", "Note", "that", "the", "returned", "arguments", "themselves", "may", "be", "functional", "types", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/SyntacticCategory.java#L419-L427
train
jayantk/jklol
src/com/jayantkrish/jklol/inference/JunctionTree.java
JunctionTree.cliqueTreeToMaxMarginalSet
private static MaxMarginalSet cliqueTreeToMaxMarginalSet(CliqueTree cliqueTree, FactorGraph originalFactorGraph) { for (int i = 0; i < cliqueTree.numFactors(); i++) { computeMarginal(cliqueTree, i, false); } return new FactorMaxMarginalSet(cliqueTree, originalFactorGraph.getConditionedValues()); }
java
private static MaxMarginalSet cliqueTreeToMaxMarginalSet(CliqueTree cliqueTree, FactorGraph originalFactorGraph) { for (int i = 0; i < cliqueTree.numFactors(); i++) { computeMarginal(cliqueTree, i, false); } return new FactorMaxMarginalSet(cliqueTree, originalFactorGraph.getConditionedValues()); }
[ "private", "static", "MaxMarginalSet", "cliqueTreeToMaxMarginalSet", "(", "CliqueTree", "cliqueTree", ",", "FactorGraph", "originalFactorGraph", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cliqueTree", ".", "numFactors", "(", ")", ";", "i", "++...
Retrieves max marginals from the given clique tree. @param cliqueTree @param rootFactorNum @return
[ "Retrieves", "max", "marginals", "from", "the", "given", "clique", "tree", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/inference/JunctionTree.java#L309-L315
train
davidcarboni/cryptolite-java
src/main/java/com/github/davidcarboni/cryptolite/DigitalSignature.java
DigitalSignature.sign
public String sign(String content, PrivateKey privateKey) { if (content == null) { return null; } byte[] bytes = content.getBytes(StandardCharsets.UTF_8); InputStream input = new ByteArrayInputStream(bytes); return sign(input, privateKey); // ByteArrayInputStream does not need to be closed. }
java
public String sign(String content, PrivateKey privateKey) { if (content == null) { return null; } byte[] bytes = content.getBytes(StandardCharsets.UTF_8); InputStream input = new ByteArrayInputStream(bytes); return sign(input, privateKey); // ByteArrayInputStream does not need to be closed. }
[ "public", "String", "sign", "(", "String", "content", ",", "PrivateKey", "privateKey", ")", "{", "if", "(", "content", "==", "null", ")", "{", "return", "null", ";", "}", "byte", "[", "]", "bytes", "=", "content", ".", "getBytes", "(", "StandardCharsets"...
Generates a digital signature for the given string. @param content The string to be digitally signed. @param privateKey The {@link PrivateKey} with which the string is to be signed. This can be obtained via {@link Keys#newKeyPair()}. @return The signature as a base64-encoded string. If the content is null, null is returned.
[ "Generates", "a", "digital", "signature", "for", "the", "given", "string", "." ]
e67954181a04ffc9beb1d9abca1421195fcf9764
https://github.com/davidcarboni/cryptolite-java/blob/e67954181a04ffc9beb1d9abca1421195fcf9764/src/main/java/com/github/davidcarboni/cryptolite/DigitalSignature.java#L50-L60
train
davidcarboni/cryptolite-java
src/main/java/com/github/davidcarboni/cryptolite/DigitalSignature.java
DigitalSignature.verify
public boolean verify(String content, PublicKey publicKey, String signature) { byte[] bytes = content.getBytes(StandardCharsets.UTF_8); InputStream input = new ByteArrayInputStream(bytes); return verify(input, publicKey, signature); // ByteArrayInputStream does not need to be closed. }
java
public boolean verify(String content, PublicKey publicKey, String signature) { byte[] bytes = content.getBytes(StandardCharsets.UTF_8); InputStream input = new ByteArrayInputStream(bytes); return verify(input, publicKey, signature); // ByteArrayInputStream does not need to be closed. }
[ "public", "boolean", "verify", "(", "String", "content", ",", "PublicKey", "publicKey", ",", "String", "signature", ")", "{", "byte", "[", "]", "bytes", "=", "content", ".", "getBytes", "(", "StandardCharsets", ".", "UTF_8", ")", ";", "InputStream", "input",...
Verifies whether the given content matches the given signature. @param content The content to be verified. @param publicKey The public key to use in the verification process. @param signature The signature with which the content is to be verified. This can be obtained via {@link Keys#newKeyPair()}. @return If the content matches the given signature, using the given key, true.
[ "Verifies", "whether", "the", "given", "content", "matches", "the", "given", "signature", "." ]
e67954181a04ffc9beb1d9abca1421195fcf9764
https://github.com/davidcarboni/cryptolite-java/blob/e67954181a04ffc9beb1d9abca1421195fcf9764/src/main/java/com/github/davidcarboni/cryptolite/DigitalSignature.java#L113-L120
train
jayantk/jklol
src/com/jayantkrish/jklol/util/Assignment.java
Assignment.union
public final Assignment union(Assignment other) { Preconditions.checkNotNull(other); if (other.size() == 0) { return this; } if (vars.length == 0) { return other; } // Merge varnums / values int[] otherNums = other.getVariableNumsArray(); int[] myNums = getVariableNumsArray(); Object[] otherVals = other.getValuesArray(); Object[] myVals = getValuesArray(); int[] mergedNums = new int[otherNums.length + myNums.length]; Object[] mergedVals = new Object[otherNums.length + myNums.length]; int i = 0; int j = 0; int numFilled = 0; while (i < otherNums.length && j < myNums.length) { if (otherNums[i] < myNums[j]) { mergedNums[numFilled] = otherNums[i]; mergedVals[numFilled] = otherVals[i]; i++; numFilled++; } else if (otherNums[i] > myNums[j]) { mergedNums[numFilled] = myNums[j]; mergedVals[numFilled] = myVals[j]; j++; numFilled++; } else { Preconditions.checkState(false, "Cannot combine non-disjoint assignments: %s with %s", this, other); } } // One list might still have elements in it. while (i < otherNums.length) { mergedNums[numFilled] = otherNums[i]; mergedVals[numFilled] = otherVals[i]; i++; numFilled++; } while (j < myNums.length) { mergedNums[numFilled] = myNums[j]; mergedVals[numFilled] = myVals[j]; j++; numFilled++; } Preconditions.checkState(numFilled == mergedNums.length); return Assignment.fromSortedArrays(mergedNums, mergedVals); }
java
public final Assignment union(Assignment other) { Preconditions.checkNotNull(other); if (other.size() == 0) { return this; } if (vars.length == 0) { return other; } // Merge varnums / values int[] otherNums = other.getVariableNumsArray(); int[] myNums = getVariableNumsArray(); Object[] otherVals = other.getValuesArray(); Object[] myVals = getValuesArray(); int[] mergedNums = new int[otherNums.length + myNums.length]; Object[] mergedVals = new Object[otherNums.length + myNums.length]; int i = 0; int j = 0; int numFilled = 0; while (i < otherNums.length && j < myNums.length) { if (otherNums[i] < myNums[j]) { mergedNums[numFilled] = otherNums[i]; mergedVals[numFilled] = otherVals[i]; i++; numFilled++; } else if (otherNums[i] > myNums[j]) { mergedNums[numFilled] = myNums[j]; mergedVals[numFilled] = myVals[j]; j++; numFilled++; } else { Preconditions.checkState(false, "Cannot combine non-disjoint assignments: %s with %s", this, other); } } // One list might still have elements in it. while (i < otherNums.length) { mergedNums[numFilled] = otherNums[i]; mergedVals[numFilled] = otherVals[i]; i++; numFilled++; } while (j < myNums.length) { mergedNums[numFilled] = myNums[j]; mergedVals[numFilled] = myVals[j]; j++; numFilled++; } Preconditions.checkState(numFilled == mergedNums.length); return Assignment.fromSortedArrays(mergedNums, mergedVals); }
[ "public", "final", "Assignment", "union", "(", "Assignment", "other", ")", "{", "Preconditions", ".", "checkNotNull", "(", "other", ")", ";", "if", "(", "other", ".", "size", "(", ")", "==", "0", ")", "{", "return", "this", ";", "}", "if", "(", "vars...
Combines two assignments into a single joint assignment to all of the variables in each assignment. The two assignments must contain disjoint sets of variables.
[ "Combines", "two", "assignments", "into", "a", "single", "joint", "assignment", "to", "all", "of", "the", "variables", "in", "each", "assignment", ".", "The", "two", "assignments", "must", "contain", "disjoint", "sets", "of", "variables", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/util/Assignment.java#L261-L311
train
jayantk/jklol
src/com/jayantkrish/jklol/util/Assignment.java
Assignment.removeAll
@Deprecated public final Assignment removeAll(Collection<Integer> varNumsToRemove) { return removeAll(Ints.toArray(varNumsToRemove)); }
java
@Deprecated public final Assignment removeAll(Collection<Integer> varNumsToRemove) { return removeAll(Ints.toArray(varNumsToRemove)); }
[ "@", "Deprecated", "public", "final", "Assignment", "removeAll", "(", "Collection", "<", "Integer", ">", "varNumsToRemove", ")", "{", "return", "removeAll", "(", "Ints", ".", "toArray", "(", "varNumsToRemove", ")", ")", ";", "}" ]
Returns a copy of this assignment without any assignments to the variable numbers in varNumsToRemove @param varNumsToRemove @return
[ "Returns", "a", "copy", "of", "this", "assignment", "without", "any", "assignments", "to", "the", "variable", "numbers", "in", "varNumsToRemove" ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/util/Assignment.java#L320-L323
train
jayantk/jklol
src/com/jayantkrish/jklol/util/Assignment.java
Assignment.mapVariables
public Assignment mapVariables(Map<Integer, Integer> varMap) { int[] newVarNums = new int[vars.length]; Object[] newValues = new Object[vars.length]; int numFilled = 0; for (int i = 0; i < vars.length; i++) { if (varMap.containsKey(vars[i])) { newVarNums[numFilled] = varMap.get(vars[i]); newValues[numFilled] = values[i]; numFilled++; } } if (numFilled < newVarNums.length) { newVarNums = Arrays.copyOf(newVarNums, numFilled); newValues = Arrays.copyOf(newValues, numFilled); } return Assignment.fromUnsortedArrays(newVarNums, newValues); }
java
public Assignment mapVariables(Map<Integer, Integer> varMap) { int[] newVarNums = new int[vars.length]; Object[] newValues = new Object[vars.length]; int numFilled = 0; for (int i = 0; i < vars.length; i++) { if (varMap.containsKey(vars[i])) { newVarNums[numFilled] = varMap.get(vars[i]); newValues[numFilled] = values[i]; numFilled++; } } if (numFilled < newVarNums.length) { newVarNums = Arrays.copyOf(newVarNums, numFilled); newValues = Arrays.copyOf(newValues, numFilled); } return Assignment.fromUnsortedArrays(newVarNums, newValues); }
[ "public", "Assignment", "mapVariables", "(", "Map", "<", "Integer", ",", "Integer", ">", "varMap", ")", "{", "int", "[", "]", "newVarNums", "=", "new", "int", "[", "vars", ".", "length", "]", ";", "Object", "[", "]", "newValues", "=", "new", "Object", ...
Return a new assignment where each var num has been replaced by its value in varMap.
[ "Return", "a", "new", "assignment", "where", "each", "var", "num", "has", "been", "replaced", "by", "its", "value", "in", "varMap", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/util/Assignment.java#L359-L377
train
ivanceras/orm
src/main/java/com/ivanceras/db/api/DB_Rdbms.java
DB_Rdbms.curateIgnoredColumns
private String[] curateIgnoredColumns(String[] ignoredColumns) { if(ignoredColumns == null){ return null; }else{ String[] curated = new String[ignoredColumns.length]; for(int i = 0; i < ignoredColumns.length; i++){ if(ignoredColumns[i] != null){ String[] splinters = ignoredColumns[i].split("\\."); if(splinters != null && splinters.length > 0){ String last = splinters[splinters.length - 1]; curated[i] = last; } } } return curated; } }
java
private String[] curateIgnoredColumns(String[] ignoredColumns) { if(ignoredColumns == null){ return null; }else{ String[] curated = new String[ignoredColumns.length]; for(int i = 0; i < ignoredColumns.length; i++){ if(ignoredColumns[i] != null){ String[] splinters = ignoredColumns[i].split("\\."); if(splinters != null && splinters.length > 0){ String last = splinters[splinters.length - 1]; curated[i] = last; } } } return curated; } }
[ "private", "String", "[", "]", "curateIgnoredColumns", "(", "String", "[", "]", "ignoredColumns", ")", "{", "if", "(", "ignoredColumns", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "String", "[", "]", "curated", "=", "new", "String",...
while ignoring specific table
[ "while", "ignoring", "specific", "table" ]
e63213cb8abefd11df0e2d34b1c95477788e600e
https://github.com/ivanceras/orm/blob/e63213cb8abefd11df0e2d34b1c95477788e600e/src/main/java/com/ivanceras/db/api/DB_Rdbms.java#L321-L337
train
HiddenStage/divide
Shared/src/main/java/io/divide/shared/file/XmlStorage.java
XmlStorage.hasFileChangedUnexpectedly
private boolean hasFileChangedUnexpectedly() { synchronized (this) { if (mDiskWritesInFlight > 0) { // If we know we caused it, it's not unexpected. if (DEBUG) System.out.println( "disk write in flight, not unexpected."); return false; } } if (!mFile.canRead()) { return true; } synchronized (this) { return mStatTimestamp != mFile.lastModified() || mStatSize != mFile.length(); } }
java
private boolean hasFileChangedUnexpectedly() { synchronized (this) { if (mDiskWritesInFlight > 0) { // If we know we caused it, it's not unexpected. if (DEBUG) System.out.println( "disk write in flight, not unexpected."); return false; } } if (!mFile.canRead()) { return true; } synchronized (this) { return mStatTimestamp != mFile.lastModified() || mStatSize != mFile.length(); } }
[ "private", "boolean", "hasFileChangedUnexpectedly", "(", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "mDiskWritesInFlight", ">", "0", ")", "{", "// If we know we caused it, it's not unexpected.", "if", "(", "DEBUG", ")", "System", ".", "out", ".", ...
we didn't instigate.
[ "we", "didn", "t", "instigate", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Shared/src/main/java/io/divide/shared/file/XmlStorage.java#L123-L137
train
HiddenStage/divide
Shared/src/main/java/io/divide/shared/file/XmlStorage.java
XmlStorage.enqueueDiskWrite
private void enqueueDiskWrite(final MemoryCommitResult mcr, final Runnable postWriteRunnable) { final Runnable writeToDiskRunnable = new Runnable() { public void run() { synchronized (mWritingToDiskLock) { writeToFile(mcr); } synchronized (XmlStorage.this) { mDiskWritesInFlight--; } if (postWriteRunnable != null) { postWriteRunnable.run(); } } }; final boolean isFromSyncCommit = (postWriteRunnable == null); // Typical #commit() path with fewer allocations, doing a write on // the current thread. if (isFromSyncCommit) { boolean wasEmpty = false; synchronized (XmlStorage.this) { wasEmpty = mDiskWritesInFlight == 1; } if (wasEmpty) { writeToDiskRunnable.run(); return; } } QueuedWork.singleThreadExecutor().execute(writeToDiskRunnable); }
java
private void enqueueDiskWrite(final MemoryCommitResult mcr, final Runnable postWriteRunnable) { final Runnable writeToDiskRunnable = new Runnable() { public void run() { synchronized (mWritingToDiskLock) { writeToFile(mcr); } synchronized (XmlStorage.this) { mDiskWritesInFlight--; } if (postWriteRunnable != null) { postWriteRunnable.run(); } } }; final boolean isFromSyncCommit = (postWriteRunnable == null); // Typical #commit() path with fewer allocations, doing a write on // the current thread. if (isFromSyncCommit) { boolean wasEmpty = false; synchronized (XmlStorage.this) { wasEmpty = mDiskWritesInFlight == 1; } if (wasEmpty) { writeToDiskRunnable.run(); return; } } QueuedWork.singleThreadExecutor().execute(writeToDiskRunnable); }
[ "private", "void", "enqueueDiskWrite", "(", "final", "MemoryCommitResult", "mcr", ",", "final", "Runnable", "postWriteRunnable", ")", "{", "final", "Runnable", "writeToDiskRunnable", "=", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", ...
Enqueue an already-committed-to-memory result to be written to disk. They will be written to disk one-at-a-time in the order that they're enqueued. @param postWriteRunnable if non-null, we're being called from apply() and this is the runnable to run after the write proceeds. if null (from a regular commit()), then we're allowed to do this disk write on the main thread (which in addition to reducing allocations and creating a background thread, this has the advantage that we catch them in userdebug StrictMode reports to convert them where possible to apply() ...)
[ "Enqueue", "an", "already", "-", "committed", "-", "to", "-", "memory", "result", "to", "be", "written", "to", "disk", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Shared/src/main/java/io/divide/shared/file/XmlStorage.java#L409-L441
train
jayantk/jklol
src/com/jayantkrish/jklol/util/IoUtils.java
IoUtils.readLines
public static List<String> readLines(String filename) { List<String> lines = Lists.newArrayList(); try { BufferedReader in = new BufferedReader(new FileReader(filename)); String line; while ((line = in.readLine()) != null) { // Ignore blank lines. if (line.trim().length() > 0) { lines.add(line); } } in.close(); } catch (IOException e) { throw new RuntimeException(e); } return lines; }
java
public static List<String> readLines(String filename) { List<String> lines = Lists.newArrayList(); try { BufferedReader in = new BufferedReader(new FileReader(filename)); String line; while ((line = in.readLine()) != null) { // Ignore blank lines. if (line.trim().length() > 0) { lines.add(line); } } in.close(); } catch (IOException e) { throw new RuntimeException(e); } return lines; }
[ "public", "static", "List", "<", "String", ">", "readLines", "(", "String", "filename", ")", "{", "List", "<", "String", ">", "lines", "=", "Lists", ".", "newArrayList", "(", ")", ";", "try", "{", "BufferedReader", "in", "=", "new", "BufferedReader", "("...
Read the lines of a file into a list of strings, with each line represented as its own string. @param filename @return
[ "Read", "the", "lines", "of", "a", "file", "into", "a", "list", "of", "strings", "with", "each", "line", "represented", "as", "its", "own", "string", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/util/IoUtils.java#L27-L43
train
jayantk/jklol
src/com/jayantkrish/jklol/sequence/TaggerUtils.java
TaggerUtils.reformatTrainingData
public static <I, O> List<Example<DynamicAssignment, DynamicAssignment>> reformatTrainingData( List<? extends TaggedSequence<I, O>> sequences, FeatureVectorGenerator<LocalContext<I>> featureGen, Function<? super LocalContext<I>, ? extends Object> inputGen, DynamicVariableSet modelVariables, I startInput, O startLabel) { Preconditions.checkArgument(!(startInput == null ^ startLabel == null)); DynamicVariableSet plate = modelVariables.getPlate(PLATE_NAME); VariableNumMap x = plate.getFixedVariables().getVariablesByName(INPUT_FEATURES_NAME); VariableNumMap xInput = plate.getFixedVariables().getVariablesByName(INPUT_NAME); VariableNumMap y = plate.getFixedVariables().getVariablesByName(OUTPUT_NAME); List<Example<DynamicAssignment, DynamicAssignment>> examples = Lists.newArrayList(); for (TaggedSequence<I, O> sequence : sequences) { List<Assignment> inputs = Lists.newArrayList(); if (startInput != null) { List<I> newItems = Lists.newArrayList(); newItems.add(startInput); newItems.addAll(sequence.getItems()); LocalContext<I> startContext = new ListLocalContext<I>(newItems, 0); Assignment inputFeatureVector = x.outcomeArrayToAssignment(featureGen.apply(startContext)); Assignment inputElement = xInput.outcomeArrayToAssignment(inputGen.apply(startContext)); Assignment firstLabel = y.outcomeArrayToAssignment(startLabel); inputs.add(Assignment.unionAll(inputFeatureVector, inputElement, firstLabel)); } List<LocalContext<I>> contexts = sequence.getLocalContexts(); for (int i = 0; i < contexts.size(); i++) { Assignment inputFeatureVector = x.outcomeArrayToAssignment(featureGen.apply(contexts.get(i))); Assignment inputElement = xInput.outcomeArrayToAssignment(inputGen.apply(contexts.get(i))); inputs.add(inputFeatureVector.union(inputElement)); } DynamicAssignment input = DynamicAssignment.createPlateAssignment(PLATE_NAME, inputs); DynamicAssignment output = DynamicAssignment.EMPTY; if (sequence.getLabels() != null) { List<Assignment> outputs = Lists.newArrayList(); if (startInput != null) { // First label is given (and equal to the special start label). outputs.add(Assignment.EMPTY); } List<O> labels = sequence.getLabels(); for (int i = 0; i < contexts.size(); i++) { outputs.add(y.outcomeArrayToAssignment(labels.get(i))); } output = DynamicAssignment.createPlateAssignment(PLATE_NAME, outputs); } examples.add(Example.create(input, output)); } return examples; }
java
public static <I, O> List<Example<DynamicAssignment, DynamicAssignment>> reformatTrainingData( List<? extends TaggedSequence<I, O>> sequences, FeatureVectorGenerator<LocalContext<I>> featureGen, Function<? super LocalContext<I>, ? extends Object> inputGen, DynamicVariableSet modelVariables, I startInput, O startLabel) { Preconditions.checkArgument(!(startInput == null ^ startLabel == null)); DynamicVariableSet plate = modelVariables.getPlate(PLATE_NAME); VariableNumMap x = plate.getFixedVariables().getVariablesByName(INPUT_FEATURES_NAME); VariableNumMap xInput = plate.getFixedVariables().getVariablesByName(INPUT_NAME); VariableNumMap y = plate.getFixedVariables().getVariablesByName(OUTPUT_NAME); List<Example<DynamicAssignment, DynamicAssignment>> examples = Lists.newArrayList(); for (TaggedSequence<I, O> sequence : sequences) { List<Assignment> inputs = Lists.newArrayList(); if (startInput != null) { List<I> newItems = Lists.newArrayList(); newItems.add(startInput); newItems.addAll(sequence.getItems()); LocalContext<I> startContext = new ListLocalContext<I>(newItems, 0); Assignment inputFeatureVector = x.outcomeArrayToAssignment(featureGen.apply(startContext)); Assignment inputElement = xInput.outcomeArrayToAssignment(inputGen.apply(startContext)); Assignment firstLabel = y.outcomeArrayToAssignment(startLabel); inputs.add(Assignment.unionAll(inputFeatureVector, inputElement, firstLabel)); } List<LocalContext<I>> contexts = sequence.getLocalContexts(); for (int i = 0; i < contexts.size(); i++) { Assignment inputFeatureVector = x.outcomeArrayToAssignment(featureGen.apply(contexts.get(i))); Assignment inputElement = xInput.outcomeArrayToAssignment(inputGen.apply(contexts.get(i))); inputs.add(inputFeatureVector.union(inputElement)); } DynamicAssignment input = DynamicAssignment.createPlateAssignment(PLATE_NAME, inputs); DynamicAssignment output = DynamicAssignment.EMPTY; if (sequence.getLabels() != null) { List<Assignment> outputs = Lists.newArrayList(); if (startInput != null) { // First label is given (and equal to the special start label). outputs.add(Assignment.EMPTY); } List<O> labels = sequence.getLabels(); for (int i = 0; i < contexts.size(); i++) { outputs.add(y.outcomeArrayToAssignment(labels.get(i))); } output = DynamicAssignment.createPlateAssignment(PLATE_NAME, outputs); } examples.add(Example.create(input, output)); } return examples; }
[ "public", "static", "<", "I", ",", "O", ">", "List", "<", "Example", "<", "DynamicAssignment", ",", "DynamicAssignment", ">", ">", "reformatTrainingData", "(", "List", "<", "?", "extends", "TaggedSequence", "<", "I", ",", "O", ">", ">", "sequences", ",", ...
Converts training data as sequences into assignments that can be used for parameter estimation. @param sequences @param featureGen @param model @return
[ "Converts", "training", "data", "as", "sequences", "into", "assignments", "that", "can", "be", "used", "for", "parameter", "estimation", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/sequence/TaggerUtils.java#L121-L175
train
jayantk/jklol
src/com/jayantkrish/jklol/sequence/TaggerUtils.java
TaggerUtils.reformatTrainingDataPerItem
public static <I, O> List<Example<DynamicAssignment, DynamicAssignment>> reformatTrainingDataPerItem( List<? extends TaggedSequence<I, O>> sequences, FeatureVectorGenerator<LocalContext<I>> featureGen, Function<? super LocalContext<I>, ? extends Object> inputGen, DynamicVariableSet modelVariables, I startInput, O startLabel) { DynamicVariableSet plate = modelVariables.getPlate(PLATE_NAME); VariableNumMap x = plate.getFixedVariables().getVariablesByName(INPUT_FEATURES_NAME); VariableNumMap xInput = plate.getFixedVariables().getVariablesByName(INPUT_NAME); VariableNumMap y = plate.getFixedVariables().getVariablesByName(OUTPUT_NAME); ReformatPerItemMapper<I, O> mapper = new ReformatPerItemMapper<I, O>(featureGen, inputGen, x, xInput, y, startInput, startLabel); List<List<Example<DynamicAssignment, DynamicAssignment>>> exampleLists = MapReduceConfiguration .getMapReduceExecutor().map(sequences, mapper); List<Example<DynamicAssignment, DynamicAssignment>> examples = Lists.newArrayList(); for (List<Example<DynamicAssignment, DynamicAssignment>> exampleList : exampleLists) { examples.addAll(exampleList); } return examples; }
java
public static <I, O> List<Example<DynamicAssignment, DynamicAssignment>> reformatTrainingDataPerItem( List<? extends TaggedSequence<I, O>> sequences, FeatureVectorGenerator<LocalContext<I>> featureGen, Function<? super LocalContext<I>, ? extends Object> inputGen, DynamicVariableSet modelVariables, I startInput, O startLabel) { DynamicVariableSet plate = modelVariables.getPlate(PLATE_NAME); VariableNumMap x = plate.getFixedVariables().getVariablesByName(INPUT_FEATURES_NAME); VariableNumMap xInput = plate.getFixedVariables().getVariablesByName(INPUT_NAME); VariableNumMap y = plate.getFixedVariables().getVariablesByName(OUTPUT_NAME); ReformatPerItemMapper<I, O> mapper = new ReformatPerItemMapper<I, O>(featureGen, inputGen, x, xInput, y, startInput, startLabel); List<List<Example<DynamicAssignment, DynamicAssignment>>> exampleLists = MapReduceConfiguration .getMapReduceExecutor().map(sequences, mapper); List<Example<DynamicAssignment, DynamicAssignment>> examples = Lists.newArrayList(); for (List<Example<DynamicAssignment, DynamicAssignment>> exampleList : exampleLists) { examples.addAll(exampleList); } return examples; }
[ "public", "static", "<", "I", ",", "O", ">", "List", "<", "Example", "<", "DynamicAssignment", ",", "DynamicAssignment", ">", ">", "reformatTrainingDataPerItem", "(", "List", "<", "?", "extends", "TaggedSequence", "<", "I", ",", "O", ">", ">", "sequences", ...
Creates training examples from sequential data where each example involves predicting a single label given the current input and previous label. Such examples are suitable for training locally-normalized sequence models, such as HMMs and MEMMs. @param sequences @param featureGen @param inputGen @param modelVariables @return
[ "Creates", "training", "examples", "from", "sequential", "data", "where", "each", "example", "involves", "predicting", "a", "single", "label", "given", "the", "current", "input", "and", "previous", "label", ".", "Such", "examples", "are", "suitable", "for", "tra...
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/sequence/TaggerUtils.java#L189-L208
train
jayantk/jklol
src/com/jayantkrish/jklol/sequence/TaggerUtils.java
TaggerUtils.trainSequenceModel
public static <I, O> FactorGraphSequenceTagger<I, O> trainSequenceModel( ParametricFactorGraph sequenceModelFamily, List<Example<DynamicAssignment, DynamicAssignment>> examples, Class<O> outputClass, FeatureVectorGenerator<LocalContext<I>> featureGen, Function<? super LocalContext<I>, ? extends Object> inputGen, I startInput, O startLabel, GradientOptimizer optimizer, boolean useMaxMargin) { // Generate the training data and estimate parameters. SufficientStatistics parameters = estimateParameters(sequenceModelFamily, examples, optimizer, useMaxMargin); DynamicFactorGraph factorGraph = sequenceModelFamily.getModelFromParameters(parameters); return new FactorGraphSequenceTagger<I, O>(sequenceModelFamily, parameters, factorGraph, featureGen, inputGen, outputClass, new JunctionTree(), new JunctionTree(true), startInput, startLabel); }
java
public static <I, O> FactorGraphSequenceTagger<I, O> trainSequenceModel( ParametricFactorGraph sequenceModelFamily, List<Example<DynamicAssignment, DynamicAssignment>> examples, Class<O> outputClass, FeatureVectorGenerator<LocalContext<I>> featureGen, Function<? super LocalContext<I>, ? extends Object> inputGen, I startInput, O startLabel, GradientOptimizer optimizer, boolean useMaxMargin) { // Generate the training data and estimate parameters. SufficientStatistics parameters = estimateParameters(sequenceModelFamily, examples, optimizer, useMaxMargin); DynamicFactorGraph factorGraph = sequenceModelFamily.getModelFromParameters(parameters); return new FactorGraphSequenceTagger<I, O>(sequenceModelFamily, parameters, factorGraph, featureGen, inputGen, outputClass, new JunctionTree(), new JunctionTree(true), startInput, startLabel); }
[ "public", "static", "<", "I", ",", "O", ">", "FactorGraphSequenceTagger", "<", "I", ",", "O", ">", "trainSequenceModel", "(", "ParametricFactorGraph", "sequenceModelFamily", ",", "List", "<", "Example", "<", "DynamicAssignment", ",", "DynamicAssignment", ">", ">",...
Trains a sequence model. @param sequenceModelFamily @param trainingData @param outputClass @param featureGen @param inputGen @param optimizer @param useMaxMargin @return
[ "Trains", "a", "sequence", "model", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/sequence/TaggerUtils.java#L328-L342
train
HiddenStage/divide
Client/android-client/src/main/java/com/google/android/gcm/GCMRegistrar.java
GCMRegistrar.onDestroy
public static synchronized void onDestroy(Context context) { if (sRetryReceiver != null) { Log.v(TAG, "Unregistering receiver"); context.unregisterReceiver(sRetryReceiver); sRetryReceiver = null; } }
java
public static synchronized void onDestroy(Context context) { if (sRetryReceiver != null) { Log.v(TAG, "Unregistering receiver"); context.unregisterReceiver(sRetryReceiver); sRetryReceiver = null; } }
[ "public", "static", "synchronized", "void", "onDestroy", "(", "Context", "context", ")", "{", "if", "(", "sRetryReceiver", "!=", "null", ")", "{", "Log", ".", "v", "(", "TAG", ",", "\"Unregistering receiver\"", ")", ";", "context", ".", "unregisterReceiver", ...
Clear internal resources. <p> This method should be called by the main activity's {@code onDestroy()} method.
[ "Clear", "internal", "resources", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/android-client/src/main/java/com/google/android/gcm/GCMRegistrar.java#L258-L264
train
HiddenStage/divide
Client/android-client/src/main/java/com/google/android/gcm/GCMRegistrar.java
GCMRegistrar.setRegistrationId
static String setRegistrationId(Context context, String regId) { final SharedPreferences prefs = getGCMPreferences(context); String oldRegistrationId = prefs.getString(PROPERTY_REG_ID, ""); int appVersion = getAppVersion(context); Log.v(TAG, "Saving regId on app version " + appVersion); Editor editor = prefs.edit(); editor.putString(PROPERTY_REG_ID, regId); editor.putInt(PROPERTY_APP_VERSION, appVersion); editor.commit(); return oldRegistrationId; }
java
static String setRegistrationId(Context context, String regId) { final SharedPreferences prefs = getGCMPreferences(context); String oldRegistrationId = prefs.getString(PROPERTY_REG_ID, ""); int appVersion = getAppVersion(context); Log.v(TAG, "Saving regId on app version " + appVersion); Editor editor = prefs.edit(); editor.putString(PROPERTY_REG_ID, regId); editor.putInt(PROPERTY_APP_VERSION, appVersion); editor.commit(); return oldRegistrationId; }
[ "static", "String", "setRegistrationId", "(", "Context", "context", ",", "String", "regId", ")", "{", "final", "SharedPreferences", "prefs", "=", "getGCMPreferences", "(", "context", ")", ";", "String", "oldRegistrationId", "=", "prefs", ".", "getString", "(", "...
Sets the registration id in the persistence store. @param context application's context. @param regId registration id
[ "Sets", "the", "registration", "id", "in", "the", "persistence", "store", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/android-client/src/main/java/com/google/android/gcm/GCMRegistrar.java#L364-L374
train
HiddenStage/divide
Client/android-client/src/main/java/com/google/android/gcm/GCMRegistrar.java
GCMRegistrar.setRegisteredOnServer
public static void setRegisteredOnServer(Context context, boolean flag) { final SharedPreferences prefs = getGCMPreferences(context); Editor editor = prefs.edit(); editor.putBoolean(PROPERTY_ON_SERVER, flag); // set the flag's expiration date long lifespan = getRegisterOnServerLifespan(context); long expirationTime = System.currentTimeMillis() + lifespan; Log.v(TAG, "Setting registeredOnServer status as " + flag + " until " + new Timestamp(expirationTime)); editor.putLong(PROPERTY_ON_SERVER_EXPIRATION_TIME, expirationTime); editor.commit(); }
java
public static void setRegisteredOnServer(Context context, boolean flag) { final SharedPreferences prefs = getGCMPreferences(context); Editor editor = prefs.edit(); editor.putBoolean(PROPERTY_ON_SERVER, flag); // set the flag's expiration date long lifespan = getRegisterOnServerLifespan(context); long expirationTime = System.currentTimeMillis() + lifespan; Log.v(TAG, "Setting registeredOnServer status as " + flag + " until " + new Timestamp(expirationTime)); editor.putLong(PROPERTY_ON_SERVER_EXPIRATION_TIME, expirationTime); editor.commit(); }
[ "public", "static", "void", "setRegisteredOnServer", "(", "Context", "context", ",", "boolean", "flag", ")", "{", "final", "SharedPreferences", "prefs", "=", "getGCMPreferences", "(", "context", ")", ";", "Editor", "editor", "=", "prefs", ".", "edit", "(", ")"...
Sets whether the device was successfully registered in the server side.
[ "Sets", "whether", "the", "device", "was", "successfully", "registered", "in", "the", "server", "side", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/android-client/src/main/java/com/google/android/gcm/GCMRegistrar.java#L379-L390
train
HiddenStage/divide
Client/android-client/src/main/java/com/google/android/gcm/GCMRegistrar.java
GCMRegistrar.getAppVersion
private static int getAppVersion(Context context) { try { PackageInfo packageInfo = context.getPackageManager() .getPackageInfo(context.getPackageName(), 0); return packageInfo.versionCode; } catch (NameNotFoundException e) { // should never happen throw new RuntimeException("Coult not get package name: " + e); } }
java
private static int getAppVersion(Context context) { try { PackageInfo packageInfo = context.getPackageManager() .getPackageInfo(context.getPackageName(), 0); return packageInfo.versionCode; } catch (NameNotFoundException e) { // should never happen throw new RuntimeException("Coult not get package name: " + e); } }
[ "private", "static", "int", "getAppVersion", "(", "Context", "context", ")", "{", "try", "{", "PackageInfo", "packageInfo", "=", "context", ".", "getPackageManager", "(", ")", ".", "getPackageInfo", "(", "context", ".", "getPackageName", "(", ")", ",", "0", ...
Gets the application version.
[ "Gets", "the", "application", "version", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/android-client/src/main/java/com/google/android/gcm/GCMRegistrar.java#L446-L455
train
HiddenStage/divide
Client/android-client/src/main/java/com/google/android/gcm/GCMRegistrar.java
GCMRegistrar.getBackoff
static int getBackoff(Context context) { final SharedPreferences prefs = getGCMPreferences(context); return prefs.getInt(BACKOFF_MS, DEFAULT_BACKOFF_MS); }
java
static int getBackoff(Context context) { final SharedPreferences prefs = getGCMPreferences(context); return prefs.getInt(BACKOFF_MS, DEFAULT_BACKOFF_MS); }
[ "static", "int", "getBackoff", "(", "Context", "context", ")", "{", "final", "SharedPreferences", "prefs", "=", "getGCMPreferences", "(", "context", ")", ";", "return", "prefs", ".", "getInt", "(", "BACKOFF_MS", ",", "DEFAULT_BACKOFF_MS", ")", ";", "}" ]
Gets the current backoff counter. @param context application's context. @return current backoff counter, in milliseconds.
[ "Gets", "the", "current", "backoff", "counter", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/android-client/src/main/java/com/google/android/gcm/GCMRegistrar.java#L475-L478
train
jayantk/jklol
src/com/jayantkrish/jklol/tensor/DenseTensor.java
DenseTensor.denseTensorInnerProduct
private double denseTensorInnerProduct(DenseTensor other) { double[] otherValues = other.values; int length = values.length; Preconditions.checkArgument(otherValues.length == length); double innerProduct = 0.0; for (int i = 0; i < length; i++) { innerProduct += values[i] * otherValues[i]; } return innerProduct; }
java
private double denseTensorInnerProduct(DenseTensor other) { double[] otherValues = other.values; int length = values.length; Preconditions.checkArgument(otherValues.length == length); double innerProduct = 0.0; for (int i = 0; i < length; i++) { innerProduct += values[i] * otherValues[i]; } return innerProduct; }
[ "private", "double", "denseTensorInnerProduct", "(", "DenseTensor", "other", ")", "{", "double", "[", "]", "otherValues", "=", "other", ".", "values", ";", "int", "length", "=", "values", ".", "length", ";", "Preconditions", ".", "checkArgument", "(", "otherVa...
Implementation of inner product where both tensors are dense and have the same dimensionality. These properties enable the inner product to be computed extremely quickly by iterating over both dense arrays of values. @param other @return
[ "Implementation", "of", "inner", "product", "where", "both", "tensors", "are", "dense", "and", "have", "the", "same", "dimensionality", ".", "These", "properties", "enable", "the", "inner", "product", "to", "be", "computed", "extremely", "quickly", "by", "iterat...
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/tensor/DenseTensor.java#L234-L244
train
GoodforGod/dummymaker
src/main/java/io/dummymaker/scan/impl/BasicScanner.java
BasicScanner.buildDeclaredAnnotationList
private List<Annotation> buildDeclaredAnnotationList(final Annotation annotation) { final List<Annotation> list = Arrays.stream(annotation.annotationType().getDeclaredAnnotations()) .collect(Collectors.toList()); list.add(annotation); return list; }
java
private List<Annotation> buildDeclaredAnnotationList(final Annotation annotation) { final List<Annotation> list = Arrays.stream(annotation.annotationType().getDeclaredAnnotations()) .collect(Collectors.toList()); list.add(annotation); return list; }
[ "private", "List", "<", "Annotation", ">", "buildDeclaredAnnotationList", "(", "final", "Annotation", "annotation", ")", "{", "final", "List", "<", "Annotation", ">", "list", "=", "Arrays", ".", "stream", "(", "annotation", ".", "annotationType", "(", ")", "."...
Retrieve declared annotations from parent one and build set of them all @param annotation parent annotation @return parent annotation and its declared ones
[ "Retrieve", "declared", "annotations", "from", "parent", "one", "and", "build", "set", "of", "them", "all" ]
a4809c0a8139ab9cdb42814a3e37772717a313b4
https://github.com/GoodforGod/dummymaker/blob/a4809c0a8139ab9cdb42814a3e37772717a313b4/src/main/java/io/dummymaker/scan/impl/BasicScanner.java#L55-L60
train
jayantk/jklol
src/com/jayantkrish/jklol/evaluation/CrossValidationEvaluation.java
CrossValidationEvaluation.kFold
public static <I, O> CrossValidationEvaluation<I, O> kFold( Collection<Example<I, O>> data, int k) { Preconditions.checkNotNull(data); Preconditions.checkArgument(k > 1); int numTrainingPoints = data.size(); List<Collection<Example<I, O>>> folds = Lists.newArrayList(); for (List<Example<I, O>> fold : Iterables.partition(data, (int) Math.ceil(numTrainingPoints / k))) { folds.add(fold); } return new CrossValidationEvaluation<I, O>(folds); }
java
public static <I, O> CrossValidationEvaluation<I, O> kFold( Collection<Example<I, O>> data, int k) { Preconditions.checkNotNull(data); Preconditions.checkArgument(k > 1); int numTrainingPoints = data.size(); List<Collection<Example<I, O>>> folds = Lists.newArrayList(); for (List<Example<I, O>> fold : Iterables.partition(data, (int) Math.ceil(numTrainingPoints / k))) { folds.add(fold); } return new CrossValidationEvaluation<I, O>(folds); }
[ "public", "static", "<", "I", ",", "O", ">", "CrossValidationEvaluation", "<", "I", ",", "O", ">", "kFold", "(", "Collection", "<", "Example", "<", "I", ",", "O", ">", ">", "data", ",", "int", "k", ")", "{", "Preconditions", ".", "checkNotNull", "(",...
Construct a cross validation evaluation from a data set by partitioning it into k folds. The elements in data should be in a random order.
[ "Construct", "a", "cross", "validation", "evaluation", "from", "a", "data", "set", "by", "partitioning", "it", "into", "k", "folds", ".", "The", "elements", "in", "data", "should", "be", "in", "a", "random", "order", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/evaluation/CrossValidationEvaluation.java#L50-L62
train
ivanceras/orm
src/main/java/com/ivanceras/db/api/ModelDef.java
ModelDef.getLocalColumns
public String[] getLocalColumns(String modelName) { List<String> columnList = new ArrayList<String>(); for(int i = 0; i < this.hasOne.length; i++){ if(modelName.equalsIgnoreCase(this.hasOne[i])){ columnList.add(hasOneLocalColumn[i]); } } for(int j = 0; j < this.hasMany.length; j++){ if(modelName.equalsIgnoreCase(hasMany[j])){ columnList.add(hasManyLocalColumn[j]); } } if(columnList.size() == 0){ return null; } return columnList.toArray(new String[columnList.size()]); }
java
public String[] getLocalColumns(String modelName) { List<String> columnList = new ArrayList<String>(); for(int i = 0; i < this.hasOne.length; i++){ if(modelName.equalsIgnoreCase(this.hasOne[i])){ columnList.add(hasOneLocalColumn[i]); } } for(int j = 0; j < this.hasMany.length; j++){ if(modelName.equalsIgnoreCase(hasMany[j])){ columnList.add(hasManyLocalColumn[j]); } } if(columnList.size() == 0){ return null; } return columnList.toArray(new String[columnList.size()]); }
[ "public", "String", "[", "]", "getLocalColumns", "(", "String", "modelName", ")", "{", "List", "<", "String", ">", "columnList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", "....
get the foreign key column of this table definition from this refered table
[ "get", "the", "foreign", "key", "column", "of", "this", "table", "definition", "from", "this", "refered", "table" ]
e63213cb8abefd11df0e2d34b1c95477788e600e
https://github.com/ivanceras/orm/blob/e63213cb8abefd11df0e2d34b1c95477788e600e/src/main/java/com/ivanceras/db/api/ModelDef.java#L239-L255
train
ivanceras/orm
src/main/java/com/ivanceras/db/api/ModelDef.java
ModelDef.getPlainProperties
public String[] getPlainProperties(){ String[] commonColumns = {"created", "createdby", "updated","updatedby", "isactive"}; String[] referencedProperties = getReferencedColumns(); List<String> plainProperties = new ArrayList<String>(); for(String att : attributes){ if(CStringUtils.indexOf(referencedProperties, att) >= 0 ){ //do not include referenced columns } else if(att.endsWith("_id")){ ;//do not include implied columns } else if(CStringUtils.indexOf(commonColumns, att) >= 0){ ;//do not include common columns } else{ plainProperties.add(att); } } return plainProperties.toArray(new String[plainProperties.size()]); }
java
public String[] getPlainProperties(){ String[] commonColumns = {"created", "createdby", "updated","updatedby", "isactive"}; String[] referencedProperties = getReferencedColumns(); List<String> plainProperties = new ArrayList<String>(); for(String att : attributes){ if(CStringUtils.indexOf(referencedProperties, att) >= 0 ){ //do not include referenced columns } else if(att.endsWith("_id")){ ;//do not include implied columns } else if(CStringUtils.indexOf(commonColumns, att) >= 0){ ;//do not include common columns } else{ plainProperties.add(att); } } return plainProperties.toArray(new String[plainProperties.size()]); }
[ "public", "String", "[", "]", "getPlainProperties", "(", ")", "{", "String", "[", "]", "commonColumns", "=", "{", "\"created\"", ",", "\"createdby\"", ",", "\"updated\"", ",", "\"updatedby\"", ",", "\"isactive\"", "}", ";", "String", "[", "]", "referencedPrope...
Get the properties that are pertaining to the model, this does not include linker columns @return
[ "Get", "the", "properties", "that", "are", "pertaining", "to", "the", "model", "this", "does", "not", "include", "linker", "columns" ]
e63213cb8abefd11df0e2d34b1c95477788e600e
https://github.com/ivanceras/orm/blob/e63213cb8abefd11df0e2d34b1c95477788e600e/src/main/java/com/ivanceras/db/api/ModelDef.java#L342-L361
train
cpollet/jixture
core/src/main/java/net/cpollet/jixture/fixtures/capacities/extraction/ExtractionResult.java
ExtractionResult.add
public void add(Object entity, String name) { Result result = new Result(entity, name); results.add(result); }
java
public void add(Object entity, String name) { Result result = new Result(entity, name); results.add(result); }
[ "public", "void", "add", "(", "Object", "entity", ",", "String", "name", ")", "{", "Result", "result", "=", "new", "Result", "(", "entity", ",", "name", ")", ";", "results", ".", "add", "(", "result", ")", ";", "}" ]
Add a new entity to an extraction collection. @param entity the entity to add. @param name the name of the collection where this entity should be put.
[ "Add", "a", "new", "entity", "to", "an", "extraction", "collection", "." ]
faef0d4991f81c2cdb5be3ba24176636ef0cc433
https://github.com/cpollet/jixture/blob/faef0d4991f81c2cdb5be3ba24176636ef0cc433/core/src/main/java/net/cpollet/jixture/fixtures/capacities/extraction/ExtractionResult.java#L43-L46
train
cpollet/jixture
core/src/main/java/net/cpollet/jixture/fixtures/capacities/extraction/ExtractionResult.java
ExtractionResult.getEntities
public List<Object> getEntities(String name) { List<Object> entitiesList = new LinkedList<Object>(); for (Result result : results) { if (result.getResultName().equals(name)) { entitiesList.add(result.getObject()); } } return entitiesList; }
java
public List<Object> getEntities(String name) { List<Object> entitiesList = new LinkedList<Object>(); for (Result result : results) { if (result.getResultName().equals(name)) { entitiesList.add(result.getObject()); } } return entitiesList; }
[ "public", "List", "<", "Object", ">", "getEntities", "(", "String", "name", ")", "{", "List", "<", "Object", ">", "entitiesList", "=", "new", "LinkedList", "<", "Object", ">", "(", ")", ";", "for", "(", "Result", "result", ":", "results", ")", "{", "...
Returns all entities stored in the given collection. @param name the collection's name @return all entities stored in the given collection.
[ "Returns", "all", "entities", "stored", "in", "the", "given", "collection", "." ]
faef0d4991f81c2cdb5be3ba24176636ef0cc433
https://github.com/cpollet/jixture/blob/faef0d4991f81c2cdb5be3ba24176636ef0cc433/core/src/main/java/net/cpollet/jixture/fixtures/capacities/extraction/ExtractionResult.java#L54-L64
train
cpollet/jixture
core/src/main/java/net/cpollet/jixture/fixtures/capacities/extraction/ExtractionResult.java
ExtractionResult.getEntities
public List<Object> getEntities() { List<Object> entitiesList = new LinkedList<Object>(); for (Result result : results) { entitiesList.add(result.getObject()); } return entitiesList; }
java
public List<Object> getEntities() { List<Object> entitiesList = new LinkedList<Object>(); for (Result result : results) { entitiesList.add(result.getObject()); } return entitiesList; }
[ "public", "List", "<", "Object", ">", "getEntities", "(", ")", "{", "List", "<", "Object", ">", "entitiesList", "=", "new", "LinkedList", "<", "Object", ">", "(", ")", ";", "for", "(", "Result", "result", ":", "results", ")", "{", "entitiesList", ".", ...
Returns all entities. @return all entities.
[ "Returns", "all", "entities", "." ]
faef0d4991f81c2cdb5be3ba24176636ef0cc433
https://github.com/cpollet/jixture/blob/faef0d4991f81c2cdb5be3ba24176636ef0cc433/core/src/main/java/net/cpollet/jixture/fixtures/capacities/extraction/ExtractionResult.java#L108-L116
train
jayantk/jklol
src/com/jayantkrish/jklol/tensor/DenseTensorBuilder.java
DenseTensorBuilder.simpleIncrement
private void simpleIncrement(TensorBase other, double multiplier) { Preconditions.checkArgument(Arrays.equals(other.getDimensionNumbers(), getDimensionNumbers())); if (other instanceof DenseTensorBase) { double[] otherTensorValues = ((DenseTensorBase) other).values; Preconditions.checkArgument(otherTensorValues.length == values.length); int length = values.length; for (int i = 0; i < length; i++) { values[i] += otherTensorValues[i] * multiplier; } } else { int otherSize = other.size(); for (int i = 0; i < otherSize; i++) { long keyNum = other.indexToKeyNum(i); double value = other.getByIndex(i); values[keyNumToIndex(keyNum)] += value * multiplier; } } }
java
private void simpleIncrement(TensorBase other, double multiplier) { Preconditions.checkArgument(Arrays.equals(other.getDimensionNumbers(), getDimensionNumbers())); if (other instanceof DenseTensorBase) { double[] otherTensorValues = ((DenseTensorBase) other).values; Preconditions.checkArgument(otherTensorValues.length == values.length); int length = values.length; for (int i = 0; i < length; i++) { values[i] += otherTensorValues[i] * multiplier; } } else { int otherSize = other.size(); for (int i = 0; i < otherSize; i++) { long keyNum = other.indexToKeyNum(i); double value = other.getByIndex(i); values[keyNumToIndex(keyNum)] += value * multiplier; } } }
[ "private", "void", "simpleIncrement", "(", "TensorBase", "other", ",", "double", "multiplier", ")", "{", "Preconditions", ".", "checkArgument", "(", "Arrays", ".", "equals", "(", "other", ".", "getDimensionNumbers", "(", ")", ",", "getDimensionNumbers", "(", ")"...
Increment algorithm for the case where both tensors have the same set of dimensions. @param other @param multiplier
[ "Increment", "algorithm", "for", "the", "case", "where", "both", "tensors", "have", "the", "same", "set", "of", "dimensions", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/tensor/DenseTensorBuilder.java#L197-L214
train
ivanceras/orm
src/main/java/com/ivanceras/db/server/util/DAOGenerator.java
DAOGenerator.getOverrideModel
private ModelDef getOverrideModel(ModelDef model, ModelMetaData explicitMeta2) { if(explicitMeta2 == null){ return model; } List<ModelDef> explicitList = explicitMeta2.getModelDefinitionList(); for(ModelDef explicitModel : explicitList){ if(explicitModel.getModelName().equals(model.getModelName())){ return explicitModel; } } return model; }
java
private ModelDef getOverrideModel(ModelDef model, ModelMetaData explicitMeta2) { if(explicitMeta2 == null){ return model; } List<ModelDef> explicitList = explicitMeta2.getModelDefinitionList(); for(ModelDef explicitModel : explicitList){ if(explicitModel.getModelName().equals(model.getModelName())){ return explicitModel; } } return model; }
[ "private", "ModelDef", "getOverrideModel", "(", "ModelDef", "model", ",", "ModelMetaData", "explicitMeta2", ")", "{", "if", "(", "explicitMeta2", "==", "null", ")", "{", "return", "model", ";", "}", "List", "<", "ModelDef", ">", "explicitList", "=", "explicitM...
When the mode is in the explecit model, use it instead, else use what's the in database @param model @param explicitMeta2 @return
[ "When", "the", "mode", "is", "in", "the", "explecit", "model", "use", "it", "instead", "else", "use", "what", "s", "the", "in", "database" ]
e63213cb8abefd11df0e2d34b1c95477788e600e
https://github.com/ivanceras/orm/blob/e63213cb8abefd11df0e2d34b1c95477788e600e/src/main/java/com/ivanceras/db/server/util/DAOGenerator.java#L133-L145
train
ivanceras/orm
src/main/java/com/ivanceras/db/server/util/DAOGenerator.java
DAOGenerator.chooseFirstOccurence
private String chooseFirstOccurence(String[] among_owners, String[] within_listgroup, String prior_tableName) { int index = CStringUtils.indexOf(within_listgroup, prior_tableName); for(int i = index-1; i >= 0; i-- ){ String closest = within_listgroup[i]; if(CStringUtils.indexOf(among_owners, closest) >= 0){ return closest; } } return null; }
java
private String chooseFirstOccurence(String[] among_owners, String[] within_listgroup, String prior_tableName) { int index = CStringUtils.indexOf(within_listgroup, prior_tableName); for(int i = index-1; i >= 0; i-- ){ String closest = within_listgroup[i]; if(CStringUtils.indexOf(among_owners, closest) >= 0){ return closest; } } return null; }
[ "private", "String", "chooseFirstOccurence", "(", "String", "[", "]", "among_owners", ",", "String", "[", "]", "within_listgroup", ",", "String", "prior_tableName", ")", "{", "int", "index", "=", "CStringUtils", ".", "indexOf", "(", "within_listgroup", ",", "pri...
Choose among the owners that are present within the list group that occurs before the tableName, and closest to it @param owners @param group @param tableName
[ "Choose", "among", "the", "owners", "that", "are", "present", "within", "the", "list", "group", "that", "occurs", "before", "the", "tableName", "and", "closest", "to", "it" ]
e63213cb8abefd11df0e2d34b1c95477788e600e
https://github.com/ivanceras/orm/blob/e63213cb8abefd11df0e2d34b1c95477788e600e/src/main/java/com/ivanceras/db/server/util/DAOGenerator.java#L279-L289
train
ivanceras/orm
src/main/java/com/ivanceras/db/server/util/DAOGenerator.java
DAOGenerator.transformGroup
private Map<String, Set<String[]>> transformGroup(List<String[]> tableGroups) { Map<String, Set<String[]>> model_tableGroup = new LinkedHashMap<String, Set<String[]>>(); for(String[] list : tableGroups){ for(String table : list){ if(model_tableGroup.containsKey(table)){ Set<String[]> tableGroupSet = model_tableGroup.get(table); tableGroupSet.add(list); } else{ Set<String[]> tableGroupSet = new HashSet<String[]>(); tableGroupSet.add(list); model_tableGroup.put(table, tableGroupSet); } } } return model_tableGroup; }
java
private Map<String, Set<String[]>> transformGroup(List<String[]> tableGroups) { Map<String, Set<String[]>> model_tableGroup = new LinkedHashMap<String, Set<String[]>>(); for(String[] list : tableGroups){ for(String table : list){ if(model_tableGroup.containsKey(table)){ Set<String[]> tableGroupSet = model_tableGroup.get(table); tableGroupSet.add(list); } else{ Set<String[]> tableGroupSet = new HashSet<String[]>(); tableGroupSet.add(list); model_tableGroup.put(table, tableGroupSet); } } } return model_tableGroup; }
[ "private", "Map", "<", "String", ",", "Set", "<", "String", "[", "]", ">", ">", "transformGroup", "(", "List", "<", "String", "[", "]", ">", "tableGroups", ")", "{", "Map", "<", "String", ",", "Set", "<", "String", "[", "]", ">", ">", "model_tableG...
transform the listing of table groups, according to table
[ "transform", "the", "listing", "of", "table", "groups", "according", "to", "table" ]
e63213cb8abefd11df0e2d34b1c95477788e600e
https://github.com/ivanceras/orm/blob/e63213cb8abefd11df0e2d34b1c95477788e600e/src/main/java/com/ivanceras/db/server/util/DAOGenerator.java#L322-L338
train
getlantern/kaleidoscope
src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java
BasicRandomRoutingTable.getNextHop
@Override public TrustGraphNodeId getNextHop(final TrustGraphAdvertisement message) { final TrustGraphNodeId prev = message.getSender(); return getNextHop(prev); }
java
@Override public TrustGraphNodeId getNextHop(final TrustGraphAdvertisement message) { final TrustGraphNodeId prev = message.getSender(); return getNextHop(prev); }
[ "@", "Override", "public", "TrustGraphNodeId", "getNextHop", "(", "final", "TrustGraphAdvertisement", "message", ")", "{", "final", "TrustGraphNodeId", "prev", "=", "message", ".", "getSender", "(", ")", ";", "return", "getNextHop", "(", "prev", ")", ";", "}" ]
Determine the next hop for a message. @param message the message to determine the next hop for @return the next TrustGraphNodeId to send the message to or null if the next hop cannot be determined. @see RandomRoutingTable.getNextHop(TrustGraphAdvertisement)
[ "Determine", "the", "next", "hop", "for", "a", "message", "." ]
7516f05724c8f54e5d535d23da9116817c08a09f
https://github.com/getlantern/kaleidoscope/blob/7516f05724c8f54e5d535d23da9116817c08a09f/src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java#L149-L153
train
getlantern/kaleidoscope
src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java
BasicRandomRoutingTable.getNextHop
@Override public TrustGraphNodeId getNextHop(final TrustGraphNodeId priorNeighbor) { if (priorNeighbor != null) { return routingTable.get(priorNeighbor); } else { return null; } }
java
@Override public TrustGraphNodeId getNextHop(final TrustGraphNodeId priorNeighbor) { if (priorNeighbor != null) { return routingTable.get(priorNeighbor); } else { return null; } }
[ "@", "Override", "public", "TrustGraphNodeId", "getNextHop", "(", "final", "TrustGraphNodeId", "priorNeighbor", ")", "{", "if", "(", "priorNeighbor", "!=", "null", ")", "{", "return", "routingTable", ".", "get", "(", "priorNeighbor", ")", ";", "}", "else", "{"...
Determine the next TrustGraphNodeId in a route containing a given neighbor as the prior node. The next hop is the TrustGraphNodeId paired with the given neighbor in the table. @param priorNeighbor the prior node on the route @return the next TrustGraphNodeId to route a message to or null if the next hop cannot be determined. @see RandomRoutingTable.getNextHop(TrustGraphNodeId)
[ "Determine", "the", "next", "TrustGraphNodeId", "in", "a", "route", "containing", "a", "given", "neighbor", "as", "the", "prior", "node", ".", "The", "next", "hop", "is", "the", "TrustGraphNodeId", "paired", "with", "the", "given", "neighbor", "in", "the", "...
7516f05724c8f54e5d535d23da9116817c08a09f
https://github.com/getlantern/kaleidoscope/blob/7516f05724c8f54e5d535d23da9116817c08a09f/src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java#L165-L173
train
getlantern/kaleidoscope
src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java
BasicRandomRoutingTable.addNeighbor
@Override public void addNeighbor(final TrustGraphNodeId neighbor) { if (neighbor == null) { return; } // all modification operations are serialized synchronized(this) { // do not add this neighbor if it is already present if (contains(neighbor)) { return; } /* If there is nothing in the table, route the neighbor to itself. * this condition is fixed during the next single addition since * the route is always selected to be split. The bulk add * operation also takes special care to perform a single addition * if this state exists before adding additional routes. */ if (routingTable.isEmpty()) { routingTable.put(neighbor, neighbor); } /* otherwise, pick a random existing route X->Y and * split it into two routes, X->neighbor and neighbor->Y */ else { Map.Entry<TrustGraphNodeId,TrustGraphNodeId> split = randomRoute(); TrustGraphNodeId splitKey = split.getKey(); TrustGraphNodeId splitVal = split.getValue(); /* * The new route neighbor->Y is inserted first. This * preserves the existing routing behavior for readers * until the entire operation is complete. */ routingTable.put(neighbor, splitVal); routingTable.replace(splitKey, neighbor); } // add the neighbor to the ordering addNeighborToOrdering(neighbor); } }
java
@Override public void addNeighbor(final TrustGraphNodeId neighbor) { if (neighbor == null) { return; } // all modification operations are serialized synchronized(this) { // do not add this neighbor if it is already present if (contains(neighbor)) { return; } /* If there is nothing in the table, route the neighbor to itself. * this condition is fixed during the next single addition since * the route is always selected to be split. The bulk add * operation also takes special care to perform a single addition * if this state exists before adding additional routes. */ if (routingTable.isEmpty()) { routingTable.put(neighbor, neighbor); } /* otherwise, pick a random existing route X->Y and * split it into two routes, X->neighbor and neighbor->Y */ else { Map.Entry<TrustGraphNodeId,TrustGraphNodeId> split = randomRoute(); TrustGraphNodeId splitKey = split.getKey(); TrustGraphNodeId splitVal = split.getValue(); /* * The new route neighbor->Y is inserted first. This * preserves the existing routing behavior for readers * until the entire operation is complete. */ routingTable.put(neighbor, splitVal); routingTable.replace(splitKey, neighbor); } // add the neighbor to the ordering addNeighborToOrdering(neighbor); } }
[ "@", "Override", "public", "void", "addNeighbor", "(", "final", "TrustGraphNodeId", "neighbor", ")", "{", "if", "(", "neighbor", "==", "null", ")", "{", "return", ";", "}", "// all modification operations are serialized", "synchronized", "(", "this", ")", "{", "...
Add a single TrustGraphNodeId to the routing table. A random existing route X->Y is split into two routes, X -> neighbor, neighbor -> Y to accommodate the new neighbor. If there are no existing routes, the neighbor is mapped to itself. If there is an existing route of the form neighbor -> X in the routing table, this operation has no effect. @param neighbor the TrustGraphNieghbor to add @see RandomRoutingTable.addNeighbor(TrustGraphNodeId)
[ "Add", "a", "single", "TrustGraphNodeId", "to", "the", "routing", "table", "." ]
7516f05724c8f54e5d535d23da9116817c08a09f
https://github.com/getlantern/kaleidoscope/blob/7516f05724c8f54e5d535d23da9116817c08a09f/src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java#L189-L233
train
getlantern/kaleidoscope
src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java
BasicRandomRoutingTable.randomRoute
protected Map.Entry<TrustGraphNodeId,TrustGraphNodeId> randomRoute() { final int routeNumber = rng.nextInt(routingTable.size()); final Iterator<Map.Entry<TrustGraphNodeId,TrustGraphNodeId>> routes = routingTable.entrySet().iterator(); for (int i = 0; i < routeNumber; i++) { routes.next(); } return routes.next(); }
java
protected Map.Entry<TrustGraphNodeId,TrustGraphNodeId> randomRoute() { final int routeNumber = rng.nextInt(routingTable.size()); final Iterator<Map.Entry<TrustGraphNodeId,TrustGraphNodeId>> routes = routingTable.entrySet().iterator(); for (int i = 0; i < routeNumber; i++) { routes.next(); } return routes.next(); }
[ "protected", "Map", ".", "Entry", "<", "TrustGraphNodeId", ",", "TrustGraphNodeId", ">", "randomRoute", "(", ")", "{", "final", "int", "routeNumber", "=", "rng", ".", "nextInt", "(", "routingTable", ".", "size", "(", ")", ")", ";", "final", "Iterator", "<"...
internal helper method to pick a random route from the table.
[ "internal", "helper", "method", "to", "pick", "a", "random", "route", "from", "the", "table", "." ]
7516f05724c8f54e5d535d23da9116817c08a09f
https://github.com/getlantern/kaleidoscope/blob/7516f05724c8f54e5d535d23da9116817c08a09f/src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java#L238-L244
train
getlantern/kaleidoscope
src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java
BasicRandomRoutingTable.addNeighbors
@Override public void addNeighbors(final Collection<TrustGraphNodeId> neighborsIn) { if (neighborsIn.isEmpty()) { return; } // all modification operations are serialized synchronized (this) { /* filter out any neighbors that are already in the routing table * and the new ones to the newNeighbors list */ final LinkedList<TrustGraphNodeId> newNeighbors = new LinkedList<TrustGraphNodeId>(); for (TrustGraphNodeId n : neighborsIn) { if (!contains(n)) { newNeighbors.add(n); } } // if there is nothing new, we're done. if (newNeighbors.size() == 0) { return; } // handle list of length 1 the same way as a single insertion else if (newNeighbors.size() == 1) { addNeighbor(newNeighbors.get(0)); return; } // otherwise there is more than one new neighbor to add. /* if there are existing routes, a random route in the * table will be split. It is picked prior to adding * any of the new routes. */ Map.Entry<TrustGraphNodeId,TrustGraphNodeId> split = null; if (!routingTable.isEmpty()) { // Pick a random existing route X->Y to split split = randomRoute(); } /* Create a random permutation of the list. * Add in new neighbors from this permutation, routing * i->i+1. These routes do not disturb any existing * routes and create no self references. */ Collections.shuffle(newNeighbors, rng); final Iterator<TrustGraphNodeId> i = newNeighbors.iterator(); TrustGraphNodeId key = i.next(); while (i.hasNext()) { final TrustGraphNodeId val = i.next(); routingTable.put(key,val); key = val; } /* if there was nothing in the routing table yet, the first * item in the permutation is routed to the last. */ if (split == null) { // loop around, bind the last to the first routingTable.put(newNeighbors.getLast(), newNeighbors.getFirst()); } /* Otherwise, split the route chosen beforehand. Map the * key to the first node in the chain, and map the * last node in the chain to the value. ie X->Y becomes * X->first->....->last->Y. Similarly to the single * neighbor add method above, this preserves the structure * of the routing table forming some circular chain of * nodes of length equal to the size of the table. */ else { TrustGraphNodeId splitKey = split.getKey(); TrustGraphNodeId splitVal = split.getValue(); /* * Add routes X-> first and last->Y. The new route last->Y is * inserted first. This preserves the existing routing behavior * for readers until the entire operation is complete. */ routingTable.put(newNeighbors.getLast(), splitVal); routingTable.replace(splitKey, newNeighbors.getFirst()); } /* add the new neighbors into the ordering */ addNeighborsToOrdering(newNeighbors); } }
java
@Override public void addNeighbors(final Collection<TrustGraphNodeId> neighborsIn) { if (neighborsIn.isEmpty()) { return; } // all modification operations are serialized synchronized (this) { /* filter out any neighbors that are already in the routing table * and the new ones to the newNeighbors list */ final LinkedList<TrustGraphNodeId> newNeighbors = new LinkedList<TrustGraphNodeId>(); for (TrustGraphNodeId n : neighborsIn) { if (!contains(n)) { newNeighbors.add(n); } } // if there is nothing new, we're done. if (newNeighbors.size() == 0) { return; } // handle list of length 1 the same way as a single insertion else if (newNeighbors.size() == 1) { addNeighbor(newNeighbors.get(0)); return; } // otherwise there is more than one new neighbor to add. /* if there are existing routes, a random route in the * table will be split. It is picked prior to adding * any of the new routes. */ Map.Entry<TrustGraphNodeId,TrustGraphNodeId> split = null; if (!routingTable.isEmpty()) { // Pick a random existing route X->Y to split split = randomRoute(); } /* Create a random permutation of the list. * Add in new neighbors from this permutation, routing * i->i+1. These routes do not disturb any existing * routes and create no self references. */ Collections.shuffle(newNeighbors, rng); final Iterator<TrustGraphNodeId> i = newNeighbors.iterator(); TrustGraphNodeId key = i.next(); while (i.hasNext()) { final TrustGraphNodeId val = i.next(); routingTable.put(key,val); key = val; } /* if there was nothing in the routing table yet, the first * item in the permutation is routed to the last. */ if (split == null) { // loop around, bind the last to the first routingTable.put(newNeighbors.getLast(), newNeighbors.getFirst()); } /* Otherwise, split the route chosen beforehand. Map the * key to the first node in the chain, and map the * last node in the chain to the value. ie X->Y becomes * X->first->....->last->Y. Similarly to the single * neighbor add method above, this preserves the structure * of the routing table forming some circular chain of * nodes of length equal to the size of the table. */ else { TrustGraphNodeId splitKey = split.getKey(); TrustGraphNodeId splitVal = split.getValue(); /* * Add routes X-> first and last->Y. The new route last->Y is * inserted first. This preserves the existing routing behavior * for readers until the entire operation is complete. */ routingTable.put(newNeighbors.getLast(), splitVal); routingTable.replace(splitKey, newNeighbors.getFirst()); } /* add the new neighbors into the ordering */ addNeighborsToOrdering(newNeighbors); } }
[ "@", "Override", "public", "void", "addNeighbors", "(", "final", "Collection", "<", "TrustGraphNodeId", ">", "neighborsIn", ")", "{", "if", "(", "neighborsIn", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "// all modification operations are serialized",...
Add a group of TrustGraphNeighbors to the routing table. A maximum of one route is disrupted by this operation, as many routes as possible are assigned within the group. Any previously mapped neighbors will be ignored. @param neighbor the set of TrustGraphNieghbors to add @see addNeighbor @see RandomRoutingTable.addNeighbors(Collection<TrustGraphNeighbor>)
[ "Add", "a", "group", "of", "TrustGraphNeighbors", "to", "the", "routing", "table", "." ]
7516f05724c8f54e5d535d23da9116817c08a09f
https://github.com/getlantern/kaleidoscope/blob/7516f05724c8f54e5d535d23da9116817c08a09f/src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java#L258-L345
train
getlantern/kaleidoscope
src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java
BasicRandomRoutingTable.removeNeighbor
@Override public void removeNeighbor(final TrustGraphNodeId neighbor) { // all modification operations are serialized synchronized(this) { // do nothing if there is no entry for the neighbor specified if (!contains(neighbor)) { return; } /* first remove the neighbor from the ordering. This will * prevent it from being advertised to. */ removeNeighborFromOrdering(neighbor); removeNeighborFromRoutingTable(neighbor); } }
java
@Override public void removeNeighbor(final TrustGraphNodeId neighbor) { // all modification operations are serialized synchronized(this) { // do nothing if there is no entry for the neighbor specified if (!contains(neighbor)) { return; } /* first remove the neighbor from the ordering. This will * prevent it from being advertised to. */ removeNeighborFromOrdering(neighbor); removeNeighborFromRoutingTable(neighbor); } }
[ "@", "Override", "public", "void", "removeNeighbor", "(", "final", "TrustGraphNodeId", "neighbor", ")", "{", "// all modification operations are serialized", "synchronized", "(", "this", ")", "{", "// do nothing if there is no entry for the neighbor specified", "if", "(", "!"...
Remove a single TrustGraphNodeId from the routing table If the node is mapped to itself, the route is removed. Otherwise this operation merges the two routes of the form X -> neighbor , neighbor -> Y into X -> Y. If the table does not contain the referenced neighbor, this operation has no effect. @param neighbor the TrustGraphNodeId to remove @see RandomRoutingTable.removeNeighbor
[ "Remove", "a", "single", "TrustGraphNodeId", "from", "the", "routing", "table" ]
7516f05724c8f54e5d535d23da9116817c08a09f
https://github.com/getlantern/kaleidoscope/blob/7516f05724c8f54e5d535d23da9116817c08a09f/src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java#L414-L429
train
getlantern/kaleidoscope
src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java
BasicRandomRoutingTable.removeNeighbors
@Override public void removeNeighbors(final Collection<TrustGraphNodeId> neighbors) { synchronized(this) { // remove the neighbors from the ordering in bulk removeNeighborsFromOrdering(neighbors); // just loop over the neighbors and use the single removal operation. for (TrustGraphNodeId n : neighbors) { removeNeighborFromRoutingTable(n); } } }
java
@Override public void removeNeighbors(final Collection<TrustGraphNodeId> neighbors) { synchronized(this) { // remove the neighbors from the ordering in bulk removeNeighborsFromOrdering(neighbors); // just loop over the neighbors and use the single removal operation. for (TrustGraphNodeId n : neighbors) { removeNeighborFromRoutingTable(n); } } }
[ "@", "Override", "public", "void", "removeNeighbors", "(", "final", "Collection", "<", "TrustGraphNodeId", ">", "neighbors", ")", "{", "synchronized", "(", "this", ")", "{", "// remove the neighbors from the ordering in bulk", "removeNeighborsFromOrdering", "(", "neighbor...
Remove a set of TrustGraphNeighbors from the routing table. This operation does not occur atomically, each neighbor is removed in turn equivalently to a series of calls to removeNeighbor. @param neighbors the TrustGraphNeighbors to remove @see RandomRoutingTable.removeNeighbors
[ "Remove", "a", "set", "of", "TrustGraphNeighbors", "from", "the", "routing", "table", "." ]
7516f05724c8f54e5d535d23da9116817c08a09f
https://github.com/getlantern/kaleidoscope/blob/7516f05724c8f54e5d535d23da9116817c08a09f/src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java#L440-L449
train
getlantern/kaleidoscope
src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java
BasicRandomRoutingTable.addNeighborToOrdering
protected void addNeighborToOrdering(TrustGraphNodeId neighbor) { int position = rng.nextInt(orderedNeighbors.size()+1); if (position == orderedNeighbors.size()) { orderedNeighbors.add(neighbor); } else { orderedNeighbors.add(position, neighbor); } }
java
protected void addNeighborToOrdering(TrustGraphNodeId neighbor) { int position = rng.nextInt(orderedNeighbors.size()+1); if (position == orderedNeighbors.size()) { orderedNeighbors.add(neighbor); } else { orderedNeighbors.add(position, neighbor); } }
[ "protected", "void", "addNeighborToOrdering", "(", "TrustGraphNodeId", "neighbor", ")", "{", "int", "position", "=", "rng", ".", "nextInt", "(", "orderedNeighbors", ".", "size", "(", ")", "+", "1", ")", ";", "if", "(", "position", "==", "orderedNeighbors", "...
Internal policy method. Implements the policy for updating the random ordering of neighbors when a new neighbor is added. By default this inserts at the back and then swaps with a random neighbor. Note: When using this policy, adding neighbors may distrupt the set of neighbors that are advertised to in the case that only a subset is used. It is assumed that the neighbor is not already in the list.
[ "Internal", "policy", "method", "." ]
7516f05724c8f54e5d535d23da9116817c08a09f
https://github.com/getlantern/kaleidoscope/blob/7516f05724c8f54e5d535d23da9116817c08a09f/src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java#L474-L484
train
getlantern/kaleidoscope
src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java
BasicRandomRoutingTable.snapshot
@Override public RandomRoutingTable.Snapshot snapshot() { // block modification operations while creating the snapshot synchronized (this) { return new Snapshot(new HashMap<TrustGraphNodeId,TrustGraphNodeId>(routingTable), new ArrayList<TrustGraphNodeId>(orderedNeighbors)); } }
java
@Override public RandomRoutingTable.Snapshot snapshot() { // block modification operations while creating the snapshot synchronized (this) { return new Snapshot(new HashMap<TrustGraphNodeId,TrustGraphNodeId>(routingTable), new ArrayList<TrustGraphNodeId>(orderedNeighbors)); } }
[ "@", "Override", "public", "RandomRoutingTable", ".", "Snapshot", "snapshot", "(", ")", "{", "// block modification operations while creating the snapshot", "synchronized", "(", "this", ")", "{", "return", "new", "Snapshot", "(", "new", "HashMap", "<", "TrustGraphNodeId...
Creates a snapshot of the current state of the routing table. A mapping X->Y between two TrustGraphNeighbors represents that the next hop of a message received from the neighbor X is Y. This snapshot will contain each neighbor exactly once as a key and once as a value. @return a snapshot of the current state of the routing table represented as a Map between TrustGraphNeigbors. @see RandomRoutingTable.snapshot()
[ "Creates", "a", "snapshot", "of", "the", "current", "state", "of", "the", "routing", "table", ".", "A", "mapping", "X", "-", ">", "Y", "between", "two", "TrustGraphNeighbors", "represents", "that", "the", "next", "hop", "of", "a", "message", "received", "f...
7516f05724c8f54e5d535d23da9116817c08a09f
https://github.com/getlantern/kaleidoscope/blob/7516f05724c8f54e5d535d23da9116817c08a09f/src/main/java/org/kaleidoscope/BasicRandomRoutingTable.java#L584-L592
train
jayantk/jklol
src/com/jayantkrish/jklol/p3/P3Parse.java
P3Parse.getStates
public List<IncEvalState> getStates() { List<IncEvalState> states = Lists.newArrayList(); getStatesHelper(states); return states; }
java
public List<IncEvalState> getStates() { List<IncEvalState> states = Lists.newArrayList(); getStatesHelper(states); return states; }
[ "public", "List", "<", "IncEvalState", ">", "getStates", "(", ")", "{", "List", "<", "IncEvalState", ">", "states", "=", "Lists", ".", "newArrayList", "(", ")", ";", "getStatesHelper", "(", "states", ")", ";", "return", "states", ";", "}" ]
Gets the result of all evaluations anywhere in this tree. @return
[ "Gets", "the", "result", "of", "all", "evaluations", "anywhere", "in", "this", "tree", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/p3/P3Parse.java#L133-L137
train
lastaflute/lasta-job
src/main/java/org/lastaflute/job/cron4j/Cron4jTask.java
Cron4jTask.actuallyExecute
protected RunnerResult actuallyExecute(JobIdentityAttr identityProvider, String cronExp, VaryingCronOption cronOption, TaskExecutionContext context, OptionalThing<LaunchNowOption> nowOption) { // in synchronized world adjustThreadNameIfNeeds(cronOption); return runJob(identityProvider, cronExp, cronOption, context, nowOption); }
java
protected RunnerResult actuallyExecute(JobIdentityAttr identityProvider, String cronExp, VaryingCronOption cronOption, TaskExecutionContext context, OptionalThing<LaunchNowOption> nowOption) { // in synchronized world adjustThreadNameIfNeeds(cronOption); return runJob(identityProvider, cronExp, cronOption, context, nowOption); }
[ "protected", "RunnerResult", "actuallyExecute", "(", "JobIdentityAttr", "identityProvider", ",", "String", "cronExp", ",", "VaryingCronOption", "cronOption", ",", "TaskExecutionContext", "context", ",", "OptionalThing", "<", "LaunchNowOption", ">", "nowOption", ")", "{", ...
in execution lock, cannot use varingCron here
[ "in", "execution", "lock", "cannot", "use", "varingCron", "here" ]
5fee7bb1e908463c56b4668de404fd8bce1c2710
https://github.com/lastaflute/lasta-job/blob/5fee7bb1e908463c56b4668de404fd8bce1c2710/src/main/java/org/lastaflute/job/cron4j/Cron4jTask.java#L352-L356
train
getlantern/kaleidoscope
src/main/java/org/kaleidoscope/TrustGraphNode.java
TrustGraphNode.forwardAdvertisement
protected boolean forwardAdvertisement(TrustGraphAdvertisement message) { // don't forward if the forwarding policy rejects if (!shouldForward(message)) { return false; } // determine the next hop to send to TrustGraphNodeId nextHop = getRoutingTable().getNextHop(message); // if there is no next hop, reject if (nextHop == null) { return false; } // forward the message to the next node on the route // with ttl decreased by 1 sendAdvertisement(message, nextHop, message.getInboundTTL() - 1); return true; }
java
protected boolean forwardAdvertisement(TrustGraphAdvertisement message) { // don't forward if the forwarding policy rejects if (!shouldForward(message)) { return false; } // determine the next hop to send to TrustGraphNodeId nextHop = getRoutingTable().getNextHop(message); // if there is no next hop, reject if (nextHop == null) { return false; } // forward the message to the next node on the route // with ttl decreased by 1 sendAdvertisement(message, nextHop, message.getInboundTTL() - 1); return true; }
[ "protected", "boolean", "forwardAdvertisement", "(", "TrustGraphAdvertisement", "message", ")", "{", "// don't forward if the forwarding policy rejects", "if", "(", "!", "shouldForward", "(", "message", ")", ")", "{", "return", "false", ";", "}", "// determine the next ho...
This method performs the forwarding behavior for a received message. The message is forwarded to the next hop on the route according to the routing table, with ttl decreased by 1. The message is dropped if it has an invalid hop count or the sender of the message is not a known peer (ie is not paired to another outbound neighbor) @return true if and only if the message was forwarded
[ "This", "method", "performs", "the", "forwarding", "behavior", "for", "a", "received", "message", ".", "The", "message", "is", "forwarded", "to", "the", "next", "hop", "on", "the", "route", "according", "to", "the", "routing", "table", "with", "ttl", "decrea...
7516f05724c8f54e5d535d23da9116817c08a09f
https://github.com/getlantern/kaleidoscope/blob/7516f05724c8f54e5d535d23da9116817c08a09f/src/main/java/org/kaleidoscope/TrustGraphNode.java#L254-L273
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java
AuthManager.getUserFromAuthToken
public Observable<BackendUser> getUserFromAuthToken(final String authToken){ return Observable.create(new Observable.OnSubscribe<BackendUser>() { @Override public void call(Subscriber<? super BackendUser> subscriber) { try{ setLoginState(LOGGING_IN); logger.debug("getWebService(): " + getWebService()); logger.debug("getuserFromAuthToken: " + authToken); ValidCredentials validCredentials = getWebService().getUserFromAuthToken(authToken).toBlocking().first(); if(validCredentials == null) throw new Exception("Null User Returned"); subscriber.onNext(setUser(validCredentials)); }catch (Exception e){ setLoginState(LOGGED_OUT); subscriber.onError(e); } } }); }
java
public Observable<BackendUser> getUserFromAuthToken(final String authToken){ return Observable.create(new Observable.OnSubscribe<BackendUser>() { @Override public void call(Subscriber<? super BackendUser> subscriber) { try{ setLoginState(LOGGING_IN); logger.debug("getWebService(): " + getWebService()); logger.debug("getuserFromAuthToken: " + authToken); ValidCredentials validCredentials = getWebService().getUserFromAuthToken(authToken).toBlocking().first(); if(validCredentials == null) throw new Exception("Null User Returned"); subscriber.onNext(setUser(validCredentials)); }catch (Exception e){ setLoginState(LOGGED_OUT); subscriber.onError(e); } } }); }
[ "public", "Observable", "<", "BackendUser", ">", "getUserFromAuthToken", "(", "final", "String", "authToken", ")", "{", "return", "Observable", ".", "create", "(", "new", "Observable", ".", "OnSubscribe", "<", "BackendUser", ">", "(", ")", "{", "@", "Override"...
Login using user authentication token @param authToken authentication user for user. @return Logged in user.
[ "Login", "using", "user", "authentication", "token" ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java#L108-L126
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java
AuthManager.getUserFromRecoveryToken
public Observable<BackendUser> getUserFromRecoveryToken(final String recoveryToken){ return Observable.create(new Observable.OnSubscribe<BackendUser>() { @Override public void call(Subscriber<? super BackendUser> subscriber) { try{ setLoginState(LOGGING_IN); ValidCredentials validCredentials = getWebService().getUserFromRecoveryToken(recoveryToken).toBlockingObservable().first(); if(validCredentials == null) throw new Exception("Null User Returned"); subscriber.onNext(setUser(validCredentials)); }catch (Exception e){ setLoginState(LOGGED_OUT); subscriber.onError(e); } } }); }
java
public Observable<BackendUser> getUserFromRecoveryToken(final String recoveryToken){ return Observable.create(new Observable.OnSubscribe<BackendUser>() { @Override public void call(Subscriber<? super BackendUser> subscriber) { try{ setLoginState(LOGGING_IN); ValidCredentials validCredentials = getWebService().getUserFromRecoveryToken(recoveryToken).toBlockingObservable().first(); if(validCredentials == null) throw new Exception("Null User Returned"); subscriber.onNext(setUser(validCredentials)); }catch (Exception e){ setLoginState(LOGGED_OUT); subscriber.onError(e); } } }); }
[ "public", "Observable", "<", "BackendUser", ">", "getUserFromRecoveryToken", "(", "final", "String", "recoveryToken", ")", "{", "return", "Observable", ".", "create", "(", "new", "Observable", ".", "OnSubscribe", "<", "BackendUser", ">", "(", ")", "{", "@", "O...
Login using user recovery token @param recoveryToken recovery token for user. @return Logged in user.
[ "Login", "using", "user", "recovery", "token" ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java#L133-L150
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java
AuthManager.logout
public void logout(){ List<LocalCredentials> accountList = accountStorage.getAccounts(); if(accountList.size() == 1){ String userName = accountList.get(0).getName(); logger.debug("logout: " + userName); accountStorage.removeAccount(userName); user = null; } setLoginState(LoginState.LOGGED_OUT); }
java
public void logout(){ List<LocalCredentials> accountList = accountStorage.getAccounts(); if(accountList.size() == 1){ String userName = accountList.get(0).getName(); logger.debug("logout: " + userName); accountStorage.removeAccount(userName); user = null; } setLoginState(LoginState.LOGGED_OUT); }
[ "public", "void", "logout", "(", ")", "{", "List", "<", "LocalCredentials", ">", "accountList", "=", "accountStorage", ".", "getAccounts", "(", ")", ";", "if", "(", "accountList", ".", "size", "(", ")", "==", "1", ")", "{", "String", "userName", "=", "...
Log out current user if logged in.
[ "Log", "out", "current", "user", "if", "logged", "in", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java#L163-L172
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java
AuthManager.getServerKey
public PublicKey getServerKey(){ logger.debug("getServerKey()"); try { if(serverPublicKey!=null) return serverPublicKey; byte[] pubKey = getWebService().getPublicKey(); logger.debug("pubKey: " + String.valueOf(pubKey)); serverPublicKey = Crypto.pubKeyFromBytes(pubKey); return serverPublicKey; } catch (Exception e) { logger.error("Failed to getServerKey()", e); } return null; }
java
public PublicKey getServerKey(){ logger.debug("getServerKey()"); try { if(serverPublicKey!=null) return serverPublicKey; byte[] pubKey = getWebService().getPublicKey(); logger.debug("pubKey: " + String.valueOf(pubKey)); serverPublicKey = Crypto.pubKeyFromBytes(pubKey); return serverPublicKey; } catch (Exception e) { logger.error("Failed to getServerKey()", e); } return null; }
[ "public", "PublicKey", "getServerKey", "(", ")", "{", "logger", ".", "debug", "(", "\"getServerKey()\"", ")", ";", "try", "{", "if", "(", "serverPublicKey", "!=", "null", ")", "return", "serverPublicKey", ";", "byte", "[", "]", "pubKey", "=", "getWebService"...
Returns server public key. Queries server or local copy. @return Server public key.
[ "Returns", "server", "public", "key", ".", "Queries", "server", "or", "local", "copy", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java#L216-L230
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java
AuthManager.signUp
public SignUpResponse signUp(SignUpCredentials loginCreds){ logger.debug("signUp(" + loginCreds + ")"); try { setLoginState(LOGGING_IN); PublicKey key = Crypto.pubKeyFromBytes(getWebService().getPublicKey()); loginCreds.encryptPassword(key); logger.debug("Login Creds: " + loginCreds); ServerResponse<ValidCredentials> response = ServerResponse.from(ValidCredentials.class, getWebService().userSignUp(loginCreds)); logger.debug("Response: " + response.getStatus()); BackendUser user; if (response.getStatus().isSuccess()) { user = setUser(response.get()); } else { return new SignUpResponse(null, Status.SERVER_ERROR_INTERNAL, " null user returned"); } return new SignUpResponse(user, response.getStatus(), response.getError()); } catch (Exception e) { logger.error("SignUp Failure(" + loginCreds.getEmailAddress() + ")", e); return new SignUpResponse(null, Status.SERVER_ERROR_INTERNAL, e.getLocalizedMessage()); } }
java
public SignUpResponse signUp(SignUpCredentials loginCreds){ logger.debug("signUp(" + loginCreds + ")"); try { setLoginState(LOGGING_IN); PublicKey key = Crypto.pubKeyFromBytes(getWebService().getPublicKey()); loginCreds.encryptPassword(key); logger.debug("Login Creds: " + loginCreds); ServerResponse<ValidCredentials> response = ServerResponse.from(ValidCredentials.class, getWebService().userSignUp(loginCreds)); logger.debug("Response: " + response.getStatus()); BackendUser user; if (response.getStatus().isSuccess()) { user = setUser(response.get()); } else { return new SignUpResponse(null, Status.SERVER_ERROR_INTERNAL, " null user returned"); } return new SignUpResponse(user, response.getStatus(), response.getError()); } catch (Exception e) { logger.error("SignUp Failure(" + loginCreds.getEmailAddress() + ")", e); return new SignUpResponse(null, Status.SERVER_ERROR_INTERNAL, e.getLocalizedMessage()); } }
[ "public", "SignUpResponse", "signUp", "(", "SignUpCredentials", "loginCreds", ")", "{", "logger", ".", "debug", "(", "\"signUp(\"", "+", "loginCreds", "+", "\")\"", ")", ";", "try", "{", "setLoginState", "(", "LOGGING_IN", ")", ";", "PublicKey", "key", "=", ...
Syncronously attempt to create user account @param loginCreds Credentials used to create account. @return Response of the operation
[ "Syncronously", "attempt", "to", "create", "user", "account" ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java#L237-L261
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java
AuthManager.signUpASync
public Observable<BackendUser> signUpASync(final SignUpCredentials signInCreds){ logger.debug("signUpASync("+signInCreds+")"); try { setLoginState(LOGGING_IN); return getWebService().getPublicKeyA().flatMap(new Func1<byte[], Observable<SignUpCredentials>>() { @Override public Observable<SignUpCredentials> call(byte[] bytes) { try { PublicKey key = Crypto.pubKeyFromBytes(bytes); signInCreds.encryptPassword(key); return Observable.from(signInCreds); }catch (Exception e) { return Observable.error(e); } } }).flatMap(new Func1<SignUpCredentials, Observable<ValidCredentials>>() { @Override public Observable<ValidCredentials> call(SignUpCredentials o) { return getWebService().userSignUpA(signInCreds); } }).map(new Func1<ValidCredentials, BackendUser>() { @Override public BackendUser call(ValidCredentials validCredentials) { return setUser(validCredentials); } }) .subscribeOn(Schedulers.io()).observeOn(config.observeOn()); } catch (Exception e) { logger.error("Failed to signUp(" + signInCreds.getEmailAddress() + ")", e); return Observable.error(e); } }
java
public Observable<BackendUser> signUpASync(final SignUpCredentials signInCreds){ logger.debug("signUpASync("+signInCreds+")"); try { setLoginState(LOGGING_IN); return getWebService().getPublicKeyA().flatMap(new Func1<byte[], Observable<SignUpCredentials>>() { @Override public Observable<SignUpCredentials> call(byte[] bytes) { try { PublicKey key = Crypto.pubKeyFromBytes(bytes); signInCreds.encryptPassword(key); return Observable.from(signInCreds); }catch (Exception e) { return Observable.error(e); } } }).flatMap(new Func1<SignUpCredentials, Observable<ValidCredentials>>() { @Override public Observable<ValidCredentials> call(SignUpCredentials o) { return getWebService().userSignUpA(signInCreds); } }).map(new Func1<ValidCredentials, BackendUser>() { @Override public BackendUser call(ValidCredentials validCredentials) { return setUser(validCredentials); } }) .subscribeOn(Schedulers.io()).observeOn(config.observeOn()); } catch (Exception e) { logger.error("Failed to signUp(" + signInCreds.getEmailAddress() + ")", e); return Observable.error(e); } }
[ "public", "Observable", "<", "BackendUser", ">", "signUpASync", "(", "final", "SignUpCredentials", "signInCreds", ")", "{", "logger", ".", "debug", "(", "\"signUpASync(\"", "+", "signInCreds", "+", "\")\"", ")", ";", "try", "{", "setLoginState", "(", "LOGGING_IN...
Asyncronously attempt to create user account @param signInCreds Credentials used to create account. @return Response of the operation
[ "Asyncronously", "attempt", "to", "create", "user", "account" ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java#L268-L301
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java
AuthManager.login
public SignInResponse login(final LoginCredentials loginCreds){ logger.debug("login("+loginCreds+")"); try{ setLoginState(LOGGING_IN); if(!loginCreds.isEncrypted()){ PublicKey key = Crypto.pubKeyFromBytes(getWebService().getPublicKey()); loginCreds.encryptPassword(key); } logger.debug("Login Creds: " + loginCreds); ServerResponse<ValidCredentials> response = ServerResponse.from(ValidCredentials.class,getWebService().login(loginCreds)); BackendUser user; if(response.getStatus().isSuccess()){ user = setUser(response.get()); } else { logger.error("Login Failure("+loginCreds.getEmailAddress()+"): " + response.getStatus().getCode() + " " + response.getError()); setLoginState(LOGGED_OUT); return new SignInResponse(null, Status.SERVER_ERROR_INTERNAL,"Login failed"); } return new SignInResponse(user,response.getStatus(),response.getError()); }catch (Exception e){ logger.error("Login Failure("+loginCreds.getEmailAddress()+")",e); setLoginState(LOGGED_OUT); return new SignInResponse(null, Status.SERVER_ERROR_INTERNAL,e.getLocalizedMessage()); } }
java
public SignInResponse login(final LoginCredentials loginCreds){ logger.debug("login("+loginCreds+")"); try{ setLoginState(LOGGING_IN); if(!loginCreds.isEncrypted()){ PublicKey key = Crypto.pubKeyFromBytes(getWebService().getPublicKey()); loginCreds.encryptPassword(key); } logger.debug("Login Creds: " + loginCreds); ServerResponse<ValidCredentials> response = ServerResponse.from(ValidCredentials.class,getWebService().login(loginCreds)); BackendUser user; if(response.getStatus().isSuccess()){ user = setUser(response.get()); } else { logger.error("Login Failure("+loginCreds.getEmailAddress()+"): " + response.getStatus().getCode() + " " + response.getError()); setLoginState(LOGGED_OUT); return new SignInResponse(null, Status.SERVER_ERROR_INTERNAL,"Login failed"); } return new SignInResponse(user,response.getStatus(),response.getError()); }catch (Exception e){ logger.error("Login Failure("+loginCreds.getEmailAddress()+")",e); setLoginState(LOGGED_OUT); return new SignInResponse(null, Status.SERVER_ERROR_INTERNAL,e.getLocalizedMessage()); } }
[ "public", "SignInResponse", "login", "(", "final", "LoginCredentials", "loginCreds", ")", "{", "logger", ".", "debug", "(", "\"login(\"", "+", "loginCreds", "+", "\")\"", ")", ";", "try", "{", "setLoginState", "(", "LOGGING_IN", ")", ";", "if", "(", "!", "...
Syncronously attempt to log into user account @param loginCreds Credentials used to login. @return Response of the operation
[ "Syncronously", "attempt", "to", "log", "into", "user", "account" ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java#L308-L336
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java
AuthManager.loginASync
public Observable<BackendUser> loginASync(final LoginCredentials loginCreds){ logger.debug("loginASync("+loginCreds+")"); try{ setLoginState(LOGGING_IN); return getWebService().getPublicKeyA().flatMap(new Func1<byte[], Observable<LoginCredentials>>() { @Override public Observable<LoginCredentials> call(byte[] bytes) { try { if (!loginCreds.isEncrypted()) { PublicKey key = Crypto.pubKeyFromBytes(bytes); loginCreds.encryptPassword(key); } return Observable.from(loginCreds); } catch (Exception e) { return Observable.error(e); } } }).flatMap(new Func1<LoginCredentials, Observable<ValidCredentials>>() { @Override public Observable<ValidCredentials> call(LoginCredentials credentials) { return getWebService().loginA(credentials); } }).map(new Func1<ValidCredentials, BackendUser>() { @Override public BackendUser call(ValidCredentials validCredentials) { return setUser(validCredentials); } }) .subscribeOn(Schedulers.io()).observeOn(config.observeOn()); }catch (Exception e){ logger.error("Failed to SignIn("+loginCreds.getEmailAddress()+")",e); setLoginState(LOGGED_OUT); return Observable.error(e); } }
java
public Observable<BackendUser> loginASync(final LoginCredentials loginCreds){ logger.debug("loginASync("+loginCreds+")"); try{ setLoginState(LOGGING_IN); return getWebService().getPublicKeyA().flatMap(new Func1<byte[], Observable<LoginCredentials>>() { @Override public Observable<LoginCredentials> call(byte[] bytes) { try { if (!loginCreds.isEncrypted()) { PublicKey key = Crypto.pubKeyFromBytes(bytes); loginCreds.encryptPassword(key); } return Observable.from(loginCreds); } catch (Exception e) { return Observable.error(e); } } }).flatMap(new Func1<LoginCredentials, Observable<ValidCredentials>>() { @Override public Observable<ValidCredentials> call(LoginCredentials credentials) { return getWebService().loginA(credentials); } }).map(new Func1<ValidCredentials, BackendUser>() { @Override public BackendUser call(ValidCredentials validCredentials) { return setUser(validCredentials); } }) .subscribeOn(Schedulers.io()).observeOn(config.observeOn()); }catch (Exception e){ logger.error("Failed to SignIn("+loginCreds.getEmailAddress()+")",e); setLoginState(LOGGED_OUT); return Observable.error(e); } }
[ "public", "Observable", "<", "BackendUser", ">", "loginASync", "(", "final", "LoginCredentials", "loginCreds", ")", "{", "logger", ".", "debug", "(", "\"loginASync(\"", "+", "loginCreds", "+", "\")\"", ")", ";", "try", "{", "setLoginState", "(", "LOGGING_IN", ...
Asyncronously attempt to log into user account @param loginCreds Credentials used to login. @return Response of the operation
[ "Asyncronously", "attempt", "to", "log", "into", "user", "account" ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java#L343-L379
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java
AuthManager.sendUserData
public Observable<Void> sendUserData(BackendUser backendUser){ return getWebService().sendUserData(isLoggedIn(),backendUser.getOwnerId()+"",backendUser.getUserData()) .subscribeOn(config.subscribeOn()).observeOn(config.observeOn()); }
java
public Observable<Void> sendUserData(BackendUser backendUser){ return getWebService().sendUserData(isLoggedIn(),backendUser.getOwnerId()+"",backendUser.getUserData()) .subscribeOn(config.subscribeOn()).observeOn(config.observeOn()); }
[ "public", "Observable", "<", "Void", ">", "sendUserData", "(", "BackendUser", "backendUser", ")", "{", "return", "getWebService", "(", ")", ".", "sendUserData", "(", "isLoggedIn", "(", ")", ",", "backendUser", ".", "getOwnerId", "(", ")", "+", "\"\"", ",", ...
Update remote server with new user data. @return status of update.
[ "Update", "remote", "server", "with", "new", "user", "data", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java#L390-L393
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java
AuthManager.getUserData
public Observable<Map<String,Object>> getUserData(BackendUser backendUser){ return getWebService().getUserData(isLoggedIn(), backendUser.getOwnerId() + "") .subscribeOn(config.subscribeOn()).observeOn(config.observeOn()); }
java
public Observable<Map<String,Object>> getUserData(BackendUser backendUser){ return getWebService().getUserData(isLoggedIn(), backendUser.getOwnerId() + "") .subscribeOn(config.subscribeOn()).observeOn(config.observeOn()); }
[ "public", "Observable", "<", "Map", "<", "String", ",", "Object", ">", ">", "getUserData", "(", "BackendUser", "backendUser", ")", "{", "return", "getWebService", "(", ")", ".", "getUserData", "(", "isLoggedIn", "(", ")", ",", "backendUser", ".", "getOwnerId...
Query server to return user data for the logged in user @return updated BackendUser.
[ "Query", "server", "to", "return", "user", "data", "for", "the", "logged", "in", "user" ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java#L399-L402
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java
AuthManager.addLoginListener
public void addLoginListener(LoginListener listener){ logger.debug("addLoginListener"); Subscription subscription = loginEventPublisher .subscribeOn(config.subscribeOn()) .observeOn(config.observeOn()) .subscribe(listener); listener.setSubscription(subscription); }
java
public void addLoginListener(LoginListener listener){ logger.debug("addLoginListener"); Subscription subscription = loginEventPublisher .subscribeOn(config.subscribeOn()) .observeOn(config.observeOn()) .subscribe(listener); listener.setSubscription(subscription); }
[ "public", "void", "addLoginListener", "(", "LoginListener", "listener", ")", "{", "logger", ".", "debug", "(", "\"addLoginListener\"", ")", ";", "Subscription", "subscription", "=", "loginEventPublisher", ".", "subscribeOn", "(", "config", ".", "subscribeOn", "(", ...
Add loginListener to listen to login events @param listener LoginListener to receive events.
[ "Add", "loginListener", "to", "listen", "to", "login", "events" ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/auth/AuthManager.java#L413-L420
train
jayantk/jklol
src/com/jayantkrish/jklol/cli/AbstractCli.java
AbstractCli.processOptions
private void processOptions(OptionSet options) { Pseudorandom.get().setSeed(options.valueOf(randomSeed)); if (opts.contains(CommonOptions.MAP_REDUCE)) { MapReduceConfiguration.setMapReduceExecutor(new LocalMapReduceExecutor( options.valueOf(mrMaxThreads), options.valueOf(mrMaxBatchesPerThread))); } if (opts.contains(CommonOptions.STOCHASTIC_GRADIENT) || opts.contains(CommonOptions.LBFGS)) { LogFunction log = null; if (parsedOptions.has(logBrief)) { log = new NullLogFunction(); } else { log = new DefaultLogFunction(parsedOptions.valueOf(logInterval), false, options.valueOf(logParametersInterval), options.valueOf(logParametersDir)); } LogFunctions.setLogFunction(log); } }
java
private void processOptions(OptionSet options) { Pseudorandom.get().setSeed(options.valueOf(randomSeed)); if (opts.contains(CommonOptions.MAP_REDUCE)) { MapReduceConfiguration.setMapReduceExecutor(new LocalMapReduceExecutor( options.valueOf(mrMaxThreads), options.valueOf(mrMaxBatchesPerThread))); } if (opts.contains(CommonOptions.STOCHASTIC_GRADIENT) || opts.contains(CommonOptions.LBFGS)) { LogFunction log = null; if (parsedOptions.has(logBrief)) { log = new NullLogFunction(); } else { log = new DefaultLogFunction(parsedOptions.valueOf(logInterval), false, options.valueOf(logParametersInterval), options.valueOf(logParametersDir)); } LogFunctions.setLogFunction(log); } }
[ "private", "void", "processOptions", "(", "OptionSet", "options", ")", "{", "Pseudorandom", ".", "get", "(", ")", ".", "setSeed", "(", "options", ".", "valueOf", "(", "randomSeed", ")", ")", ";", "if", "(", "opts", ".", "contains", "(", "CommonOptions", ...
Initializes program state using any options processable by this class. @param options
[ "Initializes", "program", "state", "using", "any", "options", "processable", "by", "this", "class", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/cli/AbstractCli.java#L349-L367
train
davidcarboni/cryptolite-java
src/main/java/com/github/davidcarboni/cryptolite/ByteArray.java
ByteArray.toBase64
public static String toBase64(byte[] byteArray) { String result = null; if (byteArray != null) { result = Base64.encodeBase64String(byteArray); } return result; }
java
public static String toBase64(byte[] byteArray) { String result = null; if (byteArray != null) { result = Base64.encodeBase64String(byteArray); } return result; }
[ "public", "static", "String", "toBase64", "(", "byte", "[", "]", "byteArray", ")", "{", "String", "result", "=", "null", ";", "if", "(", "byteArray", "!=", "null", ")", "{", "result", "=", "Base64", ".", "encodeBase64String", "(", "byteArray", ")", ";", ...
Encodes the given byte array as a base-64 String. @param byteArray The byte array to be encoded. @return The byte array encoded using base-64.
[ "Encodes", "the", "given", "byte", "array", "as", "a", "base", "-", "64", "String", "." ]
e67954181a04ffc9beb1d9abca1421195fcf9764
https://github.com/davidcarboni/cryptolite-java/blob/e67954181a04ffc9beb1d9abca1421195fcf9764/src/main/java/com/github/davidcarboni/cryptolite/ByteArray.java#L91-L98
train
davidcarboni/cryptolite-java
src/main/java/com/github/davidcarboni/cryptolite/ByteArray.java
ByteArray.fromBase64
public static byte[] fromBase64(String base64String) { byte[] result = null; if (base64String != null) { result = Base64.decodeBase64(base64String); } return result; }
java
public static byte[] fromBase64(String base64String) { byte[] result = null; if (base64String != null) { result = Base64.decodeBase64(base64String); } return result; }
[ "public", "static", "byte", "[", "]", "fromBase64", "(", "String", "base64String", ")", "{", "byte", "[", "]", "result", "=", "null", ";", "if", "(", "base64String", "!=", "null", ")", "{", "result", "=", "Base64", ".", "decodeBase64", "(", "base64String...
Decodes the given base-64 string to a byte array. @param base64String A base-64 encoded string. @return The decoded byte array.
[ "Decodes", "the", "given", "base", "-", "64", "string", "to", "a", "byte", "array", "." ]
e67954181a04ffc9beb1d9abca1421195fcf9764
https://github.com/davidcarboni/cryptolite-java/blob/e67954181a04ffc9beb1d9abca1421195fcf9764/src/main/java/com/github/davidcarboni/cryptolite/ByteArray.java#L106-L113
train
davidcarboni/cryptolite-java
src/main/java/com/github/davidcarboni/cryptolite/ByteArray.java
ByteArray.fromString
public static byte[] fromString(String unicodeString) { byte[] result = null; if (unicodeString != null) { result = unicodeString.getBytes(StandardCharsets.UTF_8); } return result; }
java
public static byte[] fromString(String unicodeString) { byte[] result = null; if (unicodeString != null) { result = unicodeString.getBytes(StandardCharsets.UTF_8); } return result; }
[ "public", "static", "byte", "[", "]", "fromString", "(", "String", "unicodeString", ")", "{", "byte", "[", "]", "result", "=", "null", ";", "if", "(", "unicodeString", "!=", "null", ")", "{", "result", "=", "unicodeString", ".", "getBytes", "(", "Standar...
Converts the given String to a byte array. @param unicodeString The String to be converted to a byte array. @return A byte array representing the String.
[ "Converts", "the", "given", "String", "to", "a", "byte", "array", "." ]
e67954181a04ffc9beb1d9abca1421195fcf9764
https://github.com/davidcarboni/cryptolite-java/blob/e67954181a04ffc9beb1d9abca1421195fcf9764/src/main/java/com/github/davidcarboni/cryptolite/ByteArray.java#L136-L143
train
jayantk/jklol
src/com/jayantkrish/jklol/ccg/lambda2/TypeInference.java
TypeInference.infer
public void infer() { scopes = StaticAnalysis.getScopes(expression); expressionTypes = Maps.newHashMap(); constraints = ConstraintSet.empty(); for (Scope scope : scopes.getScopes()) { for (String variable : scope.getBoundVariables()) { int location = scope.getBindingIndex(variable); if (!expressionTypes.containsKey(location)) { expressionTypes.put(location, constraints.getFreshTypeVar()); } } } populateExpressionTypes(0); // TODO: root type. solved = constraints.solve(typeDeclaration); for (int k : expressionTypes.keySet()) { expressionTypes.put(k, expressionTypes.get(k).substitute(solved.getBindings())); } }
java
public void infer() { scopes = StaticAnalysis.getScopes(expression); expressionTypes = Maps.newHashMap(); constraints = ConstraintSet.empty(); for (Scope scope : scopes.getScopes()) { for (String variable : scope.getBoundVariables()) { int location = scope.getBindingIndex(variable); if (!expressionTypes.containsKey(location)) { expressionTypes.put(location, constraints.getFreshTypeVar()); } } } populateExpressionTypes(0); // TODO: root type. solved = constraints.solve(typeDeclaration); for (int k : expressionTypes.keySet()) { expressionTypes.put(k, expressionTypes.get(k).substitute(solved.getBindings())); } }
[ "public", "void", "infer", "(", ")", "{", "scopes", "=", "StaticAnalysis", ".", "getScopes", "(", "expression", ")", ";", "expressionTypes", "=", "Maps", ".", "newHashMap", "(", ")", ";", "constraints", "=", "ConstraintSet", ".", "empty", "(", ")", ";", ...
Run type inference.
[ "Run", "type", "inference", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/lambda2/TypeInference.java#L81-L101
train
HiddenStage/divide
Shared/src/main/java/io/divide/shared/util/Crypto.java
Crypto.concat
private static byte[] concat(byte[] a, byte[] b) { byte[] c = new byte[a.length + b.length]; System.arraycopy(a, 0, c, 0, a.length); System.arraycopy(b, 0, c, a.length, b.length); return c; }
java
private static byte[] concat(byte[] a, byte[] b) { byte[] c = new byte[a.length + b.length]; System.arraycopy(a, 0, c, 0, a.length); System.arraycopy(b, 0, c, a.length, b.length); return c; }
[ "private", "static", "byte", "[", "]", "concat", "(", "byte", "[", "]", "a", ",", "byte", "[", "]", "b", ")", "{", "byte", "[", "]", "c", "=", "new", "byte", "[", "a", ".", "length", "+", "b", ".", "length", "]", ";", "System", ".", "arraycop...
Concatenates two byte arrays and returns the resulting byte array. @param a first byte array @param b second byte array @return byte array containing first and second byte array
[ "Concatenates", "two", "byte", "arrays", "and", "returns", "the", "resulting", "byte", "array", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Shared/src/main/java/io/divide/shared/util/Crypto.java#L225-L232
train
jayantk/jklol
src/com/jayantkrish/jklol/ccg/CcgSyntaxTree.java
CcgSyntaxTree.getAllSpannedLexiconEntries
public List<SyntacticCategory> getAllSpannedLexiconEntries() { List<SyntacticCategory> categories = Lists.newArrayList(); getAllSpannedLexiconEntriesHelper(categories); return categories; }
java
public List<SyntacticCategory> getAllSpannedLexiconEntries() { List<SyntacticCategory> categories = Lists.newArrayList(); getAllSpannedLexiconEntriesHelper(categories); return categories; }
[ "public", "List", "<", "SyntacticCategory", ">", "getAllSpannedLexiconEntries", "(", ")", "{", "List", "<", "SyntacticCategory", ">", "categories", "=", "Lists", ".", "newArrayList", "(", ")", ";", "getAllSpannedLexiconEntriesHelper", "(", "categories", ")", ";", ...
Gets the syntactic categories assigned to the words in this parse. @return
[ "Gets", "the", "syntactic", "categories", "assigned", "to", "the", "words", "in", "this", "parse", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/CcgSyntaxTree.java#L174-L178
train
HiddenStage/divide
Shared/src/main/java/io/divide/shared/util/Base64.java
Base64.encodeEnternal
private static byte[] encodeEnternal(byte[] d) { if (d == null) return null; byte data[] = new byte[d.length+2]; System.arraycopy(d, 0, data, 0, d.length); byte dest[] = new byte[(data.length/3)*4]; // 3-byte to 4-byte conversion for (int sidx = 0, didx=0; sidx < d.length; sidx += 3, didx += 4) { dest[didx] = (byte) ((data[sidx] >>> 2) & 077); dest[didx+1] = (byte) ((data[sidx+1] >>> 4) & 017 | (data[sidx] << 4) & 077); dest[didx+2] = (byte) ((data[sidx+2] >>> 6) & 003 | (data[sidx+1] << 2) & 077); dest[didx+3] = (byte) (data[sidx+2] & 077); } // 0-63 to ascii printable conversion for (int idx = 0; idx <dest.length; idx++) { if (dest[idx] < 26) dest[idx] = (byte)(dest[idx] + 'A'); else if (dest[idx] < 52) dest[idx] = (byte)(dest[idx] + 'a' - 26); else if (dest[idx] < 62) dest[idx] = (byte)(dest[idx] + '0' - 52); else if (dest[idx] < 63) dest[idx] = (byte)'+'; else dest[idx] = (byte)'/'; } // add padding for (int idx = dest.length-1; idx > (d.length*4)/3; idx--) { dest[idx] = (byte)'='; } return dest; }
java
private static byte[] encodeEnternal(byte[] d) { if (d == null) return null; byte data[] = new byte[d.length+2]; System.arraycopy(d, 0, data, 0, d.length); byte dest[] = new byte[(data.length/3)*4]; // 3-byte to 4-byte conversion for (int sidx = 0, didx=0; sidx < d.length; sidx += 3, didx += 4) { dest[didx] = (byte) ((data[sidx] >>> 2) & 077); dest[didx+1] = (byte) ((data[sidx+1] >>> 4) & 017 | (data[sidx] << 4) & 077); dest[didx+2] = (byte) ((data[sidx+2] >>> 6) & 003 | (data[sidx+1] << 2) & 077); dest[didx+3] = (byte) (data[sidx+2] & 077); } // 0-63 to ascii printable conversion for (int idx = 0; idx <dest.length; idx++) { if (dest[idx] < 26) dest[idx] = (byte)(dest[idx] + 'A'); else if (dest[idx] < 52) dest[idx] = (byte)(dest[idx] + 'a' - 26); else if (dest[idx] < 62) dest[idx] = (byte)(dest[idx] + '0' - 52); else if (dest[idx] < 63) dest[idx] = (byte)'+'; else dest[idx] = (byte)'/'; } // add padding for (int idx = dest.length-1; idx > (d.length*4)/3; idx--) { dest[idx] = (byte)'='; } return dest; }
[ "private", "static", "byte", "[", "]", "encodeEnternal", "(", "byte", "[", "]", "d", ")", "{", "if", "(", "d", "==", "null", ")", "return", "null", ";", "byte", "data", "[", "]", "=", "new", "byte", "[", "d", ".", "length", "+", "2", "]", ";", ...
Encode some data and return a String.
[ "Encode", "some", "data", "and", "return", "a", "String", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Shared/src/main/java/io/divide/shared/util/Base64.java#L55-L89
train
HiddenStage/divide
Shared/src/main/java/io/divide/shared/util/Base64.java
Base64.decodeInternal
private static byte[] decodeInternal(byte[] data) { int tail = data.length; while (data[tail-1] == '=') tail--; byte dest[] = new byte[tail - data.length/4]; // ascii printable to 0-63 conversion for (int idx = 0; idx <data.length; idx++) { if (data[idx] == '=') data[idx] = 0; else if (data[idx] == '/') data[idx] = 63; else if (data[idx] == '+') data[idx] = 62; else if (data[idx] >= '0' && data[idx] <= '9') data[idx] = (byte)(data[idx] - ('0' - 52)); else if (data[idx] >= 'a' && data[idx] <= 'z') data[idx] = (byte)(data[idx] - ('a' - 26)); else if (data[idx] >= 'A' && data[idx] <= 'Z') data[idx] = (byte)(data[idx] - 'A'); } // 4-byte to 3-byte conversion int sidx, didx; for (sidx = 0, didx=0; didx < dest.length-2; sidx += 4, didx += 3) { dest[didx] = (byte) ( ((data[sidx] << 2) & 255) | ((data[sidx+1] >>> 4) & 3) ); dest[didx+1] = (byte) ( ((data[sidx+1] << 4) & 255) | ((data[sidx+2] >>> 2) & 017) ); dest[didx+2] = (byte) ( ((data[sidx+2] << 6) & 255) | (data[sidx+3] & 077) ); } if (didx < dest.length) { dest[didx] = (byte) ( ((data[sidx] << 2) & 255) | ((data[sidx+1] >>> 4) & 3) ); } if (++didx < dest.length) { dest[didx] = (byte) ( ((data[sidx+1] << 4) & 255) | ((data[sidx+2] >>> 2) & 017) ); } return dest; }
java
private static byte[] decodeInternal(byte[] data) { int tail = data.length; while (data[tail-1] == '=') tail--; byte dest[] = new byte[tail - data.length/4]; // ascii printable to 0-63 conversion for (int idx = 0; idx <data.length; idx++) { if (data[idx] == '=') data[idx] = 0; else if (data[idx] == '/') data[idx] = 63; else if (data[idx] == '+') data[idx] = 62; else if (data[idx] >= '0' && data[idx] <= '9') data[idx] = (byte)(data[idx] - ('0' - 52)); else if (data[idx] >= 'a' && data[idx] <= 'z') data[idx] = (byte)(data[idx] - ('a' - 26)); else if (data[idx] >= 'A' && data[idx] <= 'Z') data[idx] = (byte)(data[idx] - 'A'); } // 4-byte to 3-byte conversion int sidx, didx; for (sidx = 0, didx=0; didx < dest.length-2; sidx += 4, didx += 3) { dest[didx] = (byte) ( ((data[sidx] << 2) & 255) | ((data[sidx+1] >>> 4) & 3) ); dest[didx+1] = (byte) ( ((data[sidx+1] << 4) & 255) | ((data[sidx+2] >>> 2) & 017) ); dest[didx+2] = (byte) ( ((data[sidx+2] << 6) & 255) | (data[sidx+3] & 077) ); } if (didx < dest.length) { dest[didx] = (byte) ( ((data[sidx] << 2) & 255) | ((data[sidx+1] >>> 4) & 3) ); } if (++didx < dest.length) { dest[didx] = (byte) ( ((data[sidx+1] << 4) & 255) | ((data[sidx+2] >>> 2) & 017) ); } return dest; }
[ "private", "static", "byte", "[", "]", "decodeInternal", "(", "byte", "[", "]", "data", ")", "{", "int", "tail", "=", "data", ".", "length", ";", "while", "(", "data", "[", "tail", "-", "1", "]", "==", "'", "'", ")", "tail", "--", ";", "byte", ...
Decode data and return bytes. Assumes that the data passed in is ASCII text.
[ "Decode", "data", "and", "return", "bytes", ".", "Assumes", "that", "the", "data", "passed", "in", "is", "ASCII", "text", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Shared/src/main/java/io/divide/shared/util/Base64.java#L95-L137
train
ivanceras/orm
src/main/java/com/ivanceras/db/server/core/DB_PostgreSQL.java
DB_PostgreSQL.jsonToObject
private Object jsonToObject(String recordValue) throws JsonParseException, JsonMappingException, IOException{ ObjectMapper mapper = new ObjectMapper(); Object json = mapper.readValue(recordValue, Object.class); return json; }
java
private Object jsonToObject(String recordValue) throws JsonParseException, JsonMappingException, IOException{ ObjectMapper mapper = new ObjectMapper(); Object json = mapper.readValue(recordValue, Object.class); return json; }
[ "private", "Object", "jsonToObject", "(", "String", "recordValue", ")", "throws", "JsonParseException", ",", "JsonMappingException", ",", "IOException", "{", "ObjectMapper", "mapper", "=", "new", "ObjectMapper", "(", ")", ";", "Object", "json", "=", "mapper", ".",...
Remapping json directly to object as opposed to traversing the tree @param recordValue @return @throws JsonParseException @throws JsonMappingException @throws IOException
[ "Remapping", "json", "directly", "to", "object", "as", "opposed", "to", "traversing", "the", "tree" ]
e63213cb8abefd11df0e2d34b1c95477788e600e
https://github.com/ivanceras/orm/blob/e63213cb8abefd11df0e2d34b1c95477788e600e/src/main/java/com/ivanceras/db/server/core/DB_PostgreSQL.java#L789-L793
train
ivanceras/orm
src/main/java/com/ivanceras/db/server/core/DB_PostgreSQL.java
DB_PostgreSQL.correctDataTypes
@Override public void correctDataTypes(DAO[] daoList, ModelDef model) { for(DAO dao : daoList){ correctDataTypes(dao, model); } }
java
@Override public void correctDataTypes(DAO[] daoList, ModelDef model) { for(DAO dao : daoList){ correctDataTypes(dao, model); } }
[ "@", "Override", "public", "void", "correctDataTypes", "(", "DAO", "[", "]", "daoList", ",", "ModelDef", "model", ")", "{", "for", "(", "DAO", "dao", ":", "daoList", ")", "{", "correctDataTypes", "(", "dao", ",", "model", ")", ";", "}", "}" ]
Most of postgresql database datatype already mapped to the correct data type by the JDBC
[ "Most", "of", "postgresql", "database", "datatype", "already", "mapped", "to", "the", "correct", "data", "type", "by", "the", "JDBC" ]
e63213cb8abefd11df0e2d34b1c95477788e600e
https://github.com/ivanceras/orm/blob/e63213cb8abefd11df0e2d34b1c95477788e600e/src/main/java/com/ivanceras/db/server/core/DB_PostgreSQL.java#L856-L861
train
ivanceras/orm
src/main/java/com/ivanceras/db/server/core/DB_PostgreSQL.java
DB_PostgreSQL.correctDataType
private Object correctDataType(Object value, String dataType) { if(value == null ){return null;} return value; }
java
private Object correctDataType(Object value, String dataType) { if(value == null ){return null;} return value; }
[ "private", "Object", "correctDataType", "(", "Object", "value", ",", "String", "dataType", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "return", "value", ";", "}" ]
add logic here if PostgreSQL JDBC didn't map DB data type to their correct Java Data type @param value @param dataType @return
[ "add", "logic", "here", "if", "PostgreSQL", "JDBC", "didn", "t", "map", "DB", "data", "type", "to", "their", "correct", "Java", "Data", "type" ]
e63213cb8abefd11df0e2d34b1c95477788e600e
https://github.com/ivanceras/orm/blob/e63213cb8abefd11df0e2d34b1c95477788e600e/src/main/java/com/ivanceras/db/server/core/DB_PostgreSQL.java#L881-L884
train
cpollet/jixture
core/src/main/java/net/cpollet/jixture/fixtures/capacities/filtering/FilterableFixtureProxy.java
FilterableFixtureProxy.filter
@Override public boolean filter(Object entity) { if (fixture instanceof FilterableFixture) { return filterableFixture().filter(entity); } return true; }
java
@Override public boolean filter(Object entity) { if (fixture instanceof FilterableFixture) { return filterableFixture().filter(entity); } return true; }
[ "@", "Override", "public", "boolean", "filter", "(", "Object", "entity", ")", "{", "if", "(", "fixture", "instanceof", "FilterableFixture", ")", "{", "return", "filterableFixture", "(", ")", ".", "filter", "(", "entity", ")", ";", "}", "return", "true", ";...
Determines whether the entity must be inserted in database or not. @param entity the entity to filter. @return {@code true} if the entity must be inserted.
[ "Determines", "whether", "the", "entity", "must", "be", "inserted", "in", "database", "or", "not", "." ]
faef0d4991f81c2cdb5be3ba24176636ef0cc433
https://github.com/cpollet/jixture/blob/faef0d4991f81c2cdb5be3ba24176636ef0cc433/core/src/main/java/net/cpollet/jixture/fixtures/capacities/filtering/FilterableFixtureProxy.java#L51-L58
train
lite2073/email-validator
src/com/dominicsayers/isemail/intl/UniPunyCode.java
UniPunyCode.isUnicode
public static boolean isUnicode(String str) { if (str == null) { return false; } return (!IDN.toASCII(str).equals(str)); }
java
public static boolean isUnicode(String str) { if (str == null) { return false; } return (!IDN.toASCII(str).equals(str)); }
[ "public", "static", "boolean", "isUnicode", "(", "String", "str", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "false", ";", "}", "return", "(", "!", "IDN", ".", "toASCII", "(", "str", ")", ".", "equals", "(", "str", ")", ")", ";...
Determinates if a given string can be converted into Punycode. @param str The string which should be checked @return Boolean which shows if the string is not yet punicoded.
[ "Determinates", "if", "a", "given", "string", "can", "be", "converted", "into", "Punycode", "." ]
cfdda77ed630854b44d62def0d5b7228d5c4e712
https://github.com/lite2073/email-validator/blob/cfdda77ed630854b44d62def0d5b7228d5c4e712/src/com/dominicsayers/isemail/intl/UniPunyCode.java#L20-L25
train
lite2073/email-validator
src/com/dominicsayers/isemail/intl/UniPunyCode.java
UniPunyCode.isPunycode
public static boolean isPunycode(String str) { if (str == null) { return false; } return (!IDN.toUnicode(str).equals(str)); }
java
public static boolean isPunycode(String str) { if (str == null) { return false; } return (!IDN.toUnicode(str).equals(str)); }
[ "public", "static", "boolean", "isPunycode", "(", "String", "str", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "false", ";", "}", "return", "(", "!", "IDN", ".", "toUnicode", "(", "str", ")", ".", "equals", "(", "str", ")", ")", ...
Determinates if a given string is in Punycode format. @param str The string which should be checked @return Boolean which shows if the string is punycoded or not.
[ "Determinates", "if", "a", "given", "string", "is", "in", "Punycode", "format", "." ]
cfdda77ed630854b44d62def0d5b7228d5c4e712
https://github.com/lite2073/email-validator/blob/cfdda77ed630854b44d62def0d5b7228d5c4e712/src/com/dominicsayers/isemail/intl/UniPunyCode.java#L34-L39
train
jayantk/jklol
src/com/jayantkrish/jklol/models/FactorGraph.java
FactorGraph.outcomeToAssignment
public Assignment outcomeToAssignment(List<String> factorVariables, List<? extends Object> outcome) { assert factorVariables.size() == outcome.size(); int[] varNums = new int[factorVariables.size()]; Object[] values = new Object[factorVariables.size()]; for (int i = 0; i < factorVariables.size(); i++) { int varInd = getVariables().getVariableByName(factorVariables.get(i)); varNums[i] = varInd; values[i] = outcome.get(i); } return Assignment.fromUnsortedArrays(varNums, values); }
java
public Assignment outcomeToAssignment(List<String> factorVariables, List<? extends Object> outcome) { assert factorVariables.size() == outcome.size(); int[] varNums = new int[factorVariables.size()]; Object[] values = new Object[factorVariables.size()]; for (int i = 0; i < factorVariables.size(); i++) { int varInd = getVariables().getVariableByName(factorVariables.get(i)); varNums[i] = varInd; values[i] = outcome.get(i); } return Assignment.fromUnsortedArrays(varNums, values); }
[ "public", "Assignment", "outcomeToAssignment", "(", "List", "<", "String", ">", "factorVariables", ",", "List", "<", "?", "extends", "Object", ">", "outcome", ")", "{", "assert", "factorVariables", ".", "size", "(", ")", "==", "outcome", ".", "size", "(", ...
Gets an assignment for the named set of variables.
[ "Gets", "an", "assignment", "for", "the", "named", "set", "of", "variables", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/models/FactorGraph.java#L331-L342
train
jayantk/jklol
src/com/jayantkrish/jklol/models/FactorGraph.java
FactorGraph.getSharedVariables
public Set<Integer> getSharedVariables(int factor1, int factor2) { Set<Integer> varNums = new HashSet<Integer>(factorVariableMap.get(factor1)); varNums.retainAll(factorVariableMap.get(factor2)); return varNums; }
java
public Set<Integer> getSharedVariables(int factor1, int factor2) { Set<Integer> varNums = new HashSet<Integer>(factorVariableMap.get(factor1)); varNums.retainAll(factorVariableMap.get(factor2)); return varNums; }
[ "public", "Set", "<", "Integer", ">", "getSharedVariables", "(", "int", "factor1", ",", "int", "factor2", ")", "{", "Set", "<", "Integer", ">", "varNums", "=", "new", "HashSet", "<", "Integer", ">", "(", "factorVariableMap", ".", "get", "(", "factor1", "...
Get all of the variables that the two factors have in common.
[ "Get", "all", "of", "the", "variables", "that", "the", "two", "factors", "have", "in", "common", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/models/FactorGraph.java#L377-L381
train
jayantk/jklol
src/com/jayantkrish/jklol/preprocessing/FeatureGenerators.java
FeatureGenerators.convertingFeatureGenerator
public static <A, B, C> FeatureGenerator<A, C> convertingFeatureGenerator( FeatureGenerator<B, C> generator, Function<A, B> converter) { return new ConvertingFeatureGenerator<A, B, C>(generator, converter); }
java
public static <A, B, C> FeatureGenerator<A, C> convertingFeatureGenerator( FeatureGenerator<B, C> generator, Function<A, B> converter) { return new ConvertingFeatureGenerator<A, B, C>(generator, converter); }
[ "public", "static", "<", "A", ",", "B", ",", "C", ">", "FeatureGenerator", "<", "A", ",", "C", ">", "convertingFeatureGenerator", "(", "FeatureGenerator", "<", "B", ",", "C", ">", "generator", ",", "Function", "<", "A", ",", "B", ">", "converter", ")",...
Gets a feature generator that first converts the data, then applies a given feature generator. @param generator @param converter @return
[ "Gets", "a", "feature", "generator", "that", "first", "converts", "the", "data", "then", "applies", "a", "given", "feature", "generator", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/preprocessing/FeatureGenerators.java#L81-L84
train
jayantk/jklol
src/com/jayantkrish/jklol/preprocessing/FeatureGenerators.java
FeatureGenerators.postConvertingFeatureGenerator
public static <A, B, C> FeatureGenerator<A, C> postConvertingFeatureGenerator( FeatureGenerator<A, B> generator, Function<B, C> converter) { return new PostConvertingFeatureGenerator<A, B, C>(generator, converter); }
java
public static <A, B, C> FeatureGenerator<A, C> postConvertingFeatureGenerator( FeatureGenerator<A, B> generator, Function<B, C> converter) { return new PostConvertingFeatureGenerator<A, B, C>(generator, converter); }
[ "public", "static", "<", "A", ",", "B", ",", "C", ">", "FeatureGenerator", "<", "A", ",", "C", ">", "postConvertingFeatureGenerator", "(", "FeatureGenerator", "<", "A", ",", "B", ">", "generator", ",", "Function", "<", "B", ",", "C", ">", "converter", ...
Gets a feature generator that applies a generator, then applies a converter to the generated feature names. @param generator @param converter @return
[ "Gets", "a", "feature", "generator", "that", "applies", "a", "generator", "then", "applies", "a", "converter", "to", "the", "generated", "feature", "names", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/preprocessing/FeatureGenerators.java#L94-L97
train
jayantk/jklol
src/com/jayantkrish/jklol/probdb/TableAssignment.java
TableAssignment.getTuples
public List<List<Object>> getTuples() { Iterator<KeyValue> keyValueIter = indicators.keyValueIterator(); List<List<Object>> tuples = Lists.newArrayList(); while (keyValueIter.hasNext()) { KeyValue keyValue = keyValueIter.next(); if (keyValue.getValue() != 0.0) { tuples.add(vars.intArrayToAssignment(keyValue.getKey()).getValues()); } } return tuples; }
java
public List<List<Object>> getTuples() { Iterator<KeyValue> keyValueIter = indicators.keyValueIterator(); List<List<Object>> tuples = Lists.newArrayList(); while (keyValueIter.hasNext()) { KeyValue keyValue = keyValueIter.next(); if (keyValue.getValue() != 0.0) { tuples.add(vars.intArrayToAssignment(keyValue.getKey()).getValues()); } } return tuples; }
[ "public", "List", "<", "List", "<", "Object", ">", ">", "getTuples", "(", ")", "{", "Iterator", "<", "KeyValue", ">", "keyValueIter", "=", "indicators", ".", "keyValueIterator", "(", ")", ";", "List", "<", "List", "<", "Object", ">", ">", "tuples", "="...
Gets the tuples which are in this assignment. @return
[ "Gets", "the", "tuples", "which", "are", "in", "this", "assignment", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/probdb/TableAssignment.java#L60-L70
train
ivanceras/orm
src/main/java/com/ivanceras/db/server/core/DB_Jdbc.java
DB_Jdbc.executeSelect
public DAO[] executeSelect(String sql, Object[] parameters) throws DatabaseException { ResultSet rs = executeSelectSQL(sql, parameters, null, false); return resultSetToDAO(rs, null); }
java
public DAO[] executeSelect(String sql, Object[] parameters) throws DatabaseException { ResultSet rs = executeSelectSQL(sql, parameters, null, false); return resultSetToDAO(rs, null); }
[ "public", "DAO", "[", "]", "executeSelect", "(", "String", "sql", ",", "Object", "[", "]", "parameters", ")", "throws", "DatabaseException", "{", "ResultSet", "rs", "=", "executeSelectSQL", "(", "sql", ",", "parameters", ",", "null", ",", "false", ")", ";"...
Execute generic SQL statement @param sql @param parameters @return @throws DatabaseException
[ "Execute", "generic", "SQL", "statement" ]
e63213cb8abefd11df0e2d34b1c95477788e600e
https://github.com/ivanceras/orm/blob/e63213cb8abefd11df0e2d34b1c95477788e600e/src/main/java/com/ivanceras/db/server/core/DB_Jdbc.java#L330-L334
train
ivanceras/orm
src/main/java/com/ivanceras/db/server/core/DB_Jdbc.java
DB_Jdbc.getPreparedStatement
public Statement getPreparedStatement(String sql, Object[] parameters, boolean returnValues) throws DatabaseException { Statement stmt = null; try { if(supportPreparedStatement()){ if (appendReturningColumnClause() && returnValues) { stmt = connection.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS); } else { stmt = connection.prepareStatement(sql); } if (parameters != null) { for (int i = 0; i < parameters.length; i++) { ((PreparedStatement)stmt).setObject(i + 1,getEquivalentDBObject(parameters[i])); } } }else{//no substition of parameters stmt = connection.createStatement(); return stmt; } } catch (SQLException e) { logSQL(stmt, sql, parameters, true); e.printStackTrace(); throw new DataEntryException(e.getMessage()); } return stmt; }
java
public Statement getPreparedStatement(String sql, Object[] parameters, boolean returnValues) throws DatabaseException { Statement stmt = null; try { if(supportPreparedStatement()){ if (appendReturningColumnClause() && returnValues) { stmt = connection.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS); } else { stmt = connection.prepareStatement(sql); } if (parameters != null) { for (int i = 0; i < parameters.length; i++) { ((PreparedStatement)stmt).setObject(i + 1,getEquivalentDBObject(parameters[i])); } } }else{//no substition of parameters stmt = connection.createStatement(); return stmt; } } catch (SQLException e) { logSQL(stmt, sql, parameters, true); e.printStackTrace(); throw new DataEntryException(e.getMessage()); } return stmt; }
[ "public", "Statement", "getPreparedStatement", "(", "String", "sql", ",", "Object", "[", "]", "parameters", ",", "boolean", "returnValues", ")", "throws", "DatabaseException", "{", "Statement", "stmt", "=", "null", ";", "try", "{", "if", "(", "supportPreparedSta...
Get the SQL statements based on different cases DB does not support PrepareStatement DB does not allow returning of Generated Keys @param sql @param parameters @return @throws DatabaseException
[ "Get", "the", "SQL", "statements", "based", "on", "different", "cases", "DB", "does", "not", "support", "PrepareStatement", "DB", "does", "not", "allow", "returning", "of", "Generated", "Keys" ]
e63213cb8abefd11df0e2d34b1c95477788e600e
https://github.com/ivanceras/orm/blob/e63213cb8abefd11df0e2d34b1c95477788e600e/src/main/java/com/ivanceras/db/server/core/DB_Jdbc.java#L472-L497
train
jayantk/jklol
src/com/jayantkrish/jklol/ccg/HeadedSyntacticCategory.java
HeadedSyntacticCategory.getCanonicalForm
public HeadedSyntacticCategory getCanonicalForm(Map<Integer, Integer> relabeling) { Preconditions.checkArgument(relabeling.size() == 0); int[] relabeledVariables = canonicalizeVariableArray(semanticVariables, relabeling); return new HeadedSyntacticCategory(syntacticCategory.getCanonicalForm(), relabeledVariables, rootIndex); }
java
public HeadedSyntacticCategory getCanonicalForm(Map<Integer, Integer> relabeling) { Preconditions.checkArgument(relabeling.size() == 0); int[] relabeledVariables = canonicalizeVariableArray(semanticVariables, relabeling); return new HeadedSyntacticCategory(syntacticCategory.getCanonicalForm(), relabeledVariables, rootIndex); }
[ "public", "HeadedSyntacticCategory", "getCanonicalForm", "(", "Map", "<", "Integer", ",", "Integer", ">", "relabeling", ")", "{", "Preconditions", ".", "checkArgument", "(", "relabeling", ".", "size", "(", ")", "==", "0", ")", ";", "int", "[", "]", "relabele...
Gets a canonical representation of this category that treats each variable number as an equivalence class. The canonical form relabels variables in the category such that all categories with the same variable equivalence relations have the same canonical form. @param relabeling the relabeling applied to variables in this to produce the relabeled category. @return
[ "Gets", "a", "canonical", "representation", "of", "this", "category", "that", "treats", "each", "variable", "number", "as", "an", "equivalence", "class", ".", "The", "canonical", "form", "relabels", "variables", "in", "the", "category", "such", "that", "all", ...
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/HeadedSyntacticCategory.java#L217-L221
train
jayantk/jklol
src/com/jayantkrish/jklol/ccg/HeadedSyntacticCategory.java
HeadedSyntacticCategory.getArgumentType
public HeadedSyntacticCategory getArgumentType() { SyntacticCategory argumentSyntax = syntacticCategory.getArgument(); int[] argumentSemantics = ArrayUtils.copyOfRange(semanticVariables, rootIndex + 1, semanticVariables.length); int argumentRoot = argumentSyntax.getNumReturnSubcategories(); return new HeadedSyntacticCategory(argumentSyntax, argumentSemantics, argumentRoot); }
java
public HeadedSyntacticCategory getArgumentType() { SyntacticCategory argumentSyntax = syntacticCategory.getArgument(); int[] argumentSemantics = ArrayUtils.copyOfRange(semanticVariables, rootIndex + 1, semanticVariables.length); int argumentRoot = argumentSyntax.getNumReturnSubcategories(); return new HeadedSyntacticCategory(argumentSyntax, argumentSemantics, argumentRoot); }
[ "public", "HeadedSyntacticCategory", "getArgumentType", "(", ")", "{", "SyntacticCategory", "argumentSyntax", "=", "syntacticCategory", ".", "getArgument", "(", ")", ";", "int", "[", "]", "argumentSemantics", "=", "ArrayUtils", ".", "copyOfRange", "(", "semanticVariab...
Gets the syntactic type and semantic variable assignments to the argument type of this category. @return
[ "Gets", "the", "syntactic", "type", "and", "semantic", "variable", "assignments", "to", "the", "argument", "type", "of", "this", "category", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/HeadedSyntacticCategory.java#L247-L252
train
jayantk/jklol
src/com/jayantkrish/jklol/ccg/HeadedSyntacticCategory.java
HeadedSyntacticCategory.getArgumentTypes
public List<HeadedSyntacticCategory> getArgumentTypes() { List<HeadedSyntacticCategory> arguments = Lists.newArrayList(); HeadedSyntacticCategory cat = this; while (!cat.isAtomic()) { arguments.add(cat.getArgumentType()); cat = cat.getReturnType(); } return arguments; }
java
public List<HeadedSyntacticCategory> getArgumentTypes() { List<HeadedSyntacticCategory> arguments = Lists.newArrayList(); HeadedSyntacticCategory cat = this; while (!cat.isAtomic()) { arguments.add(cat.getArgumentType()); cat = cat.getReturnType(); } return arguments; }
[ "public", "List", "<", "HeadedSyntacticCategory", ">", "getArgumentTypes", "(", ")", "{", "List", "<", "HeadedSyntacticCategory", ">", "arguments", "=", "Lists", ".", "newArrayList", "(", ")", ";", "HeadedSyntacticCategory", "cat", "=", "this", ";", "while", "("...
Returns a list of all arguments to this category until an atomic return category is reached. The first element of the returned list is the argument that must be given first, etc. @return
[ "Returns", "a", "list", "of", "all", "arguments", "to", "this", "category", "until", "an", "atomic", "return", "category", "is", "reached", ".", "The", "first", "element", "of", "the", "returned", "list", "is", "the", "argument", "that", "must", "be", "giv...
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/HeadedSyntacticCategory.java#L261-L269
train
jayantk/jklol
src/com/jayantkrish/jklol/ccg/HeadedSyntacticCategory.java
HeadedSyntacticCategory.getReturnType
public HeadedSyntacticCategory getReturnType() { SyntacticCategory returnSyntax = syntacticCategory.getReturn(); int[] returnSemantics = ArrayUtils.copyOf(semanticVariables, rootIndex); int returnRoot = returnSyntax.getNumReturnSubcategories(); return new HeadedSyntacticCategory(returnSyntax, returnSemantics, returnRoot); }
java
public HeadedSyntacticCategory getReturnType() { SyntacticCategory returnSyntax = syntacticCategory.getReturn(); int[] returnSemantics = ArrayUtils.copyOf(semanticVariables, rootIndex); int returnRoot = returnSyntax.getNumReturnSubcategories(); return new HeadedSyntacticCategory(returnSyntax, returnSemantics, returnRoot); }
[ "public", "HeadedSyntacticCategory", "getReturnType", "(", ")", "{", "SyntacticCategory", "returnSyntax", "=", "syntacticCategory", ".", "getReturn", "(", ")", ";", "int", "[", "]", "returnSemantics", "=", "ArrayUtils", ".", "copyOf", "(", "semanticVariables", ",", ...
Gets the syntactic type and semantic variable assignments to the return type of this category. @return
[ "Gets", "the", "syntactic", "type", "and", "semantic", "variable", "assignments", "to", "the", "return", "type", "of", "this", "category", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/HeadedSyntacticCategory.java#L277-L282
train
HiddenStage/divide
Shared/src/main/java/io/divide/shared/transitory/Credentials.java
Credentials.getSafe
public Credentials getSafe(){ Credentials safeCreds = new Credentials(this); safeCreds.meta_remove(PASSWORD_KEY); safeCreds.meta_remove(AUTH_TOKEN_KEY); safeCreds.meta_remove(AUTH_TOKEN_EXPIRE_KEY); safeCreds.meta_remove(VALIDATION_KEY); safeCreds.meta_remove(PUSH_MESSAGING_KEY); safeCreds.meta_remove(RECOVERY_TOKEN_KEY); return safeCreds; }
java
public Credentials getSafe(){ Credentials safeCreds = new Credentials(this); safeCreds.meta_remove(PASSWORD_KEY); safeCreds.meta_remove(AUTH_TOKEN_KEY); safeCreds.meta_remove(AUTH_TOKEN_EXPIRE_KEY); safeCreds.meta_remove(VALIDATION_KEY); safeCreds.meta_remove(PUSH_MESSAGING_KEY); safeCreds.meta_remove(RECOVERY_TOKEN_KEY); return safeCreds; }
[ "public", "Credentials", "getSafe", "(", ")", "{", "Credentials", "safeCreds", "=", "new", "Credentials", "(", "this", ")", ";", "safeCreds", ".", "meta_remove", "(", "PASSWORD_KEY", ")", ";", "safeCreds", ".", "meta_remove", "(", "AUTH_TOKEN_KEY", ")", ";", ...
New Credentials object which contains no sensitive information, removing Password auth token auth token expiration date validation token push messaging token recovery token @return save version of this Credentials object.
[ "New", "Credentials", "object", "which", "contains", "no", "sensitive", "information", "removing", "Password", "auth", "token", "auth", "token", "expiration", "date", "validation", "token", "push", "messaging", "token", "recovery", "token" ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Shared/src/main/java/io/divide/shared/transitory/Credentials.java#L156-L165
train
jayantk/jklol
src/com/jayantkrish/jklol/cfg/CfgParser.java
CfgParser.parseMarginal
public CfgParseChart parseMarginal(List<?> terminals, Object root, boolean useSumProduct) { CfgParseChart chart = createParseChart(terminals, useSumProduct); Factor rootFactor = TableFactor.pointDistribution(parentVar, parentVar.outcomeArrayToAssignment(root)); return marginal(chart, terminals, rootFactor); }
java
public CfgParseChart parseMarginal(List<?> terminals, Object root, boolean useSumProduct) { CfgParseChart chart = createParseChart(terminals, useSumProduct); Factor rootFactor = TableFactor.pointDistribution(parentVar, parentVar.outcomeArrayToAssignment(root)); return marginal(chart, terminals, rootFactor); }
[ "public", "CfgParseChart", "parseMarginal", "(", "List", "<", "?", ">", "terminals", ",", "Object", "root", ",", "boolean", "useSumProduct", ")", "{", "CfgParseChart", "chart", "=", "createParseChart", "(", "terminals", ",", "useSumProduct", ")", ";", "Factor", ...
Compute the marginal distribution over all grammar entries conditioned on the given sequence of terminals.
[ "Compute", "the", "marginal", "distribution", "over", "all", "grammar", "entries", "conditioned", "on", "the", "given", "sequence", "of", "terminals", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/cfg/CfgParser.java#L133-L138
train
jayantk/jklol
src/com/jayantkrish/jklol/cfg/CfgParser.java
CfgParser.parseMarginal
public CfgParseChart parseMarginal(List<?> terminals, boolean useSumProduct) { Factor rootDist = TableFactor.unity(parentVar); return parseMarginal(terminals, rootDist, useSumProduct); }
java
public CfgParseChart parseMarginal(List<?> terminals, boolean useSumProduct) { Factor rootDist = TableFactor.unity(parentVar); return parseMarginal(terminals, rootDist, useSumProduct); }
[ "public", "CfgParseChart", "parseMarginal", "(", "List", "<", "?", ">", "terminals", ",", "boolean", "useSumProduct", ")", "{", "Factor", "rootDist", "=", "TableFactor", ".", "unity", "(", "parentVar", ")", ";", "return", "parseMarginal", "(", "terminals", ","...
Computes the marginal distribution over CFG parses given terminals. @param terminals @param useSumProduct @return
[ "Computes", "the", "marginal", "distribution", "over", "CFG", "parses", "given", "terminals", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/cfg/CfgParser.java#L147-L150
train
jayantk/jklol
src/com/jayantkrish/jklol/cfg/CfgParser.java
CfgParser.parseMarginal
public CfgParseChart parseMarginal(List<?> terminals, Factor rootDist, boolean useSumProduct) { return marginal(createParseChart(terminals, useSumProduct), terminals, rootDist); }
java
public CfgParseChart parseMarginal(List<?> terminals, Factor rootDist, boolean useSumProduct) { return marginal(createParseChart(terminals, useSumProduct), terminals, rootDist); }
[ "public", "CfgParseChart", "parseMarginal", "(", "List", "<", "?", ">", "terminals", ",", "Factor", "rootDist", ",", "boolean", "useSumProduct", ")", "{", "return", "marginal", "(", "createParseChart", "(", "terminals", ",", "useSumProduct", ")", ",", "terminals...
Compute the distribution over CFG entries, the parse root, and the children, conditioned on the provided terminals and assuming the provided distributions over the root node.
[ "Compute", "the", "distribution", "over", "CFG", "entries", "the", "parse", "root", "and", "the", "children", "conditioned", "on", "the", "provided", "terminals", "and", "assuming", "the", "provided", "distributions", "over", "the", "root", "node", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/cfg/CfgParser.java#L157-L159
train
jayantk/jklol
src/com/jayantkrish/jklol/cfg/CfgParser.java
CfgParser.createParseChart
private CfgParseChart createParseChart(List<?> terminals, boolean useSumProduct) { return new CfgParseChart(terminals, parentVar, leftVar, rightVar, terminalVar, ruleTypeVar, binaryDistribution, useSumProduct); }
java
private CfgParseChart createParseChart(List<?> terminals, boolean useSumProduct) { return new CfgParseChart(terminals, parentVar, leftVar, rightVar, terminalVar, ruleTypeVar, binaryDistribution, useSumProduct); }
[ "private", "CfgParseChart", "createParseChart", "(", "List", "<", "?", ">", "terminals", ",", "boolean", "useSumProduct", ")", "{", "return", "new", "CfgParseChart", "(", "terminals", ",", "parentVar", ",", "leftVar", ",", "rightVar", ",", "terminalVar", ",", ...
Initializes parse charts with the correct variable arguments. @param terminals @param useSumProduct @return
[ "Initializes", "parse", "charts", "with", "the", "correct", "variable", "arguments", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/cfg/CfgParser.java#L393-L396
train
jayantk/jklol
src/com/jayantkrish/jklol/cfg/CfgParser.java
CfgParser.initializeBeamSearchChart
private void initializeBeamSearchChart(List<Object> terminals, BeamSearchCfgParseChart chart, long[] treeEncodingOffsets) { Variable terminalListValue = terminalVar.getOnlyVariable(); // Adding this to a tree key indicates that the tree is a terminal. long terminalSignal = ((long) chart.chartSize()) * (treeEncodingOffsets[3] + treeEncodingOffsets[2]); for (int i = 0; i < terminals.size(); i++) { for (int j = i; j < terminals.size(); j++) { if (terminalListValue.canTakeValue(terminals.subList(i, j + 1))) { Assignment assignment = terminalVar.outcomeArrayToAssignment(terminals.subList(i, j + 1)); Iterator<Outcome> iterator = terminalDistribution.outcomePrefixIterator(assignment); while (iterator.hasNext()) { Outcome bestOutcome = iterator.next(); int root = nonterminalVariableType.getValueIndex(bestOutcome.getAssignment().getValue(parentVar.getOnlyVariableNum())); int ruleType = ruleVariableType.getValueIndex(bestOutcome.getAssignment().getValue(ruleTypeVar.getOnlyVariableNum())); long partialKeyNum = (root * treeEncodingOffsets[4]) + (ruleType * treeEncodingOffsets[5]); chart.addParseTreeKeyForSpan(i, j, terminalSignal + partialKeyNum, bestOutcome.getProbability()); } // System.out.println(i + "." + j + ": " + assignment + " : " + // chart.getParseTreesForSpan(i, j)); } } } }
java
private void initializeBeamSearchChart(List<Object> terminals, BeamSearchCfgParseChart chart, long[] treeEncodingOffsets) { Variable terminalListValue = terminalVar.getOnlyVariable(); // Adding this to a tree key indicates that the tree is a terminal. long terminalSignal = ((long) chart.chartSize()) * (treeEncodingOffsets[3] + treeEncodingOffsets[2]); for (int i = 0; i < terminals.size(); i++) { for (int j = i; j < terminals.size(); j++) { if (terminalListValue.canTakeValue(terminals.subList(i, j + 1))) { Assignment assignment = terminalVar.outcomeArrayToAssignment(terminals.subList(i, j + 1)); Iterator<Outcome> iterator = terminalDistribution.outcomePrefixIterator(assignment); while (iterator.hasNext()) { Outcome bestOutcome = iterator.next(); int root = nonterminalVariableType.getValueIndex(bestOutcome.getAssignment().getValue(parentVar.getOnlyVariableNum())); int ruleType = ruleVariableType.getValueIndex(bestOutcome.getAssignment().getValue(ruleTypeVar.getOnlyVariableNum())); long partialKeyNum = (root * treeEncodingOffsets[4]) + (ruleType * treeEncodingOffsets[5]); chart.addParseTreeKeyForSpan(i, j, terminalSignal + partialKeyNum, bestOutcome.getProbability()); } // System.out.println(i + "." + j + ": " + assignment + " : " + // chart.getParseTreesForSpan(i, j)); } } } }
[ "private", "void", "initializeBeamSearchChart", "(", "List", "<", "Object", ">", "terminals", ",", "BeamSearchCfgParseChart", "chart", ",", "long", "[", "]", "treeEncodingOffsets", ")", "{", "Variable", "terminalListValue", "=", "terminalVar", ".", "getOnlyVariable", ...
Initializes a beam search chart using the terminal production distribution. @param terminals @param chart
[ "Initializes", "a", "beam", "search", "chart", "using", "the", "terminal", "production", "distribution", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/cfg/CfgParser.java#L661-L687
train
GoodforGod/dummymaker
src/main/java/io/dummymaker/container/impl/ClassContainer.java
ClassContainer.isExportable
public boolean isExportable() { return fieldContainerMap.entrySet().stream().anyMatch(e -> format.isTypeSupported(e.getValue().getType())); }
java
public boolean isExportable() { return fieldContainerMap.entrySet().stream().anyMatch(e -> format.isTypeSupported(e.getValue().getType())); }
[ "public", "boolean", "isExportable", "(", ")", "{", "return", "fieldContainerMap", ".", "entrySet", "(", ")", ".", "stream", "(", ")", ".", "anyMatch", "(", "e", "->", "format", ".", "isTypeSupported", "(", "e", ".", "getValue", "(", ")", ".", "getType",...
If empty then no export values are present and export is pointless
[ "If", "empty", "then", "no", "export", "values", "are", "present", "and", "export", "is", "pointless" ]
a4809c0a8139ab9cdb42814a3e37772717a313b4
https://github.com/GoodforGod/dummymaker/blob/a4809c0a8139ab9cdb42814a3e37772717a313b4/src/main/java/io/dummymaker/container/impl/ClassContainer.java#L55-L57
train
jayantk/jklol
src/com/jayantkrish/jklol/util/PairCountAccumulator.java
PairCountAccumulator.toTableString
public String toTableString(boolean probs) { Set<B> key2s = Sets.newHashSet(); for (A key : counts.keySet()) { key2s.addAll(counts.get(key).keySet()); } List<B> key2List = Lists.newArrayList(key2s); StringBuilder sb = new StringBuilder(); sb.append("\t"); for (B key2 : key2List) { sb.append(key2); sb.append("\t"); } sb.append("\n"); for (A key1 : counts.keySet()) { sb.append(key1); sb.append("\t"); for (B key2 : key2List) { if (probs) { sb.append(String.format("%.3f", getProbability(key1, key2))); } else { sb.append(getCount(key1, key2)); } sb.append("\t"); } sb.append("\n"); } return sb.toString(); }
java
public String toTableString(boolean probs) { Set<B> key2s = Sets.newHashSet(); for (A key : counts.keySet()) { key2s.addAll(counts.get(key).keySet()); } List<B> key2List = Lists.newArrayList(key2s); StringBuilder sb = new StringBuilder(); sb.append("\t"); for (B key2 : key2List) { sb.append(key2); sb.append("\t"); } sb.append("\n"); for (A key1 : counts.keySet()) { sb.append(key1); sb.append("\t"); for (B key2 : key2List) { if (probs) { sb.append(String.format("%.3f", getProbability(key1, key2))); } else { sb.append(getCount(key1, key2)); } sb.append("\t"); } sb.append("\n"); } return sb.toString(); }
[ "public", "String", "toTableString", "(", "boolean", "probs", ")", "{", "Set", "<", "B", ">", "key2s", "=", "Sets", ".", "newHashSet", "(", ")", ";", "for", "(", "A", "key", ":", "counts", ".", "keySet", "(", ")", ")", "{", "key2s", ".", "addAll", ...
Generates a 2D table displaying the contents of this accumulator. @param showProb if {@code true} print the joint probability of each pair. Otherwise print the raw count. @return
[ "Generates", "a", "2D", "table", "displaying", "the", "contents", "of", "this", "accumulator", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/util/PairCountAccumulator.java#L227-L257
train
jayantk/jklol
src/com/jayantkrish/jklol/util/IntMultimap.java
IntMultimap.reindexItems
public void reindexItems() { if (numUnsortedItems > 0) { int[] newSortedKeys = Arrays.copyOf(sortedKeys, sortedKeys.length + numUnsortedItems); int[] newSortedValues = Arrays.copyOf(sortedValues, sortedValues.length + numUnsortedItems); int oldLength = sortedKeys.length; for (int i = 0; i < numUnsortedItems; i++) { newSortedKeys[i + oldLength] = unsortedKeys[i]; newSortedValues[i + oldLength] = unsortedValues[i]; } ArrayUtils.sortKeyValuePairs(newSortedKeys, newSortedValues, 0, newSortedKeys.length); sortedKeys = newSortedKeys; sortedValues = newSortedValues; numUnsortedItems = 0; rebuildKeySet(); } }
java
public void reindexItems() { if (numUnsortedItems > 0) { int[] newSortedKeys = Arrays.copyOf(sortedKeys, sortedKeys.length + numUnsortedItems); int[] newSortedValues = Arrays.copyOf(sortedValues, sortedValues.length + numUnsortedItems); int oldLength = sortedKeys.length; for (int i = 0; i < numUnsortedItems; i++) { newSortedKeys[i + oldLength] = unsortedKeys[i]; newSortedValues[i + oldLength] = unsortedValues[i]; } ArrayUtils.sortKeyValuePairs(newSortedKeys, newSortedValues, 0, newSortedKeys.length); sortedKeys = newSortedKeys; sortedValues = newSortedValues; numUnsortedItems = 0; rebuildKeySet(); } }
[ "public", "void", "reindexItems", "(", ")", "{", "if", "(", "numUnsortedItems", ">", "0", ")", "{", "int", "[", "]", "newSortedKeys", "=", "Arrays", ".", "copyOf", "(", "sortedKeys", ",", "sortedKeys", ".", "length", "+", "numUnsortedItems", ")", ";", "i...
Moves all elements from the unsorted portion of this map into the sorted portion.
[ "Moves", "all", "elements", "from", "the", "unsorted", "portion", "of", "this", "map", "into", "the", "sorted", "portion", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/util/IntMultimap.java#L162-L181
train
jayantk/jklol
src/com/jayantkrish/jklol/util/IntMultimap.java
IntMultimap.resizeMap
private void resizeMap() { int[] newUnsortedKeys = Arrays.copyOf(unsortedKeys, unsortedKeys.length * 2); int[] newUnsortedValues = Arrays.copyOf(unsortedValues, unsortedValues.length * 2); unsortedKeys = newUnsortedKeys; unsortedValues = newUnsortedValues; }
java
private void resizeMap() { int[] newUnsortedKeys = Arrays.copyOf(unsortedKeys, unsortedKeys.length * 2); int[] newUnsortedValues = Arrays.copyOf(unsortedValues, unsortedValues.length * 2); unsortedKeys = newUnsortedKeys; unsortedValues = newUnsortedValues; }
[ "private", "void", "resizeMap", "(", ")", "{", "int", "[", "]", "newUnsortedKeys", "=", "Arrays", ".", "copyOf", "(", "unsortedKeys", ",", "unsortedKeys", ".", "length", "*", "2", ")", ";", "int", "[", "]", "newUnsortedValues", "=", "Arrays", ".", "copyO...
Doubles the size of the unsorted portion of the map. @return
[ "Doubles", "the", "size", "of", "the", "unsorted", "portion", "of", "the", "map", "." ]
d27532ca83e212d51066cf28f52621acc3fd44cc
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/util/IntMultimap.java#L188-L194
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/BackendUser.java
BackendUser.from
public static BackendUser from(ValidCredentials credentials){ BackendUser beu = new BackendUser(); beu.initFrom(credentials); return beu; }
java
public static BackendUser from(ValidCredentials credentials){ BackendUser beu = new BackendUser(); beu.initFrom(credentials); return beu; }
[ "public", "static", "BackendUser", "from", "(", "ValidCredentials", "credentials", ")", "{", "BackendUser", "beu", "=", "new", "BackendUser", "(", ")", ";", "beu", ".", "initFrom", "(", "credentials", ")", ";", "return", "beu", ";", "}" ]
Convience method to initialize BackendUser from ValidCredentials @param credentials @return
[ "Convience", "method", "to", "initialize", "BackendUser", "from", "ValidCredentials" ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/BackendUser.java#L64-L68
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/BackendUser.java
BackendUser.signIn
public static SignInResponse signIn(String email, String password){ return signIn(new LoginCredentials(email,password)); }
java
public static SignInResponse signIn(String email, String password){ return signIn(new LoginCredentials(email,password)); }
[ "public", "static", "SignInResponse", "signIn", "(", "String", "email", ",", "String", "password", ")", "{", "return", "signIn", "(", "new", "LoginCredentials", "(", "email", ",", "password", ")", ")", ";", "}" ]
Perform syncronously login attempt. @param email user email address @param password user password @return login results.
[ "Perform", "syncronously", "login", "attempt", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/BackendUser.java#L152-L154
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/BackendUser.java
BackendUser.signUp
public static SignUpResponse signUp(String username, String email, String password){ return signUp(new SignUpCredentials(username,email,password)); }
java
public static SignUpResponse signUp(String username, String email, String password){ return signUp(new SignUpCredentials(username,email,password)); }
[ "public", "static", "SignUpResponse", "signUp", "(", "String", "username", ",", "String", "email", ",", "String", "password", ")", "{", "return", "signUp", "(", "new", "SignUpCredentials", "(", "username", ",", "email", ",", "password", ")", ")", ";", "}" ]
Perform syncronously sign up attempt. @param username user name user will be identified by. @param email user email address @param password user password @return login results.
[ "Perform", "syncronously", "sign", "up", "attempt", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/BackendUser.java#L172-L174
train
HiddenStage/divide
Client/java-client/src/main/java/io/divide/client/BackendUser.java
BackendUser.signInInBackground
public static Observable<BackendUser> signInInBackground(String email, String password){ return getAM().loginASync(new LoginCredentials(email, password)); }
java
public static Observable<BackendUser> signInInBackground(String email, String password){ return getAM().loginASync(new LoginCredentials(email, password)); }
[ "public", "static", "Observable", "<", "BackendUser", ">", "signInInBackground", "(", "String", "email", ",", "String", "password", ")", "{", "return", "getAM", "(", ")", ".", "loginASync", "(", "new", "LoginCredentials", "(", "email", ",", "password", ")", ...
Perform asyncronously login attempt. @param email user email address @param password user password @return login results as observable.
[ "Perform", "asyncronously", "login", "attempt", "." ]
14e36598c50d92b4393e6649915e32b86141c598
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Client/java-client/src/main/java/io/divide/client/BackendUser.java#L182-L184
train