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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/dependency/ExtendedPathView.java | ExtendedPathView.getNextNode | private DependencyTreeNode getNextNode(DependencyRelation prev,
DependencyRelation cur) {
return (prev.headNode() == cur.headNode()
|| prev.dependentNode() == cur.headNode())
? cur.dependentNode()
: cur.headNode();
} | java | private DependencyTreeNode getNextNode(DependencyRelation prev,
DependencyRelation cur) {
return (prev.headNode() == cur.headNode()
|| prev.dependentNode() == cur.headNode())
? cur.dependentNode()
: cur.headNode();
} | [
"private",
"DependencyTreeNode",
"getNextNode",
"(",
"DependencyRelation",
"prev",
",",
"DependencyRelation",
"cur",
")",
"{",
"return",
"(",
"prev",
".",
"headNode",
"(",
")",
"==",
"cur",
".",
"headNode",
"(",
")",
"||",
"prev",
".",
"dependentNode",
"(",
... | Given the nodes in the previous relation, determine which of the nodes in
the next relation is new and return that.
@param prev the dependency relation that was previously seen in the path
@param cur the current dependency relation | [
"Given",
"the",
"nodes",
"in",
"the",
"previous",
"relation",
"determine",
"which",
"of",
"the",
"nodes",
"in",
"the",
"next",
"relation",
"is",
"new",
"and",
"return",
"that",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/dependency/ExtendedPathView.java#L89-L95 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/AtomicGrowingSparseMatrix.java | AtomicGrowingSparseMatrix.toArray | private static double[] toArray(DoubleVector v, int length) {
double[] arr = new double[length];
for (int i = 0; i < arr.length; ++i) {
arr[i] = v.get(i);
}
return arr;
} | java | private static double[] toArray(DoubleVector v, int length) {
double[] arr = new double[length];
for (int i = 0; i < arr.length; ++i) {
arr[i] = v.get(i);
}
return arr;
} | [
"private",
"static",
"double",
"[",
"]",
"toArray",
"(",
"DoubleVector",
"v",
",",
"int",
"length",
")",
"{",
"double",
"[",
"]",
"arr",
"=",
"new",
"double",
"[",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
... | Returns an array of the specified length using the data in the provided
vector. This method allows row vectors to be converted to arrays based
on the size of the matrix at the time of the call, thereby prevent
changes in length due to external vector modifications. | [
"Returns",
"an",
"array",
"of",
"the",
"specified",
"length",
"using",
"the",
"data",
"in",
"the",
"provided",
"vector",
".",
"This",
"method",
"allows",
"row",
"vectors",
"to",
"be",
"converted",
"to",
"arrays",
"based",
"on",
"the",
"size",
"of",
"the",
... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/AtomicGrowingSparseMatrix.java#L386-L392 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/evaluation/RubensteinGoodenoughWordSimilarityEvaluation.java | RubensteinGoodenoughWordSimilarityEvaluation.parse | private Collection<WordSimilarity> parse(File word353file) {
Collection<WordSimilarity> pairs = new LinkedList<WordSimilarity>();
try {
BufferedReader br = new BufferedReader(new FileReader(word353file));
// skip the first line
br.readLine();
... | java | private Collection<WordSimilarity> parse(File word353file) {
Collection<WordSimilarity> pairs = new LinkedList<WordSimilarity>();
try {
BufferedReader br = new BufferedReader(new FileReader(word353file));
// skip the first line
br.readLine();
... | [
"private",
"Collection",
"<",
"WordSimilarity",
">",
"parse",
"(",
"File",
"word353file",
")",
"{",
"Collection",
"<",
"WordSimilarity",
">",
"pairs",
"=",
"new",
"LinkedList",
"<",
"WordSimilarity",
">",
"(",
")",
";",
"try",
"{",
"BufferedReader",
"br",
"=... | Parses the WordSimilarity353 file and returns the set of judgements. | [
"Parses",
"the",
"WordSimilarity353",
"file",
"and",
"returns",
"the",
"set",
"of",
"judgements",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/evaluation/RubensteinGoodenoughWordSimilarityEvaluation.java#L81-L110 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/MatrixFile.java | MatrixFile.iterator | public Iterator<MatrixEntry> iterator() {
try {
return MatrixIO.getMatrixFileIterator(matrixFile, format);
} catch (IOException ioe) {
throw new IOError(ioe);
}
} | java | public Iterator<MatrixEntry> iterator() {
try {
return MatrixIO.getMatrixFileIterator(matrixFile, format);
} catch (IOException ioe) {
throw new IOError(ioe);
}
} | [
"public",
"Iterator",
"<",
"MatrixEntry",
">",
"iterator",
"(",
")",
"{",
"try",
"{",
"return",
"MatrixIO",
".",
"getMatrixFileIterator",
"(",
"matrixFile",
",",
"format",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"IOErro... | Returns an iterator over all the entries in the matrix. The order in
which entries are returned is format-specific; no guarantee is provided
about the ordering. | [
"Returns",
"an",
"iterator",
"over",
"all",
"the",
"entries",
"in",
"the",
"matrix",
".",
"The",
"order",
"in",
"which",
"entries",
"are",
"returned",
"is",
"format",
"-",
"specific",
";",
"no",
"guarantee",
"is",
"provided",
"about",
"the",
"ordering",
".... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/MatrixFile.java#L94-L100 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/StaticSemanticSpace.java | StaticSemanticSpace.loadFromFormat | private void loadFromFormat(InputStream is, SSpaceFormat format)
throws IOException {
// NOTE: Use a LinkedHashMap here because this will ensure that the
// words are returned in the same row-order as the matrix. This
// generates better disk I/O behavior for accessing the matrix si... | java | private void loadFromFormat(InputStream is, SSpaceFormat format)
throws IOException {
// NOTE: Use a LinkedHashMap here because this will ensure that the
// words are returned in the same row-order as the matrix. This
// generates better disk I/O behavior for accessing the matrix si... | [
"private",
"void",
"loadFromFormat",
"(",
"InputStream",
"is",
",",
"SSpaceFormat",
"format",
")",
"throws",
"IOException",
"{",
"// NOTE: Use a LinkedHashMap here because this will ensure that the",
"// words are returned in the same row-order as the matrix. This",
"// generates bett... | Loads the semantic space data from the specified stream, using the format
to determine how the data is layed out internally within the stream.
@param is the input stream from which the semantic space will be read
@param format the internal data formatting of the semantic space | [
"Loads",
"the",
"semantic",
"space",
"data",
"from",
"the",
"specified",
"stream",
"using",
"the",
"format",
"to",
"determine",
"how",
"the",
"data",
"is",
"layed",
"out",
"internally",
"within",
"the",
"stream",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/StaticSemanticSpace.java#L161-L196 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/graph/SamplingSubgraphIterator.java | SamplingSubgraphIterator.next | public Graph<T> next() {
if (nextSubgraphs.isEmpty())
throw new NoSuchElementException();
Graph<T> next = nextSubgraphs.poll();
// If we've exhausted the current set of subgraphs, queue up more of
// them, generated from the remaining vertices
if (nextSubgra... | java | public Graph<T> next() {
if (nextSubgraphs.isEmpty())
throw new NoSuchElementException();
Graph<T> next = nextSubgraphs.poll();
// If we've exhausted the current set of subgraphs, queue up more of
// them, generated from the remaining vertices
if (nextSubgra... | [
"public",
"Graph",
"<",
"T",
">",
"next",
"(",
")",
"{",
"if",
"(",
"nextSubgraphs",
".",
"isEmpty",
"(",
")",
")",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"Graph",
"<",
"T",
">",
"next",
"=",
"nextSubgraphs",
".",
"poll",
"(",
")",
... | Returns the next subgraph from the backing graph. | [
"Returns",
"the",
"next",
"subgraph",
"from",
"the",
"backing",
"graph",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/graph/SamplingSubgraphIterator.java#L281-L291 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/ri/RandomIndexing.java | RandomIndexing.add | private static void add(IntegerVector semantics, TernaryVector index) {
// Lock on the semantic vector to avoid a race condition with another
// thread updating its semantics. Use the vector to avoid a class-level
// lock, which would limit the concurrency.
synchronized(semantics) {
... | java | private static void add(IntegerVector semantics, TernaryVector index) {
// Lock on the semantic vector to avoid a race condition with another
// thread updating its semantics. Use the vector to avoid a class-level
// lock, which would limit the concurrency.
synchronized(semantics) {
... | [
"private",
"static",
"void",
"add",
"(",
"IntegerVector",
"semantics",
",",
"TernaryVector",
"index",
")",
"{",
"// Lock on the semantic vector to avoid a race condition with another",
"// thread updating its semantics. Use the vector to avoid a class-level",
"// lock, which would limit... | Atomically adds the values of the index vector to the semantic vector.
This is a special case addition operation that only iterates over the
non-zero values of the index vector. | [
"Atomically",
"adds",
"the",
"values",
"of",
"the",
"index",
"vector",
"to",
"the",
"semantic",
"vector",
".",
"This",
"is",
"a",
"special",
"case",
"addition",
"operation",
"that",
"only",
"iterates",
"over",
"the",
"non",
"-",
"zero",
"values",
"of",
"th... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/ri/RandomIndexing.java#L676-L686 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/dependency/SimpleDependencyPath.java | SimpleDependencyPath.copy | public SimpleDependencyPath copy() {
SimpleDependencyPath copy = new SimpleDependencyPath();
copy.path.addAll(path);
copy.nodes.addAll(nodes);
return copy;
} | java | public SimpleDependencyPath copy() {
SimpleDependencyPath copy = new SimpleDependencyPath();
copy.path.addAll(path);
copy.nodes.addAll(nodes);
return copy;
} | [
"public",
"SimpleDependencyPath",
"copy",
"(",
")",
"{",
"SimpleDependencyPath",
"copy",
"=",
"new",
"SimpleDependencyPath",
"(",
")",
";",
"copy",
".",
"path",
".",
"addAll",
"(",
"path",
")",
";",
"copy",
".",
"nodes",
".",
"addAll",
"(",
"nodes",
")",
... | Returns a copy of this dependency path | [
"Returns",
"a",
"copy",
"of",
"this",
"dependency",
"path"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/dependency/SimpleDependencyPath.java#L133-L138 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/dependency/SimpleDependencyPath.java | SimpleDependencyPath.extend | public SimpleDependencyPath extend(DependencyRelation relation) {
SimpleDependencyPath copy = copy();
// Figure out which node is at the end of our path, and then add the new
// node to the end of our nodes
DependencyTreeNode last = last();
copy.nodes.add((relation.headNode().eq... | java | public SimpleDependencyPath extend(DependencyRelation relation) {
SimpleDependencyPath copy = copy();
// Figure out which node is at the end of our path, and then add the new
// node to the end of our nodes
DependencyTreeNode last = last();
copy.nodes.add((relation.headNode().eq... | [
"public",
"SimpleDependencyPath",
"extend",
"(",
"DependencyRelation",
"relation",
")",
"{",
"SimpleDependencyPath",
"copy",
"=",
"copy",
"(",
")",
";",
"// Figure out which node is at the end of our path, and then add the new",
"// node to the end of our nodes",
"DependencyTreeNod... | Returns a copy of this dependency path that has the provided related
appended to the end of its path sequence. | [
"Returns",
"a",
"copy",
"of",
"this",
"dependency",
"path",
"that",
"has",
"the",
"provided",
"related",
"appended",
"to",
"the",
"end",
"of",
"its",
"path",
"sequence",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/dependency/SimpleDependencyPath.java#L144-L153 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/Matrices.java | Matrices.create | public static Matrix create(int rows, int cols, boolean isDense) {
// Estimate the number of bytes that the matrix will take up based on
// its maximum dimensions and its sparsity.
long size = (isDense)
? (long)rows * (long)cols * BYTES_PER_DOUBLE
: (long)(rows * (long)co... | java | public static Matrix create(int rows, int cols, boolean isDense) {
// Estimate the number of bytes that the matrix will take up based on
// its maximum dimensions and its sparsity.
long size = (isDense)
? (long)rows * (long)cols * BYTES_PER_DOUBLE
: (long)(rows * (long)co... | [
"public",
"static",
"Matrix",
"create",
"(",
"int",
"rows",
",",
"int",
"cols",
",",
"boolean",
"isDense",
")",
"{",
"// Estimate the number of bytes that the matrix will take up based on",
"// its maximum dimensions and its sparsity.",
"long",
"size",
"=",
"(",
"isDense",
... | Creates a matrix of the given dimensions and selects the matrix
implementation by considering the size and density of the new matrix with
respect to the available memory for the JVM.
@param rows the number of rows in the matrix
@param cols the number of columns in the matrix
@param isDense whether the returned matrix ... | [
"Creates",
"a",
"matrix",
"of",
"the",
"given",
"dimensions",
"and",
"selects",
"the",
"matrix",
"implementation",
"by",
"considering",
"the",
"size",
"and",
"density",
"of",
"the",
"new",
"matrix",
"with",
"respect",
"to",
"the",
"available",
"memory",
"for",... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/Matrices.java#L102-L134 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/Matrices.java | Matrices.copy | public static Matrix copy(Matrix matrix) {
Matrix copiedMatrix = null;
if (matrix instanceof SparseMatrix)
copiedMatrix = Matrices.create(
matrix.rows(), matrix.columns(), Type.SPARSE_IN_MEMORY);
else
copiedMatrix = Matrices.create(
... | java | public static Matrix copy(Matrix matrix) {
Matrix copiedMatrix = null;
if (matrix instanceof SparseMatrix)
copiedMatrix = Matrices.create(
matrix.rows(), matrix.columns(), Type.SPARSE_IN_MEMORY);
else
copiedMatrix = Matrices.create(
... | [
"public",
"static",
"Matrix",
"copy",
"(",
"Matrix",
"matrix",
")",
"{",
"Matrix",
"copiedMatrix",
"=",
"null",
";",
"if",
"(",
"matrix",
"instanceof",
"SparseMatrix",
")",
"copiedMatrix",
"=",
"Matrices",
".",
"create",
"(",
"matrix",
".",
"rows",
"(",
")... | Returns a copied version of a given matrix. The returned matrix will
have the same dimensionality, values, and sparsity, but it may not have
the same exact sub-type.
@param matrix the matrix to be copied
@throws IllegalArgumentException when the dimensionality of matrix and
output do not match
@return a copied vers... | [
"Returns",
"a",
"copied",
"version",
"of",
"a",
"given",
"matrix",
".",
"The",
"returned",
"matrix",
"will",
"have",
"the",
"same",
"dimensionality",
"values",
"and",
"sparsity",
"but",
"it",
"may",
"not",
"have",
"the",
"same",
"exact",
"sub",
"-",
"type"... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/Matrices.java#L148-L157 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/text/WordReplacementIterator.java | WordReplacementIterator.next | public String next() {
if (next == null)
throw new NoSuchElementException();
String replacement = replacementMap.get(next);
replacement = (replacement == null) ? next : replacement;
advance();
return replacement;
} | java | public String next() {
if (next == null)
throw new NoSuchElementException();
String replacement = replacementMap.get(next);
replacement = (replacement == null) ? next : replacement;
advance();
return replacement;
} | [
"public",
"String",
"next",
"(",
")",
"{",
"if",
"(",
"next",
"==",
"null",
")",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"String",
"replacement",
"=",
"replacementMap",
".",
"get",
"(",
"next",
")",
";",
"replacement",
"=",
"(",
"replace... | Return the next token's replacement if such a replacement exists. If no
replacement for the next token exists, the original token is returned.
@return The next token stored in this iterator, replaced with a
subsituted value if one exists. | [
"Return",
"the",
"next",
"token",
"s",
"replacement",
"if",
"such",
"a",
"replacement",
"exists",
".",
"If",
"no",
"replacement",
"for",
"the",
"next",
"token",
"exists",
"the",
"original",
"token",
"is",
"returned",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/text/WordReplacementIterator.java#L84-L91 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/ColorGenerator.java | ColorGenerator.next | public Color next() {
int r = rand.nextInt(256);
int g = rand.nextInt(256);
int b = rand.nextInt(256);
return (seed == null)
? new Color(r, g, b)
: new Color((r + seed.getRed()) / 2,
(g + seed.getGreen()) / 2,
(b + s... | java | public Color next() {
int r = rand.nextInt(256);
int g = rand.nextInt(256);
int b = rand.nextInt(256);
return (seed == null)
? new Color(r, g, b)
: new Color((r + seed.getRed()) / 2,
(g + seed.getGreen()) / 2,
(b + s... | [
"public",
"Color",
"next",
"(",
")",
"{",
"int",
"r",
"=",
"rand",
".",
"nextInt",
"(",
"256",
")",
";",
"int",
"g",
"=",
"rand",
".",
"nextInt",
"(",
"256",
")",
";",
"int",
"b",
"=",
"rand",
".",
"nextInt",
"(",
"256",
")",
";",
"return",
"... | Returns the next random color | [
"Returns",
"the",
"next",
"random",
"color"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/ColorGenerator.java#L61-L70 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/text/IteratorFactory.java | IteratorFactory.setProperties | public static synchronized void setProperties(Properties props) {
wordLimit = Integer.parseInt(
props.getProperty(TOKEN_COUNT_LIMIT_PROPERTY, "0"));
String filterProp =
props.getProperty(TOKEN_FILTER_PROPERTY);
filter = (filterProp != null)
? TokenFilter... | java | public static synchronized void setProperties(Properties props) {
wordLimit = Integer.parseInt(
props.getProperty(TOKEN_COUNT_LIMIT_PROPERTY, "0"));
String filterProp =
props.getProperty(TOKEN_FILTER_PROPERTY);
filter = (filterProp != null)
? TokenFilter... | [
"public",
"static",
"synchronized",
"void",
"setProperties",
"(",
"Properties",
"props",
")",
"{",
"wordLimit",
"=",
"Integer",
".",
"parseInt",
"(",
"props",
".",
"getProperty",
"(",
"TOKEN_COUNT_LIMIT_PROPERTY",
",",
"\"0\"",
")",
")",
";",
"String",
"filterPr... | Reconfigures the type of iterator returned by this factory based on the
specified properties. | [
"Reconfigures",
"the",
"type",
"of",
"iterator",
"returned",
"by",
"this",
"factory",
"based",
"on",
"the",
"specified",
"properties",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/text/IteratorFactory.java#L246-L309 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/text/IteratorFactory.java | IteratorFactory.getBaseIterator | private static Iterator<String> getBaseIterator(BufferedReader reader,
boolean keepOrdering) {
// The final iterator is how the stream will be tokenized after all the
// tokenizing options have been applied. This value is iteratively set
// a... | java | private static Iterator<String> getBaseIterator(BufferedReader reader,
boolean keepOrdering) {
// The final iterator is how the stream will be tokenized after all the
// tokenizing options have been applied. This value is iteratively set
// a... | [
"private",
"static",
"Iterator",
"<",
"String",
">",
"getBaseIterator",
"(",
"BufferedReader",
"reader",
",",
"boolean",
"keepOrdering",
")",
"{",
"// The final iterator is how the stream will be tokenized after all the",
"// tokenizing options have been applied. This value is itera... | Returns an iterator for the basic tokenization of the stream before
filtering has been applied to the tokens.
@param reader a reader whose contents are to be tokenized
@return an iterator over the tokens in the stream | [
"Returns",
"an",
"iterator",
"for",
"the",
"basic",
"tokenization",
"of",
"the",
"stream",
"before",
"filtering",
"has",
"been",
"applied",
"to",
"the",
"tokens",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/text/IteratorFactory.java#L419-L471 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/isa/IncrementalSemanticAnalysis.java | IncrementalSemanticAnalysis.updateSemantics | @SuppressWarnings("unchecked")
private void updateSemantics(SemanticVector toUpdate,
String cooccurringWord,
TernaryVector iv) {
SemanticVector prevWordSemantics = getSemanticVector(cooccurringWord);
Integer occurrences = wor... | java | @SuppressWarnings("unchecked")
private void updateSemantics(SemanticVector toUpdate,
String cooccurringWord,
TernaryVector iv) {
SemanticVector prevWordSemantics = getSemanticVector(cooccurringWord);
Integer occurrences = wor... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"updateSemantics",
"(",
"SemanticVector",
"toUpdate",
",",
"String",
"cooccurringWord",
",",
"TernaryVector",
"iv",
")",
"{",
"SemanticVector",
"prevWordSemantics",
"=",
"getSemanticVector",
"(",
"... | Update the semantics using the weighed combination of the semantics of
the co-occurring word and the provided index vector. Note that the index
vector is provided so that the caller can permute it as necessary.
@param toUpdate the semantics to be updated
@param cooccurringWord the word that is co-occurring
@param iv ... | [
"Update",
"the",
"semantics",
"using",
"the",
"weighed",
"combination",
"of",
"the",
"semantics",
"of",
"the",
"co",
"-",
"occurring",
"word",
"and",
"the",
"provided",
"index",
"vector",
".",
"Note",
"that",
"the",
"index",
"vector",
"is",
"provided",
"so",... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/isa/IncrementalSemanticAnalysis.java#L622-L640 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/isa/IncrementalSemanticAnalysis.java | IncrementalSemanticAnalysis.add | private static void add(DoubleVector semantics,
TernaryVector index,
double percentage) {
for (int p : index.positiveDimensions())
semantics.add(p, percentage);
for (int n : index.negativeDimensions())
semantics.add(n, -perc... | java | private static void add(DoubleVector semantics,
TernaryVector index,
double percentage) {
for (int p : index.positiveDimensions())
semantics.add(p, percentage);
for (int n : index.negativeDimensions())
semantics.add(n, -perc... | [
"private",
"static",
"void",
"add",
"(",
"DoubleVector",
"semantics",
",",
"TernaryVector",
"index",
",",
"double",
"percentage",
")",
"{",
"for",
"(",
"int",
"p",
":",
"index",
".",
"positiveDimensions",
"(",
")",
")",
"semantics",
".",
"(",
"p",
",",
"... | Adds the index vector to the semantic vector using the percentage to
specify how much of each dimesion is added.
@param semantics the semantic vector whose values will be modified by the
index vector
@param index the index vector that will be added to the semantic vector
@param the percentage of the index vector's val... | [
"Adds",
"the",
"index",
"vector",
"to",
"the",
"semantic",
"vector",
"using",
"the",
"percentage",
"to",
"specify",
"how",
"much",
"of",
"each",
"dimesion",
"is",
"added",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/isa/IncrementalSemanticAnalysis.java#L652-L659 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/index/RandomOrthogonalVectorGenerator.java | RandomOrthogonalVectorGenerator.generateInitialVector | private static DoubleVector generateInitialVector(int length,
double mean,
double std) {
DoubleVector vector = new DenseVector(length);
for (int i = 0; i < length; ++i) {
double v = RA... | java | private static DoubleVector generateInitialVector(int length,
double mean,
double std) {
DoubleVector vector = new DenseVector(length);
for (int i = 0; i < length; ++i) {
double v = RA... | [
"private",
"static",
"DoubleVector",
"generateInitialVector",
"(",
"int",
"length",
",",
"double",
"mean",
",",
"double",
"std",
")",
"{",
"DoubleVector",
"vector",
"=",
"new",
"DenseVector",
"(",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
... | Generates a simple random vector. | [
"Generates",
"a",
"simple",
"random",
"vector",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/index/RandomOrthogonalVectorGenerator.java#L188-L198 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/index/RandomOrthogonalVectorGenerator.java | RandomOrthogonalVectorGenerator.dotProduct | private static double dotProduct(DoubleVector u,
DoubleVector v) {
double dot = 0;
for (int i = 0; i < u.length(); ++i) {
double a = u.get(i);
double b = v.get(i);
dot += u.get(i) * v.get(i);
}
return dot;
} | java | private static double dotProduct(DoubleVector u,
DoubleVector v) {
double dot = 0;
for (int i = 0; i < u.length(); ++i) {
double a = u.get(i);
double b = v.get(i);
dot += u.get(i) * v.get(i);
}
return dot;
} | [
"private",
"static",
"double",
"dotProduct",
"(",
"DoubleVector",
"u",
",",
"DoubleVector",
"v",
")",
"{",
"double",
"dot",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"u",
".",
"length",
"(",
")",
";",
"++",
"i",
")",
"{",
... | Compute the dot product between two vectors. | [
"Compute",
"the",
"dot",
"product",
"between",
"two",
"vectors",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/index/RandomOrthogonalVectorGenerator.java#L203-L212 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/graph/WeightedDirectedMultigraph.java | WeightedDirectedMultigraph.updateTypeCounts | private void updateTypeCounts(T type, int delta) {
if (!typeCounts.containsKey(type)) {
assert delta > 0
: "removing edge type that was not originally present";
typeCounts.put(type, delta);
}
else {
int curCount = typeCounts.get(type);
... | java | private void updateTypeCounts(T type, int delta) {
if (!typeCounts.containsKey(type)) {
assert delta > 0
: "removing edge type that was not originally present";
typeCounts.put(type, delta);
}
else {
int curCount = typeCounts.get(type);
... | [
"private",
"void",
"updateTypeCounts",
"(",
"T",
"type",
",",
"int",
"delta",
")",
"{",
"if",
"(",
"!",
"typeCounts",
".",
"containsKey",
"(",
"type",
")",
")",
"{",
"assert",
"delta",
">",
"0",
":",
"\"removing edge type that was not originally present\"",
";... | Updates how many edges have this type in the graph | [
"Updates",
"how",
"many",
"edges",
"have",
"this",
"type",
"in",
"the",
"graph"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/graph/WeightedDirectedMultigraph.java#L575-L591 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/MatlabSparseMatrixBuilder.java | MatlabSparseMatrixBuilder.getTempMatrixFile | private static File getTempMatrixFile() {
File tmp = null;
try {
tmp = File.createTempFile("matlab-sparse-matrix", ".dat");
} catch (IOException ioe) {
throw new IOError(ioe);
}
tmp.deleteOnExit();
return tmp;
} | java | private static File getTempMatrixFile() {
File tmp = null;
try {
tmp = File.createTempFile("matlab-sparse-matrix", ".dat");
} catch (IOException ioe) {
throw new IOError(ioe);
}
tmp.deleteOnExit();
return tmp;
} | [
"private",
"static",
"File",
"getTempMatrixFile",
"(",
")",
"{",
"File",
"tmp",
"=",
"null",
";",
"try",
"{",
"tmp",
"=",
"File",
".",
"createTempFile",
"(",
"\"matlab-sparse-matrix\"",
",",
"\".dat\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")... | Returns a temporary file that will be deleted on JVM exit.
'
@return a temporary file used to store a matrix | [
"Returns",
"a",
"temporary",
"file",
"that",
"will",
"be",
"deleted",
"on",
"JVM",
"exit",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/MatlabSparseMatrixBuilder.java#L142-L151 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/dri/DependencyRandomIndexing.java | DependencyRandomIndexing.getSemanticVector | private IntegerVector getSemanticVector(String word) {
IntegerVector v = wordSpace.get(word);
if (v == null) {
// lock on the word in case multiple threads attempt to add it at
// once
synchronized(this) {
// recheck in case another thread added it whi... | java | private IntegerVector getSemanticVector(String word) {
IntegerVector v = wordSpace.get(word);
if (v == null) {
// lock on the word in case multiple threads attempt to add it at
// once
synchronized(this) {
// recheck in case another thread added it whi... | [
"private",
"IntegerVector",
"getSemanticVector",
"(",
"String",
"word",
")",
"{",
"IntegerVector",
"v",
"=",
"wordSpace",
".",
"get",
"(",
"word",
")",
";",
"if",
"(",
"v",
"==",
"null",
")",
"{",
"// lock on the word in case multiple threads attempt to add it at",
... | Returns the current semantic vector for the provided word. If the word
is not currently in the semantic space, a vector is added for it and
returned.
@param word a word that requires a semantic vector
@return the {@code SemanticVector} representing {@code word} | [
"Returns",
"the",
"current",
"semantic",
"vector",
"for",
"the",
"provided",
"word",
".",
"If",
"the",
"word",
"is",
"not",
"currently",
"in",
"the",
"semantic",
"space",
"a",
"vector",
"is",
"added",
"for",
"it",
"and",
"returned",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/dri/DependencyRandomIndexing.java#L486-L502 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/primitive/PrimitiveCollections.java | PrimitiveCollections.shuffle | public static void shuffle(int[] arr, Random rand) {
int size = arr.length;
for (int i = size; i > 1; i--) {
int tmp = arr[i-1];
int r = rand.nextInt(i);
arr[i-1] = arr[r];
arr[r] = tmp;
}
} | java | public static void shuffle(int[] arr, Random rand) {
int size = arr.length;
for (int i = size; i > 1; i--) {
int tmp = arr[i-1];
int r = rand.nextInt(i);
arr[i-1] = arr[r];
arr[r] = tmp;
}
} | [
"public",
"static",
"void",
"shuffle",
"(",
"int",
"[",
"]",
"arr",
",",
"Random",
"rand",
")",
"{",
"int",
"size",
"=",
"arr",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"size",
";",
"i",
">",
"1",
";",
"i",
"--",
")",
"{",
"int",
"tmp... | Randomly shuffles the contents of the provided array | [
"Randomly",
"shuffles",
"the",
"contents",
"of",
"the",
"provided",
"array"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/primitive/PrimitiveCollections.java#L62-L70 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/graph/isomorphism/TypedIsomorphicGraphCounter.java | TypedIsomorphicGraphCounter.addInitial | private void addInitial(G g) {
Set<T> typeCounts = g.edgeTypes();
LinkedList<Map.Entry<G,Integer>> graphs = typesToGraphs.get(typeCounts);
if (graphs == null) {
graphs = new LinkedList<Map.Entry<G,Integer>>();
typesToGraphs.put(new HashSet<T>(typeCounts), graphs);
... | java | private void addInitial(G g) {
Set<T> typeCounts = g.edgeTypes();
LinkedList<Map.Entry<G,Integer>> graphs = typesToGraphs.get(typeCounts);
if (graphs == null) {
graphs = new LinkedList<Map.Entry<G,Integer>>();
typesToGraphs.put(new HashSet<T>(typeCounts), graphs);
... | [
"private",
"void",
"addInitial",
"(",
"G",
"g",
")",
"{",
"Set",
"<",
"T",
">",
"typeCounts",
"=",
"g",
".",
"edgeTypes",
"(",
")",
";",
"LinkedList",
"<",
"Map",
".",
"Entry",
"<",
"G",
",",
"Integer",
">",
">",
"graphs",
"=",
"typesToGraphs",
"."... | Adds an initial set of valid motifs to this counter with no counts. This
method enables the fixed-motif constructor to initialize the set of valid
motifs prior to counting. | [
"Adds",
"an",
"initial",
"set",
"of",
"valid",
"motifs",
"to",
"this",
"counter",
"with",
"no",
"counts",
".",
"This",
"method",
"enables",
"the",
"fixed",
"-",
"motif",
"constructor",
"to",
"initialize",
"the",
"set",
"of",
"valid",
"motifs",
"prior",
"to... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/graph/isomorphism/TypedIsomorphicGraphCounter.java#L124-L133 | train |
fozziethebeat/S-Space | opt/src/main/java/edu/ucla/sspace/tools/FanmodTool.java | FanmodTool.usage | private static void usage(ArgOptions options) {
System.out.println(
"Fanmod 1.0, " +
"usage: java -jar fanmod.jar [options] input.graph output.serialized \n\n"
+ options.prettyPrint() +
"\nThe edge file format is:\n" +
" vertex1 vertex2 [edge_label]... | java | private static void usage(ArgOptions options) {
System.out.println(
"Fanmod 1.0, " +
"usage: java -jar fanmod.jar [options] input.graph output.serialized \n\n"
+ options.prettyPrint() +
"\nThe edge file format is:\n" +
" vertex1 vertex2 [edge_label]... | [
"private",
"static",
"void",
"usage",
"(",
"ArgOptions",
"options",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Fanmod 1.0, \"",
"+",
"\"usage: java -jar fanmod.jar [options] input.graph output.serialized \\n\\n\"",
"+",
"options",
".",
"prettyPrint",
"(",
"... | Prints the options and supported commands used by this program.
@param options the options supported by the system | [
"Prints",
"the",
"options",
"and",
"supported",
"commands",
"used",
"by",
"this",
"program",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/opt/src/main/java/edu/ucla/sspace/tools/FanmodTool.java#L335-L343 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/MatrixEntropy.java | MatrixEntropy.entropy | private static double entropy(double count, double sum) {
double p = count / sum;
return Math.log(p) * p;
} | java | private static double entropy(double count, double sum) {
double p = count / sum;
return Math.log(p) * p;
} | [
"private",
"static",
"double",
"entropy",
"(",
"double",
"count",
",",
"double",
"sum",
")",
"{",
"double",
"p",
"=",
"count",
"/",
"sum",
";",
"return",
"Math",
".",
"log",
"(",
"p",
")",
"*",
"p",
";",
"}"
] | Computes the entropy of a raw count given a particular summation using
the natural log. | [
"Computes",
"the",
"entropy",
"of",
"a",
"raw",
"count",
"given",
"a",
"particular",
"summation",
"using",
"the",
"natural",
"log",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/MatrixEntropy.java#L92-L95 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/IndexedCounter.java | IndexedCounter.getCount | public int getCount(T obj) {
int objIndex = (allowNewIndices)
? objectIndices.index(obj)
: objectIndices.find(obj);
return (objIndex < 0) ? 0 : indexToCount.get(objIndex);
} | java | public int getCount(T obj) {
int objIndex = (allowNewIndices)
? objectIndices.index(obj)
: objectIndices.find(obj);
return (objIndex < 0) ? 0 : indexToCount.get(objIndex);
} | [
"public",
"int",
"getCount",
"(",
"T",
"obj",
")",
"{",
"int",
"objIndex",
"=",
"(",
"allowNewIndices",
")",
"?",
"objectIndices",
".",
"index",
"(",
"obj",
")",
":",
"objectIndices",
".",
"find",
"(",
"obj",
")",
";",
"return",
"(",
"objIndex",
"<",
... | Returns the number of times the specified object has been seen by this
counter. | [
"Returns",
"the",
"number",
"of",
"times",
"the",
"specified",
"object",
"has",
"been",
"seen",
"by",
"this",
"counter",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/IndexedCounter.java#L171-L176 | train |
fozziethebeat/S-Space | src/main/java/jnt/FFT/Factorize.java | Factorize.log2 | public static int log2 (int n){
int log = 0;
for(int k=1; k < n; k *= 2, log++);
if (n != (1 << log))
return -1 ; /* n is not a power of 2 */
return log; } | java | public static int log2 (int n){
int log = 0;
for(int k=1; k < n; k *= 2, log++);
if (n != (1 << log))
return -1 ; /* n is not a power of 2 */
return log; } | [
"public",
"static",
"int",
"log2",
"(",
"int",
"n",
")",
"{",
"int",
"log",
"=",
"0",
";",
"for",
"(",
"int",
"k",
"=",
"1",
";",
"k",
"<",
"n",
";",
"k",
"*=",
"2",
",",
"log",
"++",
")",
";",
"if",
"(",
"n",
"!=",
"(",
"1",
"<<",
"log... | Return the integer log, base 2, of n, or -1 if n is not an integral power of 2. | [
"Return",
"the",
"integer",
"log",
"base",
"2",
"of",
"n",
"or",
"-",
"1",
"if",
"n",
"is",
"not",
"an",
"integral",
"power",
"of",
"2",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/jnt/FFT/Factorize.java#L62-L69 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/vector/VectorMath.java | VectorMath.sum | public static double sum(DoubleVector v) {
double sum = 0;
if (v instanceof SparseVector) {
for (int nz : ((SparseVector)v).getNonZeroIndices())
sum += v.get(nz);
}
else {
int len = v.length();
for (int i = 0; i < len; ++i)
... | java | public static double sum(DoubleVector v) {
double sum = 0;
if (v instanceof SparseVector) {
for (int nz : ((SparseVector)v).getNonZeroIndices())
sum += v.get(nz);
}
else {
int len = v.length();
for (int i = 0; i < len; ++i)
... | [
"public",
"static",
"double",
"sum",
"(",
"DoubleVector",
"v",
")",
"{",
"double",
"sum",
"=",
"0",
";",
"if",
"(",
"v",
"instanceof",
"SparseVector",
")",
"{",
"for",
"(",
"int",
"nz",
":",
"(",
"(",
"SparseVector",
")",
"v",
")",
".",
"getNonZeroIn... | Sums the values in the vector, returning the result. | [
"Sums",
"the",
"values",
"in",
"the",
"vector",
"returning",
"the",
"result",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/vector/VectorMath.java#L740-L752 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/LocalityPreservingProjection.java | LocalityPreservingProjection.execute | private static void execute(File dataMatrixFile,
File affMatrixFile,
int dims, File outputMatrix)
throws IOException {
// Decide whether to use Matlab or Octave
if (isMatlabAvailable())
invokeMatlab(dataMatrixFile,... | java | private static void execute(File dataMatrixFile,
File affMatrixFile,
int dims, File outputMatrix)
throws IOException {
// Decide whether to use Matlab or Octave
if (isMatlabAvailable())
invokeMatlab(dataMatrixFile,... | [
"private",
"static",
"void",
"execute",
"(",
"File",
"dataMatrixFile",
",",
"File",
"affMatrixFile",
",",
"int",
"dims",
",",
"File",
"outputMatrix",
")",
"throws",
"IOException",
"{",
"// Decide whether to use Matlab or Octave",
"if",
"(",
"isMatlabAvailable",
"(",
... | Executes the LPP script, thereby computing the locality preserving
projection of the data matrix to the specified number of dimension, using
the affinity matrix to determine locality. The result is written to the
output file.
@param dataMatrixFile a file containing the original data points to be
projected
@param affM... | [
"Executes",
"the",
"LPP",
"script",
"thereby",
"computing",
"the",
"locality",
"preserving",
"projection",
"of",
"the",
"data",
"matrix",
"to",
"the",
"specified",
"number",
"of",
"dimension",
"using",
"the",
"affinity",
"matrix",
"to",
"determine",
"locality",
... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/LocalityPreservingProjection.java#L383-L396 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/LocalityPreservingProjection.java | LocalityPreservingProjection.invokeMatlab | private static void invokeMatlab(File dataMatrixFile, File affMatrixFile,
int dimensions, File outputFile)
throws IOException {
String commandLine = "matlab -nodisplay -nosplash -nojvm";
LOGGER.fine(commandLine);
Process matlab = Runtime.getRun... | java | private static void invokeMatlab(File dataMatrixFile, File affMatrixFile,
int dimensions, File outputFile)
throws IOException {
String commandLine = "matlab -nodisplay -nosplash -nojvm";
LOGGER.fine(commandLine);
Process matlab = Runtime.getRun... | [
"private",
"static",
"void",
"invokeMatlab",
"(",
"File",
"dataMatrixFile",
",",
"File",
"affMatrixFile",
",",
"int",
"dimensions",
",",
"File",
"outputFile",
")",
"throws",
"IOException",
"{",
"String",
"commandLine",
"=",
"\"matlab -nodisplay -nosplash -nojvm\"",
";... | Invokes Matlab to run the LPP script | [
"Invokes",
"Matlab",
"to",
"run",
"the",
"LPP",
"script"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/LocalityPreservingProjection.java#L401-L459 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/LocalityPreservingProjection.java | LocalityPreservingProjection.invokeOctave | private static void invokeOctave(File dataMatrixFile, File affMatrixFile,
int dimensions, File outputFile)
throws IOException {
// Create the octave file for executing
File octaveFile = File.createTempFile("octave-LPP",".m");
// Create the Matl... | java | private static void invokeOctave(File dataMatrixFile, File affMatrixFile,
int dimensions, File outputFile)
throws IOException {
// Create the octave file for executing
File octaveFile = File.createTempFile("octave-LPP",".m");
// Create the Matl... | [
"private",
"static",
"void",
"invokeOctave",
"(",
"File",
"dataMatrixFile",
",",
"File",
"affMatrixFile",
",",
"int",
"dimensions",
",",
"File",
"outputFile",
")",
"throws",
"IOException",
"{",
"// Create the octave file for executing",
"File",
"octaveFile",
"=",
"Fil... | Invokes Octave to run the LPP script | [
"Invokes",
"Octave",
"to",
"run",
"the",
"LPP",
"script"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/LocalityPreservingProjection.java#L464-L524 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/LoggerUtil.java | LoggerUtil.setLevel | public static void setLevel(Level outputLevel) {
Logger appRooLogger = Logger.getLogger("edu.ucla.sspace");
Handler verboseHandler = new ConsoleHandler();
verboseHandler.setLevel(outputLevel);
appRooLogger.addHandler(verboseHandler);
appRooLogger.setLevel(outputLevel);
ap... | java | public static void setLevel(Level outputLevel) {
Logger appRooLogger = Logger.getLogger("edu.ucla.sspace");
Handler verboseHandler = new ConsoleHandler();
verboseHandler.setLevel(outputLevel);
appRooLogger.addHandler(verboseHandler);
appRooLogger.setLevel(outputLevel);
ap... | [
"public",
"static",
"void",
"setLevel",
"(",
"Level",
"outputLevel",
")",
"{",
"Logger",
"appRooLogger",
"=",
"Logger",
".",
"getLogger",
"(",
"\"edu.ucla.sspace\"",
")",
";",
"Handler",
"verboseHandler",
"=",
"new",
"ConsoleHandler",
"(",
")",
";",
"verboseHand... | Sets the output level of the S-Space package according to the desired
level. | [
"Sets",
"the",
"output",
"level",
"of",
"the",
"S",
"-",
"Space",
"package",
"according",
"to",
"the",
"desired",
"level",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/LoggerUtil.java#L66-L73 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/text/WordIterator.java | WordIterator.advance | private void advance() {
try {
// loop until we find a word in the reader, or there are no more
// words
while (true) {
// if we haven't looked at any lines yet, or if the index into
// the current line is already at the end
if... | java | private void advance() {
try {
// loop until we find a word in the reader, or there are no more
// words
while (true) {
// if we haven't looked at any lines yet, or if the index into
// the current line is already at the end
if... | [
"private",
"void",
"advance",
"(",
")",
"{",
"try",
"{",
"// loop until we find a word in the reader, or there are no more",
"// words",
"while",
"(",
"true",
")",
"{",
"// if we haven't looked at any lines yet, or if the index into",
"// the current line is already at the end ",
"... | Advances to the next word in the buffer. | [
"Advances",
"to",
"the",
"next",
"word",
"in",
"the",
"buffer",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/text/WordIterator.java#L87-L121 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/AtomicGrowingSparseHashMatrix.java | AtomicGrowingSparseHashMatrix.checkIndices | private void checkIndices(int row, int col, boolean expand) {
if (row < 0 || col < 0) {
throw new ArrayIndexOutOfBoundsException();
}
if (expand) {
int r = row + 1;
int cur = 0;
while (r > (cur = rows.get()) && !rows.compareAndSet(cur, r))
... | java | private void checkIndices(int row, int col, boolean expand) {
if (row < 0 || col < 0) {
throw new ArrayIndexOutOfBoundsException();
}
if (expand) {
int r = row + 1;
int cur = 0;
while (r > (cur = rows.get()) && !rows.compareAndSet(cur, r))
... | [
"private",
"void",
"checkIndices",
"(",
"int",
"row",
",",
"int",
"col",
",",
"boolean",
"expand",
")",
"{",
"if",
"(",
"row",
"<",
"0",
"||",
"col",
"<",
"0",
")",
"{",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
")",
";",
"}",
"if",
"(",... | Verify that the given row and column value is non-negative, and
optionally expand the size of the matrix if the row or column are outside
the current bounds.
@param row the row index to check.
@param the the column index to check.
@param expand {@code true} if the current dimensions of the matrix should
be updated if ... | [
"Verify",
"that",
"the",
"given",
"row",
"and",
"column",
"value",
"is",
"non",
"-",
"negative",
"and",
"optionally",
"expand",
"the",
"size",
"of",
"the",
"matrix",
"if",
"the",
"row",
"or",
"column",
"are",
"outside",
"the",
"current",
"bounds",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/AtomicGrowingSparseHashMatrix.java#L191-L205 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/graph/SparseDirectedTypedEdgeSet.java | SparseDirectedTypedEdgeSet.index | private static int index(Object o) {
Integer i = TYPE_INDICES.get(o);
if (i == null) {
synchronized (TYPE_INDICES) {
// check that another thread did not already update the index
i = TYPE_INDICES.get(o);
if (i != null)
retur... | java | private static int index(Object o) {
Integer i = TYPE_INDICES.get(o);
if (i == null) {
synchronized (TYPE_INDICES) {
// check that another thread did not already update the index
i = TYPE_INDICES.get(o);
if (i != null)
retur... | [
"private",
"static",
"int",
"index",
"(",
"Object",
"o",
")",
"{",
"Integer",
"i",
"=",
"TYPE_INDICES",
".",
"get",
"(",
"o",
")",
";",
"if",
"(",
"i",
"==",
"null",
")",
"{",
"synchronized",
"(",
"TYPE_INDICES",
")",
"{",
"// check that another thread d... | Returns the index for the given type, creating a new index if necessary | [
"Returns",
"the",
"index",
"for",
"the",
"given",
"type",
"creating",
"a",
"new",
"index",
"if",
"necessary"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/graph/SparseDirectedTypedEdgeSet.java#L105-L122 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/WorkQueue.java | WorkQueue.addThread | private void addThread() {
Thread t = new WorkerThread(workQueue);
threads.add(t);
t.start();
} | java | private void addThread() {
Thread t = new WorkerThread(workQueue);
threads.add(t);
t.start();
} | [
"private",
"void",
"addThread",
"(",
")",
"{",
"Thread",
"t",
"=",
"new",
"WorkerThread",
"(",
"workQueue",
")",
";",
"threads",
".",
"add",
"(",
"t",
")",
";",
"t",
".",
"start",
"(",
")",
";",
"}"
] | Increases the number of concurrently processing threads by one. | [
"Increases",
"the",
"number",
"of",
"concurrently",
"processing",
"threads",
"by",
"one",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/WorkQueue.java#L145-L149 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/WorkQueue.java | WorkQueue.getRemainingTasks | public long getRemainingTasks(Object taskGroupId) {
CountDownLatch latch = taskKeyToLatch.get(taskGroupId);
return (latch == null)
? 0
: latch.getCount();
} | java | public long getRemainingTasks(Object taskGroupId) {
CountDownLatch latch = taskKeyToLatch.get(taskGroupId);
return (latch == null)
? 0
: latch.getCount();
} | [
"public",
"long",
"getRemainingTasks",
"(",
"Object",
"taskGroupId",
")",
"{",
"CountDownLatch",
"latch",
"=",
"taskKeyToLatch",
".",
"get",
"(",
"taskGroupId",
")",
";",
"return",
"(",
"latch",
"==",
"null",
")",
"?",
"0",
":",
"latch",
".",
"getCount",
"... | Returns the number of tasks that need to be completed before the group
associated with the key is complete. Note that this number includes both
those tasks running and not yet completed, as well as tasks that have yet
to be enqueued on behalf of this id.
@param taskGroupId the key associated with a task group
@retur... | [
"Returns",
"the",
"number",
"of",
"tasks",
"that",
"need",
"to",
"be",
"completed",
"before",
"the",
"group",
"associated",
"with",
"the",
"key",
"is",
"complete",
".",
"Note",
"that",
"this",
"number",
"includes",
"both",
"those",
"tasks",
"running",
"and",... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/WorkQueue.java#L216-L221 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/WorkQueue.java | WorkQueue.registerTaskGroup | public Object registerTaskGroup(int numTasks) {
Object key = new Object();
taskKeyToLatch.putIfAbsent(key, new CountDownLatch(numTasks));
return key;
} | java | public Object registerTaskGroup(int numTasks) {
Object key = new Object();
taskKeyToLatch.putIfAbsent(key, new CountDownLatch(numTasks));
return key;
} | [
"public",
"Object",
"registerTaskGroup",
"(",
"int",
"numTasks",
")",
"{",
"Object",
"key",
"=",
"new",
"Object",
"(",
")",
";",
"taskKeyToLatch",
".",
"putIfAbsent",
"(",
"key",
",",
"new",
"CountDownLatch",
"(",
"numTasks",
")",
")",
";",
"return",
"key"... | Registers a new task group with the specified number of tasks to execute and
returns a task group identifier to use when registering its tasks.
@param numTasks the number of tasks that will be eventually run as a part
of this group.
@returns an identifier associated with a group of tasks | [
"Registers",
"a",
"new",
"task",
"group",
"with",
"the",
"specified",
"number",
"of",
"tasks",
"to",
"execute",
"and",
"returns",
"a",
"task",
"group",
"identifier",
"to",
"use",
"when",
"registering",
"its",
"tasks",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/WorkQueue.java#L266-L270 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/WorkQueue.java | WorkQueue.run | public void run(Collection<Runnable> tasks) {
// Create a semphore that the wrapped runnables will execute
int numTasks = tasks.size();
CountDownLatch latch = new CountDownLatch(numTasks);
for (Runnable r : tasks) {
if (r == null)
throw new NullPointerExceptio... | java | public void run(Collection<Runnable> tasks) {
// Create a semphore that the wrapped runnables will execute
int numTasks = tasks.size();
CountDownLatch latch = new CountDownLatch(numTasks);
for (Runnable r : tasks) {
if (r == null)
throw new NullPointerExceptio... | [
"public",
"void",
"run",
"(",
"Collection",
"<",
"Runnable",
">",
"tasks",
")",
"{",
"// Create a semphore that the wrapped runnables will execute",
"int",
"numTasks",
"=",
"tasks",
".",
"size",
"(",
")",
";",
"CountDownLatch",
"latch",
"=",
"new",
"CountDownLatch",... | Executes the tasks using a thread pool and returns once all tasks have
finished.
@throws IllegalStateException if interrupted while waiting for the tasks
to finish | [
"Executes",
"the",
"tasks",
"using",
"a",
"thread",
"pool",
"and",
"returns",
"once",
"all",
"tasks",
"have",
"finished",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/WorkQueue.java#L309-L325 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/ReflectionUtil.java | ReflectionUtil.getObjectInstance | @SuppressWarnings("unchecked")
public static <T> T getObjectInstance(String className) {
try {
Class clazz = Class.forName(className);
return (T) clazz.newInstance();
} catch (Exception e) {
throw new Error(e);
}
} | java | @SuppressWarnings("unchecked")
public static <T> T getObjectInstance(String className) {
try {
Class clazz = Class.forName(className);
return (T) clazz.newInstance();
} catch (Exception e) {
throw new Error(e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"getObjectInstance",
"(",
"String",
"className",
")",
"{",
"try",
"{",
"Class",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"className",
")",
";",
"return",
"(",
... | Returns an arbitrary object instance based on a class name.
@param className The name of a desired class to instantiate. | [
"Returns",
"an",
"arbitrary",
"object",
"instance",
"based",
"on",
"a",
"class",
"name",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/ReflectionUtil.java#L41-L49 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Similarity.java | Similarity.getSimilarity | public static <T extends Vector> double getSimilarity(
SimType similarityType, T a, T b) {
switch (similarityType) {
case COSINE:
return cosineSimilarity(a, b);
case PEARSON_CORRELATION:
return correlation(a, b);
case EUCLIDEAN:
... | java | public static <T extends Vector> double getSimilarity(
SimType similarityType, T a, T b) {
switch (similarityType) {
case COSINE:
return cosineSimilarity(a, b);
case PEARSON_CORRELATION:
return correlation(a, b);
case EUCLIDEAN:
... | [
"public",
"static",
"<",
"T",
"extends",
"Vector",
">",
"double",
"getSimilarity",
"(",
"SimType",
"similarityType",
",",
"T",
"a",
",",
"T",
"b",
")",
"{",
"switch",
"(",
"similarityType",
")",
"{",
"case",
"COSINE",
":",
"return",
"cosineSimilarity",
"("... | Calculates the similarity of the two vectors using the provided
similarity measure.
@param similarityType the similarity evaluation to use when comparing
{@code a} and {@code b}
@param a a {@code Vector}
@param b a {@code Vector}
@return the similarity according to the specified measure | [
"Calculates",
"the",
"similarity",
"of",
"the",
"two",
"vectors",
"using",
"the",
"provided",
"similarity",
"measure",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Similarity.java#L260-L285 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Similarity.java | Similarity.cosineSimilarity | public static double cosineSimilarity(double[] a, double[] b) {
check(a,b);
double dotProduct = 0.0;
double aMagnitude = 0.0;
double bMagnitude = 0.0;
for (int i = 0; i < b.length ; i++) {
double aValue = a[i];
double bValue = b[i];
aMagnitude ... | java | public static double cosineSimilarity(double[] a, double[] b) {
check(a,b);
double dotProduct = 0.0;
double aMagnitude = 0.0;
double bMagnitude = 0.0;
for (int i = 0; i < b.length ; i++) {
double aValue = a[i];
double bValue = b[i];
aMagnitude ... | [
"public",
"static",
"double",
"cosineSimilarity",
"(",
"double",
"[",
"]",
"a",
",",
"double",
"[",
"]",
"b",
")",
"{",
"check",
"(",
"a",
",",
"b",
")",
";",
"double",
"dotProduct",
"=",
"0.0",
";",
"double",
"aMagnitude",
"=",
"0.0",
";",
"double",... | Returns the cosine similarity of the two arrays.
@throws IllegalArgumentException when the length of the two vectors are
not the same. | [
"Returns",
"the",
"cosine",
"similarity",
"of",
"the",
"two",
"arrays",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Similarity.java#L325-L342 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Similarity.java | Similarity.spearmanRankCorrelationCoefficient | public static double spearmanRankCorrelationCoefficient(double[] a,
double[] b) {
check(a, b);
int N = a.length;
int NcubedMinusN = (N * N * N) - N;
// Convert a and b into rankings. The last value of this array is the
... | java | public static double spearmanRankCorrelationCoefficient(double[] a,
double[] b) {
check(a, b);
int N = a.length;
int NcubedMinusN = (N * N * N) - N;
// Convert a and b into rankings. The last value of this array is the
... | [
"public",
"static",
"double",
"spearmanRankCorrelationCoefficient",
"(",
"double",
"[",
"]",
"a",
",",
"double",
"[",
"]",
"b",
")",
"{",
"check",
"(",
"a",
",",
"b",
")",
";",
"int",
"N",
"=",
"a",
".",
"length",
";",
"int",
"NcubedMinusN",
"=",
"("... | Computes the Spearman rank correlation coefficient for the two arrays.
<p> This implementation properly accounts for ties according to the
procedure specified in <i>Nonparametric Statistics for The Behavioral
Sciences</i> by Sidney Siegel and N. John Castellan Jr. Second
Ed. (1988).
@throws IllegalArgumentException w... | [
"Computes",
"the",
"Spearman",
"rank",
"correlation",
"coefficient",
"for",
"the",
"two",
"arrays",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Similarity.java#L1020-L1050 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/graph/SparseTypedEdgeSet.java | SparseTypedEdgeSet.types | public Set<T> types() {
// NOTE: purely unoptimized!
Set<T> types = new HashSet<T>();
for (Object o : edges.values()) {
Set<T> s = (Set<T>)o;
types.addAll(s);
}
return types;
} | java | public Set<T> types() {
// NOTE: purely unoptimized!
Set<T> types = new HashSet<T>();
for (Object o : edges.values()) {
Set<T> s = (Set<T>)o;
types.addAll(s);
}
return types;
} | [
"public",
"Set",
"<",
"T",
">",
"types",
"(",
")",
"{",
"// NOTE: purely unoptimized!",
"Set",
"<",
"T",
">",
"types",
"=",
"new",
"HashSet",
"<",
"T",
">",
"(",
")",
";",
"for",
"(",
"Object",
"o",
":",
"edges",
".",
"values",
"(",
")",
")",
"{"... | Returns the set of types contained within this set | [
"Returns",
"the",
"set",
"of",
"types",
"contained",
"within",
"this",
"set"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/graph/SparseTypedEdgeSet.java#L318-L326 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Statistics.java | Statistics.mean | public static double mean(Collection<? extends Number> values) {
double sum = 0d;
for (Number n : values)
sum += n.doubleValue();
return sum / values.size();
} | java | public static double mean(Collection<? extends Number> values) {
double sum = 0d;
for (Number n : values)
sum += n.doubleValue();
return sum / values.size();
} | [
"public",
"static",
"double",
"mean",
"(",
"Collection",
"<",
"?",
"extends",
"Number",
">",
"values",
")",
"{",
"double",
"sum",
"=",
"0d",
";",
"for",
"(",
"Number",
"n",
":",
"values",
")",
"sum",
"+=",
"n",
".",
"doubleValue",
"(",
")",
";",
"r... | Returns the mean value of the collection of numbers | [
"Returns",
"the",
"mean",
"value",
"of",
"the",
"collection",
"of",
"numbers"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Statistics.java#L103-L108 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Statistics.java | Statistics.mean | public static double mean(int[] values) {
double sum = 0d;
for (int i : values)
sum += i;
return sum / values.length;
} | java | public static double mean(int[] values) {
double sum = 0d;
for (int i : values)
sum += i;
return sum / values.length;
} | [
"public",
"static",
"double",
"mean",
"(",
"int",
"[",
"]",
"values",
")",
"{",
"double",
"sum",
"=",
"0d",
";",
"for",
"(",
"int",
"i",
":",
"values",
")",
"sum",
"+=",
"i",
";",
"return",
"sum",
"/",
"values",
".",
"length",
";",
"}"
] | Returns the mean value of the array of ints | [
"Returns",
"the",
"mean",
"value",
"of",
"the",
"array",
"of",
"ints"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Statistics.java#L113-L118 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Statistics.java | Statistics.median | @SuppressWarnings("unchecked")
public static <T extends Number & Comparable> T median(Collection<T> values) {
if (values.isEmpty())
throw new IllegalArgumentException(
"No median in an empty collection");
List<T> sorted = new ArrayList<T>(values);
Collect... | java | @SuppressWarnings("unchecked")
public static <T extends Number & Comparable> T median(Collection<T> values) {
if (values.isEmpty())
throw new IllegalArgumentException(
"No median in an empty collection");
List<T> sorted = new ArrayList<T>(values);
Collect... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
"extends",
"Number",
"&",
"Comparable",
">",
"T",
"median",
"(",
"Collection",
"<",
"T",
">",
"values",
")",
"{",
"if",
"(",
"values",
".",
"isEmpty",
"(",
")",
")",
"thr... | Returns the median value of the collection of numbers | [
"Returns",
"the",
"median",
"value",
"of",
"the",
"collection",
"of",
"numbers"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Statistics.java#L133-L142 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Statistics.java | Statistics.median | public static double median(int[] values) {
if (values.length == 0)
throw new IllegalArgumentException("No median in an empty array");
int[] sorted = Arrays.copyOf(values, values.length);
Arrays.sort(sorted);
return sorted[sorted.length/2];
} | java | public static double median(int[] values) {
if (values.length == 0)
throw new IllegalArgumentException("No median in an empty array");
int[] sorted = Arrays.copyOf(values, values.length);
Arrays.sort(sorted);
return sorted[sorted.length/2];
} | [
"public",
"static",
"double",
"median",
"(",
"int",
"[",
"]",
"values",
")",
"{",
"if",
"(",
"values",
".",
"length",
"==",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No median in an empty array\"",
")",
";",
"int",
"[",
"]",
"sorted",
"... | Returns the median value of the array of ints | [
"Returns",
"the",
"median",
"value",
"of",
"the",
"array",
"of",
"ints"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Statistics.java#L147-L153 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Statistics.java | Statistics.mode | public static <T extends Number> T mode(Collection<T> values) {
if (values.isEmpty())
throw new IllegalArgumentException(
"No mode in an empty collection");
Counter<T> c = new ObjectCounter<T>();
for (T n : values)
c.count(n);
return c.max();
} | java | public static <T extends Number> T mode(Collection<T> values) {
if (values.isEmpty())
throw new IllegalArgumentException(
"No mode in an empty collection");
Counter<T> c = new ObjectCounter<T>();
for (T n : values)
c.count(n);
return c.max();
} | [
"public",
"static",
"<",
"T",
"extends",
"Number",
">",
"T",
"mode",
"(",
"Collection",
"<",
"T",
">",
"values",
")",
"{",
"if",
"(",
"values",
".",
"isEmpty",
"(",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No mode in an empty collection\... | Returns the mode value of the collection of numbers | [
"Returns",
"the",
"mode",
"value",
"of",
"the",
"collection",
"of",
"numbers"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Statistics.java#L169-L177 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Statistics.java | Statistics.mode | public static int mode(int[] values) {
if (values.length == 0)
throw new IllegalArgumentException("No mode in an empty array");
Counter<Integer> c = new ObjectCounter<Integer>();
for (int i : values)
c.count(i);
return c.max();
} | java | public static int mode(int[] values) {
if (values.length == 0)
throw new IllegalArgumentException("No mode in an empty array");
Counter<Integer> c = new ObjectCounter<Integer>();
for (int i : values)
c.count(i);
return c.max();
} | [
"public",
"static",
"int",
"mode",
"(",
"int",
"[",
"]",
"values",
")",
"{",
"if",
"(",
"values",
".",
"length",
"==",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No mode in an empty array\"",
")",
";",
"Counter",
"<",
"Integer",
">",
"c"... | Returns the mode value of the array of ints | [
"Returns",
"the",
"mode",
"value",
"of",
"the",
"array",
"of",
"ints"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Statistics.java#L182-L189 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Statistics.java | Statistics.mode | public static double mode(double[] values) {
if (values.length == 0)
throw new IllegalArgumentException("No mode in an empty array");
Counter<Double> c = new ObjectCounter<Double>();
for (double d : values)
c.count(d);
return c.max();
} | java | public static double mode(double[] values) {
if (values.length == 0)
throw new IllegalArgumentException("No mode in an empty array");
Counter<Double> c = new ObjectCounter<Double>();
for (double d : values)
c.count(d);
return c.max();
} | [
"public",
"static",
"double",
"mode",
"(",
"double",
"[",
"]",
"values",
")",
"{",
"if",
"(",
"values",
".",
"length",
"==",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No mode in an empty array\"",
")",
";",
"Counter",
"<",
"Double",
">",
... | Returns the mode value of the array of doubles | [
"Returns",
"the",
"mode",
"value",
"of",
"the",
"array",
"of",
"doubles"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Statistics.java#L194-L201 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Statistics.java | Statistics.stddev | public static double stddev(Collection<? extends Number> values) {
double mean = mean(values);
double sum = 0d;
for (Number n : values) {
double d = n.doubleValue() - mean;
sum += d*d;
}
return Math.sqrt(sum / values.size());
} | java | public static double stddev(Collection<? extends Number> values) {
double mean = mean(values);
double sum = 0d;
for (Number n : values) {
double d = n.doubleValue() - mean;
sum += d*d;
}
return Math.sqrt(sum / values.size());
} | [
"public",
"static",
"double",
"stddev",
"(",
"Collection",
"<",
"?",
"extends",
"Number",
">",
"values",
")",
"{",
"double",
"mean",
"=",
"mean",
"(",
"values",
")",
";",
"double",
"sum",
"=",
"0d",
";",
"for",
"(",
"Number",
"n",
":",
"values",
")",... | Returns the standard deviation of the collection of numbers | [
"Returns",
"the",
"standard",
"deviation",
"of",
"the",
"collection",
"of",
"numbers"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Statistics.java#L250-L258 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Statistics.java | Statistics.stddev | public static double stddev(int[] values) {
double mean = mean(values);
double sum = 0d;
for (int i : values) {
double d = i - mean;
sum += d*d;
}
return Math.sqrt(sum / values.length);
} | java | public static double stddev(int[] values) {
double mean = mean(values);
double sum = 0d;
for (int i : values) {
double d = i - mean;
sum += d*d;
}
return Math.sqrt(sum / values.length);
} | [
"public",
"static",
"double",
"stddev",
"(",
"int",
"[",
"]",
"values",
")",
"{",
"double",
"mean",
"=",
"mean",
"(",
"values",
")",
";",
"double",
"sum",
"=",
"0d",
";",
"for",
"(",
"int",
"i",
":",
"values",
")",
"{",
"double",
"d",
"=",
"i",
... | Returns the standard deviation of the values in the int array | [
"Returns",
"the",
"standard",
"deviation",
"of",
"the",
"values",
"in",
"the",
"int",
"array"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Statistics.java#L263-L271 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Statistics.java | Statistics.sum | public static double sum(Collection<? extends Number> values) {
double sum = 0d;
for (Number n : values)
sum += n.doubleValue();
return sum;
} | java | public static double sum(Collection<? extends Number> values) {
double sum = 0d;
for (Number n : values)
sum += n.doubleValue();
return sum;
} | [
"public",
"static",
"double",
"sum",
"(",
"Collection",
"<",
"?",
"extends",
"Number",
">",
"values",
")",
"{",
"double",
"sum",
"=",
"0d",
";",
"for",
"(",
"Number",
"n",
":",
"values",
")",
"sum",
"+=",
"n",
".",
"doubleValue",
"(",
")",
";",
"re... | Returns the sum of the collection of numbers | [
"Returns",
"the",
"sum",
"of",
"the",
"collection",
"of",
"numbers"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Statistics.java#L289-L294 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/graph/LinkClustering.java | LinkClustering.getConnectionSimilarity | private <E extends Edge> double getConnectionSimilarity(
Graph<E> graph, Edge e1, Edge e2) {
int e1to = e1.to();
int e1from = e1.from();
int e2to = e2.to();
int e2from = e2.from();
if (e1to == e2to)
return getConnectionSimilarity(graph, e1to, e1from, e2fro... | java | private <E extends Edge> double getConnectionSimilarity(
Graph<E> graph, Edge e1, Edge e2) {
int e1to = e1.to();
int e1from = e1.from();
int e2to = e2.to();
int e2from = e2.from();
if (e1to == e2to)
return getConnectionSimilarity(graph, e1to, e1from, e2fro... | [
"private",
"<",
"E",
"extends",
"Edge",
">",
"double",
"getConnectionSimilarity",
"(",
"Graph",
"<",
"E",
">",
"graph",
",",
"Edge",
"e1",
",",
"Edge",
"e2",
")",
"{",
"int",
"e1to",
"=",
"e1",
".",
"to",
"(",
")",
";",
"int",
"e1from",
"=",
"e1",
... | Computes the connection similarity for the two edges, first calculating
the impost and keystones nodes. If the edges are not connected, returns
0.
@see #getConnectionSimilarity(Graph,int,int,int) | [
"Computes",
"the",
"connection",
"similarity",
"for",
"the",
"two",
"edges",
"first",
"calculating",
"the",
"impost",
"and",
"keystones",
"nodes",
".",
"If",
"the",
"edges",
"are",
"not",
"connected",
"returns",
"0",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/graph/LinkClustering.java#L967-L983 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/TrieMap.java | TrieMap.addIntermediateNode | private void addIntermediateNode(Node<V> original,
int numOverlappingCharacters,
String key,
int indexOfStartOfOverlap,
V value) {
// get the current prefix for the node
char[] originalPrefix = original.prefix;
// create the new prefix for the original node, which will ... | java | private void addIntermediateNode(Node<V> original,
int numOverlappingCharacters,
String key,
int indexOfStartOfOverlap,
V value) {
// get the current prefix for the node
char[] originalPrefix = original.prefix;
// create the new prefix for the original node, which will ... | [
"private",
"void",
"addIntermediateNode",
"(",
"Node",
"<",
"V",
">",
"original",
",",
"int",
"numOverlappingCharacters",
",",
"String",
"key",
",",
"int",
"indexOfStartOfOverlap",
",",
"V",
"value",
")",
"{",
"// get the current prefix for the node",
"char",
"[",
... | Creates a series of children under the provided node, moving the value
that was mapped to this node to the appropriate terminal node in the
series and finally creating a new node at the end to hold the new
key-value mapping.
@param node a node under which a new key-value mapping is being added
@param nodesToCreate the... | [
"Creates",
"a",
"series",
"of",
"children",
"under",
"the",
"provided",
"node",
"moving",
"the",
"value",
"that",
"was",
"mapped",
"to",
"this",
"node",
"to",
"the",
"appropriate",
"terminal",
"node",
"in",
"the",
"series",
"and",
"finally",
"creating",
"a",... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/TrieMap.java#L448-L507 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/graph/BetweennessCentrality.java | BetweennessCentrality.compute | public <E extends Edge> double[] compute(Graph<E> g) {
// Perform a quick test for whether the vertices of g are a contiguous
// sequence starting at 0, which makes the vertex mapping trivial
if (!hasContiguousVertices(g))
throw new IllegalArgumentException(
"Vertices... | java | public <E extends Edge> double[] compute(Graph<E> g) {
// Perform a quick test for whether the vertices of g are a contiguous
// sequence starting at 0, which makes the vertex mapping trivial
if (!hasContiguousVertices(g))
throw new IllegalArgumentException(
"Vertices... | [
"public",
"<",
"E",
"extends",
"Edge",
">",
"double",
"[",
"]",
"compute",
"(",
"Graph",
"<",
"E",
">",
"g",
")",
"{",
"// Perform a quick test for whether the vertices of g are a contiguous",
"// sequence starting at 0, which makes the vertex mapping trivial",
"if",
"(",
... | Returns a mapping from each vertex to its betweenness centrality measure. | [
"Returns",
"a",
"mapping",
"from",
"each",
"vertex",
"to",
"its",
"betweenness",
"centrality",
"measure",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/graph/BetweennessCentrality.java#L54-L113 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/clustering/LinkClustering.java | LinkClustering.getEdgeSimMatrix | private Matrix getEdgeSimMatrix(List<Edge> edgeList, SparseMatrix sm,
boolean keepSimilarityMatrixInMemory) {
return (keepSimilarityMatrixInMemory)
? calculateEdgeSimMatrix(edgeList, sm)
: new LazySimilarityMatrix(edgeList, sm);
} | java | private Matrix getEdgeSimMatrix(List<Edge> edgeList, SparseMatrix sm,
boolean keepSimilarityMatrixInMemory) {
return (keepSimilarityMatrixInMemory)
? calculateEdgeSimMatrix(edgeList, sm)
: new LazySimilarityMatrix(edgeList, sm);
} | [
"private",
"Matrix",
"getEdgeSimMatrix",
"(",
"List",
"<",
"Edge",
">",
"edgeList",
",",
"SparseMatrix",
"sm",
",",
"boolean",
"keepSimilarityMatrixInMemory",
")",
"{",
"return",
"(",
"keepSimilarityMatrixInMemory",
")",
"?",
"calculateEdgeSimMatrix",
"(",
"edgeList",... | Returns the edge similarity matrix for the edges in the provided sparse
matrix. | [
"Returns",
"the",
"edge",
"similarity",
"matrix",
"for",
"the",
"edges",
"in",
"the",
"provided",
"sparse",
"matrix",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/clustering/LinkClustering.java#L357-L362 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/clustering/LinkClustering.java | LinkClustering.calculateEdgeSimMatrix | private Matrix calculateEdgeSimMatrix(
final List<Edge> edgeList, final SparseMatrix sm) {
final int numEdges = edgeList.size();
final Matrix edgeSimMatrix =
new SparseSymmetricMatrix(
new SparseHashMatrix(numEdges, numEdges));
Object key = workQueue.re... | java | private Matrix calculateEdgeSimMatrix(
final List<Edge> edgeList, final SparseMatrix sm) {
final int numEdges = edgeList.size();
final Matrix edgeSimMatrix =
new SparseSymmetricMatrix(
new SparseHashMatrix(numEdges, numEdges));
Object key = workQueue.re... | [
"private",
"Matrix",
"calculateEdgeSimMatrix",
"(",
"final",
"List",
"<",
"Edge",
">",
"edgeList",
",",
"final",
"SparseMatrix",
"sm",
")",
"{",
"final",
"int",
"numEdges",
"=",
"edgeList",
".",
"size",
"(",
")",
";",
"final",
"Matrix",
"edgeSimMatrix",
"=",... | Calculates the similarity matrix for the edges. The similarity matrix is
symmetric.
@param edgeList the list of all edges known to the system
@param sm a square matrix whose values denote edges between the rows.
@return the similarity matrix | [
"Calculates",
"the",
"similarity",
"matrix",
"for",
"the",
"edges",
".",
"The",
"similarity",
"matrix",
"is",
"symmetric",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/clustering/LinkClustering.java#L373-L402 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/clustering/LinkClustering.java | LinkClustering.convertMergesToAssignments | private static MultiMap<Integer,Integer> convertMergesToAssignments(
List<Merge> merges, int numOriginalClusters) {
MultiMap<Integer,Integer> clusterToElements =
new HashMultiMap<Integer,Integer>();
for (int i = 0; i < numOriginalClusters; ++i)
clusterToElements.put... | java | private static MultiMap<Integer,Integer> convertMergesToAssignments(
List<Merge> merges, int numOriginalClusters) {
MultiMap<Integer,Integer> clusterToElements =
new HashMultiMap<Integer,Integer>();
for (int i = 0; i < numOriginalClusters; ++i)
clusterToElements.put... | [
"private",
"static",
"MultiMap",
"<",
"Integer",
",",
"Integer",
">",
"convertMergesToAssignments",
"(",
"List",
"<",
"Merge",
">",
"merges",
",",
"int",
"numOriginalClusters",
")",
"{",
"MultiMap",
"<",
"Integer",
",",
"Integer",
">",
"clusterToElements",
"=",
... | Converts a series of merges to cluster assignments. Cluster assignments
are assumed to start at 0.
@param merges the merge steps, in order
@param numOriginalClusters how many clusters are present prior to
merging. This is typically the number of rows in the matrix being
clustered
@returns a mapping from a cluster t... | [
"Converts",
"a",
"series",
"of",
"merges",
"to",
"cluster",
"assignments",
".",
"Cluster",
"assignments",
"are",
"assumed",
"to",
"start",
"at",
"0",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/clustering/LinkClustering.java#L415-L429 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/clustering/LinkClustering.java | LinkClustering.getImpostNeighbors | private static int[] getImpostNeighbors(SparseMatrix sm, int rowIndex) {
int[] impost1edges = sm.getRowVector(rowIndex).getNonZeroIndices();
int[] neighbors = Arrays.copyOf(impost1edges, impost1edges.length + 1);
neighbors[neighbors.length - 1] = rowIndex;
return neighbors;
} | java | private static int[] getImpostNeighbors(SparseMatrix sm, int rowIndex) {
int[] impost1edges = sm.getRowVector(rowIndex).getNonZeroIndices();
int[] neighbors = Arrays.copyOf(impost1edges, impost1edges.length + 1);
neighbors[neighbors.length - 1] = rowIndex;
return neighbors;
} | [
"private",
"static",
"int",
"[",
"]",
"getImpostNeighbors",
"(",
"SparseMatrix",
"sm",
",",
"int",
"rowIndex",
")",
"{",
"int",
"[",
"]",
"impost1edges",
"=",
"sm",
".",
"getRowVector",
"(",
"rowIndex",
")",
".",
"getNonZeroIndices",
"(",
")",
";",
"int",
... | Returns an array containing the row indices of the neighbors of the
impost node and the row index of the impost node itself. | [
"Returns",
"an",
"array",
"containing",
"the",
"row",
"indices",
"of",
"the",
"neighbors",
"of",
"the",
"impost",
"node",
"and",
"the",
"row",
"index",
"of",
"the",
"impost",
"node",
"itself",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/clustering/LinkClustering.java#L491-L496 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/clustering/LinkClustering.java | LinkClustering.getSolutionDensity | public double getSolutionDensity(int solutionNum) {
if (solutionNum < 0 || solutionNum >= mergeOrder.size()) {
throw new IllegalArgumentException(
"not a valid solution: " + solutionNum);
}
if (mergeOrder == null || edgeList == null) {
throw new Ille... | java | public double getSolutionDensity(int solutionNum) {
if (solutionNum < 0 || solutionNum >= mergeOrder.size()) {
throw new IllegalArgumentException(
"not a valid solution: " + solutionNum);
}
if (mergeOrder == null || edgeList == null) {
throw new Ille... | [
"public",
"double",
"getSolutionDensity",
"(",
"int",
"solutionNum",
")",
"{",
"if",
"(",
"solutionNum",
"<",
"0",
"||",
"solutionNum",
">=",
"mergeOrder",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"not a valid solution:... | Returns the partition density of the clustering solution. | [
"Returns",
"the",
"partition",
"density",
"of",
"the",
"clustering",
"solution",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/clustering/LinkClustering.java#L501-L542 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/clustering/LinkClustering.java | LinkClustering.getSolution | public Assignments getSolution(int solutionNum) {
if (solutionNum < 0 || solutionNum >= mergeOrder.size()) {
throw new IllegalArgumentException(
"not a valid solution: " + solutionNum);
}
if (mergeOrder == null || edgeList == null) {
throw new Illega... | java | public Assignments getSolution(int solutionNum) {
if (solutionNum < 0 || solutionNum >= mergeOrder.size()) {
throw new IllegalArgumentException(
"not a valid solution: " + solutionNum);
}
if (mergeOrder == null || edgeList == null) {
throw new Illega... | [
"public",
"Assignments",
"getSolution",
"(",
"int",
"solutionNum",
")",
"{",
"if",
"(",
"solutionNum",
"<",
"0",
"||",
"solutionNum",
">=",
"mergeOrder",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"not a valid solution: \... | Returns the clustering solution after the specified number of merge
steps.
@param solutionNum the number of merge steps to take prior to returning
the clustering solution.
@throws IllegalArgumentException if {@code solutionNum} is less than 0 or
is greater than or equal to {@link #numberOfSolutions()}.
@throws Illega... | [
"Returns",
"the",
"clustering",
"solution",
"after",
"the",
"specified",
"number",
"of",
"merge",
"steps",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/clustering/LinkClustering.java#L556-L598 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/Statistics.java | Statistics.average | public static Matrix average(Matrix m, Dimension dim) {
Matrix averageMatrix = null;
if (dim == Dimension.ALL) {
// Compute the average of all values in the matrix.
double average = 0;
for (int i = 0; i < m.rows(); ++i) {
for (int j = 0; j < m.columns... | java | public static Matrix average(Matrix m, Dimension dim) {
Matrix averageMatrix = null;
if (dim == Dimension.ALL) {
// Compute the average of all values in the matrix.
double average = 0;
for (int i = 0; i < m.rows(); ++i) {
for (int j = 0; j < m.columns... | [
"public",
"static",
"Matrix",
"average",
"(",
"Matrix",
"m",
",",
"Dimension",
"dim",
")",
"{",
"Matrix",
"averageMatrix",
"=",
"null",
";",
"if",
"(",
"dim",
"==",
"Dimension",
".",
"ALL",
")",
"{",
"// Compute the average of all values in the matrix.",
"double... | Return a matrix containing the averages for the dimension
specificed.
@param m The matrix containing values to evaluate.
@param dim The dimension across which analysis should take place.
@return A matrix of the averages. | [
"Return",
"a",
"matrix",
"containing",
"the",
"averages",
"for",
"the",
"dimension",
"specificed",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/Statistics.java#L138-L180 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/tools/BlogPreProcessor.java | BlogPreProcessor.processFile | public void processFile(File blogFile) throws IOException {
BufferedReader br = new BufferedReader(new FileReader(blogFile));
String line = null;
String date = null;
String id = null;
StringBuilder content = new StringBuilder();
boolean needMoreContent = false;
while ((line = br.readLine()) ... | java | public void processFile(File blogFile) throws IOException {
BufferedReader br = new BufferedReader(new FileReader(blogFile));
String line = null;
String date = null;
String id = null;
StringBuilder content = new StringBuilder();
boolean needMoreContent = false;
while ((line = br.readLine()) ... | [
"public",
"void",
"processFile",
"(",
"File",
"blogFile",
")",
"throws",
"IOException",
"{",
"BufferedReader",
"br",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"blogFile",
")",
")",
";",
"String",
"line",
"=",
"null",
";",
"String",
"date",... | Given a blog file, read through each line and extract the content and
updated date, printing these as one line to the result file. | [
"Given",
"a",
"blog",
"file",
"read",
"through",
"each",
"line",
"and",
"extract",
"the",
"content",
"and",
"updated",
"date",
"printing",
"these",
"as",
"one",
"line",
"to",
"the",
"result",
"file",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/tools/BlogPreProcessor.java#L89-L152 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/graph/SimpleGraphIterator.java | SimpleGraphIterator.enumerateSimpleGraphs | private Collection<Multigraph<T,E>> enumerateSimpleGraphs(
Multigraph<T,E> input, List<IntPair> connected,
int curPair, Multigraph<T,E> toCopy) {
List<Multigraph<T,E>> simpleGraphs = new LinkedList<Multigraph<T,E>>();
IntPair p = connected.get(curPair);
// Get th... | java | private Collection<Multigraph<T,E>> enumerateSimpleGraphs(
Multigraph<T,E> input, List<IntPair> connected,
int curPair, Multigraph<T,E> toCopy) {
List<Multigraph<T,E>> simpleGraphs = new LinkedList<Multigraph<T,E>>();
IntPair p = connected.get(curPair);
// Get th... | [
"private",
"Collection",
"<",
"Multigraph",
"<",
"T",
",",
"E",
">",
">",
"enumerateSimpleGraphs",
"(",
"Multigraph",
"<",
"T",
",",
"E",
">",
"input",
",",
"List",
"<",
"IntPair",
">",
"connected",
",",
"int",
"curPair",
",",
"Multigraph",
"<",
"T",
"... | Recursively enumerates the parallel edge permutations of the input graph,
building up the graphs and returning the entire set of graphs.
@param input the base graph from which edges are selected
@param connected the list of vertex pairs that are connected by one or
more edges
@param curPair the index into {@code conne... | [
"Recursively",
"enumerates",
"the",
"parallel",
"edge",
"permutations",
"of",
"the",
"input",
"graph",
"building",
"up",
"the",
"graphs",
"and",
"returning",
"the",
"entire",
"set",
"of",
"graphs",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/graph/SimpleGraphIterator.java#L146-L175 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/graph/SimpleGraphIterator.java | SimpleGraphIterator.next | public Multigraph<T,E> next() {
if (!hasNext())
throw new NoSuchElementException();
Multigraph<T,E> cur = next.poll();
if (next.isEmpty())
advance();
return cur;
} | java | public Multigraph<T,E> next() {
if (!hasNext())
throw new NoSuchElementException();
Multigraph<T,E> cur = next.poll();
if (next.isEmpty())
advance();
return cur;
} | [
"public",
"Multigraph",
"<",
"T",
",",
"E",
">",
"next",
"(",
")",
"{",
"if",
"(",
"!",
"hasNext",
"(",
")",
")",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"Multigraph",
"<",
"T",
",",
"E",
">",
"cur",
"=",
"next",
".",
"poll",
"("... | Returns the next simple graph from the multigraph. | [
"Returns",
"the",
"next",
"simple",
"graph",
"from",
"the",
"multigraph",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/graph/SimpleGraphIterator.java#L187-L194 | train |
fozziethebeat/S-Space | opt/src/main/java/edu/ucla/sspace/grefenstette/Grefenstette.java | Grefenstette.addRelation | private void addRelation(String object, String attribute) {
double val;
int row, col;
object = object.toLowerCase();
attribute = attribute.toLowerCase();
// get row in matrix
if( objectTable.containsKey(object) ) {
// if the object already exists in matrix, ... | java | private void addRelation(String object, String attribute) {
double val;
int row, col;
object = object.toLowerCase();
attribute = attribute.toLowerCase();
// get row in matrix
if( objectTable.containsKey(object) ) {
// if the object already exists in matrix, ... | [
"private",
"void",
"addRelation",
"(",
"String",
"object",
",",
"String",
"attribute",
")",
"{",
"double",
"val",
";",
"int",
"row",
",",
"col",
";",
"object",
"=",
"object",
".",
"toLowerCase",
"(",
")",
";",
"attribute",
"=",
"attribute",
".",
"toLower... | Adds a relation pair to the matrix | [
"Adds",
"a",
"relation",
"pair",
"to",
"the",
"matrix"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/opt/src/main/java/edu/ucla/sspace/grefenstette/Grefenstette.java#L284-L324 | train |
fozziethebeat/S-Space | opt/src/main/java/edu/ucla/sspace/grefenstette/Grefenstette.java | Grefenstette.inStartSet | private boolean inStartSet(String tag) {
return
// noun
tag.startsWith("NN") ||
// adjective
tag.startsWith("JJ") ||
// adverb
tag.startsWith("RB") ||
// cardinal number
tag.startsWith("CD");
} | java | private boolean inStartSet(String tag) {
return
// noun
tag.startsWith("NN") ||
// adjective
tag.startsWith("JJ") ||
// adverb
tag.startsWith("RB") ||
// cardinal number
tag.startsWith("CD");
} | [
"private",
"boolean",
"inStartSet",
"(",
"String",
"tag",
")",
"{",
"return",
"// noun",
"tag",
".",
"startsWith",
"(",
"\"NN\"",
")",
"||",
"// adjective",
"tag",
".",
"startsWith",
"(",
"\"JJ\"",
")",
"||",
"// adverb",
"tag",
".",
"startsWith",
"(",
"\"... | Checks to see if the tag can modify another word
@param tag A tag from the parsed corpus to be checked | [
"Checks",
"to",
"see",
"if",
"the",
"tag",
"can",
"modify",
"another",
"word"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/opt/src/main/java/edu/ucla/sspace/grefenstette/Grefenstette.java#L362-L372 | train |
fozziethebeat/S-Space | opt/src/main/java/edu/ucla/sspace/grefenstette/Grefenstette.java | Grefenstette.isPhraseOrClause | private boolean isPhraseOrClause(String tag) {
// find out why adding more reduced the number of relations
return
(!tag.equals("SYM") &&
tag.startsWith("S")) ||
tag.equals("ADJP") ||
tag.equals("ADVP") ||
tag.equals("CONJP") ||
tag... | java | private boolean isPhraseOrClause(String tag) {
// find out why adding more reduced the number of relations
return
(!tag.equals("SYM") &&
tag.startsWith("S")) ||
tag.equals("ADJP") ||
tag.equals("ADVP") ||
tag.equals("CONJP") ||
tag... | [
"private",
"boolean",
"isPhraseOrClause",
"(",
"String",
"tag",
")",
"{",
"// find out why adding more reduced the number of relations",
"return",
"(",
"!",
"tag",
".",
"equals",
"(",
"\"SYM\"",
")",
"&&",
"tag",
".",
"startsWith",
"(",
"\"S\"",
")",
")",
"||",
... | Checks to see if tag marks a phrase or clause | [
"Checks",
"to",
"see",
"if",
"tag",
"marks",
"a",
"phrase",
"or",
"clause"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/opt/src/main/java/edu/ucla/sspace/grefenstette/Grefenstette.java#L396-L420 | train |
fozziethebeat/S-Space | opt/src/main/java/edu/ucla/sspace/grefenstette/Grefenstette.java | Grefenstette.getNextTag | private String getNextTag(String str) {
String tag;
int endIndex;
int tagIndex = str.indexOf("(");
if( tagIndex < 0 ) {
return null;
}
// in case there's nothing in the sentence
endIndex = str.indexOf(" ", tagIndex);
if( endIndex < 0 ) {
... | java | private String getNextTag(String str) {
String tag;
int endIndex;
int tagIndex = str.indexOf("(");
if( tagIndex < 0 ) {
return null;
}
// in case there's nothing in the sentence
endIndex = str.indexOf(" ", tagIndex);
if( endIndex < 0 ) {
... | [
"private",
"String",
"getNextTag",
"(",
"String",
"str",
")",
"{",
"String",
"tag",
";",
"int",
"endIndex",
";",
"int",
"tagIndex",
"=",
"str",
".",
"indexOf",
"(",
"\"(\"",
")",
";",
"if",
"(",
"tagIndex",
"<",
"0",
")",
"{",
"return",
"null",
";",
... | Returns the next tag in the sentence or null if there are no more tags
@param str The sentence that the tag is extracted from | [
"Returns",
"the",
"next",
"tag",
"in",
"the",
"sentence",
"or",
"null",
"if",
"there",
"are",
"no",
"more",
"tags"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/opt/src/main/java/edu/ucla/sspace/grefenstette/Grefenstette.java#L426-L450 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/text/PatPho.java | PatPho.vectorize | public double[] vectorize(List<String> phonemes) {
int nextConsonantIndex = 0;
int nextVowelIndex = 0;
double[] result = new double[(vowelIndices.length +
consonantIndices.length) * 3];
for (String phoneme : phonemes) {
int offset = 3;
... | java | public double[] vectorize(List<String> phonemes) {
int nextConsonantIndex = 0;
int nextVowelIndex = 0;
double[] result = new double[(vowelIndices.length +
consonantIndices.length) * 3];
for (String phoneme : phonemes) {
int offset = 3;
... | [
"public",
"double",
"[",
"]",
"vectorize",
"(",
"List",
"<",
"String",
">",
"phonemes",
")",
"{",
"int",
"nextConsonantIndex",
"=",
"0",
";",
"int",
"nextVowelIndex",
"=",
"0",
";",
"double",
"[",
"]",
"result",
"=",
"new",
"double",
"[",
"(",
"vowelIn... | Returns a left-justified syllablilic template representation of the given
list of phonemes. Every three values correspond to a single phoneme
representation. If six syllables are used, a vector of 99 values is
returned, otherwise a vector of 54 values is returned.
@param phonemes A list of string phoneme representat... | [
"Returns",
"a",
"left",
"-",
"justified",
"syllablilic",
"template",
"representation",
"of",
"the",
"given",
"list",
"of",
"phonemes",
".",
"Every",
"three",
"values",
"correspond",
"to",
"a",
"single",
"phoneme",
"representation",
".",
"If",
"six",
"syllables",... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/text/PatPho.java#L134-L150 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/tools/BigramExtractor.java | BigramExtractor.process | public void process(Iterator<String> text) {
String nextToken = null, curToken = null;
// Base case for the next token buffer to ensure we always have two
// valid tokens present
if (text.hasNext())
nextToken = text.next();
while (text.hasNext()) {
curToke... | java | public void process(Iterator<String> text) {
String nextToken = null, curToken = null;
// Base case for the next token buffer to ensure we always have two
// valid tokens present
if (text.hasNext())
nextToken = text.next();
while (text.hasNext()) {
curToke... | [
"public",
"void",
"process",
"(",
"Iterator",
"<",
"String",
">",
"text",
")",
"{",
"String",
"nextToken",
"=",
"null",
",",
"curToken",
"=",
"null",
";",
"// Base case for the next token buffer to ensure we always have two",
"// valid tokens present",
"if",
"(",
"tex... | Processes the tokens in the iterator to gather statistics for any bigrams
contained therein | [
"Processes",
"the",
"tokens",
"in",
"the",
"iterator",
"to",
"gather",
"statistics",
"for",
"any",
"bigrams",
"contained",
"therein"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/tools/BigramExtractor.java#L154-L168 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/tools/BigramExtractor.java | BigramExtractor.processBigram | private void processBigram(String left, String right) {
TokenStats leftStats = getStatsFor(left);
TokenStats rightStats = getStatsFor(right);
// mark that both appeared
leftStats.count++;
rightStats.count++;
// Mark the respective positions of each
leftS... | java | private void processBigram(String left, String right) {
TokenStats leftStats = getStatsFor(left);
TokenStats rightStats = getStatsFor(right);
// mark that both appeared
leftStats.count++;
rightStats.count++;
// Mark the respective positions of each
leftS... | [
"private",
"void",
"processBigram",
"(",
"String",
"left",
",",
"String",
"right",
")",
"{",
"TokenStats",
"leftStats",
"=",
"getStatsFor",
"(",
"left",
")",
";",
"TokenStats",
"rightStats",
"=",
"getStatsFor",
"(",
"right",
")",
";",
"// mark that both appeared... | Updates the statistics for the bigram formed from the provided left and
right token.
@param left the left token in the bigram
@param right the right token in the bigram | [
"Updates",
"the",
"statistics",
"for",
"the",
"bigram",
"formed",
"from",
"the",
"provided",
"left",
"and",
"right",
"token",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/tools/BigramExtractor.java#L177-L210 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/tools/BigramExtractor.java | BigramExtractor.printBigrams | public void printBigrams(PrintWriter output,
SignificanceTest test, int minOccurrencePerToken) {
String[] indexToToken = new String[tokenCounts.size()];
for (Map.Entry<String,TokenStats> e : tokenCounts.entrySet())
indexToToken[e.getValue().index] = e.... | java | public void printBigrams(PrintWriter output,
SignificanceTest test, int minOccurrencePerToken) {
String[] indexToToken = new String[tokenCounts.size()];
for (Map.Entry<String,TokenStats> e : tokenCounts.entrySet())
indexToToken[e.getValue().index] = e.... | [
"public",
"void",
"printBigrams",
"(",
"PrintWriter",
"output",
",",
"SignificanceTest",
"test",
",",
"int",
"minOccurrencePerToken",
")",
"{",
"String",
"[",
"]",
"indexToToken",
"=",
"new",
"String",
"[",
"tokenCounts",
".",
"size",
"(",
")",
"]",
";",
"fo... | Prints all of the known bigrams, where each token in the
bigram must occur at least the number of specified time.
@param output the writer where all the bigrams should be printed
@param test the significant test to use in rating the statistical
correlation of two tokens
@param minOccurrencePerToken the minimum number ... | [
"Prints",
"all",
"of",
"the",
"known",
"bigrams",
"where",
"each",
"token",
"in",
"the",
"bigram",
"must",
"occur",
"at",
"least",
"the",
"number",
"of",
"specified",
"time",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/tools/BigramExtractor.java#L289-L322 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/tools/BigramExtractor.java | BigramExtractor.getScore | private double getScore(int[] contingencyTable, SignificanceTest test) {
switch (test) {
case PMI:
return pmi(contingencyTable);
case CHI_SQUARED:
return chiSq(contingencyTable);
case LOG_LIKELIHOOD:
return logLikelihood(contingencyTable);
defa... | java | private double getScore(int[] contingencyTable, SignificanceTest test) {
switch (test) {
case PMI:
return pmi(contingencyTable);
case CHI_SQUARED:
return chiSq(contingencyTable);
case LOG_LIKELIHOOD:
return logLikelihood(contingencyTable);
defa... | [
"private",
"double",
"getScore",
"(",
"int",
"[",
"]",
"contingencyTable",
",",
"SignificanceTest",
"test",
")",
"{",
"switch",
"(",
"test",
")",
"{",
"case",
"PMI",
":",
"return",
"pmi",
"(",
"contingencyTable",
")",
";",
"case",
"CHI_SQUARED",
":",
"retu... | Returns the score of the contingency table using the specified
significance test
@param contingencyTable a contingency table specified as four {@code int}
values
@param test the significance test to use in evaluating the table | [
"Returns",
"the",
"score",
"of",
"the",
"contingency",
"table",
"using",
"the",
"specified",
"significance",
"test"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/tools/BigramExtractor.java#L332-L343 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/tools/BigramExtractor.java | BigramExtractor.logLikelihood | private double logLikelihood(int[] contingencyTable) {
// Rename for short-hand convenience
int[] t = contingencyTable;
int col1sum = t[0] + t[2];
int col2sum = t[1] + t[3];
int row1sum = t[0] + t[1];
int row2sum = t[2] + t[3];
double sum = row1sum + row2sum;
... | java | private double logLikelihood(int[] contingencyTable) {
// Rename for short-hand convenience
int[] t = contingencyTable;
int col1sum = t[0] + t[2];
int col2sum = t[1] + t[3];
int row1sum = t[0] + t[1];
int row2sum = t[2] + t[3];
double sum = row1sum + row2sum;
... | [
"private",
"double",
"logLikelihood",
"(",
"int",
"[",
"]",
"contingencyTable",
")",
"{",
"// Rename for short-hand convenience",
"int",
"[",
"]",
"t",
"=",
"contingencyTable",
";",
"int",
"col1sum",
"=",
"t",
"[",
"0",
"]",
"+",
"t",
"[",
"2",
"]",
";",
... | Returns the log-likelihood score of the contingency table | [
"Returns",
"the",
"log",
"-",
"likelihood",
"score",
"of",
"the",
"contingency",
"table"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/tools/BigramExtractor.java#L389-L409 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/dv/RelationBasedBasisMapping.java | RelationBasedBasisMapping.getDimension | public int getDimension(DependencyPath path) {
String endToken = path.last().word();
// Extract out how the current word is related to the last word in the
// path.
String relation = path.getRelation(path.length() - 1);
return getDimensionInternal(endToken + "+" + relation);
... | java | public int getDimension(DependencyPath path) {
String endToken = path.last().word();
// Extract out how the current word is related to the last word in the
// path.
String relation = path.getRelation(path.length() - 1);
return getDimensionInternal(endToken + "+" + relation);
... | [
"public",
"int",
"getDimension",
"(",
"DependencyPath",
"path",
")",
"{",
"String",
"endToken",
"=",
"path",
".",
"last",
"(",
")",
".",
"word",
"(",
")",
";",
"// Extract out how the current word is related to the last word in the",
"// path. ",
"String",
"relation"... | Returns the dimension number corresponding to the term at the end of the
provided path.
@param path a path whose end represents a semantic connection
@return the dimension for the occurrence of the last word in the path | [
"Returns",
"the",
"dimension",
"number",
"corresponding",
"to",
"the",
"term",
"at",
"the",
"end",
"of",
"the",
"provided",
"path",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/dv/RelationBasedBasisMapping.java#L51-L58 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/index/GaussianVectorGenerator.java | GaussianVectorGenerator.generate | public synchronized DoubleVector generate() {
DoubleVector termVector = new DenseVector(indexVectorLength);
for (int i = 0; i < indexVectorLength; i++)
termVector.set(i, mean + (randomGenerator.nextGaussian() * stdev));
return termVector;
} | java | public synchronized DoubleVector generate() {
DoubleVector termVector = new DenseVector(indexVectorLength);
for (int i = 0; i < indexVectorLength; i++)
termVector.set(i, mean + (randomGenerator.nextGaussian() * stdev));
return termVector;
} | [
"public",
"synchronized",
"DoubleVector",
"generate",
"(",
")",
"{",
"DoubleVector",
"termVector",
"=",
"new",
"DenseVector",
"(",
"indexVectorLength",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"indexVectorLength",
";",
"i",
"++",
")",
"te... | Generate a new random vector using a guassian distribution for each
value. | [
"Generate",
"a",
"new",
"random",
"vector",
"using",
"a",
"guassian",
"distribution",
"for",
"each",
"value",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/index/GaussianVectorGenerator.java#L137-L142 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/wordsi/WordOccrrenceContextGenerator.java | WordOccrrenceContextGenerator.addContextTerms | protected void addContextTerms(SparseDoubleVector meaning,
Queue<String> words,
int distance) {
// Iterate through each of the context words.
for (String term : words) {
if (!term.equals(IteratorFactory.EMPTY_TOKEN)) {
... | java | protected void addContextTerms(SparseDoubleVector meaning,
Queue<String> words,
int distance) {
// Iterate through each of the context words.
for (String term : words) {
if (!term.equals(IteratorFactory.EMPTY_TOKEN)) {
... | [
"protected",
"void",
"addContextTerms",
"(",
"SparseDoubleVector",
"meaning",
",",
"Queue",
"<",
"String",
">",
"words",
",",
"int",
"distance",
")",
"{",
"// Iterate through each of the context words.",
"for",
"(",
"String",
"term",
":",
"words",
")",
"{",
"if",
... | Adds a feature for each word in the context that has a valid dimension.
Feature are scored based on the context word's distance from the focus
word. | [
"Adds",
"a",
"feature",
"for",
"each",
"word",
"in",
"the",
"context",
"that",
"has",
"a",
"valid",
"dimension",
".",
"Feature",
"are",
"scored",
"based",
"on",
"the",
"context",
"word",
"s",
"distance",
"from",
"the",
"focus",
"word",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/wordsi/WordOccrrenceContextGenerator.java#L108-L125 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/purandare/PurandareFirstOrder.java | PurandareFirstOrder.processSpace | @SuppressWarnings("unchecked")
private void processSpace() throws IOException {
compressedDocumentsWriter.close();
// Generate the reverse index-to-term mapping. We will need this for
// assigning specific senses to each term
String[] indexToTerm = new String[termToIndex.si... | java | @SuppressWarnings("unchecked")
private void processSpace() throws IOException {
compressedDocumentsWriter.close();
// Generate the reverse index-to-term mapping. We will need this for
// assigning specific senses to each term
String[] indexToTerm = new String[termToIndex.si... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"processSpace",
"(",
")",
"throws",
"IOException",
"{",
"compressedDocumentsWriter",
".",
"close",
"(",
")",
";",
"// Generate the reverse index-to-term mapping. We will need this for",
"// assigning spec... | Calculates the first order co-occurrence statics to determine the feature
set for each term, then clusters the feature vectors for each terms
contexts and finally induces the sense-specific vectors for each term. | [
"Calculates",
"the",
"first",
"order",
"co",
"-",
"occurrence",
"statics",
"to",
"determine",
"the",
"feature",
"set",
"for",
"each",
"term",
"then",
"clusters",
"the",
"feature",
"vectors",
"for",
"each",
"terms",
"contexts",
"and",
"finally",
"induces",
"the... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/purandare/PurandareFirstOrder.java#L404-L473 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/purandare/PurandareFirstOrder.java | PurandareFirstOrder.senseInduce | private void senseInduce(String term, Matrix contexts) throws IOException {
LOGGER.fine("Clustering " + contexts.rows() + " contexts for " + term);
// For terms with fewer than seven contexts, set the number of potential
// clusters lower
int numClusters = Math.min(7, contexts.rows());
... | java | private void senseInduce(String term, Matrix contexts) throws IOException {
LOGGER.fine("Clustering " + contexts.rows() + " contexts for " + term);
// For terms with fewer than seven contexts, set the number of potential
// clusters lower
int numClusters = Math.min(7, contexts.rows());
... | [
"private",
"void",
"senseInduce",
"(",
"String",
"term",
",",
"Matrix",
"contexts",
")",
"throws",
"IOException",
"{",
"LOGGER",
".",
"fine",
"(",
"\"Clustering \"",
"+",
"contexts",
".",
"rows",
"(",
")",
"+",
"\" contexts for \"",
"+",
"term",
")",
";",
... | Given a matrix for the term where each row is a different context,
clusters the rows to identify how many senses the word has.
@param term the term for which the senses will be discovered
@param contexts a matrix containing all the contexts in which {@code
term} appear, with one context per row | [
"Given",
"a",
"matrix",
"for",
"the",
"term",
"where",
"each",
"row",
"is",
"a",
"different",
"context",
"clusters",
"the",
"rows",
"to",
"identify",
"how",
"many",
"senses",
"the",
"word",
"has",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/purandare/PurandareFirstOrder.java#L580-L646 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/purandare/PurandareFirstOrder.java | PurandareFirstOrder.processIntDocument | private int processIntDocument(int termIndex, int[] document,
Matrix contextMatrix,
int rowStart,
BitSet featuresForTerm) {
int contexts = 0;
for (int i = 0; i < document.length; ++i) {
... | java | private int processIntDocument(int termIndex, int[] document,
Matrix contextMatrix,
int rowStart,
BitSet featuresForTerm) {
int contexts = 0;
for (int i = 0; i < document.length; ++i) {
... | [
"private",
"int",
"processIntDocument",
"(",
"int",
"termIndex",
",",
"int",
"[",
"]",
"document",
",",
"Matrix",
"contextMatrix",
",",
"int",
"rowStart",
",",
"BitSet",
"featuresForTerm",
")",
"{",
"int",
"contexts",
"=",
"0",
";",
"for",
"(",
"int",
"i",... | Processes the compressed version of a document where each integer
indicates that token's index and identifies all the contexts for the
target word, adding them as new rows to the context matrix.
@param termIndex the term whose contexts should be extracted
@param document the document to be processed where each {@code ... | [
"Processes",
"the",
"compressed",
"version",
"of",
"a",
"document",
"where",
"each",
"integer",
"indicates",
"that",
"token",
"s",
"index",
"and",
"identifies",
"all",
"the",
"contexts",
"for",
"the",
"target",
"word",
"adding",
"them",
"as",
"new",
"rows",
... | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/purandare/PurandareFirstOrder.java#L665-L720 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/purandare/PurandareFirstOrder.java | PurandareFirstOrder.logLikelihood | private static double logLikelihood(double a, double b,
double c, double d) {
// Table set up as:
// a b
// c d
double col1sum = a + c;
double col2sum = b + d;
double row1sum = a + b;
double row2sum = c + d;
d... | java | private static double logLikelihood(double a, double b,
double c, double d) {
// Table set up as:
// a b
// c d
double col1sum = a + c;
double col2sum = b + d;
double row1sum = a + b;
double row2sum = c + d;
d... | [
"private",
"static",
"double",
"logLikelihood",
"(",
"double",
"a",
",",
"double",
"b",
",",
"double",
"c",
",",
"double",
"d",
")",
"{",
"// Table set up as:",
"// a b",
"// c d",
"double",
"col1sum",
"=",
"a",
"+",
"c",
";",
"double",
"col2sum",
"=... | Returns the log-likelihood of the contingency table made up of the four
values. | [
"Returns",
"the",
"log",
"-",
"likelihood",
"of",
"the",
"contingency",
"table",
"made",
"up",
"of",
"the",
"four",
"values",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/purandare/PurandareFirstOrder.java#L741-L766 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/ArrayMatrix.java | ArrayMatrix.checkIndices | private void checkIndices(int row, int col) {
if (row < 0 || row >= rows)
throw new ArrayIndexOutOfBoundsException("row: " + row);
else if (col < 0 || col >= cols)
throw new ArrayIndexOutOfBoundsException("column: " + col);
} | java | private void checkIndices(int row, int col) {
if (row < 0 || row >= rows)
throw new ArrayIndexOutOfBoundsException("row: " + row);
else if (col < 0 || col >= cols)
throw new ArrayIndexOutOfBoundsException("column: " + col);
} | [
"private",
"void",
"checkIndices",
"(",
"int",
"row",
",",
"int",
"col",
")",
"{",
"if",
"(",
"row",
"<",
"0",
"||",
"row",
">=",
"rows",
")",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
"\"row: \"",
"+",
"row",
")",
";",
"else",
"if",
"(",
... | Check that the indices of a requested cell are within bounds.
@param row The row of the cell to check.
@param col The column of the cell to check.
@throws ArrayIndexOutOfBoundsException if | [
"Check",
"that",
"the",
"indices",
"of",
"a",
"requested",
"cell",
"are",
"within",
"bounds",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/ArrayMatrix.java#L139-L144 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/graph/SparseWeightedEdgeSet.java | SparseWeightedEdgeSet.add | public boolean add(WeightedEdge e) {
int toAdd = -1;
if (e.from() == rootVertex)
toAdd = e.to();
else if (e.to() == rootVertex)
toAdd = e.from();
else {
return false;
}
double w = e.weight();
if (edges.contains... | java | public boolean add(WeightedEdge e) {
int toAdd = -1;
if (e.from() == rootVertex)
toAdd = e.to();
else if (e.to() == rootVertex)
toAdd = e.from();
else {
return false;
}
double w = e.weight();
if (edges.contains... | [
"public",
"boolean",
"add",
"(",
"WeightedEdge",
"e",
")",
"{",
"int",
"toAdd",
"=",
"-",
"1",
";",
"if",
"(",
"e",
".",
"from",
"(",
")",
"==",
"rootVertex",
")",
"toAdd",
"=",
"e",
".",
"to",
"(",
")",
";",
"else",
"if",
"(",
"e",
".",
"to"... | Adds the edge to this set if one of the vertices is the root vertex.
@return {@code true} if e was added or if the weight was changed for the
conenction between an existing edge that matched | [
"Adds",
"the",
"edge",
"to",
"this",
"set",
"if",
"one",
"of",
"the",
"vertices",
"is",
"the",
"root",
"vertex",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/graph/SparseWeightedEdgeSet.java#L96-L116 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/clustering/CandidateCluster.java | CandidateCluster.centerOfMass | public DoubleVector centerOfMass() {
// Handle lazy initialization
if (centroid == null) {
if (indices.size() == 1)
centroid = sumVector;
else {
// Update the centroid by normalizing by the number of elements.
// We expect that the ... | java | public DoubleVector centerOfMass() {
// Handle lazy initialization
if (centroid == null) {
if (indices.size() == 1)
centroid = sumVector;
else {
// Update the centroid by normalizing by the number of elements.
// We expect that the ... | [
"public",
"DoubleVector",
"centerOfMass",
"(",
")",
"{",
"// Handle lazy initialization",
"if",
"(",
"centroid",
"==",
"null",
")",
"{",
"if",
"(",
"indices",
".",
"size",
"(",
")",
"==",
"1",
")",
"centroid",
"=",
"sumVector",
";",
"else",
"{",
"// Update... | Returns the average data point assigned to this candidate cluster | [
"Returns",
"the",
"average",
"data",
"point",
"assigned",
"to",
"this",
"candidate",
"cluster"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/clustering/CandidateCluster.java#L64-L94 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/clustering/CandidateCluster.java | CandidateCluster.add | public void add(int index, DoubleVector v) {
boolean added = indices.add(index);
assert added : "Adding duplicate indices to candidate facility";
if (sumVector == null) {
sumVector = (v instanceof SparseVector)
? new SparseHashDoubleVector(v)
: new Den... | java | public void add(int index, DoubleVector v) {
boolean added = indices.add(index);
assert added : "Adding duplicate indices to candidate facility";
if (sumVector == null) {
sumVector = (v instanceof SparseVector)
? new SparseHashDoubleVector(v)
: new Den... | [
"public",
"void",
"add",
"(",
"int",
"index",
",",
"DoubleVector",
"v",
")",
"{",
"boolean",
"added",
"=",
"indices",
".",
"add",
"(",
"index",
")",
";",
"assert",
"added",
":",
"\"Adding duplicate indices to candidate facility\"",
";",
"if",
"(",
"sumVector",... | Adds the data point with the specified index to the facility | [
"Adds",
"the",
"data",
"point",
"with",
"the",
"specified",
"index",
"to",
"the",
"facility"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/clustering/CandidateCluster.java#L99-L111 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/clustering/CandidateCluster.java | CandidateCluster.merge | public void merge(CandidateCluster other) {
indices.addAll(other.indices);
VectorMath.add(sumVector, other.sumVector);
centroid = null;
} | java | public void merge(CandidateCluster other) {
indices.addAll(other.indices);
VectorMath.add(sumVector, other.sumVector);
centroid = null;
} | [
"public",
"void",
"merge",
"(",
"CandidateCluster",
"other",
")",
"{",
"indices",
".",
"addAll",
"(",
"other",
".",
"indices",
")",
";",
"VectorMath",
".",
"add",
"(",
"sumVector",
",",
"other",
".",
"sumVector",
")",
";",
"centroid",
"=",
"null",
";",
... | Merges the elements assigned to the other cluster into this one. | [
"Merges",
"the",
"elements",
"assigned",
"to",
"the",
"other",
"cluster",
"into",
"this",
"one",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/clustering/CandidateCluster.java#L135-L139 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/mains/FixedDurationTemporalRandomIndexingMain.java | FixedDurationTemporalRandomIndexingMain.printSpace | private void printSpace(SemanticSpace sspace, String tag) {
try {
String EXT = ".sspace";
File output = (overwrite)
? new File(outputDir, sspace.getSpaceName() + tag + EXT)
: File.createTempFile(sspace.getSpaceName() + tag, EXT,
... | java | private void printSpace(SemanticSpace sspace, String tag) {
try {
String EXT = ".sspace";
File output = (overwrite)
? new File(outputDir, sspace.getSpaceName() + tag + EXT)
: File.createTempFile(sspace.getSpaceName() + tag, EXT,
... | [
"private",
"void",
"printSpace",
"(",
"SemanticSpace",
"sspace",
",",
"String",
"tag",
")",
"{",
"try",
"{",
"String",
"EXT",
"=",
"\".sspace\"",
";",
"File",
"output",
"=",
"(",
"overwrite",
")",
"?",
"new",
"File",
"(",
"outputDir",
",",
"sspace",
".",... | Prints the semantic space to file, inserting the tag into the .sspace
file name | [
"Prints",
"the",
"semantic",
"space",
"to",
"file",
"inserting",
"the",
"tag",
"into",
"the",
".",
"sspace",
"file",
"name"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/mains/FixedDurationTemporalRandomIndexingMain.java#L481-L497 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/mains/FixedDurationTemporalRandomIndexingMain.java | FixedDurationTemporalRandomIndexingMain.updateTemporalSemantics | private void updateTemporalSemantics(long currentSemanticPartitionStartTime,
SemanticSpace semanticPartition) {
// Pre-allocate the zero vector so that if multiple interesting words
// are not present in the space, they all point to the same zero
... | java | private void updateTemporalSemantics(long currentSemanticPartitionStartTime,
SemanticSpace semanticPartition) {
// Pre-allocate the zero vector so that if multiple interesting words
// are not present in the space, they all point to the same zero
... | [
"private",
"void",
"updateTemporalSemantics",
"(",
"long",
"currentSemanticPartitionStartTime",
",",
"SemanticSpace",
"semanticPartition",
")",
"{",
"// Pre-allocate the zero vector so that if multiple interesting words",
"// are not present in the space, they all point to the same zero",
... | Adds the temporal semantics for each interesting word using the provided
semantic partition.
@param currentSemanticPartitionStartTime the start time of the semantic
partition | [
"Adds",
"the",
"temporal",
"semantics",
"for",
"each",
"interesting",
"word",
"using",
"the",
"provided",
"semantic",
"partition",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/mains/FixedDurationTemporalRandomIndexingMain.java#L506-L528 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/mains/FixedDurationTemporalRandomIndexingMain.java | FixedDurationTemporalRandomIndexingMain.printShiftRankings | private void printShiftRankings(String dateString,
long startOfMostRecentPartition,
TimeSpan partitionDuration)
throws IOException {
SortedMultiMap<Double,String> shiftToWord =
new TreeMultiMap<Double,String>();
... | java | private void printShiftRankings(String dateString,
long startOfMostRecentPartition,
TimeSpan partitionDuration)
throws IOException {
SortedMultiMap<Double,String> shiftToWord =
new TreeMultiMap<Double,String>();
... | [
"private",
"void",
"printShiftRankings",
"(",
"String",
"dateString",
",",
"long",
"startOfMostRecentPartition",
",",
"TimeSpan",
"partitionDuration",
")",
"throws",
"IOException",
"{",
"SortedMultiMap",
"<",
"Double",
",",
"String",
">",
"shiftToWord",
"=",
"new",
... | Computes the ranking of which words underwent the most dramatic shifts in
the most recent partition and then prints the ranking list of a file.
@param dateString the string to use when indiciation which partition is
having its ranking lists printed. This string becomes a part of
the file name. | [
"Computes",
"the",
"ranking",
"of",
"which",
"words",
"underwent",
"the",
"most",
"dramatic",
"shifts",
"in",
"the",
"most",
"recent",
"partition",
"and",
"then",
"prints",
"the",
"ranking",
"list",
"of",
"a",
"file",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/mains/FixedDurationTemporalRandomIndexingMain.java#L591-L654 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/mains/FixedDurationTemporalRandomIndexingMain.java | FixedDurationTemporalRandomIndexingMain.usage | protected void usage() {
System.out.println(
"usage: java FixedDurationTemporalRandomIndexingMain [options] " +
"<output-dir>\n\n" +
argOptions.prettyPrint() +
"\nFixed-Duration TRI provides four main output options:\n\n" +
" 1) Outputting each s... | java | protected void usage() {
System.out.println(
"usage: java FixedDurationTemporalRandomIndexingMain [options] " +
"<output-dir>\n\n" +
argOptions.prettyPrint() +
"\nFixed-Duration TRI provides four main output options:\n\n" +
" 1) Outputting each s... | [
"protected",
"void",
"usage",
"(",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"usage: java FixedDurationTemporalRandomIndexingMain [options] \"",
"+",
"\"<output-dir>\\n\\n\"",
"+",
"argOptions",
".",
"prettyPrint",
"(",
")",
"+",
"\"\\nFixed-Duration TRI prov... | Prints the instructions on how to execute this program to standard out. | [
"Prints",
"the",
"instructions",
"on",
"how",
"to",
"execute",
"this",
"program",
"to",
"standard",
"out",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/mains/FixedDurationTemporalRandomIndexingMain.java#L1018-L1059 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/DisjointSets.java | DisjointSets.iterator | public Iterator<T> iterator() {
List<Iterator<T>> iters = new ArrayList<Iterator<T>>(sets.size());
for (Set<T> s : sets)
iters.add(s.iterator());
return new CombinedIterator<T>(iters);
} | java | public Iterator<T> iterator() {
List<Iterator<T>> iters = new ArrayList<Iterator<T>>(sets.size());
for (Set<T> s : sets)
iters.add(s.iterator());
return new CombinedIterator<T>(iters);
} | [
"public",
"Iterator",
"<",
"T",
">",
"iterator",
"(",
")",
"{",
"List",
"<",
"Iterator",
"<",
"T",
">>",
"iters",
"=",
"new",
"ArrayList",
"<",
"Iterator",
"<",
"T",
">",
">",
"(",
"sets",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Set",
"<"... | Returns an iterator over all the unique items across all sets. | [
"Returns",
"an",
"iterator",
"over",
"all",
"the",
"unique",
"items",
"across",
"all",
"sets",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/DisjointSets.java#L103-L108 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/DisjointSets.java | DisjointSets.size | public int size() {
// Since the sets are disjoint, we can simple sum their sizes
int size = 0;
for (Set<T> s : sets)
size += s.size();
return size;
} | java | public int size() {
// Since the sets are disjoint, we can simple sum their sizes
int size = 0;
for (Set<T> s : sets)
size += s.size();
return size;
} | [
"public",
"int",
"size",
"(",
")",
"{",
"// Since the sets are disjoint, we can simple sum their sizes",
"int",
"size",
"=",
"0",
";",
"for",
"(",
"Set",
"<",
"T",
">",
"s",
":",
"sets",
")",
"size",
"+=",
"s",
".",
"size",
"(",
")",
";",
"return",
"size... | Returns the number of unique items across all sets. | [
"Returns",
"the",
"number",
"of",
"unique",
"items",
"across",
"all",
"sets",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/DisjointSets.java#L136-L142 | train |
fozziethebeat/S-Space | hadoop/src/main/java/edu/ucla/sspace/hadoop/TextIntWritable.java | TextIntWritable.readFields | public void readFields(DataInput in) throws IOException {
t.readFields(in);
position = in.readInt();
} | java | public void readFields(DataInput in) throws IOException {
t.readFields(in);
position = in.readInt();
} | [
"public",
"void",
"readFields",
"(",
"DataInput",
"in",
")",
"throws",
"IOException",
"{",
"t",
".",
"readFields",
"(",
"in",
")",
";",
"position",
"=",
"in",
".",
"readInt",
"(",
")",
";",
"}"
] | Deserializes the internal data from the provided stream. | [
"Deserializes",
"the",
"internal",
"data",
"from",
"the",
"provided",
"stream",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/hadoop/src/main/java/edu/ucla/sspace/hadoop/TextIntWritable.java#L128-L131 | train |
fozziethebeat/S-Space | hadoop/src/main/java/edu/ucla/sspace/hadoop/TextIntWritable.java | TextIntWritable.write | public void write(DataOutput out) throws IOException {
t.write(out);
out.writeInt(position);
} | java | public void write(DataOutput out) throws IOException {
t.write(out);
out.writeInt(position);
} | [
"public",
"void",
"write",
"(",
"DataOutput",
"out",
")",
"throws",
"IOException",
"{",
"t",
".",
"write",
"(",
"out",
")",
";",
"out",
".",
"writeInt",
"(",
"position",
")",
";",
"}"
] | Serailizes the internsal data to the provided stream | [
"Serailizes",
"the",
"internsal",
"data",
"to",
"the",
"provided",
"stream"
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/hadoop/src/main/java/edu/ucla/sspace/hadoop/TextIntWritable.java#L136-L139 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/beagle/Beagle.java | Beagle.normalize | private void normalize(DoubleVector v) {
double magnitude = 0;
for (int i = 0; i < v.length(); ++i)
magnitude += Math.pow(v.get(i), 2);
if (magnitude == 0)
return;
magnitude = Math.sqrt(magnitude);
for (int i = 0; i < v.length(); ++i)
v.set(i,... | java | private void normalize(DoubleVector v) {
double magnitude = 0;
for (int i = 0; i < v.length(); ++i)
magnitude += Math.pow(v.get(i), 2);
if (magnitude == 0)
return;
magnitude = Math.sqrt(magnitude);
for (int i = 0; i < v.length(); ++i)
v.set(i,... | [
"private",
"void",
"normalize",
"(",
"DoubleVector",
"v",
")",
"{",
"double",
"magnitude",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"v",
".",
"length",
"(",
")",
";",
"++",
"i",
")",
"magnitude",
"+=",
"Math",
".",
"pow",
... | Performs l2-normalization on the vector in place. If the magnitude of
the vector is 0, the values are left unchanged. | [
"Performs",
"l2",
"-",
"normalization",
"on",
"the",
"vector",
"in",
"place",
".",
"If",
"the",
"magnitude",
"of",
"the",
"vector",
"is",
"0",
"the",
"values",
"are",
"left",
"unchanged",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/beagle/Beagle.java#L319-L329 | train |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/beagle/Beagle.java | Beagle.groupConvolution | private DoubleVector groupConvolution(Queue<String> prevWords,
Queue<String> nextWords) {
// Generate an empty DoubleVector to hold the convolution.
DoubleVector result = new DenseVector(indexVectorSize);
// Do the convolutions starting at index 0.
... | java | private DoubleVector groupConvolution(Queue<String> prevWords,
Queue<String> nextWords) {
// Generate an empty DoubleVector to hold the convolution.
DoubleVector result = new DenseVector(indexVectorSize);
// Do the convolutions starting at index 0.
... | [
"private",
"DoubleVector",
"groupConvolution",
"(",
"Queue",
"<",
"String",
">",
"prevWords",
",",
"Queue",
"<",
"String",
">",
"nextWords",
")",
"{",
"// Generate an empty DoubleVector to hold the convolution.",
"DoubleVector",
"result",
"=",
"new",
"DenseVector",
"(",... | Generate the circular convoltion of n-grams composed of words in the
given context. The result of this convolution is returned as a
DoubleVector.
@param prevWords The words prior to the focus word in the context.
@param nextWords The Words after the focus word in the context.
@return The semantic vector generated fro... | [
"Generate",
"the",
"circular",
"convoltion",
"of",
"n",
"-",
"grams",
"composed",
"of",
"words",
"in",
"the",
"given",
"context",
".",
"The",
"result",
"of",
"this",
"convolution",
"is",
"returned",
"as",
"a",
"DoubleVector",
"."
] | a608102737dfd3d59038a9ead33fe60356bc6029 | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/beagle/Beagle.java#L341-L376 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.