id
int32 0
165k
| 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
145,700
|
netheosgithub/pcs_api
|
java/src/main/java/net/netheos/pcsapi/utils/PcsUtils.java
|
PcsUtils.downloadDataToSink
|
public static void downloadDataToSink( CResponse response, ByteSink byteSink )
{
InputStream is = null;
ByteSinkStream bss = null;
boolean success = false;
try {
long contentLength = response.getContentLength();
if ( contentLength >= 0 ) {
// content length is known: inform any listener
byteSink.setExpectedLength( contentLength );
}
long current = 0;
is = response.openStream();
bss = byteSink.openStream();
byte[] buffer = new byte[ 8 * 1024 ];
int len;
while ( ( len = is.read( buffer ) ) != -1 ) {
current += len;
bss.write( buffer, 0, len );
}
if ( contentLength < 0 ) {
// content length was unknown; inform listener operation is terminated
byteSink.setExpectedLength( current );
}
bss.flush();
bss.close();
bss = null;
success = true;
} catch ( IOException ex ) {
throw new CStorageException( ex.getMessage(), ex );
} finally {
if ( bss != null && !success ) {
bss.abort();
}
PcsUtils.closeQuietly( is );
PcsUtils.closeQuietly( bss );
}
}
|
java
|
public static void downloadDataToSink( CResponse response, ByteSink byteSink )
{
InputStream is = null;
ByteSinkStream bss = null;
boolean success = false;
try {
long contentLength = response.getContentLength();
if ( contentLength >= 0 ) {
// content length is known: inform any listener
byteSink.setExpectedLength( contentLength );
}
long current = 0;
is = response.openStream();
bss = byteSink.openStream();
byte[] buffer = new byte[ 8 * 1024 ];
int len;
while ( ( len = is.read( buffer ) ) != -1 ) {
current += len;
bss.write( buffer, 0, len );
}
if ( contentLength < 0 ) {
// content length was unknown; inform listener operation is terminated
byteSink.setExpectedLength( current );
}
bss.flush();
bss.close();
bss = null;
success = true;
} catch ( IOException ex ) {
throw new CStorageException( ex.getMessage(), ex );
} finally {
if ( bss != null && !success ) {
bss.abort();
}
PcsUtils.closeQuietly( is );
PcsUtils.closeQuietly( bss );
}
}
|
[
"public",
"static",
"void",
"downloadDataToSink",
"(",
"CResponse",
"response",
",",
"ByteSink",
"byteSink",
")",
"{",
"InputStream",
"is",
"=",
"null",
";",
"ByteSinkStream",
"bss",
"=",
"null",
";",
"boolean",
"success",
"=",
"false",
";",
"try",
"{",
"long",
"contentLength",
"=",
"response",
".",
"getContentLength",
"(",
")",
";",
"if",
"(",
"contentLength",
">=",
"0",
")",
"{",
"// content length is known: inform any listener",
"byteSink",
".",
"setExpectedLength",
"(",
"contentLength",
")",
";",
"}",
"long",
"current",
"=",
"0",
";",
"is",
"=",
"response",
".",
"openStream",
"(",
")",
";",
"bss",
"=",
"byteSink",
".",
"openStream",
"(",
")",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"8",
"*",
"1024",
"]",
";",
"int",
"len",
";",
"while",
"(",
"(",
"len",
"=",
"is",
".",
"read",
"(",
"buffer",
")",
")",
"!=",
"-",
"1",
")",
"{",
"current",
"+=",
"len",
";",
"bss",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"len",
")",
";",
"}",
"if",
"(",
"contentLength",
"<",
"0",
")",
"{",
"// content length was unknown; inform listener operation is terminated",
"byteSink",
".",
"setExpectedLength",
"(",
"current",
")",
";",
"}",
"bss",
".",
"flush",
"(",
")",
";",
"bss",
".",
"close",
"(",
")",
";",
"bss",
"=",
"null",
";",
"success",
"=",
"true",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"CStorageException",
"(",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"bss",
"!=",
"null",
"&&",
"!",
"success",
")",
"{",
"bss",
".",
"abort",
"(",
")",
";",
"}",
"PcsUtils",
".",
"closeQuietly",
"(",
"is",
")",
";",
"PcsUtils",
".",
"closeQuietly",
"(",
"bss",
")",
";",
"}",
"}"
] |
Server has answered OK with a file to download as stream.
Open byte sink stream, and copy data from server stream to sink stream
@param response server response to read from
@param byteSink destination
|
[
"Server",
"has",
"answered",
"OK",
"with",
"a",
"file",
"to",
"download",
"as",
"stream",
"."
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/utils/PcsUtils.java#L167-L212
|
145,701
|
netheosgithub/pcs_api
|
java/src/main/java/net/netheos/pcsapi/utils/PcsUtils.java
|
PcsUtils.randomString
|
public static String randomString( char[] values, int len )
{
Random rnd = new SecureRandom();
StringBuilder sb = new StringBuilder( len );
for ( int i = 0; i < len; i++ ) {
sb.append( values[ rnd.nextInt( values.length )] );
}
return sb.toString();
}
|
java
|
public static String randomString( char[] values, int len )
{
Random rnd = new SecureRandom();
StringBuilder sb = new StringBuilder( len );
for ( int i = 0; i < len; i++ ) {
sb.append( values[ rnd.nextInt( values.length )] );
}
return sb.toString();
}
|
[
"public",
"static",
"String",
"randomString",
"(",
"char",
"[",
"]",
"values",
",",
"int",
"len",
")",
"{",
"Random",
"rnd",
"=",
"new",
"SecureRandom",
"(",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"len",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"values",
"[",
"rnd",
".",
"nextInt",
"(",
"values",
".",
"length",
")",
"]",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Generate a random String
@param values The characters list to use in the randomization
@param len The number of characters in the output String
@return The randomized String
|
[
"Generate",
"a",
"random",
"String"
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/utils/PcsUtils.java#L242-L250
|
145,702
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/StatisticalSequenceLabeler.java
|
StatisticalSequenceLabeler.seqToSpans
|
public final Span[] seqToSpans(final String[] tokens) {
final Span[] annotatedText = this.sequenceLabeler.tag(tokens);
final List<Span> probSpans = new ArrayList<Span>(
Arrays.asList(annotatedText));
return probSpans.toArray(new Span[probSpans.size()]);
}
|
java
|
public final Span[] seqToSpans(final String[] tokens) {
final Span[] annotatedText = this.sequenceLabeler.tag(tokens);
final List<Span> probSpans = new ArrayList<Span>(
Arrays.asList(annotatedText));
return probSpans.toArray(new Span[probSpans.size()]);
}
|
[
"public",
"final",
"Span",
"[",
"]",
"seqToSpans",
"(",
"final",
"String",
"[",
"]",
"tokens",
")",
"{",
"final",
"Span",
"[",
"]",
"annotatedText",
"=",
"this",
".",
"sequenceLabeler",
".",
"tag",
"(",
"tokens",
")",
";",
"final",
"List",
"<",
"Span",
">",
"probSpans",
"=",
"new",
"ArrayList",
"<",
"Span",
">",
"(",
"Arrays",
".",
"asList",
"(",
"annotatedText",
")",
")",
";",
"return",
"probSpans",
".",
"toArray",
"(",
"new",
"Span",
"[",
"probSpans",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Get array of Spans from a list of tokens.
@param tokens
the sentence tokens
@return the array of Sequence Spans
|
[
"Get",
"array",
"of",
"Spans",
"from",
"a",
"list",
"of",
"tokens",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/StatisticalSequenceLabeler.java#L98-L103
|
145,703
|
OpenBEL/openbel-framework
|
org.openbel.framework.compiler/src/main/java/org/openbel/framework/compiler/PhaseThreeImpl.java
|
PhaseThreeImpl.search
|
private Set<TableEntry> search(final ProtoNetwork pn, String... literals) {
Set<TableEntry> ret;
if (noItems(literals)) {
return emptySet();
}
// An initial capacity would be ideal for this set, but we don't
// have any reasonable estimations.
ret = new HashSet<TableEntry>();
// Establish access to the relevant table objects
final ParameterTable paramTbl = pn.getParameterTable();
final TermTable termTbl = pn.getTermTable();
final List<String> terms = termTbl.getTermValues();
final NamespaceTable nsTbl = pn.getNamespaceTable();
final int[][] indata = pn.getTermIndices();
final Set<String> literalSet = constrainedHashSet(literals.length);
for (final String s : literals) {
literalSet.add(s);
}
// Search indata for elements of the term literal set
for (int i = 0; i < indata.length; i++) {
int tid = indata[i][TERM_INDEX];
String string = terms.get(tid);
if (!literalSet.contains(string)) {
continue;
}
int pid = indata[i][PARAM_INDEX];
final TableParameter tp = paramTbl.getTableParameter(pid);
final String inval = tp.getValue();
int nid = indata[i][NAMESPACE_INDEX];
final TableNamespace tns = nsTbl.getTableNamespace(nid);
String inrl = null;
if (tns != null) inrl = tns.getResourceLocation();
final TableEntry te = new TableEntry(inval, inrl);
ret.add(te);
}
return ret;
}
|
java
|
private Set<TableEntry> search(final ProtoNetwork pn, String... literals) {
Set<TableEntry> ret;
if (noItems(literals)) {
return emptySet();
}
// An initial capacity would be ideal for this set, but we don't
// have any reasonable estimations.
ret = new HashSet<TableEntry>();
// Establish access to the relevant table objects
final ParameterTable paramTbl = pn.getParameterTable();
final TermTable termTbl = pn.getTermTable();
final List<String> terms = termTbl.getTermValues();
final NamespaceTable nsTbl = pn.getNamespaceTable();
final int[][] indata = pn.getTermIndices();
final Set<String> literalSet = constrainedHashSet(literals.length);
for (final String s : literals) {
literalSet.add(s);
}
// Search indata for elements of the term literal set
for (int i = 0; i < indata.length; i++) {
int tid = indata[i][TERM_INDEX];
String string = terms.get(tid);
if (!literalSet.contains(string)) {
continue;
}
int pid = indata[i][PARAM_INDEX];
final TableParameter tp = paramTbl.getTableParameter(pid);
final String inval = tp.getValue();
int nid = indata[i][NAMESPACE_INDEX];
final TableNamespace tns = nsTbl.getTableNamespace(nid);
String inrl = null;
if (tns != null) inrl = tns.getResourceLocation();
final TableEntry te = new TableEntry(inval, inrl);
ret.add(te);
}
return ret;
}
|
[
"private",
"Set",
"<",
"TableEntry",
">",
"search",
"(",
"final",
"ProtoNetwork",
"pn",
",",
"String",
"...",
"literals",
")",
"{",
"Set",
"<",
"TableEntry",
">",
"ret",
";",
"if",
"(",
"noItems",
"(",
"literals",
")",
")",
"{",
"return",
"emptySet",
"(",
")",
";",
"}",
"// An initial capacity would be ideal for this set, but we don't",
"// have any reasonable estimations.",
"ret",
"=",
"new",
"HashSet",
"<",
"TableEntry",
">",
"(",
")",
";",
"// Establish access to the relevant table objects",
"final",
"ParameterTable",
"paramTbl",
"=",
"pn",
".",
"getParameterTable",
"(",
")",
";",
"final",
"TermTable",
"termTbl",
"=",
"pn",
".",
"getTermTable",
"(",
")",
";",
"final",
"List",
"<",
"String",
">",
"terms",
"=",
"termTbl",
".",
"getTermValues",
"(",
")",
";",
"final",
"NamespaceTable",
"nsTbl",
"=",
"pn",
".",
"getNamespaceTable",
"(",
")",
";",
"final",
"int",
"[",
"]",
"[",
"]",
"indata",
"=",
"pn",
".",
"getTermIndices",
"(",
")",
";",
"final",
"Set",
"<",
"String",
">",
"literalSet",
"=",
"constrainedHashSet",
"(",
"literals",
".",
"length",
")",
";",
"for",
"(",
"final",
"String",
"s",
":",
"literals",
")",
"{",
"literalSet",
".",
"add",
"(",
"s",
")",
";",
"}",
"// Search indata for elements of the term literal set",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"indata",
".",
"length",
";",
"i",
"++",
")",
"{",
"int",
"tid",
"=",
"indata",
"[",
"i",
"]",
"[",
"TERM_INDEX",
"]",
";",
"String",
"string",
"=",
"terms",
".",
"get",
"(",
"tid",
")",
";",
"if",
"(",
"!",
"literalSet",
".",
"contains",
"(",
"string",
")",
")",
"{",
"continue",
";",
"}",
"int",
"pid",
"=",
"indata",
"[",
"i",
"]",
"[",
"PARAM_INDEX",
"]",
";",
"final",
"TableParameter",
"tp",
"=",
"paramTbl",
".",
"getTableParameter",
"(",
"pid",
")",
";",
"final",
"String",
"inval",
"=",
"tp",
".",
"getValue",
"(",
")",
";",
"int",
"nid",
"=",
"indata",
"[",
"i",
"]",
"[",
"NAMESPACE_INDEX",
"]",
";",
"final",
"TableNamespace",
"tns",
"=",
"nsTbl",
".",
"getTableNamespace",
"(",
"nid",
")",
";",
"String",
"inrl",
"=",
"null",
";",
"if",
"(",
"tns",
"!=",
"null",
")",
"inrl",
"=",
"tns",
".",
"getResourceLocation",
"(",
")",
";",
"final",
"TableEntry",
"te",
"=",
"new",
"TableEntry",
"(",
"inval",
",",
"inrl",
")",
";",
"ret",
".",
"add",
"(",
"te",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Aggregate the set of all table entries for a proto-network that match at
least one of the provided term literals.
@param literals Literals, e.g., {@code proteinAbundance(#)}
@return Table entry set
|
[
"Aggregate",
"the",
"set",
"of",
"all",
"table",
"entries",
"for",
"a",
"proto",
"-",
"network",
"that",
"match",
"at",
"least",
"one",
"of",
"the",
"provided",
"term",
"literals",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.compiler/src/main/java/org/openbel/framework/compiler/PhaseThreeImpl.java#L826-L872
|
145,704
|
OpenBEL/openbel-framework
|
org.openbel.framework.compiler/src/main/java/org/openbel/framework/compiler/PhaseThreeImpl.java
|
PhaseThreeImpl.validParameter
|
private static boolean validParameter(final Parameter p) {
if (p.getNamespace() == null) {
return false;
}
if (p.getValue() == null) {
return false;
}
return true;
}
|
java
|
private static boolean validParameter(final Parameter p) {
if (p.getNamespace() == null) {
return false;
}
if (p.getValue() == null) {
return false;
}
return true;
}
|
[
"private",
"static",
"boolean",
"validParameter",
"(",
"final",
"Parameter",
"p",
")",
"{",
"if",
"(",
"p",
".",
"getNamespace",
"(",
")",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"p",
".",
"getValue",
"(",
")",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Returns true if the parameter has a namespace and value, false if not.
@param p Parameter
|
[
"Returns",
"true",
"if",
"the",
"parameter",
"has",
"a",
"namespace",
"and",
"value",
"false",
"if",
"not",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.compiler/src/main/java/org/openbel/framework/compiler/PhaseThreeImpl.java#L1166-L1174
|
145,705
|
OpenBEL/openbel-framework
|
org.openbel.framework.compiler/src/main/java/org/openbel/framework/compiler/PhaseThreeImpl.java
|
PhaseThreeImpl.validParameter
|
private static boolean validParameter(final TableParameter tp) {
if (tp.getNamespace() == null) {
return false;
}
if (tp.getValue() == null) {
return false;
}
return true;
}
|
java
|
private static boolean validParameter(final TableParameter tp) {
if (tp.getNamespace() == null) {
return false;
}
if (tp.getValue() == null) {
return false;
}
return true;
}
|
[
"private",
"static",
"boolean",
"validParameter",
"(",
"final",
"TableParameter",
"tp",
")",
"{",
"if",
"(",
"tp",
".",
"getNamespace",
"(",
")",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"tp",
".",
"getValue",
"(",
")",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Returns true if the table parameter has a namespace and value, false if
not.
@param tp Table parameter
|
[
"Returns",
"true",
"if",
"the",
"table",
"parameter",
"has",
"a",
"namespace",
"and",
"value",
"false",
"if",
"not",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.compiler/src/main/java/org/openbel/framework/compiler/PhaseThreeImpl.java#L1182-L1190
|
145,706
|
OpenBEL/openbel-framework
|
org.openbel.framework.core/src/main/java/org/openbel/framework/core/CommandLineApplication.java
|
CommandLineApplication.getExtraneousArguments
|
protected final List<String> getExtraneousArguments() {
if (commandLine == null) {
return emptyList();
}
String[] args = commandLine.getArgs();
if (noItems(args)) {
return emptyList();
}
return asList(args);
}
|
java
|
protected final List<String> getExtraneousArguments() {
if (commandLine == null) {
return emptyList();
}
String[] args = commandLine.getArgs();
if (noItems(args)) {
return emptyList();
}
return asList(args);
}
|
[
"protected",
"final",
"List",
"<",
"String",
">",
"getExtraneousArguments",
"(",
")",
"{",
"if",
"(",
"commandLine",
"==",
"null",
")",
"{",
"return",
"emptyList",
"(",
")",
";",
"}",
"String",
"[",
"]",
"args",
"=",
"commandLine",
".",
"getArgs",
"(",
")",
";",
"if",
"(",
"noItems",
"(",
"args",
")",
")",
"{",
"return",
"emptyList",
"(",
")",
";",
"}",
"return",
"asList",
"(",
"args",
")",
";",
"}"
] |
Returns the extraneous command-line arguments.
@return Non-null list of strings, may be empty
|
[
"Returns",
"the",
"extraneous",
"command",
"-",
"line",
"arguments",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.core/src/main/java/org/openbel/framework/core/CommandLineApplication.java#L295-L304
|
145,707
|
OpenBEL/openbel-framework
|
org.openbel.framework.core/src/main/java/org/openbel/framework/core/CommandLineApplication.java
|
CommandLineApplication.printApplicationInfo
|
protected final void printApplicationInfo(final String applicationName) {
final StringBuilder bldr = new StringBuilder();
bldr.append("\n");
bldr.append(BELFrameworkVersion.VERSION_LABEL).append(": ")
.append(applicationName).append("\n");
bldr.append("Copyright (c) 2011-2012, Selventa. All Rights Reserved.\n");
bldr.append("\n");
reportable.output(bldr.toString());
}
|
java
|
protected final void printApplicationInfo(final String applicationName) {
final StringBuilder bldr = new StringBuilder();
bldr.append("\n");
bldr.append(BELFrameworkVersion.VERSION_LABEL).append(": ")
.append(applicationName).append("\n");
bldr.append("Copyright (c) 2011-2012, Selventa. All Rights Reserved.\n");
bldr.append("\n");
reportable.output(bldr.toString());
}
|
[
"protected",
"final",
"void",
"printApplicationInfo",
"(",
"final",
"String",
"applicationName",
")",
"{",
"final",
"StringBuilder",
"bldr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"bldr",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"bldr",
".",
"append",
"(",
"BELFrameworkVersion",
".",
"VERSION_LABEL",
")",
".",
"append",
"(",
"\": \"",
")",
".",
"append",
"(",
"applicationName",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"bldr",
".",
"append",
"(",
"\"Copyright (c) 2011-2012, Selventa. All Rights Reserved.\\n\"",
")",
";",
"bldr",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"reportable",
".",
"output",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Prints out application information.
|
[
"Prints",
"out",
"application",
"information",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.core/src/main/java/org/openbel/framework/core/CommandLineApplication.java#L463-L471
|
145,708
|
OpenBEL/openbel-framework
|
org.openbel.framework.core/src/main/java/org/openbel/framework/core/CommandLineApplication.java
|
CommandLineApplication.printUsage
|
public void printUsage(final OutputStream os) {
final StringBuilder bldr = new StringBuilder();
bldr.append("Usage: ");
bldr.append(getUsage());
bldr.append("\n");
bldr.append("Try '--help' for more information.\n");
PrintWriter pw = new PrintWriter(os);
pw.write(bldr.toString());
pw.close();
}
|
java
|
public void printUsage(final OutputStream os) {
final StringBuilder bldr = new StringBuilder();
bldr.append("Usage: ");
bldr.append(getUsage());
bldr.append("\n");
bldr.append("Try '--help' for more information.\n");
PrintWriter pw = new PrintWriter(os);
pw.write(bldr.toString());
pw.close();
}
|
[
"public",
"void",
"printUsage",
"(",
"final",
"OutputStream",
"os",
")",
"{",
"final",
"StringBuilder",
"bldr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"bldr",
".",
"append",
"(",
"\"Usage: \"",
")",
";",
"bldr",
".",
"append",
"(",
"getUsage",
"(",
")",
")",
";",
"bldr",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"bldr",
".",
"append",
"(",
"\"Try '--help' for more information.\\n\"",
")",
";",
"PrintWriter",
"pw",
"=",
"new",
"PrintWriter",
"(",
"os",
")",
";",
"pw",
".",
"write",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"pw",
".",
"close",
"(",
")",
";",
"}"
] |
Prints usage information to the provided output stream.
@param os Non-null output stream
|
[
"Prints",
"usage",
"information",
"to",
"the",
"provided",
"output",
"stream",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.core/src/main/java/org/openbel/framework/core/CommandLineApplication.java#L495-L504
|
145,709
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/features/WordShapeSuperSenseFeatureGenerator.java
|
WordShapeSuperSenseFeatureGenerator.normalize
|
public static String normalize(final String token) {
String normalizedToken = "";
char currentCharacter;
int prevCharType = -1;
char charType = '~';
boolean addedStar = false;
for (int i = 0; i < token.length(); i++) {
currentCharacter = token.charAt(i);
if (currentCharacter >= 'A' && currentCharacter <= 'Z') {
charType = 'X';
} else if (currentCharacter >= 'a' && currentCharacter <= 'z') {
charType = 'x';
} else if (currentCharacter >= '0' && currentCharacter <= '9') {
charType = 'd';
} else {
charType = currentCharacter;
}
if (charType == prevCharType) {
if (!addedStar) {
normalizedToken += "*";
addedStar = true;
}
} else {
addedStar = false;
normalizedToken += charType;
}
prevCharType = charType;
}
return normalizedToken;
}
|
java
|
public static String normalize(final String token) {
String normalizedToken = "";
char currentCharacter;
int prevCharType = -1;
char charType = '~';
boolean addedStar = false;
for (int i = 0; i < token.length(); i++) {
currentCharacter = token.charAt(i);
if (currentCharacter >= 'A' && currentCharacter <= 'Z') {
charType = 'X';
} else if (currentCharacter >= 'a' && currentCharacter <= 'z') {
charType = 'x';
} else if (currentCharacter >= '0' && currentCharacter <= '9') {
charType = 'd';
} else {
charType = currentCharacter;
}
if (charType == prevCharType) {
if (!addedStar) {
normalizedToken += "*";
addedStar = true;
}
} else {
addedStar = false;
normalizedToken += charType;
}
prevCharType = charType;
}
return normalizedToken;
}
|
[
"public",
"static",
"String",
"normalize",
"(",
"final",
"String",
"token",
")",
"{",
"String",
"normalizedToken",
"=",
"\"\"",
";",
"char",
"currentCharacter",
";",
"int",
"prevCharType",
"=",
"-",
"1",
";",
"char",
"charType",
"=",
"'",
"'",
";",
"boolean",
"addedStar",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"token",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"currentCharacter",
"=",
"token",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"currentCharacter",
">=",
"'",
"'",
"&&",
"currentCharacter",
"<=",
"'",
"'",
")",
"{",
"charType",
"=",
"'",
"'",
";",
"}",
"else",
"if",
"(",
"currentCharacter",
">=",
"'",
"'",
"&&",
"currentCharacter",
"<=",
"'",
"'",
")",
"{",
"charType",
"=",
"'",
"'",
";",
"}",
"else",
"if",
"(",
"currentCharacter",
">=",
"'",
"'",
"&&",
"currentCharacter",
"<=",
"'",
"'",
")",
"{",
"charType",
"=",
"'",
"'",
";",
"}",
"else",
"{",
"charType",
"=",
"currentCharacter",
";",
"}",
"if",
"(",
"charType",
"==",
"prevCharType",
")",
"{",
"if",
"(",
"!",
"addedStar",
")",
"{",
"normalizedToken",
"+=",
"\"*\"",
";",
"addedStar",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"addedStar",
"=",
"false",
";",
"normalizedToken",
"+=",
"charType",
";",
"}",
"prevCharType",
"=",
"charType",
";",
"}",
"return",
"normalizedToken",
";",
"}"
] |
Normalize upper case, lower case, digits and duplicate characters.
@param token
the token to be normalized
@return the normalized token
|
[
"Normalize",
"upper",
"case",
"lower",
"case",
"digits",
"and",
"duplicate",
"characters",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/features/WordShapeSuperSenseFeatureGenerator.java#L55-L87
|
145,710
|
geomajas/geomajas-project-client-gwt2
|
common-gwt/common-gwt/src/main/java/org/geomajas/gwt/client/util/impl/DomImpl.java
|
DomImpl.cloneSvgElement
|
public Element cloneSvgElement(Element source) {
if (source == null || source.getNodeName() == null) {
return null;
}
if ("#text".equals(source.getNodeName())) {
return Document.get().createTextNode(source.getNodeValue()).cast();
}
Element clone = createElementNS(Dom.NS_SVG, source.getNodeName(), Dom.createUniqueId());
cloneAttributes(source, clone);
for (int i = 0; i < source.getChildCount(); i++) {
Element child = source.getChild(i).cast();
clone.appendChild(cloneSvgElement(child));
}
return clone;
}
|
java
|
public Element cloneSvgElement(Element source) {
if (source == null || source.getNodeName() == null) {
return null;
}
if ("#text".equals(source.getNodeName())) {
return Document.get().createTextNode(source.getNodeValue()).cast();
}
Element clone = createElementNS(Dom.NS_SVG, source.getNodeName(), Dom.createUniqueId());
cloneAttributes(source, clone);
for (int i = 0; i < source.getChildCount(); i++) {
Element child = source.getChild(i).cast();
clone.appendChild(cloneSvgElement(child));
}
return clone;
}
|
[
"public",
"Element",
"cloneSvgElement",
"(",
"Element",
"source",
")",
"{",
"if",
"(",
"source",
"==",
"null",
"||",
"source",
".",
"getNodeName",
"(",
")",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"\"#text\"",
".",
"equals",
"(",
"source",
".",
"getNodeName",
"(",
")",
")",
")",
"{",
"return",
"Document",
".",
"get",
"(",
")",
".",
"createTextNode",
"(",
"source",
".",
"getNodeValue",
"(",
")",
")",
".",
"cast",
"(",
")",
";",
"}",
"Element",
"clone",
"=",
"createElementNS",
"(",
"Dom",
".",
"NS_SVG",
",",
"source",
".",
"getNodeName",
"(",
")",
",",
"Dom",
".",
"createUniqueId",
"(",
")",
")",
";",
"cloneAttributes",
"(",
"source",
",",
"clone",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"source",
".",
"getChildCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"Element",
"child",
"=",
"source",
".",
"getChild",
"(",
"i",
")",
".",
"cast",
"(",
")",
";",
"clone",
".",
"appendChild",
"(",
"cloneSvgElement",
"(",
"child",
")",
")",
";",
"}",
"return",
"clone",
";",
"}"
] |
Clone a single SVG element.
@param source
The source SVG element.
@return Returns the clone.
|
[
"Clone",
"a",
"single",
"SVG",
"element",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/common-gwt/common-gwt/src/main/java/org/geomajas/gwt/client/util/impl/DomImpl.java#L270-L285
|
145,711
|
ardoq/ardoq-java-client
|
src/main/java/com/ardoq/util/SyncUtil.java
|
SyncUtil.getTagByName
|
public Tag getTagByName(String name) {
Tag t = this.tags.get(name);
if (null == t) {
t = new Tag(name, this.workspace.getId(), "");
this.tags.put(name, t);
}
return t;
}
|
java
|
public Tag getTagByName(String name) {
Tag t = this.tags.get(name);
if (null == t) {
t = new Tag(name, this.workspace.getId(), "");
this.tags.put(name, t);
}
return t;
}
|
[
"public",
"Tag",
"getTagByName",
"(",
"String",
"name",
")",
"{",
"Tag",
"t",
"=",
"this",
".",
"tags",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"null",
"==",
"t",
")",
"{",
"t",
"=",
"new",
"Tag",
"(",
"name",
",",
"this",
".",
"workspace",
".",
"getId",
"(",
")",
",",
"\"\"",
")",
";",
"this",
".",
"tags",
".",
"put",
"(",
"name",
",",
"t",
")",
";",
"}",
"return",
"t",
";",
"}"
] |
Gets an existing tag by name
@param name Name of the tag
@return Returns the tag
|
[
"Gets",
"an",
"existing",
"tag",
"by",
"name"
] |
03731c3df864d850ef41b252364a104376dde983
|
https://github.com/ardoq/ardoq-java-client/blob/03731c3df864d850ef41b252364a104376dde983/src/main/java/com/ardoq/util/SyncUtil.java#L145-L152
|
145,712
|
ardoq/ardoq-java-client
|
src/main/java/com/ardoq/util/SyncUtil.java
|
SyncUtil.getReport
|
public String getReport() {
return "Report\n - Created " + newComponents.size() + " components\n - Updated " + this.updatedComponentCount + " components\n - Created " + newRefs.size() + " references\n - Updated " + this.updatedRefCount + " references\n - Deleted " + this.deletedComponents + " components\n - Deleted " + this.deletedRefs + " references";
}
|
java
|
public String getReport() {
return "Report\n - Created " + newComponents.size() + " components\n - Updated " + this.updatedComponentCount + " components\n - Created " + newRefs.size() + " references\n - Updated " + this.updatedRefCount + " references\n - Deleted " + this.deletedComponents + " components\n - Deleted " + this.deletedRefs + " references";
}
|
[
"public",
"String",
"getReport",
"(",
")",
"{",
"return",
"\"Report\\n - Created \"",
"+",
"newComponents",
".",
"size",
"(",
")",
"+",
"\" components\\n - Updated \"",
"+",
"this",
".",
"updatedComponentCount",
"+",
"\" components\\n - Created \"",
"+",
"newRefs",
".",
"size",
"(",
")",
"+",
"\" references\\n - Updated \"",
"+",
"this",
".",
"updatedRefCount",
"+",
"\" references\\n - Deleted \"",
"+",
"this",
".",
"deletedComponents",
"+",
"\" components\\n - Deleted \"",
"+",
"this",
".",
"deletedRefs",
"+",
"\" references\"",
";",
"}"
] |
Returns an update report with statistics of created, updated and deleted references and components.
@return a String with the report.
|
[
"Returns",
"an",
"update",
"report",
"with",
"statistics",
"of",
"created",
"updated",
"and",
"deleted",
"references",
"and",
"components",
"."
] |
03731c3df864d850ef41b252364a104376dde983
|
https://github.com/ardoq/ardoq-java-client/blob/03731c3df864d850ef41b252364a104376dde983/src/main/java/com/ardoq/util/SyncUtil.java#L247-L249
|
145,713
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/lang/Signature.java
|
Signature.function
|
private static FunctionEnum function(final String s) {
String[] args = ARGS_REGEX.split(s);
return getFunctionEnum(args[0]);
}
|
java
|
private static FunctionEnum function(final String s) {
String[] args = ARGS_REGEX.split(s);
return getFunctionEnum(args[0]);
}
|
[
"private",
"static",
"FunctionEnum",
"function",
"(",
"final",
"String",
"s",
")",
"{",
"String",
"[",
"]",
"args",
"=",
"ARGS_REGEX",
".",
"split",
"(",
"s",
")",
";",
"return",
"getFunctionEnum",
"(",
"args",
"[",
"0",
"]",
")",
";",
"}"
] |
Returns the function enum for the provided string.
@param s String
@return {@link FunctionEnum}
|
[
"Returns",
"the",
"function",
"enum",
"for",
"the",
"provided",
"string",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/lang/Signature.java#L493-L496
|
145,714
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/lang/Signature.java
|
Signature.returnType
|
private static ReturnType returnType(final String s) {
String[] args = ARGS_REGEX.split(s);
return ReturnType.getReturnType(args[args.length - 1]);
}
|
java
|
private static ReturnType returnType(final String s) {
String[] args = ARGS_REGEX.split(s);
return ReturnType.getReturnType(args[args.length - 1]);
}
|
[
"private",
"static",
"ReturnType",
"returnType",
"(",
"final",
"String",
"s",
")",
"{",
"String",
"[",
"]",
"args",
"=",
"ARGS_REGEX",
".",
"split",
"(",
"s",
")",
";",
"return",
"ReturnType",
".",
"getReturnType",
"(",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
")",
";",
"}"
] |
Returns the return type for the provided string.
@param s String
@return {@link ReturnType}
|
[
"Returns",
"the",
"return",
"type",
"for",
"the",
"provided",
"string",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/lang/Signature.java#L504-L507
|
145,715
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/lang/Signature.java
|
Signature.countArgs
|
private static String countArgs(final String s) {
String[] args = ARGS_REGEX.split(s);
if ("".equals(args[1])) return "0";
String[] argarray = args[1].split(",");
for (final String arg : argarray)
if (arg.contains(VARARGS_SUFFIX)) return "1 or more";
return valueOf(argarray.length);
}
|
java
|
private static String countArgs(final String s) {
String[] args = ARGS_REGEX.split(s);
if ("".equals(args[1])) return "0";
String[] argarray = args[1].split(",");
for (final String arg : argarray)
if (arg.contains(VARARGS_SUFFIX)) return "1 or more";
return valueOf(argarray.length);
}
|
[
"private",
"static",
"String",
"countArgs",
"(",
"final",
"String",
"s",
")",
"{",
"String",
"[",
"]",
"args",
"=",
"ARGS_REGEX",
".",
"split",
"(",
"s",
")",
";",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"args",
"[",
"1",
"]",
")",
")",
"return",
"\"0\"",
";",
"String",
"[",
"]",
"argarray",
"=",
"args",
"[",
"1",
"]",
".",
"split",
"(",
"\",\"",
")",
";",
"for",
"(",
"final",
"String",
"arg",
":",
"argarray",
")",
"if",
"(",
"arg",
".",
"contains",
"(",
"VARARGS_SUFFIX",
")",
")",
"return",
"\"1 or more\"",
";",
"return",
"valueOf",
"(",
"argarray",
".",
"length",
")",
";",
"}"
] |
Returns the number of arguments for the provided string.
@param s {@link String}
@return {@link String}
|
[
"Returns",
"the",
"number",
"of",
"arguments",
"for",
"the",
"provided",
"string",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/lang/Signature.java#L529-L537
|
145,716
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/utils/AnnotateProperties.java
|
AnnotateProperties.setTokenizeProperties
|
public static Properties setTokenizeProperties(final String lang,
final String normalize, final String untokenizable,
final String hardParagraph) {
final Properties annotateProperties = new Properties();
annotateProperties.setProperty("language", lang);
annotateProperties.setProperty("normalize", normalize);
annotateProperties.setProperty("untokenizable", untokenizable);
annotateProperties.setProperty("hardParagraph", hardParagraph);
return annotateProperties;
}
|
java
|
public static Properties setTokenizeProperties(final String lang,
final String normalize, final String untokenizable,
final String hardParagraph) {
final Properties annotateProperties = new Properties();
annotateProperties.setProperty("language", lang);
annotateProperties.setProperty("normalize", normalize);
annotateProperties.setProperty("untokenizable", untokenizable);
annotateProperties.setProperty("hardParagraph", hardParagraph);
return annotateProperties;
}
|
[
"public",
"static",
"Properties",
"setTokenizeProperties",
"(",
"final",
"String",
"lang",
",",
"final",
"String",
"normalize",
",",
"final",
"String",
"untokenizable",
",",
"final",
"String",
"hardParagraph",
")",
"{",
"final",
"Properties",
"annotateProperties",
"=",
"new",
"Properties",
"(",
")",
";",
"annotateProperties",
".",
"setProperty",
"(",
"\"language\"",
",",
"lang",
")",
";",
"annotateProperties",
".",
"setProperty",
"(",
"\"normalize\"",
",",
"normalize",
")",
";",
"annotateProperties",
".",
"setProperty",
"(",
"\"untokenizable\"",
",",
"untokenizable",
")",
";",
"annotateProperties",
".",
"setProperty",
"(",
"\"hardParagraph\"",
",",
"hardParagraph",
")",
";",
"return",
"annotateProperties",
";",
"}"
] |
Creates the Properties object required to construct a Sentence Segmenter
and a Tokenizer.
@param lang
it is required to provide a language code
@param normalize
the normalization option
@param untokenizable
print untokenizable tokens
@param hardParagraph
do not segment paragraph marks
@return the properties object
|
[
"Creates",
"the",
"Properties",
"object",
"required",
"to",
"construct",
"a",
"Sentence",
"Segmenter",
"and",
"a",
"Tokenizer",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/utils/AnnotateProperties.java#L80-L89
|
145,717
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/utils/AnnotateProperties.java
|
AnnotateProperties.setPOSLemmaProperties
|
public static Properties setPOSLemmaProperties(final String model,
final String lemmatizerModel, final String language,
final String multiwords, final String dictag,
final String allMorphology) {
final Properties annotateProperties = new Properties();
annotateProperties.setProperty("model", model);
annotateProperties.setProperty("lemmatizerModel", lemmatizerModel);
annotateProperties.setProperty("language", language);
annotateProperties.setProperty("multiwords", multiwords);
annotateProperties.setProperty("dictag", dictag);
annotateProperties.setProperty("allMorphology", allMorphology);
return annotateProperties;
}
|
java
|
public static Properties setPOSLemmaProperties(final String model,
final String lemmatizerModel, final String language,
final String multiwords, final String dictag,
final String allMorphology) {
final Properties annotateProperties = new Properties();
annotateProperties.setProperty("model", model);
annotateProperties.setProperty("lemmatizerModel", lemmatizerModel);
annotateProperties.setProperty("language", language);
annotateProperties.setProperty("multiwords", multiwords);
annotateProperties.setProperty("dictag", dictag);
annotateProperties.setProperty("allMorphology", allMorphology);
return annotateProperties;
}
|
[
"public",
"static",
"Properties",
"setPOSLemmaProperties",
"(",
"final",
"String",
"model",
",",
"final",
"String",
"lemmatizerModel",
",",
"final",
"String",
"language",
",",
"final",
"String",
"multiwords",
",",
"final",
"String",
"dictag",
",",
"final",
"String",
"allMorphology",
")",
"{",
"final",
"Properties",
"annotateProperties",
"=",
"new",
"Properties",
"(",
")",
";",
"annotateProperties",
".",
"setProperty",
"(",
"\"model\"",
",",
"model",
")",
";",
"annotateProperties",
".",
"setProperty",
"(",
"\"lemmatizerModel\"",
",",
"lemmatizerModel",
")",
";",
"annotateProperties",
".",
"setProperty",
"(",
"\"language\"",
",",
"language",
")",
";",
"annotateProperties",
".",
"setProperty",
"(",
"\"multiwords\"",
",",
"multiwords",
")",
";",
"annotateProperties",
".",
"setProperty",
"(",
"\"dictag\"",
",",
"dictag",
")",
";",
"annotateProperties",
".",
"setProperty",
"(",
"\"allMorphology\"",
",",
"allMorphology",
")",
";",
"return",
"annotateProperties",
";",
"}"
] |
Generate Properties object for POS tagging and Lemmatizing. Language, model
and lemmatizerModel are compulsory.
@param model
the pos tagger model
@param lemmatizerModel
the lemmatizer model
@param language
the language
@param multiwords
whether multiwords are to be detected
@param dictag
whether tagging from a dictionary is activated
@param allMorphology
whether to disclose all pos tags and lemmas before disambiguation
@return a properties object
|
[
"Generate",
"Properties",
"object",
"for",
"POS",
"tagging",
"and",
"Lemmatizing",
".",
"Language",
"model",
"and",
"lemmatizerModel",
"are",
"compulsory",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/utils/AnnotateProperties.java#L109-L121
|
145,718
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/utils/AnnotateProperties.java
|
AnnotateProperties.setChunkingProperties
|
public Properties setChunkingProperties(final String model,
final String language) {
final Properties annotateProperties = new Properties();
annotateProperties.setProperty("model", model);
annotateProperties.setProperty("language", language);
return annotateProperties;
}
|
java
|
public Properties setChunkingProperties(final String model,
final String language) {
final Properties annotateProperties = new Properties();
annotateProperties.setProperty("model", model);
annotateProperties.setProperty("language", language);
return annotateProperties;
}
|
[
"public",
"Properties",
"setChunkingProperties",
"(",
"final",
"String",
"model",
",",
"final",
"String",
"language",
")",
"{",
"final",
"Properties",
"annotateProperties",
"=",
"new",
"Properties",
"(",
")",
";",
"annotateProperties",
".",
"setProperty",
"(",
"\"model\"",
",",
"model",
")",
";",
"annotateProperties",
".",
"setProperty",
"(",
"\"language\"",
",",
"language",
")",
";",
"return",
"annotateProperties",
";",
"}"
] |
Generate Properties object for chunking. Both parameters are compulsory.
@param model
the model to perform the annotation
@param language
the language
@return a properties object
|
[
"Generate",
"Properties",
"object",
"for",
"chunking",
".",
"Both",
"parameters",
"are",
"compulsory",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/utils/AnnotateProperties.java#L132-L138
|
145,719
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/ShiftReduceParserTrainer.java
|
ShiftReduceParserTrainer.train
|
public final ParserModel train(final TrainingParameters params,
final TrainingParameters taggerParams,
final TrainingParameters chunkerParams) {
if (getParserFactory() == null) {
throw new IllegalStateException(
"The ParserFactory must be instantiated!!");
}
if (getTaggerFactory() == null) {
throw new IllegalStateException(
"The TaggerFactory must be instantiated!");
}
ParserModel trainedModel = null;
ParserEvaluator parserEvaluator = null;
try {
trainedModel = ShiftReduceParser.train(this.lang, this.trainSamples,
this.rules, params, this.parserFactory, taggerParams,
this.taggerFactory, chunkerParams, this.chunkerFactory);
final ShiftReduceParser parser = new ShiftReduceParser(trainedModel);
parserEvaluator = new ParserEvaluator(parser);
parserEvaluator.evaluate(this.testSamples);
} catch (final IOException e) {
System.err.println("IO error while loading training and test sets!");
e.printStackTrace();
System.exit(1);
}
System.out.println("Final Result: \n" + parserEvaluator.getFMeasure());
return trainedModel;
}
|
java
|
public final ParserModel train(final TrainingParameters params,
final TrainingParameters taggerParams,
final TrainingParameters chunkerParams) {
if (getParserFactory() == null) {
throw new IllegalStateException(
"The ParserFactory must be instantiated!!");
}
if (getTaggerFactory() == null) {
throw new IllegalStateException(
"The TaggerFactory must be instantiated!");
}
ParserModel trainedModel = null;
ParserEvaluator parserEvaluator = null;
try {
trainedModel = ShiftReduceParser.train(this.lang, this.trainSamples,
this.rules, params, this.parserFactory, taggerParams,
this.taggerFactory, chunkerParams, this.chunkerFactory);
final ShiftReduceParser parser = new ShiftReduceParser(trainedModel);
parserEvaluator = new ParserEvaluator(parser);
parserEvaluator.evaluate(this.testSamples);
} catch (final IOException e) {
System.err.println("IO error while loading training and test sets!");
e.printStackTrace();
System.exit(1);
}
System.out.println("Final Result: \n" + parserEvaluator.getFMeasure());
return trainedModel;
}
|
[
"public",
"final",
"ParserModel",
"train",
"(",
"final",
"TrainingParameters",
"params",
",",
"final",
"TrainingParameters",
"taggerParams",
",",
"final",
"TrainingParameters",
"chunkerParams",
")",
"{",
"if",
"(",
"getParserFactory",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The ParserFactory must be instantiated!!\"",
")",
";",
"}",
"if",
"(",
"getTaggerFactory",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The TaggerFactory must be instantiated!\"",
")",
";",
"}",
"ParserModel",
"trainedModel",
"=",
"null",
";",
"ParserEvaluator",
"parserEvaluator",
"=",
"null",
";",
"try",
"{",
"trainedModel",
"=",
"ShiftReduceParser",
".",
"train",
"(",
"this",
".",
"lang",
",",
"this",
".",
"trainSamples",
",",
"this",
".",
"rules",
",",
"params",
",",
"this",
".",
"parserFactory",
",",
"taggerParams",
",",
"this",
".",
"taggerFactory",
",",
"chunkerParams",
",",
"this",
".",
"chunkerFactory",
")",
";",
"final",
"ShiftReduceParser",
"parser",
"=",
"new",
"ShiftReduceParser",
"(",
"trainedModel",
")",
";",
"parserEvaluator",
"=",
"new",
"ParserEvaluator",
"(",
"parser",
")",
";",
"parserEvaluator",
".",
"evaluate",
"(",
"this",
".",
"testSamples",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"IO error while loading training and test sets!\"",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"Final Result: \\n\"",
"+",
"parserEvaluator",
".",
"getFMeasure",
"(",
")",
")",
";",
"return",
"trainedModel",
";",
"}"
] |
Train a parser model from the Treebank data.
@param params
the parser parameters
@param taggerParams
the pos tagger parameters
@param chunkerParams
the chunker parameters
@return a parser model
|
[
"Train",
"a",
"parser",
"model",
"from",
"the",
"Treebank",
"data",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/ShiftReduceParserTrainer.java#L182-L209
|
145,720
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/ShiftReduceParserTrainer.java
|
ShiftReduceParserTrainer.train
|
public final ParserModel train(final TrainingParameters params,
final InputStream taggerModel, final TrainingParameters chunkerParams) {
if (getParserFactory() == null) {
throw new IllegalStateException(
"The ParserFactory must be instantiated!!");
}
SequenceLabelerModel posModel = null;
try {
posModel = new SequenceLabelerModel(taggerModel);
} catch (final IOException e1) {
e1.printStackTrace();
}
ParserModel trainedModel = null;
ParserEvaluator parserEvaluator = null;
try {
trainedModel = ShiftReduceParser.train(this.lang, this.trainSamples,
this.rules, params, this.parserFactory, posModel, chunkerParams,
this.chunkerFactory);
final ShiftReduceParser parser = new ShiftReduceParser(trainedModel);
parserEvaluator = new ParserEvaluator(parser);
parserEvaluator.evaluate(this.testSamples);
} catch (final IOException e) {
System.err.println("IO error while loading training and test sets!");
e.printStackTrace();
System.exit(1);
}
System.out.println("Final Result: \n" + parserEvaluator.getFMeasure());
return trainedModel;
}
|
java
|
public final ParserModel train(final TrainingParameters params,
final InputStream taggerModel, final TrainingParameters chunkerParams) {
if (getParserFactory() == null) {
throw new IllegalStateException(
"The ParserFactory must be instantiated!!");
}
SequenceLabelerModel posModel = null;
try {
posModel = new SequenceLabelerModel(taggerModel);
} catch (final IOException e1) {
e1.printStackTrace();
}
ParserModel trainedModel = null;
ParserEvaluator parserEvaluator = null;
try {
trainedModel = ShiftReduceParser.train(this.lang, this.trainSamples,
this.rules, params, this.parserFactory, posModel, chunkerParams,
this.chunkerFactory);
final ShiftReduceParser parser = new ShiftReduceParser(trainedModel);
parserEvaluator = new ParserEvaluator(parser);
parserEvaluator.evaluate(this.testSamples);
} catch (final IOException e) {
System.err.println("IO error while loading training and test sets!");
e.printStackTrace();
System.exit(1);
}
System.out.println("Final Result: \n" + parserEvaluator.getFMeasure());
return trainedModel;
}
|
[
"public",
"final",
"ParserModel",
"train",
"(",
"final",
"TrainingParameters",
"params",
",",
"final",
"InputStream",
"taggerModel",
",",
"final",
"TrainingParameters",
"chunkerParams",
")",
"{",
"if",
"(",
"getParserFactory",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The ParserFactory must be instantiated!!\"",
")",
";",
"}",
"SequenceLabelerModel",
"posModel",
"=",
"null",
";",
"try",
"{",
"posModel",
"=",
"new",
"SequenceLabelerModel",
"(",
"taggerModel",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e1",
")",
"{",
"e1",
".",
"printStackTrace",
"(",
")",
";",
"}",
"ParserModel",
"trainedModel",
"=",
"null",
";",
"ParserEvaluator",
"parserEvaluator",
"=",
"null",
";",
"try",
"{",
"trainedModel",
"=",
"ShiftReduceParser",
".",
"train",
"(",
"this",
".",
"lang",
",",
"this",
".",
"trainSamples",
",",
"this",
".",
"rules",
",",
"params",
",",
"this",
".",
"parserFactory",
",",
"posModel",
",",
"chunkerParams",
",",
"this",
".",
"chunkerFactory",
")",
";",
"final",
"ShiftReduceParser",
"parser",
"=",
"new",
"ShiftReduceParser",
"(",
"trainedModel",
")",
";",
"parserEvaluator",
"=",
"new",
"ParserEvaluator",
"(",
"parser",
")",
";",
"parserEvaluator",
".",
"evaluate",
"(",
"this",
".",
"testSamples",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"IO error while loading training and test sets!\"",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"Final Result: \\n\"",
"+",
"parserEvaluator",
".",
"getFMeasure",
"(",
")",
")",
";",
"return",
"trainedModel",
";",
"}"
] |
Train a parser model providing an already trained POS tagger.
@param params
the parser parameters
@param taggerModel
the POS tagger model
@param chunkerParams
the chunker parameters
@return the parser model
|
[
"Train",
"a",
"parser",
"model",
"providing",
"an",
"already",
"trained",
"POS",
"tagger",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/ShiftReduceParserTrainer.java#L222-L250
|
145,721
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/ShiftReduceParserTrainer.java
|
ShiftReduceParserTrainer.getSequenceCodec
|
public final String getSequenceCodec() {
String seqCodec = null;
if ("BIO".equals(this.sequenceCodec)) {
seqCodec = BioCodec.class.getName();
} else if ("BILOU".equals(this.sequenceCodec)) {
seqCodec = BilouCodec.class.getName();
}
return seqCodec;
}
|
java
|
public final String getSequenceCodec() {
String seqCodec = null;
if ("BIO".equals(this.sequenceCodec)) {
seqCodec = BioCodec.class.getName();
} else if ("BILOU".equals(this.sequenceCodec)) {
seqCodec = BilouCodec.class.getName();
}
return seqCodec;
}
|
[
"public",
"final",
"String",
"getSequenceCodec",
"(",
")",
"{",
"String",
"seqCodec",
"=",
"null",
";",
"if",
"(",
"\"BIO\"",
".",
"equals",
"(",
"this",
".",
"sequenceCodec",
")",
")",
"{",
"seqCodec",
"=",
"BioCodec",
".",
"class",
".",
"getName",
"(",
")",
";",
"}",
"else",
"if",
"(",
"\"BILOU\"",
".",
"equals",
"(",
"this",
".",
"sequenceCodec",
")",
")",
"{",
"seqCodec",
"=",
"BilouCodec",
".",
"class",
".",
"getName",
"(",
")",
";",
"}",
"return",
"seqCodec",
";",
"}"
] |
Get the Sequence codec.
@return the sequence codec
|
[
"Get",
"the",
"Sequence",
"codec",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/ShiftReduceParserTrainer.java#L345-L353
|
145,722
|
alb-i986/selenium-tinafw
|
src/main/java/me/alb_i986/selenium/tinafw/ui/TinafwExpectedConditions.java
|
TinafwExpectedConditions.visibilityOfOneOfElementsLocatedBy
|
public static ExpectedCondition<WebElement> visibilityOfOneOfElementsLocatedBy(final By locator) {
return new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
for (WebElement element : driver.findElements(locator)) {
if (element.isDisplayed()) {
return element;
}
}
return null;
}
@Override
public String toString() {
return "visibility of one of the elements located by " + locator;
}
};
}
|
java
|
public static ExpectedCondition<WebElement> visibilityOfOneOfElementsLocatedBy(final By locator) {
return new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
for (WebElement element : driver.findElements(locator)) {
if (element.isDisplayed()) {
return element;
}
}
return null;
}
@Override
public String toString() {
return "visibility of one of the elements located by " + locator;
}
};
}
|
[
"public",
"static",
"ExpectedCondition",
"<",
"WebElement",
">",
"visibilityOfOneOfElementsLocatedBy",
"(",
"final",
"By",
"locator",
")",
"{",
"return",
"new",
"ExpectedCondition",
"<",
"WebElement",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"WebElement",
"apply",
"(",
"WebDriver",
"driver",
")",
"{",
"for",
"(",
"WebElement",
"element",
":",
"driver",
".",
"findElements",
"(",
"locator",
")",
")",
"{",
"if",
"(",
"element",
".",
"isDisplayed",
"(",
")",
")",
"{",
"return",
"element",
";",
"}",
"}",
"return",
"null",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"visibility of one of the elements located by \"",
"+",
"locator",
";",
"}",
"}",
";",
"}"
] |
An expectation for checking that at least one of the elements matching the locator
is visible.
@param locator used to find the elements
@return the first visible WebElement that is found
|
[
"An",
"expectation",
"for",
"checking",
"that",
"at",
"least",
"one",
"of",
"the",
"elements",
"matching",
"the",
"locator",
"is",
"visible",
"."
] |
91c66720cda9f69751f96c58c0a0624b2222186e
|
https://github.com/alb-i986/selenium-tinafw/blob/91c66720cda9f69751f96c58c0a0624b2222186e/src/main/java/me/alb_i986/selenium/tinafw/ui/TinafwExpectedConditions.java#L20-L37
|
145,723
|
OpenBEL/openbel-framework
|
org.openbel.framework.core/src/main/java/org/openbel/framework/core/df/external/CacheableAnnotationDefinitionServiceImpl.java
|
CacheableAnnotationDefinitionServiceImpl.parseRegularExpression
|
private String parseRegularExpression(File annotationCacheCopy,
long characterOffset) throws IOException {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(annotationCacheCopy));
reader.skip(characterOffset);
return reader.readLine();
} finally {
if (reader != null) {
try {
reader.close();
} catch (Exception e) {}
}
}
}
|
java
|
private String parseRegularExpression(File annotationCacheCopy,
long characterOffset) throws IOException {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(annotationCacheCopy));
reader.skip(characterOffset);
return reader.readLine();
} finally {
if (reader != null) {
try {
reader.close();
} catch (Exception e) {}
}
}
}
|
[
"private",
"String",
"parseRegularExpression",
"(",
"File",
"annotationCacheCopy",
",",
"long",
"characterOffset",
")",
"throws",
"IOException",
"{",
"BufferedReader",
"reader",
"=",
"null",
";",
"try",
"{",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"annotationCacheCopy",
")",
")",
";",
"reader",
".",
"skip",
"(",
"characterOffset",
")",
";",
"return",
"reader",
".",
"readLine",
"(",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"reader",
"!=",
"null",
")",
"{",
"try",
"{",
"reader",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"}",
"}"
] |
Reads the first line after the annotation header as a regular expression
for the annotation definition.
@param annotationCacheCopy
{@link File}, the annotation cache copy to parse
@param characterOffset
<tt>long</tt>, the character offset to start reading from
@return {@link String} the parsed regular expression
@throws IOException
Thrown if an IO error occurred reading the annotation file
|
[
"Reads",
"the",
"first",
"line",
"after",
"the",
"annotation",
"header",
"as",
"a",
"regular",
"expression",
"for",
"the",
"annotation",
"definition",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.core/src/main/java/org/openbel/framework/core/df/external/CacheableAnnotationDefinitionServiceImpl.java#L221-L235
|
145,724
|
nohana/Amalgam
|
amalgam/src/main/java/com/amalgam/security/MessageDigestUtils.java
|
MessageDigestUtils.computeSha256
|
public static byte[] computeSha256(final byte[] data) {
try {
return MessageDigest.getInstance(ALGORITHM_SHA_256).digest(data);
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("unsupported algorithm for message digest: ", e);
}
}
|
java
|
public static byte[] computeSha256(final byte[] data) {
try {
return MessageDigest.getInstance(ALGORITHM_SHA_256).digest(data);
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("unsupported algorithm for message digest: ", e);
}
}
|
[
"public",
"static",
"byte",
"[",
"]",
"computeSha256",
"(",
"final",
"byte",
"[",
"]",
"data",
")",
"{",
"try",
"{",
"return",
"MessageDigest",
".",
"getInstance",
"(",
"ALGORITHM_SHA_256",
")",
".",
"digest",
"(",
"data",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"unsupported algorithm for message digest: \"",
",",
"e",
")",
";",
"}",
"}"
] |
Calculate the message digest value with SHA 256 algorithm.
@param data to calculate.
@return message digest value.
|
[
"Calculate",
"the",
"message",
"digest",
"value",
"with",
"SHA",
"256",
"algorithm",
"."
] |
57809ddbfe7897e979cf507982ce0b3aa5e0ed8a
|
https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/security/MessageDigestUtils.java#L38-L44
|
145,725
|
geomajas/geomajas-project-client-gwt2
|
plugin/wfs/server-extension/src/main/java/org/geomajas/gwt2/plugin/wfs/server/command/factory/impl/DefaultCriterionFilterConverter.java
|
DefaultCriterionFilterConverter.convert
|
public Filter convert(Criterion criterionDto, List<AttributeDescriptor> schema) {
FilterContext fc = new FilterContext();
fc.setSchema(schema);
criterionDto.accept(this, fc);
try {
log.debug("Filter converted : " + ECQL.toCQL(fc.getFilter()));
} catch (Exception e) {
// ignore
}
return fc.getFilter();
}
|
java
|
public Filter convert(Criterion criterionDto, List<AttributeDescriptor> schema) {
FilterContext fc = new FilterContext();
fc.setSchema(schema);
criterionDto.accept(this, fc);
try {
log.debug("Filter converted : " + ECQL.toCQL(fc.getFilter()));
} catch (Exception e) {
// ignore
}
return fc.getFilter();
}
|
[
"public",
"Filter",
"convert",
"(",
"Criterion",
"criterionDto",
",",
"List",
"<",
"AttributeDescriptor",
">",
"schema",
")",
"{",
"FilterContext",
"fc",
"=",
"new",
"FilterContext",
"(",
")",
";",
"fc",
".",
"setSchema",
"(",
"schema",
")",
";",
"criterionDto",
".",
"accept",
"(",
"this",
",",
"fc",
")",
";",
"try",
"{",
"log",
".",
"debug",
"(",
"\"Filter converted : \"",
"+",
"ECQL",
".",
"toCQL",
"(",
"fc",
".",
"getFilter",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// ignore",
"}",
"return",
"fc",
".",
"getFilter",
"(",
")",
";",
"}"
] |
Convert a criterion to a filter.
@param criterionDto
@param schema
@return
|
[
"Convert",
"a",
"criterion",
"to",
"a",
"filter",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/wfs/server-extension/src/main/java/org/geomajas/gwt2/plugin/wfs/server/command/factory/impl/DefaultCriterionFilterConverter.java#L92-L102
|
145,726
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/model/Statement.java
|
Statement.getAllParameters
|
public List<Parameter> getAllParameters() {
List<Parameter> ret = new ArrayList<Parameter>();
ret.addAll(subject.getAllParameters());
if (object != null) {
if (object.getStatement() != null)
ret.addAll(object.getStatement()
.getAllParameters());
else
ret.addAll(object.getTerm().getAllParameters());
}
return ret;
}
|
java
|
public List<Parameter> getAllParameters() {
List<Parameter> ret = new ArrayList<Parameter>();
ret.addAll(subject.getAllParameters());
if (object != null) {
if (object.getStatement() != null)
ret.addAll(object.getStatement()
.getAllParameters());
else
ret.addAll(object.getTerm().getAllParameters());
}
return ret;
}
|
[
"public",
"List",
"<",
"Parameter",
">",
"getAllParameters",
"(",
")",
"{",
"List",
"<",
"Parameter",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"Parameter",
">",
"(",
")",
";",
"ret",
".",
"addAll",
"(",
"subject",
".",
"getAllParameters",
"(",
")",
")",
";",
"if",
"(",
"object",
"!=",
"null",
")",
"{",
"if",
"(",
"object",
".",
"getStatement",
"(",
")",
"!=",
"null",
")",
"ret",
".",
"addAll",
"(",
"object",
".",
"getStatement",
"(",
")",
".",
"getAllParameters",
"(",
")",
")",
";",
"else",
"ret",
".",
"addAll",
"(",
"object",
".",
"getTerm",
"(",
")",
".",
"getAllParameters",
"(",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Returns a list of all parameters contained by this statement and object.
@return List of parameters
|
[
"Returns",
"a",
"list",
"of",
"all",
"parameters",
"contained",
"by",
"this",
"statement",
"and",
"object",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/model/Statement.java#L189-L203
|
145,727
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/model/Statement.java
|
Statement.getAllTerms
|
public List<Term> getAllTerms() {
List<Term> ret = new ArrayList<Term>();
ret.add(subject);
List<Term> subjectTerms = subject.getTerms();
if (subjectTerms != null) {
ret.addAll(subjectTerms);
for (final Term term : subjectTerms) {
ret.addAll(term.getAllTerms());
}
}
if (object != null) {
ret.addAll(object.getAllTerms());
}
return ret;
}
|
java
|
public List<Term> getAllTerms() {
List<Term> ret = new ArrayList<Term>();
ret.add(subject);
List<Term> subjectTerms = subject.getTerms();
if (subjectTerms != null) {
ret.addAll(subjectTerms);
for (final Term term : subjectTerms) {
ret.addAll(term.getAllTerms());
}
}
if (object != null) {
ret.addAll(object.getAllTerms());
}
return ret;
}
|
[
"public",
"List",
"<",
"Term",
">",
"getAllTerms",
"(",
")",
"{",
"List",
"<",
"Term",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"Term",
">",
"(",
")",
";",
"ret",
".",
"add",
"(",
"subject",
")",
";",
"List",
"<",
"Term",
">",
"subjectTerms",
"=",
"subject",
".",
"getTerms",
"(",
")",
";",
"if",
"(",
"subjectTerms",
"!=",
"null",
")",
"{",
"ret",
".",
"addAll",
"(",
"subjectTerms",
")",
";",
"for",
"(",
"final",
"Term",
"term",
":",
"subjectTerms",
")",
"{",
"ret",
".",
"addAll",
"(",
"term",
".",
"getAllTerms",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"object",
"!=",
"null",
")",
"{",
"ret",
".",
"addAll",
"(",
"object",
".",
"getAllTerms",
"(",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Returns a list of all terms contained by this statement's subject and
object.
@return List of terms
|
[
"Returns",
"a",
"list",
"of",
"all",
"terms",
"contained",
"by",
"this",
"statement",
"s",
"subject",
"and",
"object",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/model/Statement.java#L211-L227
|
145,728
|
geomajas/geomajas-project-client-gwt2
|
plugin/corewidget/example-jar/src/main/java/org/geomajas/gwt2/plugin/corewidget/example/client/sample/feature/controller/FeatureClickedListener.java
|
FeatureClickedListener.calculateBufferFromPixelTolerance
|
private double calculateBufferFromPixelTolerance() {
Coordinate c1 = mapPresenter.getViewPort().getTransformationService()
.transform(new Coordinate(0, 0), RenderSpace.SCREEN, RenderSpace.WORLD);
Coordinate c2 = mapPresenter.getViewPort().getTransformationService()
.transform(new Coordinate(pixelBuffer, 0), RenderSpace.SCREEN, RenderSpace.WORLD);
return c1.distance(c2);
}
|
java
|
private double calculateBufferFromPixelTolerance() {
Coordinate c1 = mapPresenter.getViewPort().getTransformationService()
.transform(new Coordinate(0, 0), RenderSpace.SCREEN, RenderSpace.WORLD);
Coordinate c2 = mapPresenter.getViewPort().getTransformationService()
.transform(new Coordinate(pixelBuffer, 0), RenderSpace.SCREEN, RenderSpace.WORLD);
return c1.distance(c2);
}
|
[
"private",
"double",
"calculateBufferFromPixelTolerance",
"(",
")",
"{",
"Coordinate",
"c1",
"=",
"mapPresenter",
".",
"getViewPort",
"(",
")",
".",
"getTransformationService",
"(",
")",
".",
"transform",
"(",
"new",
"Coordinate",
"(",
"0",
",",
"0",
")",
",",
"RenderSpace",
".",
"SCREEN",
",",
"RenderSpace",
".",
"WORLD",
")",
";",
"Coordinate",
"c2",
"=",
"mapPresenter",
".",
"getViewPort",
"(",
")",
".",
"getTransformationService",
"(",
")",
".",
"transform",
"(",
"new",
"Coordinate",
"(",
"pixelBuffer",
",",
"0",
")",
",",
"RenderSpace",
".",
"SCREEN",
",",
"RenderSpace",
".",
"WORLD",
")",
";",
"return",
"c1",
".",
"distance",
"(",
"c2",
")",
";",
"}"
] |
Calculate a buffer in which the listener may include the features from the map.
@return double buffer
|
[
"Calculate",
"a",
"buffer",
"in",
"which",
"the",
"listener",
"may",
"include",
"the",
"features",
"from",
"the",
"map",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/corewidget/example-jar/src/main/java/org/geomajas/gwt2/plugin/corewidget/example/client/sample/feature/controller/FeatureClickedListener.java#L149-L157
|
145,729
|
geomajas/geomajas-project-client-gwt2
|
plugin/corewidget/example-jar/src/main/java/org/geomajas/gwt2/plugin/corewidget/example/client/sample/feature/controller/FeatureClickedListener.java
|
FeatureClickedListener.isDownPosition
|
private boolean isDownPosition(HumanInputEvent<?> event) {
if (clickedPosition != null) {
Coordinate location = getLocation(event, RenderSpace.SCREEN);
if (MathService.distance(clickedPosition, location) < clickDelta) {
return true;
}
}
return false;
}
|
java
|
private boolean isDownPosition(HumanInputEvent<?> event) {
if (clickedPosition != null) {
Coordinate location = getLocation(event, RenderSpace.SCREEN);
if (MathService.distance(clickedPosition, location) < clickDelta) {
return true;
}
}
return false;
}
|
[
"private",
"boolean",
"isDownPosition",
"(",
"HumanInputEvent",
"<",
"?",
">",
"event",
")",
"{",
"if",
"(",
"clickedPosition",
"!=",
"null",
")",
"{",
"Coordinate",
"location",
"=",
"getLocation",
"(",
"event",
",",
"RenderSpace",
".",
"SCREEN",
")",
";",
"if",
"(",
"MathService",
".",
"distance",
"(",
"clickedPosition",
",",
"location",
")",
"<",
"clickDelta",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Is the event at the same location as the "down" event?
@param event The event to check.
@return true or false.
|
[
"Is",
"the",
"event",
"at",
"the",
"same",
"location",
"as",
"the",
"down",
"event?"
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/corewidget/example-jar/src/main/java/org/geomajas/gwt2/plugin/corewidget/example/client/sample/feature/controller/FeatureClickedListener.java#L165-L173
|
145,730
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/record/RecordFile.java
|
RecordFile.read
|
public byte[] read(long record) throws IOException {
// (+ recordSize) allows skipping metadata record
long pos = record * recordSize + recordSize;
if (pos >= size) {
final String fmt = "bad seek to position: %d (size is %d)";
final String msg = format(fmt, pos, size);
throw new InvalidArgument(msg);
}
raf.seek(pos);
byte[] ret = new byte[recordSize];
int read = raf.read(ret);
if (read != recordSize) {
final String fmt = "read %d bytes, but expected %d";
final String msg = format(fmt, read, recordSize);
throw new InvalidArgument(msg);
}
return ret;
}
|
java
|
public byte[] read(long record) throws IOException {
// (+ recordSize) allows skipping metadata record
long pos = record * recordSize + recordSize;
if (pos >= size) {
final String fmt = "bad seek to position: %d (size is %d)";
final String msg = format(fmt, pos, size);
throw new InvalidArgument(msg);
}
raf.seek(pos);
byte[] ret = new byte[recordSize];
int read = raf.read(ret);
if (read != recordSize) {
final String fmt = "read %d bytes, but expected %d";
final String msg = format(fmt, read, recordSize);
throw new InvalidArgument(msg);
}
return ret;
}
|
[
"public",
"byte",
"[",
"]",
"read",
"(",
"long",
"record",
")",
"throws",
"IOException",
"{",
"// (+ recordSize) allows skipping metadata record",
"long",
"pos",
"=",
"record",
"*",
"recordSize",
"+",
"recordSize",
";",
"if",
"(",
"pos",
">=",
"size",
")",
"{",
"final",
"String",
"fmt",
"=",
"\"bad seek to position: %d (size is %d)\"",
";",
"final",
"String",
"msg",
"=",
"format",
"(",
"fmt",
",",
"pos",
",",
"size",
")",
";",
"throw",
"new",
"InvalidArgument",
"(",
"msg",
")",
";",
"}",
"raf",
".",
"seek",
"(",
"pos",
")",
";",
"byte",
"[",
"]",
"ret",
"=",
"new",
"byte",
"[",
"recordSize",
"]",
";",
"int",
"read",
"=",
"raf",
".",
"read",
"(",
"ret",
")",
";",
"if",
"(",
"read",
"!=",
"recordSize",
")",
"{",
"final",
"String",
"fmt",
"=",
"\"read %d bytes, but expected %d\"",
";",
"final",
"String",
"msg",
"=",
"format",
"(",
"fmt",
",",
"read",
",",
"recordSize",
")",
";",
"throw",
"new",
"InvalidArgument",
"(",
"msg",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Reads a record from this record file.
@param record The record to read
@return {@code byte[]}
@throws IOException Throw if an I/O error occurs during I/O seeks or
reads
|
[
"Reads",
"a",
"record",
"from",
"this",
"record",
"file",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/record/RecordFile.java#L240-L259
|
145,731
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/record/RecordFile.java
|
RecordFile.read
|
public void read(long record, byte[] bytes) throws IOException {
if (bytes.length != recordSize) {
final String fmt = "invalid buffer length of %d bytes, expected %d";
final String msg = format(fmt, bytes.length, recordSize);
throw new InvalidArgument(msg);
}
// (+ recordSize) allows skipping metadata record
long pos = record * recordSize + recordSize;
if (pos >= size) {
final String fmt = "bad seek to position: %d (size is %d)";
final String msg = format(fmt, pos, size);
throw new InvalidArgument(msg);
}
raf.seek(pos);
int read = raf.read(bytes);
if (read != recordSize) {
final String fmt = "read %d bytes, but expected %d";
final String msg = format(fmt, read, recordSize);
throw new InvalidArgument(msg);
}
}
|
java
|
public void read(long record, byte[] bytes) throws IOException {
if (bytes.length != recordSize) {
final String fmt = "invalid buffer length of %d bytes, expected %d";
final String msg = format(fmt, bytes.length, recordSize);
throw new InvalidArgument(msg);
}
// (+ recordSize) allows skipping metadata record
long pos = record * recordSize + recordSize;
if (pos >= size) {
final String fmt = "bad seek to position: %d (size is %d)";
final String msg = format(fmt, pos, size);
throw new InvalidArgument(msg);
}
raf.seek(pos);
int read = raf.read(bytes);
if (read != recordSize) {
final String fmt = "read %d bytes, but expected %d";
final String msg = format(fmt, read, recordSize);
throw new InvalidArgument(msg);
}
}
|
[
"public",
"void",
"read",
"(",
"long",
"record",
",",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"if",
"(",
"bytes",
".",
"length",
"!=",
"recordSize",
")",
"{",
"final",
"String",
"fmt",
"=",
"\"invalid buffer length of %d bytes, expected %d\"",
";",
"final",
"String",
"msg",
"=",
"format",
"(",
"fmt",
",",
"bytes",
".",
"length",
",",
"recordSize",
")",
";",
"throw",
"new",
"InvalidArgument",
"(",
"msg",
")",
";",
"}",
"// (+ recordSize) allows skipping metadata record",
"long",
"pos",
"=",
"record",
"*",
"recordSize",
"+",
"recordSize",
";",
"if",
"(",
"pos",
">=",
"size",
")",
"{",
"final",
"String",
"fmt",
"=",
"\"bad seek to position: %d (size is %d)\"",
";",
"final",
"String",
"msg",
"=",
"format",
"(",
"fmt",
",",
"pos",
",",
"size",
")",
";",
"throw",
"new",
"InvalidArgument",
"(",
"msg",
")",
";",
"}",
"raf",
".",
"seek",
"(",
"pos",
")",
";",
"int",
"read",
"=",
"raf",
".",
"read",
"(",
"bytes",
")",
";",
"if",
"(",
"read",
"!=",
"recordSize",
")",
"{",
"final",
"String",
"fmt",
"=",
"\"read %d bytes, but expected %d\"",
";",
"final",
"String",
"msg",
"=",
"format",
"(",
"fmt",
",",
"read",
",",
"recordSize",
")",
";",
"throw",
"new",
"InvalidArgument",
"(",
"msg",
")",
";",
"}",
"}"
] |
Reads a record from this record file into the provided byte buffer.
@param record The record to read
@param bytes Byte buffer to read into
@throws IOException Throw if an I/O error occurs during I/O seeks or
reads
|
[
"Reads",
"a",
"record",
"from",
"this",
"record",
"file",
"into",
"the",
"provided",
"byte",
"buffer",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/record/RecordFile.java#L269-L293
|
145,732
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/record/RecordFile.java
|
RecordFile.read
|
public byte[] read(long record, int column) throws IOException {
// (+ recordSize) allows skipping metadata record
long pos = record * recordSize + recordSize;
int i = 0;
for (; i < column; i++) {
pos += columns[i].size;
}
if (pos >= size) {
final String fmt = "bad seek to position: %d (size is %d)";
final String msg = format(fmt, pos, size);
throw new InvalidArgument(msg);
}
Column<?> c = columns[i - 1];
raf.seek(pos);
byte[] ret = new byte[c.size];
int read = raf.read(ret);
if (read != c.size) {
final String fmt = "read %d bytes, but expected %d";
final String msg = format(fmt, read, c.size);
throw new IOException(msg);
}
return ret;
}
|
java
|
public byte[] read(long record, int column) throws IOException {
// (+ recordSize) allows skipping metadata record
long pos = record * recordSize + recordSize;
int i = 0;
for (; i < column; i++) {
pos += columns[i].size;
}
if (pos >= size) {
final String fmt = "bad seek to position: %d (size is %d)";
final String msg = format(fmt, pos, size);
throw new InvalidArgument(msg);
}
Column<?> c = columns[i - 1];
raf.seek(pos);
byte[] ret = new byte[c.size];
int read = raf.read(ret);
if (read != c.size) {
final String fmt = "read %d bytes, but expected %d";
final String msg = format(fmt, read, c.size);
throw new IOException(msg);
}
return ret;
}
|
[
"public",
"byte",
"[",
"]",
"read",
"(",
"long",
"record",
",",
"int",
"column",
")",
"throws",
"IOException",
"{",
"// (+ recordSize) allows skipping metadata record",
"long",
"pos",
"=",
"record",
"*",
"recordSize",
"+",
"recordSize",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
";",
"i",
"<",
"column",
";",
"i",
"++",
")",
"{",
"pos",
"+=",
"columns",
"[",
"i",
"]",
".",
"size",
";",
"}",
"if",
"(",
"pos",
">=",
"size",
")",
"{",
"final",
"String",
"fmt",
"=",
"\"bad seek to position: %d (size is %d)\"",
";",
"final",
"String",
"msg",
"=",
"format",
"(",
"fmt",
",",
"pos",
",",
"size",
")",
";",
"throw",
"new",
"InvalidArgument",
"(",
"msg",
")",
";",
"}",
"Column",
"<",
"?",
">",
"c",
"=",
"columns",
"[",
"i",
"-",
"1",
"]",
";",
"raf",
".",
"seek",
"(",
"pos",
")",
";",
"byte",
"[",
"]",
"ret",
"=",
"new",
"byte",
"[",
"c",
".",
"size",
"]",
";",
"int",
"read",
"=",
"raf",
".",
"read",
"(",
"ret",
")",
";",
"if",
"(",
"read",
"!=",
"c",
".",
"size",
")",
"{",
"final",
"String",
"fmt",
"=",
"\"read %d bytes, but expected %d\"",
";",
"final",
"String",
"msg",
"=",
"format",
"(",
"fmt",
",",
"read",
",",
"c",
".",
"size",
")",
";",
"throw",
"new",
"IOException",
"(",
"msg",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Reads a record for a specific columns from this record file.
@param record The record to read
@param column The column to read from
@return {@code byte[]}
@throws IOException Thrown if an I/O error occurs during I/O seeks or
read or an invalid number of bytes were read
|
[
"Reads",
"a",
"record",
"for",
"a",
"specific",
"columns",
"from",
"this",
"record",
"file",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/record/RecordFile.java#L304-L329
|
145,733
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/record/RecordFile.java
|
RecordFile.write
|
public void write(long record, byte[] bytes) throws IOException {
if (readonly) {
throw new UnsupportedOperationException(RO_MSG);
}
if (bytes.length != recordSize) {
final String fmt = "invalid write of %d bytes, expected %d";
final String msg = format(fmt, bytes.length, recordSize);
throw new InvalidArgument(msg);
}
// (+ recordSize) allows skipping metadata record
long pos = record * recordSize + recordSize;
if (pos >= size) {
final String fmt = "bad seek to position: %d (size is %d)";
final String msg = format(fmt, pos, size);
throw new InvalidArgument(msg);
}
raf.seek(pos);
raf.write(bytes);
}
|
java
|
public void write(long record, byte[] bytes) throws IOException {
if (readonly) {
throw new UnsupportedOperationException(RO_MSG);
}
if (bytes.length != recordSize) {
final String fmt = "invalid write of %d bytes, expected %d";
final String msg = format(fmt, bytes.length, recordSize);
throw new InvalidArgument(msg);
}
// (+ recordSize) allows skipping metadata record
long pos = record * recordSize + recordSize;
if (pos >= size) {
final String fmt = "bad seek to position: %d (size is %d)";
final String msg = format(fmt, pos, size);
throw new InvalidArgument(msg);
}
raf.seek(pos);
raf.write(bytes);
}
|
[
"public",
"void",
"write",
"(",
"long",
"record",
",",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"if",
"(",
"readonly",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"RO_MSG",
")",
";",
"}",
"if",
"(",
"bytes",
".",
"length",
"!=",
"recordSize",
")",
"{",
"final",
"String",
"fmt",
"=",
"\"invalid write of %d bytes, expected %d\"",
";",
"final",
"String",
"msg",
"=",
"format",
"(",
"fmt",
",",
"bytes",
".",
"length",
",",
"recordSize",
")",
";",
"throw",
"new",
"InvalidArgument",
"(",
"msg",
")",
";",
"}",
"// (+ recordSize) allows skipping metadata record",
"long",
"pos",
"=",
"record",
"*",
"recordSize",
"+",
"recordSize",
";",
"if",
"(",
"pos",
">=",
"size",
")",
"{",
"final",
"String",
"fmt",
"=",
"\"bad seek to position: %d (size is %d)\"",
";",
"final",
"String",
"msg",
"=",
"format",
"(",
"fmt",
",",
"pos",
",",
"size",
")",
";",
"throw",
"new",
"InvalidArgument",
"(",
"msg",
")",
";",
"}",
"raf",
".",
"seek",
"(",
"pos",
")",
";",
"raf",
".",
"write",
"(",
"bytes",
")",
";",
"}"
] |
Writes a record to this record file, overwriting the previous contents.
@param record The record being written
@param bytes The bytes to write
@throws IOException Thrown if an I/O error occurs during I/O seeks or
writes
@throws UnsupportedOperationException Thrown if the mode is set to
read-only
@throws InvalidArgument Thrown if a write of anything other than the size
of the record is requested
|
[
"Writes",
"a",
"record",
"to",
"this",
"record",
"file",
"overwriting",
"the",
"previous",
"contents",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/record/RecordFile.java#L383-L401
|
145,734
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/record/RecordFile.java
|
RecordFile.write
|
public void write(long record, int column, byte[] bytes) throws IOException {
if (readonly) {
throw new UnsupportedOperationException(RO_MSG);
}
// (+ recordSize) allows skipping metadata record
long pos = record * recordSize + recordSize;
int i = 0;
for (; i < column; i++) {
pos += columns[i].size;
}
if (pos >= size) {
final String fmt = "bad seek to position: %d (size is %d)";
final String msg = format(fmt, pos, size);
throw new InvalidArgument(msg);
}
Column<?> c = columns[i];
if (bytes.length != c.size) {
final String fmt = "invalid write of %d bytes, expected %d";
final String msg = format(fmt, bytes.length, c.size);
throw new InvalidArgument(msg);
}
raf.seek(pos);
raf.write(bytes);
}
|
java
|
public void write(long record, int column, byte[] bytes) throws IOException {
if (readonly) {
throw new UnsupportedOperationException(RO_MSG);
}
// (+ recordSize) allows skipping metadata record
long pos = record * recordSize + recordSize;
int i = 0;
for (; i < column; i++) {
pos += columns[i].size;
}
if (pos >= size) {
final String fmt = "bad seek to position: %d (size is %d)";
final String msg = format(fmt, pos, size);
throw new InvalidArgument(msg);
}
Column<?> c = columns[i];
if (bytes.length != c.size) {
final String fmt = "invalid write of %d bytes, expected %d";
final String msg = format(fmt, bytes.length, c.size);
throw new InvalidArgument(msg);
}
raf.seek(pos);
raf.write(bytes);
}
|
[
"public",
"void",
"write",
"(",
"long",
"record",
",",
"int",
"column",
",",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"if",
"(",
"readonly",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"RO_MSG",
")",
";",
"}",
"// (+ recordSize) allows skipping metadata record",
"long",
"pos",
"=",
"record",
"*",
"recordSize",
"+",
"recordSize",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
";",
"i",
"<",
"column",
";",
"i",
"++",
")",
"{",
"pos",
"+=",
"columns",
"[",
"i",
"]",
".",
"size",
";",
"}",
"if",
"(",
"pos",
">=",
"size",
")",
"{",
"final",
"String",
"fmt",
"=",
"\"bad seek to position: %d (size is %d)\"",
";",
"final",
"String",
"msg",
"=",
"format",
"(",
"fmt",
",",
"pos",
",",
"size",
")",
";",
"throw",
"new",
"InvalidArgument",
"(",
"msg",
")",
";",
"}",
"Column",
"<",
"?",
">",
"c",
"=",
"columns",
"[",
"i",
"]",
";",
"if",
"(",
"bytes",
".",
"length",
"!=",
"c",
".",
"size",
")",
"{",
"final",
"String",
"fmt",
"=",
"\"invalid write of %d bytes, expected %d\"",
";",
"final",
"String",
"msg",
"=",
"format",
"(",
"fmt",
",",
"bytes",
".",
"length",
",",
"c",
".",
"size",
")",
";",
"throw",
"new",
"InvalidArgument",
"(",
"msg",
")",
";",
"}",
"raf",
".",
"seek",
"(",
"pos",
")",
";",
"raf",
".",
"write",
"(",
"bytes",
")",
";",
"}"
] |
Writes a record for a specific column to this record file, overwriting
the previous contents.
@param record The record being written
@param column The column to write
@param bytes The bytes to write
@throws IOException Thrown if an I/O error occurs during I/O seeks or
writes
@throws InvalidArgument Thrown if a write of anything other than the size
of the column is requested
@throws UnsupportedOperationException Thrown if the mode is set to
read-only
|
[
"Writes",
"a",
"record",
"for",
"a",
"specific",
"column",
"to",
"this",
"record",
"file",
"overwriting",
"the",
"previous",
"contents",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/record/RecordFile.java#L417-L443
|
145,735
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/record/RecordFile.java
|
RecordFile.writeMetadata
|
@Deprecated
public void writeMetadata(byte[] bytes) throws IOException {
if (readonly) {
throw new UnsupportedOperationException(RO_MSG);
}
if (bytes.length != recordSize) {
final String fmt = "invalid write of %d bytes, expected %d";
final String msg = format(fmt, bytes.length, recordSize);
throw new InvalidArgument(msg);
}
raf.seek(0);
raf.write(bytes);
}
|
java
|
@Deprecated
public void writeMetadata(byte[] bytes) throws IOException {
if (readonly) {
throw new UnsupportedOperationException(RO_MSG);
}
if (bytes.length != recordSize) {
final String fmt = "invalid write of %d bytes, expected %d";
final String msg = format(fmt, bytes.length, recordSize);
throw new InvalidArgument(msg);
}
raf.seek(0);
raf.write(bytes);
}
|
[
"@",
"Deprecated",
"public",
"void",
"writeMetadata",
"(",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"if",
"(",
"readonly",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"RO_MSG",
")",
";",
"}",
"if",
"(",
"bytes",
".",
"length",
"!=",
"recordSize",
")",
"{",
"final",
"String",
"fmt",
"=",
"\"invalid write of %d bytes, expected %d\"",
";",
"final",
"String",
"msg",
"=",
"format",
"(",
"fmt",
",",
"bytes",
".",
"length",
",",
"recordSize",
")",
";",
"throw",
"new",
"InvalidArgument",
"(",
"msg",
")",
";",
"}",
"raf",
".",
"seek",
"(",
"0",
")",
";",
"raf",
".",
"write",
"(",
"bytes",
")",
";",
"}"
] |
Writes metadata to this record file overwriting existing metadata.
@param bytes The metadata bytes to write
@throws IOException Thrown if an I/O error occurs during I/O seeks or
writes
@throws InvalidArgument Thrown if a write of anything other than the size
of the record is requested
@throws UnsupportedOperationException Thrown if the mode is set to
read-only
@deprecated Explicitly writing the metadata record can cause
inconsistent {@link RecordFile record files} if used incorrectly.
Metadata for the {@link RecordFile record file} should only be written
on construction.
@see RecordFile#RecordFile(File, RecordMode, Column...)
|
[
"Writes",
"metadata",
"to",
"this",
"record",
"file",
"overwriting",
"existing",
"metadata",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/record/RecordFile.java#L512-L525
|
145,736
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/xgmml/XGMMLExporter.java
|
XGMMLExporter.exportKam
|
public static void exportKam(final Kam kam, final KAMStore kAMStore,
String outputPath) throws KAMStoreException, FileNotFoundException {
if (nulls(kam, kAMStore, outputPath)) {
throw new InvalidArgument("argument(s) were null");
}
// Set up a writer to write the XGMML
PrintWriter writer = new PrintWriter(outputPath);
// Start to process the Kam
// Write xgmml <graph> element header
XGMMLUtility.writeStart(kam.getKamInfo().getName(), writer);
// We iterate over all the nodes in the Kam first
for (KamNode kamNode : kam.getNodes()) {
Node xNode = new Node();
xNode.id = kamNode.getId();
xNode.label = kamNode.getLabel();
xNode.function = kamNode.getFunctionType();
List<BelTerm> supportingTerms =
kAMStore.getSupportingTerms(kamNode);
XGMMLUtility.writeNode(xNode, supportingTerms, writer);
}
// Iterate over all the edges
for (KamEdge kamEdge : kam.getEdges()) {
Edge xEdge = new Edge();
xEdge.id = kamEdge.getId();
xEdge.rel = kamEdge.getRelationshipType();
KamNode knsrc = kamEdge.getSourceNode();
KamNode kntgt = kamEdge.getTargetNode();
xEdge.source = knsrc.getId();
xEdge.target = kntgt.getId();
Node src = new Node();
src.function = knsrc.getFunctionType();
src.label = knsrc.getLabel();
Node tgt = new Node();
tgt.function = kntgt.getFunctionType();
tgt.label = kntgt.getLabel();
XGMMLUtility.writeEdge(src, tgt, xEdge, writer);
}
// Close out the writer
XGMMLUtility.writeEnd(writer);
writer.close();
}
|
java
|
public static void exportKam(final Kam kam, final KAMStore kAMStore,
String outputPath) throws KAMStoreException, FileNotFoundException {
if (nulls(kam, kAMStore, outputPath)) {
throw new InvalidArgument("argument(s) were null");
}
// Set up a writer to write the XGMML
PrintWriter writer = new PrintWriter(outputPath);
// Start to process the Kam
// Write xgmml <graph> element header
XGMMLUtility.writeStart(kam.getKamInfo().getName(), writer);
// We iterate over all the nodes in the Kam first
for (KamNode kamNode : kam.getNodes()) {
Node xNode = new Node();
xNode.id = kamNode.getId();
xNode.label = kamNode.getLabel();
xNode.function = kamNode.getFunctionType();
List<BelTerm> supportingTerms =
kAMStore.getSupportingTerms(kamNode);
XGMMLUtility.writeNode(xNode, supportingTerms, writer);
}
// Iterate over all the edges
for (KamEdge kamEdge : kam.getEdges()) {
Edge xEdge = new Edge();
xEdge.id = kamEdge.getId();
xEdge.rel = kamEdge.getRelationshipType();
KamNode knsrc = kamEdge.getSourceNode();
KamNode kntgt = kamEdge.getTargetNode();
xEdge.source = knsrc.getId();
xEdge.target = kntgt.getId();
Node src = new Node();
src.function = knsrc.getFunctionType();
src.label = knsrc.getLabel();
Node tgt = new Node();
tgt.function = kntgt.getFunctionType();
tgt.label = kntgt.getLabel();
XGMMLUtility.writeEdge(src, tgt, xEdge, writer);
}
// Close out the writer
XGMMLUtility.writeEnd(writer);
writer.close();
}
|
[
"public",
"static",
"void",
"exportKam",
"(",
"final",
"Kam",
"kam",
",",
"final",
"KAMStore",
"kAMStore",
",",
"String",
"outputPath",
")",
"throws",
"KAMStoreException",
",",
"FileNotFoundException",
"{",
"if",
"(",
"nulls",
"(",
"kam",
",",
"kAMStore",
",",
"outputPath",
")",
")",
"{",
"throw",
"new",
"InvalidArgument",
"(",
"\"argument(s) were null\"",
")",
";",
"}",
"// Set up a writer to write the XGMML",
"PrintWriter",
"writer",
"=",
"new",
"PrintWriter",
"(",
"outputPath",
")",
";",
"// Start to process the Kam",
"// Write xgmml <graph> element header",
"XGMMLUtility",
".",
"writeStart",
"(",
"kam",
".",
"getKamInfo",
"(",
")",
".",
"getName",
"(",
")",
",",
"writer",
")",
";",
"// We iterate over all the nodes in the Kam first",
"for",
"(",
"KamNode",
"kamNode",
":",
"kam",
".",
"getNodes",
"(",
")",
")",
"{",
"Node",
"xNode",
"=",
"new",
"Node",
"(",
")",
";",
"xNode",
".",
"id",
"=",
"kamNode",
".",
"getId",
"(",
")",
";",
"xNode",
".",
"label",
"=",
"kamNode",
".",
"getLabel",
"(",
")",
";",
"xNode",
".",
"function",
"=",
"kamNode",
".",
"getFunctionType",
"(",
")",
";",
"List",
"<",
"BelTerm",
">",
"supportingTerms",
"=",
"kAMStore",
".",
"getSupportingTerms",
"(",
"kamNode",
")",
";",
"XGMMLUtility",
".",
"writeNode",
"(",
"xNode",
",",
"supportingTerms",
",",
"writer",
")",
";",
"}",
"// Iterate over all the edges",
"for",
"(",
"KamEdge",
"kamEdge",
":",
"kam",
".",
"getEdges",
"(",
")",
")",
"{",
"Edge",
"xEdge",
"=",
"new",
"Edge",
"(",
")",
";",
"xEdge",
".",
"id",
"=",
"kamEdge",
".",
"getId",
"(",
")",
";",
"xEdge",
".",
"rel",
"=",
"kamEdge",
".",
"getRelationshipType",
"(",
")",
";",
"KamNode",
"knsrc",
"=",
"kamEdge",
".",
"getSourceNode",
"(",
")",
";",
"KamNode",
"kntgt",
"=",
"kamEdge",
".",
"getTargetNode",
"(",
")",
";",
"xEdge",
".",
"source",
"=",
"knsrc",
".",
"getId",
"(",
")",
";",
"xEdge",
".",
"target",
"=",
"kntgt",
".",
"getId",
"(",
")",
";",
"Node",
"src",
"=",
"new",
"Node",
"(",
")",
";",
"src",
".",
"function",
"=",
"knsrc",
".",
"getFunctionType",
"(",
")",
";",
"src",
".",
"label",
"=",
"knsrc",
".",
"getLabel",
"(",
")",
";",
"Node",
"tgt",
"=",
"new",
"Node",
"(",
")",
";",
"tgt",
".",
"function",
"=",
"kntgt",
".",
"getFunctionType",
"(",
")",
";",
"tgt",
".",
"label",
"=",
"kntgt",
".",
"getLabel",
"(",
")",
";",
"XGMMLUtility",
".",
"writeEdge",
"(",
"src",
",",
"tgt",
",",
"xEdge",
",",
"writer",
")",
";",
"}",
"// Close out the writer",
"XGMMLUtility",
".",
"writeEnd",
"(",
"writer",
")",
";",
"writer",
".",
"close",
"(",
")",
";",
"}"
] |
Export KAM to XGMML format using the KAM API.
@param kam {@link Kam} the kam to export to XGMML
@param kAMStore {@link KAMStore} the kam store to read kam details from
@param outputPath {@link String} the output path to write XGMML file to,
which can be null, in which case the kam's name will be used and it will
be written to the current directory (user.dir).
@throws KAMStoreException Thrown if an error occurred retrieving the KAM
@throws FileNotFoundException Thrown if the export file cannot be
written to
@throws InvalidArgument Thrown if either the kam, kamInfo, kamStore, or
outputPath arguments were null
|
[
"Export",
"KAM",
"to",
"XGMML",
"format",
"using",
"the",
"KAM",
"API",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/xgmml/XGMMLExporter.java#L83-L133
|
145,737
|
ops4j/org.ops4j.pax.exam1
|
pax-exam-container-default/src/main/java/org/ops4j/pax/exam/container/def/internal/ArgumentsBuilder.java
|
ArgumentsBuilder.add
|
private void add( final List<String> arguments,
final Collection<String> argumentsToAdd )
{
if( argumentsToAdd != null && argumentsToAdd.size() > 0 )
{
arguments.addAll( argumentsToAdd );
}
}
|
java
|
private void add( final List<String> arguments,
final Collection<String> argumentsToAdd )
{
if( argumentsToAdd != null && argumentsToAdd.size() > 0 )
{
arguments.addAll( argumentsToAdd );
}
}
|
[
"private",
"void",
"add",
"(",
"final",
"List",
"<",
"String",
">",
"arguments",
",",
"final",
"Collection",
"<",
"String",
">",
"argumentsToAdd",
")",
"{",
"if",
"(",
"argumentsToAdd",
"!=",
"null",
"&&",
"argumentsToAdd",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"arguments",
".",
"addAll",
"(",
"argumentsToAdd",
")",
";",
"}",
"}"
] |
Adds a collection of arguments to a list of arguments by skipping null arguments.
@param arguments list to which the arguments should be added
@param argumentsToAdd arguments to be added (can be null or empty)
|
[
"Adds",
"a",
"collection",
"of",
"arguments",
"to",
"a",
"list",
"of",
"arguments",
"by",
"skipping",
"null",
"arguments",
"."
] |
7c8742208117ff91bd24bcd3a185d2d019f7000f
|
https://github.com/ops4j/org.ops4j.pax.exam1/blob/7c8742208117ff91bd24bcd3a185d2d019f7000f/pax-exam-container-default/src/main/java/org/ops4j/pax/exam/container/def/internal/ArgumentsBuilder.java#L139-L146
|
145,738
|
ops4j/org.ops4j.pax.exam1
|
pax-exam-container-default/src/main/java/org/ops4j/pax/exam/container/def/internal/ArgumentsBuilder.java
|
ArgumentsBuilder.add
|
private void add( final List<String> arguments,
final String argument )
{
if( argument != null && argument.trim().length() > 0 )
{
arguments.add( argument );
}
}
|
java
|
private void add( final List<String> arguments,
final String argument )
{
if( argument != null && argument.trim().length() > 0 )
{
arguments.add( argument );
}
}
|
[
"private",
"void",
"add",
"(",
"final",
"List",
"<",
"String",
">",
"arguments",
",",
"final",
"String",
"argument",
")",
"{",
"if",
"(",
"argument",
"!=",
"null",
"&&",
"argument",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"arguments",
".",
"add",
"(",
"argument",
")",
";",
"}",
"}"
] |
Adds an argumentto a list of arguments by skipping null or empty arguments.
@param arguments list to which the arguments should be added
@param argument argument to be added (can be null or empty)
|
[
"Adds",
"an",
"argumentto",
"a",
"list",
"of",
"arguments",
"by",
"skipping",
"null",
"or",
"empty",
"arguments",
"."
] |
7c8742208117ff91bd24bcd3a185d2d019f7000f
|
https://github.com/ops4j/org.ops4j.pax.exam1/blob/7c8742208117ff91bd24bcd3a185d2d019f7000f/pax-exam-container-default/src/main/java/org/ops4j/pax/exam/container/def/internal/ArgumentsBuilder.java#L154-L161
|
145,739
|
ops4j/org.ops4j.pax.exam1
|
pax-exam-container-default/src/main/java/org/ops4j/pax/exam/container/def/internal/ArgumentsBuilder.java
|
ArgumentsBuilder.defaultArguments
|
private Collection<String> defaultArguments()
{
final List<String> arguments = new ArrayList<String>();
arguments.add( "--noConsole" );
arguments.add( "--noDownloadFeedback" );
if( !argsSetManually )
{
arguments.add( "--noArgs" );
}
String folder = System.getProperty( "java.io.tmpdir" )
+ "/paxexam_runner_"
+ System.getProperty( "user.name" );
arguments.add( "--workingDirectory=" + createWorkingDirectory( folder ).getAbsolutePath() );
return arguments;
}
|
java
|
private Collection<String> defaultArguments()
{
final List<String> arguments = new ArrayList<String>();
arguments.add( "--noConsole" );
arguments.add( "--noDownloadFeedback" );
if( !argsSetManually )
{
arguments.add( "--noArgs" );
}
String folder = System.getProperty( "java.io.tmpdir" )
+ "/paxexam_runner_"
+ System.getProperty( "user.name" );
arguments.add( "--workingDirectory=" + createWorkingDirectory( folder ).getAbsolutePath() );
return arguments;
}
|
[
"private",
"Collection",
"<",
"String",
">",
"defaultArguments",
"(",
")",
"{",
"final",
"List",
"<",
"String",
">",
"arguments",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"arguments",
".",
"add",
"(",
"\"--noConsole\"",
")",
";",
"arguments",
".",
"add",
"(",
"\"--noDownloadFeedback\"",
")",
";",
"if",
"(",
"!",
"argsSetManually",
")",
"{",
"arguments",
".",
"add",
"(",
"\"--noArgs\"",
")",
";",
"}",
"String",
"folder",
"=",
"System",
".",
"getProperty",
"(",
"\"java.io.tmpdir\"",
")",
"+",
"\"/paxexam_runner_\"",
"+",
"System",
".",
"getProperty",
"(",
"\"user.name\"",
")",
";",
"arguments",
".",
"add",
"(",
"\"--workingDirectory=\"",
"+",
"createWorkingDirectory",
"(",
"folder",
")",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"return",
"arguments",
";",
"}"
] |
Returns a collection of default Pax Runner arguments.
@return collection of default arguments
|
[
"Returns",
"a",
"collection",
"of",
"default",
"Pax",
"Runner",
"arguments",
"."
] |
7c8742208117ff91bd24bcd3a185d2d019f7000f
|
https://github.com/ops4j/org.ops4j.pax.exam1/blob/7c8742208117ff91bd24bcd3a185d2d019f7000f/pax-exam-container-default/src/main/java/org/ops4j/pax/exam/container/def/internal/ArgumentsBuilder.java#L168-L183
|
145,740
|
geomajas/geomajas-project-client-gwt2
|
plugin/wms/server-extension/src/main/java/org/geomajas/gwt2/plugin/wms/client/WmsServerExtension.java
|
WmsServerExtension.supportsFeatures
|
public void supportsFeatures(String baseUrl, WmsService.WmsVersion version, final String typeName,
final Callback<WfsFeatureTypeDescriptionInfo, String> callback) {
wmsService.describeLayer(baseUrl, typeName, version, new Callback<WmsDescribeLayerInfo, String>() {
@Override
public void onSuccess(WmsDescribeLayerInfo describeLayerInfo) {
String wfsUrl = null;
for (WmsLayerDescriptionInfo layerDescription : describeLayerInfo.getLayerDescriptions()) {
if (layerDescription.getWfs() != null) {
wfsUrl = layerDescription.getWfs();
break;
} else if (layerDescription.getOwsType() == WmsLayerDescriptionInfo.WFS) {
wfsUrl = layerDescription.getOwsUrl();
break;
}
}
if (wfsUrl != null) {
// we need an extra call for the schema !!!
WfsServerExtension.getInstance().getWfsService()
.describeFeatureType(WfsVersion.V1_0_0, wfsUrl, typeName, callback);
} else {
callback.onFailure("No WFS in layer description");
}
}
@Override
public void onFailure(String reason) {
callback.onFailure(reason);
}
});
}
|
java
|
public void supportsFeatures(String baseUrl, WmsService.WmsVersion version, final String typeName,
final Callback<WfsFeatureTypeDescriptionInfo, String> callback) {
wmsService.describeLayer(baseUrl, typeName, version, new Callback<WmsDescribeLayerInfo, String>() {
@Override
public void onSuccess(WmsDescribeLayerInfo describeLayerInfo) {
String wfsUrl = null;
for (WmsLayerDescriptionInfo layerDescription : describeLayerInfo.getLayerDescriptions()) {
if (layerDescription.getWfs() != null) {
wfsUrl = layerDescription.getWfs();
break;
} else if (layerDescription.getOwsType() == WmsLayerDescriptionInfo.WFS) {
wfsUrl = layerDescription.getOwsUrl();
break;
}
}
if (wfsUrl != null) {
// we need an extra call for the schema !!!
WfsServerExtension.getInstance().getWfsService()
.describeFeatureType(WfsVersion.V1_0_0, wfsUrl, typeName, callback);
} else {
callback.onFailure("No WFS in layer description");
}
}
@Override
public void onFailure(String reason) {
callback.onFailure(reason);
}
});
}
|
[
"public",
"void",
"supportsFeatures",
"(",
"String",
"baseUrl",
",",
"WmsService",
".",
"WmsVersion",
"version",
",",
"final",
"String",
"typeName",
",",
"final",
"Callback",
"<",
"WfsFeatureTypeDescriptionInfo",
",",
"String",
">",
"callback",
")",
"{",
"wmsService",
".",
"describeLayer",
"(",
"baseUrl",
",",
"typeName",
",",
"version",
",",
"new",
"Callback",
"<",
"WmsDescribeLayerInfo",
",",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onSuccess",
"(",
"WmsDescribeLayerInfo",
"describeLayerInfo",
")",
"{",
"String",
"wfsUrl",
"=",
"null",
";",
"for",
"(",
"WmsLayerDescriptionInfo",
"layerDescription",
":",
"describeLayerInfo",
".",
"getLayerDescriptions",
"(",
")",
")",
"{",
"if",
"(",
"layerDescription",
".",
"getWfs",
"(",
")",
"!=",
"null",
")",
"{",
"wfsUrl",
"=",
"layerDescription",
".",
"getWfs",
"(",
")",
";",
"break",
";",
"}",
"else",
"if",
"(",
"layerDescription",
".",
"getOwsType",
"(",
")",
"==",
"WmsLayerDescriptionInfo",
".",
"WFS",
")",
"{",
"wfsUrl",
"=",
"layerDescription",
".",
"getOwsUrl",
"(",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"wfsUrl",
"!=",
"null",
")",
"{",
"// we need an extra call for the schema !!!",
"WfsServerExtension",
".",
"getInstance",
"(",
")",
".",
"getWfsService",
"(",
")",
".",
"describeFeatureType",
"(",
"WfsVersion",
".",
"V1_0_0",
",",
"wfsUrl",
",",
"typeName",
",",
"callback",
")",
";",
"}",
"else",
"{",
"callback",
".",
"onFailure",
"(",
"\"No WFS in layer description\"",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"onFailure",
"(",
"String",
"reason",
")",
"{",
"callback",
".",
"onFailure",
"(",
"reason",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Find out if a certain WMS layer has support for features through WFS. If successful the WFS configuration will be
returned.
@param baseUrl The base URL to the WMS service.
@param layerId The name of the layer.
@param callback Callback that will be given the answer through the associated layer configuration.
|
[
"Find",
"out",
"if",
"a",
"certain",
"WMS",
"layer",
"has",
"support",
"for",
"features",
"through",
"WFS",
".",
"If",
"successful",
"the",
"WFS",
"configuration",
"will",
"be",
"returned",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/wms/server-extension/src/main/java/org/geomajas/gwt2/plugin/wms/client/WmsServerExtension.java#L87-L117
|
145,741
|
geomajas/geomajas-project-client-gwt2
|
plugin/wms/server-extension/src/main/java/org/geomajas/gwt2/plugin/wms/client/WmsServerExtension.java
|
WmsServerExtension.setHintValue
|
public <T> void setHintValue(Hint<T> hint, T value) {
if (value == null) {
throw new IllegalArgumentException("Null value passed.");
}
hintValues.put(hint, value);
}
|
java
|
public <T> void setHintValue(Hint<T> hint, T value) {
if (value == null) {
throw new IllegalArgumentException("Null value passed.");
}
hintValues.put(hint, value);
}
|
[
"public",
"<",
"T",
">",
"void",
"setHintValue",
"(",
"Hint",
"<",
"T",
">",
"hint",
",",
"T",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Null value passed.\"",
")",
";",
"}",
"hintValues",
".",
"put",
"(",
"hint",
",",
"value",
")",
";",
"}"
] |
Apply a new value for a specific WMS hint.
@param hint The hint to change the value for.
@param value The new actual value. If the value is null, an IllegalArgumentException is thrown.
|
[
"Apply",
"a",
"new",
"value",
"for",
"a",
"specific",
"WMS",
"hint",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/wms/server-extension/src/main/java/org/geomajas/gwt2/plugin/wms/client/WmsServerExtension.java#L193-L198
|
145,742
|
netheosgithub/pcs_api
|
java/src/main/java/net/netheos/pcsapi/providers/hubic/Hubic.java
|
Hubic.getSwiftClient
|
private synchronized Swift getSwiftClient()
throws CStorageException
{
if ( swiftClient != null ) {
return swiftClient;
}
// Only a single thread should create this client
String url = ENDPOINT + "/account/credentials";
RequestInvoker<CResponse> ri = getApiRequestInvoker( new HttpGet( url ) );
JSONObject info = retryStrategy.invokeRetry( ri ).asJSONObject();
swiftClient = new Swift( info.getString( "endpoint" ),
info.getString( "token" ),
new NoRetryStrategy(),
true, // useDirectoryMarkers
httpExecutor );
swiftClient.useFirstContainer();
return swiftClient;
}
|
java
|
private synchronized Swift getSwiftClient()
throws CStorageException
{
if ( swiftClient != null ) {
return swiftClient;
}
// Only a single thread should create this client
String url = ENDPOINT + "/account/credentials";
RequestInvoker<CResponse> ri = getApiRequestInvoker( new HttpGet( url ) );
JSONObject info = retryStrategy.invokeRetry( ri ).asJSONObject();
swiftClient = new Swift( info.getString( "endpoint" ),
info.getString( "token" ),
new NoRetryStrategy(),
true, // useDirectoryMarkers
httpExecutor );
swiftClient.useFirstContainer();
return swiftClient;
}
|
[
"private",
"synchronized",
"Swift",
"getSwiftClient",
"(",
")",
"throws",
"CStorageException",
"{",
"if",
"(",
"swiftClient",
"!=",
"null",
")",
"{",
"return",
"swiftClient",
";",
"}",
"// Only a single thread should create this client",
"String",
"url",
"=",
"ENDPOINT",
"+",
"\"/account/credentials\"",
";",
"RequestInvoker",
"<",
"CResponse",
">",
"ri",
"=",
"getApiRequestInvoker",
"(",
"new",
"HttpGet",
"(",
"url",
")",
")",
";",
"JSONObject",
"info",
"=",
"retryStrategy",
".",
"invokeRetry",
"(",
"ri",
")",
".",
"asJSONObject",
"(",
")",
";",
"swiftClient",
"=",
"new",
"Swift",
"(",
"info",
".",
"getString",
"(",
"\"endpoint\"",
")",
",",
"info",
".",
"getString",
"(",
"\"token\"",
")",
",",
"new",
"NoRetryStrategy",
"(",
")",
",",
"true",
",",
"// useDirectoryMarkers",
"httpExecutor",
")",
";",
"swiftClient",
".",
"useFirstContainer",
"(",
")",
";",
"return",
"swiftClient",
";",
"}"
] |
Return current swift client, or create one if none exists yet. The internal swift client does NOT retry its
requests. Retries are performed by this class.
@return The swift client
|
[
"Return",
"current",
"swift",
"client",
"or",
"create",
"one",
"if",
"none",
"exists",
"yet",
".",
"The",
"internal",
"swift",
"client",
"does",
"NOT",
"retry",
"its",
"requests",
".",
"Retries",
"are",
"performed",
"by",
"this",
"class",
"."
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/providers/hubic/Hubic.java#L94-L112
|
145,743
|
geomajas/geomajas-project-client-gwt2
|
impl/src/main/java/org/geomajas/gwt2/client/map/ViewPortImpl.java
|
ViewPortImpl.getBounds
|
public Bbox getBounds() {
double w = mapWidth * getResolution();
double h = mapHeight * getResolution();
double x = getPosition().getX() - w / 2;
double y = getPosition().getY() - h / 2;
return new Bbox(x, y, w, h);
}
|
java
|
public Bbox getBounds() {
double w = mapWidth * getResolution();
double h = mapHeight * getResolution();
double x = getPosition().getX() - w / 2;
double y = getPosition().getY() - h / 2;
return new Bbox(x, y, w, h);
}
|
[
"public",
"Bbox",
"getBounds",
"(",
")",
"{",
"double",
"w",
"=",
"mapWidth",
"*",
"getResolution",
"(",
")",
";",
"double",
"h",
"=",
"mapHeight",
"*",
"getResolution",
"(",
")",
";",
"double",
"x",
"=",
"getPosition",
"(",
")",
".",
"getX",
"(",
")",
"-",
"w",
"/",
"2",
";",
"double",
"y",
"=",
"getPosition",
"(",
")",
".",
"getY",
"(",
")",
"-",
"h",
"/",
"2",
";",
"return",
"new",
"Bbox",
"(",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
";",
"}"
] |
Given the information in this ViewPort object, what is the currently visible area? This value is expressed in
world coordinates.
@return Returns the bounding box that covers the currently visible area on the map.
|
[
"Given",
"the",
"information",
"in",
"this",
"ViewPort",
"object",
"what",
"is",
"the",
"currently",
"visible",
"area?",
"This",
"value",
"is",
"expressed",
"in",
"world",
"coordinates",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/impl/src/main/java/org/geomajas/gwt2/client/map/ViewPortImpl.java#L252-L258
|
145,744
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java
|
Parse.cloneRoot
|
public Parse cloneRoot(final Parse node, final int parseIndex) {
final Parse c = (Parse) this.clone();
final Parse fc = c.parts.get(parseIndex);
c.parts.set(parseIndex, fc.clone(node));
return c;
}
|
java
|
public Parse cloneRoot(final Parse node, final int parseIndex) {
final Parse c = (Parse) this.clone();
final Parse fc = c.parts.get(parseIndex);
c.parts.set(parseIndex, fc.clone(node));
return c;
}
|
[
"public",
"Parse",
"cloneRoot",
"(",
"final",
"Parse",
"node",
",",
"final",
"int",
"parseIndex",
")",
"{",
"final",
"Parse",
"c",
"=",
"(",
"Parse",
")",
"this",
".",
"clone",
"(",
")",
";",
"final",
"Parse",
"fc",
"=",
"c",
".",
"parts",
".",
"get",
"(",
"parseIndex",
")",
";",
"c",
".",
"parts",
".",
"set",
"(",
"parseIndex",
",",
"fc",
".",
"clone",
"(",
"node",
")",
")",
";",
"return",
"c",
";",
"}"
] |
Clones the right frontier of this root parse up to and including the
specified node.
@param node
The last node in the right frontier of the parse tree which should
be cloned.
@param parseIndex
The child index of the parse for this root node.
@return A clone of this root parse and its right frontier up to and
including the specified node.
|
[
"Clones",
"the",
"right",
"frontier",
"of",
"this",
"root",
"parse",
"up",
"to",
"and",
"including",
"the",
"specified",
"node",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java#L236-L241
|
145,745
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java
|
Parse.addPreviousPunctuation
|
public void addPreviousPunctuation(final Parse punct) {
if (this.prevPunctSet == null) {
this.prevPunctSet = new TreeSet<Parse>();
}
this.prevPunctSet.add(punct);
}
|
java
|
public void addPreviousPunctuation(final Parse punct) {
if (this.prevPunctSet == null) {
this.prevPunctSet = new TreeSet<Parse>();
}
this.prevPunctSet.add(punct);
}
|
[
"public",
"void",
"addPreviousPunctuation",
"(",
"final",
"Parse",
"punct",
")",
"{",
"if",
"(",
"this",
".",
"prevPunctSet",
"==",
"null",
")",
"{",
"this",
".",
"prevPunctSet",
"=",
"new",
"TreeSet",
"<",
"Parse",
">",
"(",
")",
";",
"}",
"this",
".",
"prevPunctSet",
".",
"add",
"(",
"punct",
")",
";",
"}"
] |
Designates that the specified punctuation should is prior to this parse.
@param punct
The punctuation.
|
[
"Designates",
"that",
"the",
"specified",
"punctuation",
"should",
"is",
"prior",
"to",
"this",
"parse",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java#L290-L295
|
145,746
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java
|
Parse.addNextPunctuation
|
public void addNextPunctuation(final Parse punct) {
if (this.nextPunctSet == null) {
this.nextPunctSet = new TreeSet<Parse>();
}
this.nextPunctSet.add(punct);
}
|
java
|
public void addNextPunctuation(final Parse punct) {
if (this.nextPunctSet == null) {
this.nextPunctSet = new TreeSet<Parse>();
}
this.nextPunctSet.add(punct);
}
|
[
"public",
"void",
"addNextPunctuation",
"(",
"final",
"Parse",
"punct",
")",
"{",
"if",
"(",
"this",
".",
"nextPunctSet",
"==",
"null",
")",
"{",
"this",
".",
"nextPunctSet",
"=",
"new",
"TreeSet",
"<",
"Parse",
">",
"(",
")",
";",
"}",
"this",
".",
"nextPunctSet",
".",
"add",
"(",
"punct",
")",
";",
"}"
] |
Designates that the specified punctuation follows this parse.
@param punct
The punctuation set.
|
[
"Designates",
"that",
"the",
"specified",
"punctuation",
"follows",
"this",
"parse",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java#L314-L319
|
145,747
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java
|
Parse.show
|
public void show() {
final StringBuffer sb = new StringBuffer(this.text.length() * 4);
show(sb);
System.out.println(sb);
}
|
java
|
public void show() {
final StringBuffer sb = new StringBuffer(this.text.length() * 4);
show(sb);
System.out.println(sb);
}
|
[
"public",
"void",
"show",
"(",
")",
"{",
"final",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
"this",
".",
"text",
".",
"length",
"(",
")",
"*",
"4",
")",
";",
"show",
"(",
"sb",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"sb",
")",
";",
"}"
] |
Displays this parse using Penn Treebank-style formatting.
|
[
"Displays",
"this",
"parse",
"using",
"Penn",
"Treebank",
"-",
"style",
"formatting",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java#L427-L431
|
145,748
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java
|
Parse.getTagSequenceProb
|
public double getTagSequenceProb() {
// System.err.println("Parse.getTagSequenceProb: "+type+" "+this);
if (this.parts.size() == 1
&& this.parts.get(0).type.equals(ShiftReduceParser.TOK_NODE)) {
// System.err.println(this+" "+prob);
return Math.log(this.prob);
} else if (this.parts.size() == 0) {
System.err.println("Parse.getTagSequenceProb: Wrong base case!");
return 0.0;
} else {
double sum = 0.0;
for (final Parse parse : this.parts) {
sum += parse.getTagSequenceProb();
}
return sum;
}
}
|
java
|
public double getTagSequenceProb() {
// System.err.println("Parse.getTagSequenceProb: "+type+" "+this);
if (this.parts.size() == 1
&& this.parts.get(0).type.equals(ShiftReduceParser.TOK_NODE)) {
// System.err.println(this+" "+prob);
return Math.log(this.prob);
} else if (this.parts.size() == 0) {
System.err.println("Parse.getTagSequenceProb: Wrong base case!");
return 0.0;
} else {
double sum = 0.0;
for (final Parse parse : this.parts) {
sum += parse.getTagSequenceProb();
}
return sum;
}
}
|
[
"public",
"double",
"getTagSequenceProb",
"(",
")",
"{",
"// System.err.println(\"Parse.getTagSequenceProb: \"+type+\" \"+this);",
"if",
"(",
"this",
".",
"parts",
".",
"size",
"(",
")",
"==",
"1",
"&&",
"this",
".",
"parts",
".",
"get",
"(",
"0",
")",
".",
"type",
".",
"equals",
"(",
"ShiftReduceParser",
".",
"TOK_NODE",
")",
")",
"{",
"// System.err.println(this+\" \"+prob);",
"return",
"Math",
".",
"log",
"(",
"this",
".",
"prob",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"parts",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Parse.getTagSequenceProb: Wrong base case!\"",
")",
";",
"return",
"0.0",
";",
"}",
"else",
"{",
"double",
"sum",
"=",
"0.0",
";",
"for",
"(",
"final",
"Parse",
"parse",
":",
"this",
".",
"parts",
")",
"{",
"sum",
"+=",
"parse",
".",
"getTagSequenceProb",
"(",
")",
";",
"}",
"return",
"sum",
";",
"}",
"}"
] |
Returns the probability associated with the pos-tag sequence assigned to
this parse.
@return The probability associated with the pos-tag sequence assigned to
this parse.
|
[
"Returns",
"the",
"probability",
"associated",
"with",
"the",
"pos",
"-",
"tag",
"sequence",
"assigned",
"to",
"this",
"parse",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java#L440-L456
|
145,749
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java
|
Parse.setChild
|
public void setChild(final int index, final String label) {
final Parse newChild = (Parse) this.parts.get(index).clone();
newChild.setLabel(label);
this.parts.set(index, newChild);
}
|
java
|
public void setChild(final int index, final String label) {
final Parse newChild = (Parse) this.parts.get(index).clone();
newChild.setLabel(label);
this.parts.set(index, newChild);
}
|
[
"public",
"void",
"setChild",
"(",
"final",
"int",
"index",
",",
"final",
"String",
"label",
")",
"{",
"final",
"Parse",
"newChild",
"=",
"(",
"Parse",
")",
"this",
".",
"parts",
".",
"get",
"(",
"index",
")",
".",
"clone",
"(",
")",
";",
"newChild",
".",
"setLabel",
"(",
"label",
")",
";",
"this",
".",
"parts",
".",
"set",
"(",
"index",
",",
"newChild",
")",
";",
"}"
] |
Replaces the child at the specified index with a new child with the
specified label.
@param index
The index of the child to be replaced.
@param label
The label to be assigned to the new child.
|
[
"Replaces",
"the",
"child",
"at",
"the",
"specified",
"index",
"with",
"a",
"new",
"child",
"with",
"the",
"specified",
"label",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java#L542-L546
|
145,750
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java
|
Parse.adjoin
|
public Parse adjoin(final Parse sister, final HeadRules rules) {
final Parse lastChild = this.parts.get(this.parts.size() - 1);
final Parse adjNode = new Parse(this.text,
new Span(lastChild.getSpan().getStart(), sister.getSpan().getEnd()),
lastChild.getType(), 1,
rules.getHead(new Parse[] { lastChild, sister }, lastChild.getType()));
adjNode.parts.add(lastChild);
if (sister.prevPunctSet != null) {
adjNode.parts.addAll(sister.prevPunctSet);
}
adjNode.parts.add(sister);
this.parts.set(this.parts.size() - 1, adjNode);
this.span = new Span(this.span.getStart(), sister.getSpan().getEnd());
this.head = rules.getHead(getChildren(), this.type);
this.headIndex = this.head.headIndex;
return adjNode;
}
|
java
|
public Parse adjoin(final Parse sister, final HeadRules rules) {
final Parse lastChild = this.parts.get(this.parts.size() - 1);
final Parse adjNode = new Parse(this.text,
new Span(lastChild.getSpan().getStart(), sister.getSpan().getEnd()),
lastChild.getType(), 1,
rules.getHead(new Parse[] { lastChild, sister }, lastChild.getType()));
adjNode.parts.add(lastChild);
if (sister.prevPunctSet != null) {
adjNode.parts.addAll(sister.prevPunctSet);
}
adjNode.parts.add(sister);
this.parts.set(this.parts.size() - 1, adjNode);
this.span = new Span(this.span.getStart(), sister.getSpan().getEnd());
this.head = rules.getHead(getChildren(), this.type);
this.headIndex = this.head.headIndex;
return adjNode;
}
|
[
"public",
"Parse",
"adjoin",
"(",
"final",
"Parse",
"sister",
",",
"final",
"HeadRules",
"rules",
")",
"{",
"final",
"Parse",
"lastChild",
"=",
"this",
".",
"parts",
".",
"get",
"(",
"this",
".",
"parts",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"final",
"Parse",
"adjNode",
"=",
"new",
"Parse",
"(",
"this",
".",
"text",
",",
"new",
"Span",
"(",
"lastChild",
".",
"getSpan",
"(",
")",
".",
"getStart",
"(",
")",
",",
"sister",
".",
"getSpan",
"(",
")",
".",
"getEnd",
"(",
")",
")",
",",
"lastChild",
".",
"getType",
"(",
")",
",",
"1",
",",
"rules",
".",
"getHead",
"(",
"new",
"Parse",
"[",
"]",
"{",
"lastChild",
",",
"sister",
"}",
",",
"lastChild",
".",
"getType",
"(",
")",
")",
")",
";",
"adjNode",
".",
"parts",
".",
"add",
"(",
"lastChild",
")",
";",
"if",
"(",
"sister",
".",
"prevPunctSet",
"!=",
"null",
")",
"{",
"adjNode",
".",
"parts",
".",
"addAll",
"(",
"sister",
".",
"prevPunctSet",
")",
";",
"}",
"adjNode",
".",
"parts",
".",
"add",
"(",
"sister",
")",
";",
"this",
".",
"parts",
".",
"set",
"(",
"this",
".",
"parts",
".",
"size",
"(",
")",
"-",
"1",
",",
"adjNode",
")",
";",
"this",
".",
"span",
"=",
"new",
"Span",
"(",
"this",
".",
"span",
".",
"getStart",
"(",
")",
",",
"sister",
".",
"getSpan",
"(",
")",
".",
"getEnd",
"(",
")",
")",
";",
"this",
".",
"head",
"=",
"rules",
".",
"getHead",
"(",
"getChildren",
"(",
")",
",",
"this",
".",
"type",
")",
";",
"this",
".",
"headIndex",
"=",
"this",
".",
"head",
".",
"headIndex",
";",
"return",
"adjNode",
";",
"}"
] |
Sister adjoins this node's last child and the specified sister node and
returns their new parent node. The new parent node replace this nodes last
child.
@param sister
The node to be adjoined.
@param rules
The head rules for the parser.
@return The new parent node of this node and the specified sister node.
|
[
"Sister",
"adjoins",
"this",
"node",
"s",
"last",
"child",
"and",
"the",
"specified",
"sister",
"node",
"and",
"returns",
"their",
"new",
"parent",
"node",
".",
"The",
"new",
"parent",
"node",
"replace",
"this",
"nodes",
"last",
"child",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java#L599-L615
|
145,751
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java
|
Parse.pruneParse
|
public static void pruneParse(final Parse parse) {
final List<Parse> nodes = new LinkedList<Parse>();
nodes.add(parse);
while (nodes.size() != 0) {
final Parse node = nodes.remove(0);
final Parse[] children = node.getChildren();
if (children.length == 1
&& node.getType().equals(children[0].getType())) {
final int index = node.getParent().parts.indexOf(node);
children[0].setParent(node.getParent());
node.getParent().parts.set(index, children[0]);
node.parent = null;
node.parts = null;
}
nodes.addAll(Arrays.asList(children));
}
}
|
java
|
public static void pruneParse(final Parse parse) {
final List<Parse> nodes = new LinkedList<Parse>();
nodes.add(parse);
while (nodes.size() != 0) {
final Parse node = nodes.remove(0);
final Parse[] children = node.getChildren();
if (children.length == 1
&& node.getType().equals(children[0].getType())) {
final int index = node.getParent().parts.indexOf(node);
children[0].setParent(node.getParent());
node.getParent().parts.set(index, children[0]);
node.parent = null;
node.parts = null;
}
nodes.addAll(Arrays.asList(children));
}
}
|
[
"public",
"static",
"void",
"pruneParse",
"(",
"final",
"Parse",
"parse",
")",
"{",
"final",
"List",
"<",
"Parse",
">",
"nodes",
"=",
"new",
"LinkedList",
"<",
"Parse",
">",
"(",
")",
";",
"nodes",
".",
"add",
"(",
"parse",
")",
";",
"while",
"(",
"nodes",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"final",
"Parse",
"node",
"=",
"nodes",
".",
"remove",
"(",
"0",
")",
";",
"final",
"Parse",
"[",
"]",
"children",
"=",
"node",
".",
"getChildren",
"(",
")",
";",
"if",
"(",
"children",
".",
"length",
"==",
"1",
"&&",
"node",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"children",
"[",
"0",
"]",
".",
"getType",
"(",
")",
")",
")",
"{",
"final",
"int",
"index",
"=",
"node",
".",
"getParent",
"(",
")",
".",
"parts",
".",
"indexOf",
"(",
"node",
")",
";",
"children",
"[",
"0",
"]",
".",
"setParent",
"(",
"node",
".",
"getParent",
"(",
")",
")",
";",
"node",
".",
"getParent",
"(",
")",
".",
"parts",
".",
"set",
"(",
"index",
",",
"children",
"[",
"0",
"]",
")",
";",
"node",
".",
"parent",
"=",
"null",
";",
"node",
".",
"parts",
"=",
"null",
";",
"}",
"nodes",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"children",
")",
")",
";",
"}",
"}"
] |
Prune the specified sentence parse of vacuous productions.
@param parse
the parse tree
|
[
"Prune",
"the",
"specified",
"sentence",
"parse",
"of",
"vacuous",
"productions",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java#L826-L842
|
145,752
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java
|
Parse.isFlat
|
public boolean isFlat() {
boolean flat = true;
for (int ci = 0; ci < this.parts.size(); ci++) {
flat &= this.parts.get(ci).isPosTag();
}
return flat;
}
|
java
|
public boolean isFlat() {
boolean flat = true;
for (int ci = 0; ci < this.parts.size(); ci++) {
flat &= this.parts.get(ci).isPosTag();
}
return flat;
}
|
[
"public",
"boolean",
"isFlat",
"(",
")",
"{",
"boolean",
"flat",
"=",
"true",
";",
"for",
"(",
"int",
"ci",
"=",
"0",
";",
"ci",
"<",
"this",
".",
"parts",
".",
"size",
"(",
")",
";",
"ci",
"++",
")",
"{",
"flat",
"&=",
"this",
".",
"parts",
".",
"get",
"(",
"ci",
")",
".",
"isPosTag",
"(",
")",
";",
"}",
"return",
"flat",
";",
"}"
] |
Returns true if this constituent contains no sub-constituents.
@return true if this constituent contains no sub-constituents; false
otherwise.
|
[
"Returns",
"true",
"if",
"this",
"constituent",
"contains",
"no",
"sub",
"-",
"constituents",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java#L982-L988
|
145,753
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java
|
Parse.getTagNodes
|
public Parse[] getTagNodes() {
final List<Parse> tags = new LinkedList<Parse>();
final List<Parse> nodes = new LinkedList<Parse>();
nodes.addAll(this.parts);
while (nodes.size() != 0) {
final Parse p = nodes.remove(0);
if (p.isPosTag()) {
tags.add(p);
} else {
nodes.addAll(0, p.parts);
}
}
return tags.toArray(new Parse[tags.size()]);
}
|
java
|
public Parse[] getTagNodes() {
final List<Parse> tags = new LinkedList<Parse>();
final List<Parse> nodes = new LinkedList<Parse>();
nodes.addAll(this.parts);
while (nodes.size() != 0) {
final Parse p = nodes.remove(0);
if (p.isPosTag()) {
tags.add(p);
} else {
nodes.addAll(0, p.parts);
}
}
return tags.toArray(new Parse[tags.size()]);
}
|
[
"public",
"Parse",
"[",
"]",
"getTagNodes",
"(",
")",
"{",
"final",
"List",
"<",
"Parse",
">",
"tags",
"=",
"new",
"LinkedList",
"<",
"Parse",
">",
"(",
")",
";",
"final",
"List",
"<",
"Parse",
">",
"nodes",
"=",
"new",
"LinkedList",
"<",
"Parse",
">",
"(",
")",
";",
"nodes",
".",
"addAll",
"(",
"this",
".",
"parts",
")",
";",
"while",
"(",
"nodes",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"final",
"Parse",
"p",
"=",
"nodes",
".",
"remove",
"(",
"0",
")",
";",
"if",
"(",
"p",
".",
"isPosTag",
"(",
")",
")",
"{",
"tags",
".",
"add",
"(",
"p",
")",
";",
"}",
"else",
"{",
"nodes",
".",
"addAll",
"(",
"0",
",",
"p",
".",
"parts",
")",
";",
"}",
"}",
"return",
"tags",
".",
"toArray",
"(",
"new",
"Parse",
"[",
"tags",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Returns the parse nodes which are children of this node and which are pos
tags.
@return the parse nodes which are children of this node and which are pos
tags.
|
[
"Returns",
"the",
"parse",
"nodes",
"which",
"are",
"children",
"of",
"this",
"node",
"and",
"which",
"are",
"pos",
"tags",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java#L1005-L1018
|
145,754
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java
|
Parse.addNames
|
public static void addNames(final String tag, final Span[] names,
final Parse[] tokens) {
for (final Span nameTokenSpan : names) {
final Parse startToken = tokens[nameTokenSpan.getStart()];
final Parse endToken = tokens[nameTokenSpan.getEnd() - 1];
final Parse commonParent = startToken.getCommonParent(endToken);
// System.err.println("addNames: "+startToken+" .. "+endToken+"
// commonParent = "+commonParent);
if (commonParent != null) {
final Span nameSpan = new Span(startToken.getSpan().getStart(),
endToken.getSpan().getEnd());
if (nameSpan.equals(commonParent.getSpan())) {
commonParent.insert(new Parse(commonParent.getText(), nameSpan, tag,
1.0, endToken.getHeadIndex()));
} else {
final Parse[] kids = commonParent.getChildren();
boolean crossingKids = false;
for (final Parse kid : kids) {
if (nameSpan.crosses(kid.getSpan())) {
crossingKids = true;
}
}
if (!crossingKids) {
commonParent.insert(new Parse(commonParent.getText(), nameSpan, tag,
1.0, endToken.getHeadIndex()));
} else {
if (commonParent.getType().equals("NP")) {
final Parse[] grandKids = kids[0].getChildren();
if (grandKids.length > 1 && nameSpan
.contains(grandKids[grandKids.length - 1].getSpan())) {
commonParent.insert(
new Parse(commonParent.getText(), commonParent.getSpan(),
tag, 1.0, commonParent.getHeadIndex()));
}
}
}
}
}
}
}
|
java
|
public static void addNames(final String tag, final Span[] names,
final Parse[] tokens) {
for (final Span nameTokenSpan : names) {
final Parse startToken = tokens[nameTokenSpan.getStart()];
final Parse endToken = tokens[nameTokenSpan.getEnd() - 1];
final Parse commonParent = startToken.getCommonParent(endToken);
// System.err.println("addNames: "+startToken+" .. "+endToken+"
// commonParent = "+commonParent);
if (commonParent != null) {
final Span nameSpan = new Span(startToken.getSpan().getStart(),
endToken.getSpan().getEnd());
if (nameSpan.equals(commonParent.getSpan())) {
commonParent.insert(new Parse(commonParent.getText(), nameSpan, tag,
1.0, endToken.getHeadIndex()));
} else {
final Parse[] kids = commonParent.getChildren();
boolean crossingKids = false;
for (final Parse kid : kids) {
if (nameSpan.crosses(kid.getSpan())) {
crossingKids = true;
}
}
if (!crossingKids) {
commonParent.insert(new Parse(commonParent.getText(), nameSpan, tag,
1.0, endToken.getHeadIndex()));
} else {
if (commonParent.getType().equals("NP")) {
final Parse[] grandKids = kids[0].getChildren();
if (grandKids.length > 1 && nameSpan
.contains(grandKids[grandKids.length - 1].getSpan())) {
commonParent.insert(
new Parse(commonParent.getText(), commonParent.getSpan(),
tag, 1.0, commonParent.getHeadIndex()));
}
}
}
}
}
}
}
|
[
"public",
"static",
"void",
"addNames",
"(",
"final",
"String",
"tag",
",",
"final",
"Span",
"[",
"]",
"names",
",",
"final",
"Parse",
"[",
"]",
"tokens",
")",
"{",
"for",
"(",
"final",
"Span",
"nameTokenSpan",
":",
"names",
")",
"{",
"final",
"Parse",
"startToken",
"=",
"tokens",
"[",
"nameTokenSpan",
".",
"getStart",
"(",
")",
"]",
";",
"final",
"Parse",
"endToken",
"=",
"tokens",
"[",
"nameTokenSpan",
".",
"getEnd",
"(",
")",
"-",
"1",
"]",
";",
"final",
"Parse",
"commonParent",
"=",
"startToken",
".",
"getCommonParent",
"(",
"endToken",
")",
";",
"// System.err.println(\"addNames: \"+startToken+\" .. \"+endToken+\"",
"// commonParent = \"+commonParent);",
"if",
"(",
"commonParent",
"!=",
"null",
")",
"{",
"final",
"Span",
"nameSpan",
"=",
"new",
"Span",
"(",
"startToken",
".",
"getSpan",
"(",
")",
".",
"getStart",
"(",
")",
",",
"endToken",
".",
"getSpan",
"(",
")",
".",
"getEnd",
"(",
")",
")",
";",
"if",
"(",
"nameSpan",
".",
"equals",
"(",
"commonParent",
".",
"getSpan",
"(",
")",
")",
")",
"{",
"commonParent",
".",
"insert",
"(",
"new",
"Parse",
"(",
"commonParent",
".",
"getText",
"(",
")",
",",
"nameSpan",
",",
"tag",
",",
"1.0",
",",
"endToken",
".",
"getHeadIndex",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"final",
"Parse",
"[",
"]",
"kids",
"=",
"commonParent",
".",
"getChildren",
"(",
")",
";",
"boolean",
"crossingKids",
"=",
"false",
";",
"for",
"(",
"final",
"Parse",
"kid",
":",
"kids",
")",
"{",
"if",
"(",
"nameSpan",
".",
"crosses",
"(",
"kid",
".",
"getSpan",
"(",
")",
")",
")",
"{",
"crossingKids",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"crossingKids",
")",
"{",
"commonParent",
".",
"insert",
"(",
"new",
"Parse",
"(",
"commonParent",
".",
"getText",
"(",
")",
",",
"nameSpan",
",",
"tag",
",",
"1.0",
",",
"endToken",
".",
"getHeadIndex",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"commonParent",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"\"NP\"",
")",
")",
"{",
"final",
"Parse",
"[",
"]",
"grandKids",
"=",
"kids",
"[",
"0",
"]",
".",
"getChildren",
"(",
")",
";",
"if",
"(",
"grandKids",
".",
"length",
">",
"1",
"&&",
"nameSpan",
".",
"contains",
"(",
"grandKids",
"[",
"grandKids",
".",
"length",
"-",
"1",
"]",
".",
"getSpan",
"(",
")",
")",
")",
"{",
"commonParent",
".",
"insert",
"(",
"new",
"Parse",
"(",
"commonParent",
".",
"getText",
"(",
")",
",",
"commonParent",
".",
"getSpan",
"(",
")",
",",
"tag",
",",
"1.0",
",",
"commonParent",
".",
"getHeadIndex",
"(",
")",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"}"
] |
Utility method to inserts named entities.
@param tag
the tags
@param names
the spans
@param tokens
the tokens
|
[
"Utility",
"method",
"to",
"inserts",
"named",
"entities",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java#L1158-L1197
|
145,755
|
netheosgithub/pcs_api
|
java/src/main/java/net/netheos/pcsapi/models/CMetadata.java
|
CMetadata.put
|
public void put( String key, String value )
throws IllegalArgumentException
{
if ( !key.matches( "[a-z-]*" ) ) {
throw new IllegalArgumentException( "The key must contains letters and dash" );
}
// Check value is ASCII
for ( char c : value.toCharArray() ) {
if ( c < 32 || c > 127 ) {
throw new IllegalArgumentException( "The metadata value is not ASCII encoded" );
}
}
map.put( key, value );
}
|
java
|
public void put( String key, String value )
throws IllegalArgumentException
{
if ( !key.matches( "[a-z-]*" ) ) {
throw new IllegalArgumentException( "The key must contains letters and dash" );
}
// Check value is ASCII
for ( char c : value.toCharArray() ) {
if ( c < 32 || c > 127 ) {
throw new IllegalArgumentException( "The metadata value is not ASCII encoded" );
}
}
map.put( key, value );
}
|
[
"public",
"void",
"put",
"(",
"String",
"key",
",",
"String",
"value",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"!",
"key",
".",
"matches",
"(",
"\"[a-z-]*\"",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The key must contains letters and dash\"",
")",
";",
"}",
"// Check value is ASCII",
"for",
"(",
"char",
"c",
":",
"value",
".",
"toCharArray",
"(",
")",
")",
"{",
"if",
"(",
"c",
"<",
"32",
"||",
"c",
">",
"127",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The metadata value is not ASCII encoded\"",
")",
";",
"}",
"}",
"map",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}"
] |
Add a value in metadata
@param key The unique key linked to the value (must be lower case)
@param value The metadata value (must contains only ASCII characters)
@throws IllegalArgumentException If the key or value is badly formatted
|
[
"Add",
"a",
"value",
"in",
"metadata"
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/models/CMetadata.java#L47-L60
|
145,756
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/document/features/DocumentModelResources.java
|
DocumentModelResources.loadResource
|
public static void loadResource(final String serializerId,
@SuppressWarnings("rawtypes") final Map<String, ArtifactSerializer> artifactSerializers,
final String resourcePath, final Map<String, Object> resources) {
final File resourceFile = new File(resourcePath);
if (resourceFile != null) {
final String resourceId = IOUtils
.normalizeLexiconName(resourceFile.getName());
final ArtifactSerializer<?> serializer = artifactSerializers
.get(serializerId);
final InputStream resourceIn = IOUtils.openFromFile(resourceFile);
try {
resources.put(resourceId, serializer.create(resourceIn));
} catch (final InvalidFormatException e) {
e.printStackTrace();
} catch (final IOException e) {
e.printStackTrace();
} finally {
try {
resourceIn.close();
} catch (final IOException e) {
}
}
}
}
|
java
|
public static void loadResource(final String serializerId,
@SuppressWarnings("rawtypes") final Map<String, ArtifactSerializer> artifactSerializers,
final String resourcePath, final Map<String, Object> resources) {
final File resourceFile = new File(resourcePath);
if (resourceFile != null) {
final String resourceId = IOUtils
.normalizeLexiconName(resourceFile.getName());
final ArtifactSerializer<?> serializer = artifactSerializers
.get(serializerId);
final InputStream resourceIn = IOUtils.openFromFile(resourceFile);
try {
resources.put(resourceId, serializer.create(resourceIn));
} catch (final InvalidFormatException e) {
e.printStackTrace();
} catch (final IOException e) {
e.printStackTrace();
} finally {
try {
resourceIn.close();
} catch (final IOException e) {
}
}
}
}
|
[
"public",
"static",
"void",
"loadResource",
"(",
"final",
"String",
"serializerId",
",",
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"final",
"Map",
"<",
"String",
",",
"ArtifactSerializer",
">",
"artifactSerializers",
",",
"final",
"String",
"resourcePath",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"resources",
")",
"{",
"final",
"File",
"resourceFile",
"=",
"new",
"File",
"(",
"resourcePath",
")",
";",
"if",
"(",
"resourceFile",
"!=",
"null",
")",
"{",
"final",
"String",
"resourceId",
"=",
"IOUtils",
".",
"normalizeLexiconName",
"(",
"resourceFile",
".",
"getName",
"(",
")",
")",
";",
"final",
"ArtifactSerializer",
"<",
"?",
">",
"serializer",
"=",
"artifactSerializers",
".",
"get",
"(",
"serializerId",
")",
";",
"final",
"InputStream",
"resourceIn",
"=",
"IOUtils",
".",
"openFromFile",
"(",
"resourceFile",
")",
";",
"try",
"{",
"resources",
".",
"put",
"(",
"resourceId",
",",
"serializer",
".",
"create",
"(",
"resourceIn",
")",
")",
";",
"}",
"catch",
"(",
"final",
"InvalidFormatException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"resourceIn",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"}",
"}",
"}",
"}"
] |
Load a resource by resourceId.
@param serializerId
the serializer id
@param artifactSerializers
the serializers in which to put the resource
@param resourcePath
the canonical path of the resource
@param resources
the map in which to put the resource
|
[
"Load",
"a",
"resource",
"by",
"resourceId",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/document/features/DocumentModelResources.java#L288-L312
|
145,757
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/resources/Dictionary.java
|
Dictionary.getBioDictionaryMatch
|
public List<String> getBioDictionaryMatch(final String[] tokens) {
final List<String> entitiesList = new ArrayList<String>();
String prefix = "-" + BioCodec.START;
String gazEntry = null;
String searchSpan = null;
// iterative over tokens from the beginning
for (int i = 0; i < tokens.length; i++) {
gazEntry = null;
int j;
// iterate over tokens from the end
for (j = tokens.length - 1; j >= i; j--) {
// create span for search in dictionary Map; the first search takes as
// span
// the whole sentence
searchSpan = createSpan(tokens, i, j);
gazEntry = lookup(searchSpan.toLowerCase());
if (gazEntry != null) {
break;
}
}
prefix = "-" + BioCodec.START;
// multi-token case
if (gazEntry != null) {
while (i < j) {
entitiesList.add((gazEntry + prefix).intern());
prefix = "-" + BioCodec.CONTINUE;
i++;
}
}
// one word case or last member of span
if (gazEntry != null) {
entitiesList.add((gazEntry + prefix).intern());
} else {
entitiesList.add(BioCodec.OTHER);
}
}
return entitiesList;
}
|
java
|
public List<String> getBioDictionaryMatch(final String[] tokens) {
final List<String> entitiesList = new ArrayList<String>();
String prefix = "-" + BioCodec.START;
String gazEntry = null;
String searchSpan = null;
// iterative over tokens from the beginning
for (int i = 0; i < tokens.length; i++) {
gazEntry = null;
int j;
// iterate over tokens from the end
for (j = tokens.length - 1; j >= i; j--) {
// create span for search in dictionary Map; the first search takes as
// span
// the whole sentence
searchSpan = createSpan(tokens, i, j);
gazEntry = lookup(searchSpan.toLowerCase());
if (gazEntry != null) {
break;
}
}
prefix = "-" + BioCodec.START;
// multi-token case
if (gazEntry != null) {
while (i < j) {
entitiesList.add((gazEntry + prefix).intern());
prefix = "-" + BioCodec.CONTINUE;
i++;
}
}
// one word case or last member of span
if (gazEntry != null) {
entitiesList.add((gazEntry + prefix).intern());
} else {
entitiesList.add(BioCodec.OTHER);
}
}
return entitiesList;
}
|
[
"public",
"List",
"<",
"String",
">",
"getBioDictionaryMatch",
"(",
"final",
"String",
"[",
"]",
"tokens",
")",
"{",
"final",
"List",
"<",
"String",
">",
"entitiesList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"String",
"prefix",
"=",
"\"-\"",
"+",
"BioCodec",
".",
"START",
";",
"String",
"gazEntry",
"=",
"null",
";",
"String",
"searchSpan",
"=",
"null",
";",
"// iterative over tokens from the beginning",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tokens",
".",
"length",
";",
"i",
"++",
")",
"{",
"gazEntry",
"=",
"null",
";",
"int",
"j",
";",
"// iterate over tokens from the end",
"for",
"(",
"j",
"=",
"tokens",
".",
"length",
"-",
"1",
";",
"j",
">=",
"i",
";",
"j",
"--",
")",
"{",
"// create span for search in dictionary Map; the first search takes as",
"// span",
"// the whole sentence",
"searchSpan",
"=",
"createSpan",
"(",
"tokens",
",",
"i",
",",
"j",
")",
";",
"gazEntry",
"=",
"lookup",
"(",
"searchSpan",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"gazEntry",
"!=",
"null",
")",
"{",
"break",
";",
"}",
"}",
"prefix",
"=",
"\"-\"",
"+",
"BioCodec",
".",
"START",
";",
"// multi-token case",
"if",
"(",
"gazEntry",
"!=",
"null",
")",
"{",
"while",
"(",
"i",
"<",
"j",
")",
"{",
"entitiesList",
".",
"add",
"(",
"(",
"gazEntry",
"+",
"prefix",
")",
".",
"intern",
"(",
")",
")",
";",
"prefix",
"=",
"\"-\"",
"+",
"BioCodec",
".",
"CONTINUE",
";",
"i",
"++",
";",
"}",
"}",
"// one word case or last member of span",
"if",
"(",
"gazEntry",
"!=",
"null",
")",
"{",
"entitiesList",
".",
"add",
"(",
"(",
"gazEntry",
"+",
"prefix",
")",
".",
"intern",
"(",
")",
")",
";",
"}",
"else",
"{",
"entitiesList",
".",
"add",
"(",
"BioCodec",
".",
"OTHER",
")",
";",
"}",
"}",
"return",
"entitiesList",
";",
"}"
] |
Performs gazetteer match in a bio encoding.
@param tokens
the sentence
@return the list of named entities in the current sentence
|
[
"Performs",
"gazetteer",
"match",
"in",
"a",
"bio",
"encoding",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/resources/Dictionary.java#L120-L159
|
145,758
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/resources/Dictionary.java
|
Dictionary.getBilouDictionaryMatch
|
public List<String> getBilouDictionaryMatch(final String[] tokens) {
final List<String> entitiesList = new ArrayList<String>();
String prefix = "-" + BilouCodec.START;
String gazClass = null;
String searchSpan = null;
// iterative over tokens from the beginning
for (int i = 0; i < tokens.length; i++) {
gazClass = null;
int j;
// iterate over tokens from the end
for (j = tokens.length - 1; j >= i; j--) {
// create span for search in dictionary Map; the first search takes as
// span
// the whole sentence
searchSpan = createSpan(tokens, i, j);
gazClass = lookup(searchSpan.toLowerCase());
if (gazClass != null) {
break;
}
}
prefix = "-" + BilouCodec.START;
// multi-token case
if (gazClass != null) {
while (i < j) {
entitiesList.add((gazClass + prefix).intern());
prefix = "-" + BilouCodec.CONTINUE;
i++;
}
}
// one word case or last member of span
if (gazClass != null) {
if (prefix.equals("-" + BilouCodec.START)) {
entitiesList.add((gazClass + "-" + BilouCodec.UNIT).intern());
} else if (prefix.equals("-" + BilouCodec.CONTINUE)) {
entitiesList.add((gazClass + "-" + BilouCodec.LAST).intern());
}
} else {
entitiesList.add(BilouCodec.OTHER);
}
}
return entitiesList;
}
|
java
|
public List<String> getBilouDictionaryMatch(final String[] tokens) {
final List<String> entitiesList = new ArrayList<String>();
String prefix = "-" + BilouCodec.START;
String gazClass = null;
String searchSpan = null;
// iterative over tokens from the beginning
for (int i = 0; i < tokens.length; i++) {
gazClass = null;
int j;
// iterate over tokens from the end
for (j = tokens.length - 1; j >= i; j--) {
// create span for search in dictionary Map; the first search takes as
// span
// the whole sentence
searchSpan = createSpan(tokens, i, j);
gazClass = lookup(searchSpan.toLowerCase());
if (gazClass != null) {
break;
}
}
prefix = "-" + BilouCodec.START;
// multi-token case
if (gazClass != null) {
while (i < j) {
entitiesList.add((gazClass + prefix).intern());
prefix = "-" + BilouCodec.CONTINUE;
i++;
}
}
// one word case or last member of span
if (gazClass != null) {
if (prefix.equals("-" + BilouCodec.START)) {
entitiesList.add((gazClass + "-" + BilouCodec.UNIT).intern());
} else if (prefix.equals("-" + BilouCodec.CONTINUE)) {
entitiesList.add((gazClass + "-" + BilouCodec.LAST).intern());
}
} else {
entitiesList.add(BilouCodec.OTHER);
}
}
return entitiesList;
}
|
[
"public",
"List",
"<",
"String",
">",
"getBilouDictionaryMatch",
"(",
"final",
"String",
"[",
"]",
"tokens",
")",
"{",
"final",
"List",
"<",
"String",
">",
"entitiesList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"String",
"prefix",
"=",
"\"-\"",
"+",
"BilouCodec",
".",
"START",
";",
"String",
"gazClass",
"=",
"null",
";",
"String",
"searchSpan",
"=",
"null",
";",
"// iterative over tokens from the beginning",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tokens",
".",
"length",
";",
"i",
"++",
")",
"{",
"gazClass",
"=",
"null",
";",
"int",
"j",
";",
"// iterate over tokens from the end",
"for",
"(",
"j",
"=",
"tokens",
".",
"length",
"-",
"1",
";",
"j",
">=",
"i",
";",
"j",
"--",
")",
"{",
"// create span for search in dictionary Map; the first search takes as",
"// span",
"// the whole sentence",
"searchSpan",
"=",
"createSpan",
"(",
"tokens",
",",
"i",
",",
"j",
")",
";",
"gazClass",
"=",
"lookup",
"(",
"searchSpan",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"gazClass",
"!=",
"null",
")",
"{",
"break",
";",
"}",
"}",
"prefix",
"=",
"\"-\"",
"+",
"BilouCodec",
".",
"START",
";",
"// multi-token case",
"if",
"(",
"gazClass",
"!=",
"null",
")",
"{",
"while",
"(",
"i",
"<",
"j",
")",
"{",
"entitiesList",
".",
"add",
"(",
"(",
"gazClass",
"+",
"prefix",
")",
".",
"intern",
"(",
")",
")",
";",
"prefix",
"=",
"\"-\"",
"+",
"BilouCodec",
".",
"CONTINUE",
";",
"i",
"++",
";",
"}",
"}",
"// one word case or last member of span",
"if",
"(",
"gazClass",
"!=",
"null",
")",
"{",
"if",
"(",
"prefix",
".",
"equals",
"(",
"\"-\"",
"+",
"BilouCodec",
".",
"START",
")",
")",
"{",
"entitiesList",
".",
"add",
"(",
"(",
"gazClass",
"+",
"\"-\"",
"+",
"BilouCodec",
".",
"UNIT",
")",
".",
"intern",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"prefix",
".",
"equals",
"(",
"\"-\"",
"+",
"BilouCodec",
".",
"CONTINUE",
")",
")",
"{",
"entitiesList",
".",
"add",
"(",
"(",
"gazClass",
"+",
"\"-\"",
"+",
"BilouCodec",
".",
"LAST",
")",
".",
"intern",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"entitiesList",
".",
"add",
"(",
"BilouCodec",
".",
"OTHER",
")",
";",
"}",
"}",
"return",
"entitiesList",
";",
"}"
] |
Performs gazetteer match in a bilou encoding.
@param tokens
the sentence
@return the list of named entities in the current sentence
|
[
"Performs",
"gazetteer",
"match",
"in",
"a",
"bilou",
"encoding",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/resources/Dictionary.java#L168-L211
|
145,759
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/resources/Dictionary.java
|
Dictionary.createSpan
|
private String createSpan(final String[] tokens, final int from,
final int to) {
String tokenSpan = "";
for (int i = from; i < to; i++) {
tokenSpan += tokens[i] + " ";
}
tokenSpan += tokens[to];
return tokenSpan;
}
|
java
|
private String createSpan(final String[] tokens, final int from,
final int to) {
String tokenSpan = "";
for (int i = from; i < to; i++) {
tokenSpan += tokens[i] + " ";
}
tokenSpan += tokens[to];
return tokenSpan;
}
|
[
"private",
"String",
"createSpan",
"(",
"final",
"String",
"[",
"]",
"tokens",
",",
"final",
"int",
"from",
",",
"final",
"int",
"to",
")",
"{",
"String",
"tokenSpan",
"=",
"\"\"",
";",
"for",
"(",
"int",
"i",
"=",
"from",
";",
"i",
"<",
"to",
";",
"i",
"++",
")",
"{",
"tokenSpan",
"+=",
"tokens",
"[",
"i",
"]",
"+",
"\" \"",
";",
"}",
"tokenSpan",
"+=",
"tokens",
"[",
"to",
"]",
";",
"return",
"tokenSpan",
";",
"}"
] |
Create a multi token entry search in the dictionary Map.
@param tokens
the sentence
@param from
the start index
@param to
the end index
@return the string representing the possibly multi token entity
|
[
"Create",
"a",
"multi",
"token",
"entry",
"search",
"in",
"the",
"dictionary",
"Map",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/resources/Dictionary.java#L224-L232
|
145,760
|
geomajas/geomajas-project-client-gwt2
|
plugin/editing/common/src/main/java/org/geomajas/plugin/editing/client/snap/SnapService.java
|
SnapService.update
|
public void update(Bbox mapBounds) {
for (final SnappingRule condition : snappingRules) {
condition.getSourceProvider().update(mapBounds);
condition.getSourceProvider().getSnappingSources(new GeometryArrayFunction() {
public void execute(Geometry[] geometries) {
condition.getAlgorithm().setGeometries(geometries);
}
});
}
}
|
java
|
public void update(Bbox mapBounds) {
for (final SnappingRule condition : snappingRules) {
condition.getSourceProvider().update(mapBounds);
condition.getSourceProvider().getSnappingSources(new GeometryArrayFunction() {
public void execute(Geometry[] geometries) {
condition.getAlgorithm().setGeometries(geometries);
}
});
}
}
|
[
"public",
"void",
"update",
"(",
"Bbox",
"mapBounds",
")",
"{",
"for",
"(",
"final",
"SnappingRule",
"condition",
":",
"snappingRules",
")",
"{",
"condition",
".",
"getSourceProvider",
"(",
")",
".",
"update",
"(",
"mapBounds",
")",
";",
"condition",
".",
"getSourceProvider",
"(",
")",
".",
"getSnappingSources",
"(",
"new",
"GeometryArrayFunction",
"(",
")",
"{",
"public",
"void",
"execute",
"(",
"Geometry",
"[",
"]",
"geometries",
")",
"{",
"condition",
".",
"getAlgorithm",
"(",
")",
".",
"setGeometries",
"(",
"geometries",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] |
Update the playing field for snapping, by providing a bounding box wherein the source providers should present
their geometries.
@param mapBounds The bounding box wherein we expect snapping to occur. Is usually the current view on the map.
|
[
"Update",
"the",
"playing",
"field",
"for",
"snapping",
"by",
"providing",
"a",
"bounding",
"box",
"wherein",
"the",
"source",
"providers",
"should",
"present",
"their",
"geometries",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/editing/common/src/main/java/org/geomajas/plugin/editing/client/snap/SnapService.java#L126-L136
|
145,761
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/editable/checkbox/EditableCheckbox.java
|
EditableCheckbox.swap
|
public void swap()
{
if (modeContext.equals(ModeContext.VIEW_MODE))
{
modeContext = ModeContext.EDIT_MODE;
}
else
{
modeContext = ModeContext.VIEW_MODE;
}
}
|
java
|
public void swap()
{
if (modeContext.equals(ModeContext.VIEW_MODE))
{
modeContext = ModeContext.EDIT_MODE;
}
else
{
modeContext = ModeContext.VIEW_MODE;
}
}
|
[
"public",
"void",
"swap",
"(",
")",
"{",
"if",
"(",
"modeContext",
".",
"equals",
"(",
"ModeContext",
".",
"VIEW_MODE",
")",
")",
"{",
"modeContext",
"=",
"ModeContext",
".",
"EDIT_MODE",
";",
"}",
"else",
"{",
"modeContext",
"=",
"ModeContext",
".",
"VIEW_MODE",
";",
"}",
"}"
] |
Swap the ModeContext.
|
[
"Swap",
"the",
"ModeContext",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/editable/checkbox/EditableCheckbox.java#L151-L161
|
145,762
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/sign/in/SigninPanel.java
|
SigninPanel.newPasswordTextField
|
protected LabeledPasswordTextFieldPanel<String, T> newPasswordTextField(final String id,
final IModel<T> model)
{
final IModel<String> labelModel = ResourceModelFactory
.newResourceModel("global.password.label", this);
final IModel<String> placeholderModel = ResourceModelFactory
.newResourceModel("global.enter.your.password.label", this);
final LabeledPasswordTextFieldPanel<String, T> pwTextField = new LabeledPasswordTextFieldPanel<String, T>(
id, model, labelModel)
{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
protected PasswordTextField newPasswordTextField(final String id, final IModel<T> model)
{
final PasswordTextField pwTextField = new PasswordTextField(id,
new PropertyModel<>(model, "password"));
pwTextField.setOutputMarkupId(true);
if (placeholderModel != null)
{
pwTextField.add(new AttributeAppender("placeholder", placeholderModel));
}
return pwTextField;
}
};
return pwTextField;
}
|
java
|
protected LabeledPasswordTextFieldPanel<String, T> newPasswordTextField(final String id,
final IModel<T> model)
{
final IModel<String> labelModel = ResourceModelFactory
.newResourceModel("global.password.label", this);
final IModel<String> placeholderModel = ResourceModelFactory
.newResourceModel("global.enter.your.password.label", this);
final LabeledPasswordTextFieldPanel<String, T> pwTextField = new LabeledPasswordTextFieldPanel<String, T>(
id, model, labelModel)
{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
protected PasswordTextField newPasswordTextField(final String id, final IModel<T> model)
{
final PasswordTextField pwTextField = new PasswordTextField(id,
new PropertyModel<>(model, "password"));
pwTextField.setOutputMarkupId(true);
if (placeholderModel != null)
{
pwTextField.add(new AttributeAppender("placeholder", placeholderModel));
}
return pwTextField;
}
};
return pwTextField;
}
|
[
"protected",
"LabeledPasswordTextFieldPanel",
"<",
"String",
",",
"T",
">",
"newPasswordTextField",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"T",
">",
"model",
")",
"{",
"final",
"IModel",
"<",
"String",
">",
"labelModel",
"=",
"ResourceModelFactory",
".",
"newResourceModel",
"(",
"\"global.password.label\"",
",",
"this",
")",
";",
"final",
"IModel",
"<",
"String",
">",
"placeholderModel",
"=",
"ResourceModelFactory",
".",
"newResourceModel",
"(",
"\"global.enter.your.password.label\"",
",",
"this",
")",
";",
"final",
"LabeledPasswordTextFieldPanel",
"<",
"String",
",",
"T",
">",
"pwTextField",
"=",
"new",
"LabeledPasswordTextFieldPanel",
"<",
"String",
",",
"T",
">",
"(",
"id",
",",
"model",
",",
"labelModel",
")",
"{",
"/** The Constant serialVersionUID. */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"/**\n\t\t\t * {@inheritDoc}\n\t\t\t */",
"@",
"Override",
"protected",
"PasswordTextField",
"newPasswordTextField",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"T",
">",
"model",
")",
"{",
"final",
"PasswordTextField",
"pwTextField",
"=",
"new",
"PasswordTextField",
"(",
"id",
",",
"new",
"PropertyModel",
"<>",
"(",
"model",
",",
"\"password\"",
")",
")",
";",
"pwTextField",
".",
"setOutputMarkupId",
"(",
"true",
")",
";",
"if",
"(",
"placeholderModel",
"!=",
"null",
")",
"{",
"pwTextField",
".",
"add",
"(",
"new",
"AttributeAppender",
"(",
"\"placeholder\"",
",",
"placeholderModel",
")",
")",
";",
"}",
"return",
"pwTextField",
";",
"}",
"}",
";",
"return",
"pwTextField",
";",
"}"
] |
Factory method for creating the EmailTextField for the password. This method is invoked in
the constructor from the derived classes and can be overridden so users can provide their own
version of a EmailTextField for the password.
@param id
the id
@param model
the model
@return the text field LabeledPasswordTextFieldPanel
|
[
"Factory",
"method",
"for",
"creating",
"the",
"EmailTextField",
"for",
"the",
"password",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"EmailTextField",
"for",
"the",
"password",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/sign/in/SigninPanel.java#L121-L152
|
145,763
|
netheosgithub/pcs_api
|
android/pcs-api-android/src/main/java/net/netheos/pcsapi/OAuth2AuthorizationActivity.java
|
OAuth2AuthorizationActivity.prepareWebView
|
private void prepareWebView() {
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setVisibility(View.VISIBLE);
mWebView.setWebViewClient(new WebViewClient() {
private boolean done = false;
@Override
public void onPageFinished(WebView view, String url) {
// Catch the redirect url with the parameters added by the provider auth web page
if (!done && url.startsWith(mAppInfo.getRedirectUrl())) {
done = true;
getCredentials(url);
mWebView.setVisibility(View.INVISIBLE);
}
}
});
}
|
java
|
private void prepareWebView() {
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setVisibility(View.VISIBLE);
mWebView.setWebViewClient(new WebViewClient() {
private boolean done = false;
@Override
public void onPageFinished(WebView view, String url) {
// Catch the redirect url with the parameters added by the provider auth web page
if (!done && url.startsWith(mAppInfo.getRedirectUrl())) {
done = true;
getCredentials(url);
mWebView.setVisibility(View.INVISIBLE);
}
}
});
}
|
[
"private",
"void",
"prepareWebView",
"(",
")",
"{",
"mWebView",
".",
"getSettings",
"(",
")",
".",
"setJavaScriptEnabled",
"(",
"true",
")",
";",
"mWebView",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"mWebView",
".",
"setWebViewClient",
"(",
"new",
"WebViewClient",
"(",
")",
"{",
"private",
"boolean",
"done",
"=",
"false",
";",
"@",
"Override",
"public",
"void",
"onPageFinished",
"(",
"WebView",
"view",
",",
"String",
"url",
")",
"{",
"// Catch the redirect url with the parameters added by the provider auth web page",
"if",
"(",
"!",
"done",
"&&",
"url",
".",
"startsWith",
"(",
"mAppInfo",
".",
"getRedirectUrl",
"(",
")",
")",
")",
"{",
"done",
"=",
"true",
";",
"getCredentials",
"(",
"url",
")",
";",
"mWebView",
".",
"setVisibility",
"(",
"View",
".",
"INVISIBLE",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] |
Adds a callback on the web view to catch the redirect URL
|
[
"Adds",
"a",
"callback",
"on",
"the",
"web",
"view",
"to",
"catch",
"the",
"redirect",
"URL"
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/android/pcs-api-android/src/main/java/net/netheos/pcsapi/OAuth2AuthorizationActivity.java#L106-L123
|
145,764
|
netheosgithub/pcs_api
|
android/pcs-api-android/src/main/java/net/netheos/pcsapi/OAuth2AuthorizationActivity.java
|
OAuth2AuthorizationActivity.getCredentials
|
private void getCredentials(final String code) {
new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... params) {
try {
mBootstrapper.getUserCredentials(code);
return true;
} catch (IOException ex) {
LOGGER.error("Error getting oauth credentials", ex);
setResult(RESULT_CANCELED);
finish();
} catch (CStorageException ex) {
LOGGER.error("Error getting oauth credentials", ex);
setResult(RESULT_CANCELED);
finish();
}
// Failure
return false;
}
@Override
protected void onPostExecute(Boolean result) {
if(result) {
setResult(RESULT_OK);
} else {
setResult(RESULT_CANCELED);
}
finish();
}
}.execute();
}
|
java
|
private void getCredentials(final String code) {
new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... params) {
try {
mBootstrapper.getUserCredentials(code);
return true;
} catch (IOException ex) {
LOGGER.error("Error getting oauth credentials", ex);
setResult(RESULT_CANCELED);
finish();
} catch (CStorageException ex) {
LOGGER.error("Error getting oauth credentials", ex);
setResult(RESULT_CANCELED);
finish();
}
// Failure
return false;
}
@Override
protected void onPostExecute(Boolean result) {
if(result) {
setResult(RESULT_OK);
} else {
setResult(RESULT_CANCELED);
}
finish();
}
}.execute();
}
|
[
"private",
"void",
"getCredentials",
"(",
"final",
"String",
"code",
")",
"{",
"new",
"AsyncTask",
"<",
"Void",
",",
"Void",
",",
"Boolean",
">",
"(",
")",
"{",
"@",
"Override",
"protected",
"Boolean",
"doInBackground",
"(",
"Void",
"...",
"params",
")",
"{",
"try",
"{",
"mBootstrapper",
".",
"getUserCredentials",
"(",
"code",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Error getting oauth credentials\"",
",",
"ex",
")",
";",
"setResult",
"(",
"RESULT_CANCELED",
")",
";",
"finish",
"(",
")",
";",
"}",
"catch",
"(",
"CStorageException",
"ex",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Error getting oauth credentials\"",
",",
"ex",
")",
";",
"setResult",
"(",
"RESULT_CANCELED",
")",
";",
"finish",
"(",
")",
";",
"}",
"// Failure",
"return",
"false",
";",
"}",
"@",
"Override",
"protected",
"void",
"onPostExecute",
"(",
"Boolean",
"result",
")",
"{",
"if",
"(",
"result",
")",
"{",
"setResult",
"(",
"RESULT_OK",
")",
";",
"}",
"else",
"{",
"setResult",
"(",
"RESULT_CANCELED",
")",
";",
"}",
"finish",
"(",
")",
";",
"}",
"}",
".",
"execute",
"(",
")",
";",
"}"
] |
Gets user credentials and save them
If OK, set result OK and come back to calling activity
@param code The code used to retrieve the OAuth access token
|
[
"Gets",
"user",
"credentials",
"and",
"save",
"them",
"If",
"OK",
"set",
"result",
"OK",
"and",
"come",
"back",
"to",
"calling",
"activity"
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/android/pcs-api-android/src/main/java/net/netheos/pcsapi/OAuth2AuthorizationActivity.java#L132-L164
|
145,765
|
Danny02/JOpenCTM
|
src/main/java/darwin/jopenctm/compression/MG2Decoder.java
|
MG2Decoder.restoreAttribs
|
private float[] restoreAttribs(float precision, int[] intAttribs) {
int ae = CTM_ATTR_ELEMENT_COUNT;
int vc = intAttribs.length / ae;
float[] values = new float[intAttribs.length];
int[] prev = new int[ae];
for (int i = 0; i < vc; ++i) {
// Calculate inverse delta, and convert to floating point
for (int j = 0; j < ae; ++j) {
int value = intAttribs[i * ae + j] + prev[j];
values[i * ae + j] = value * precision;
prev[j] = value;
}
}
return values;
}
|
java
|
private float[] restoreAttribs(float precision, int[] intAttribs) {
int ae = CTM_ATTR_ELEMENT_COUNT;
int vc = intAttribs.length / ae;
float[] values = new float[intAttribs.length];
int[] prev = new int[ae];
for (int i = 0; i < vc; ++i) {
// Calculate inverse delta, and convert to floating point
for (int j = 0; j < ae; ++j) {
int value = intAttribs[i * ae + j] + prev[j];
values[i * ae + j] = value * precision;
prev[j] = value;
}
}
return values;
}
|
[
"private",
"float",
"[",
"]",
"restoreAttribs",
"(",
"float",
"precision",
",",
"int",
"[",
"]",
"intAttribs",
")",
"{",
"int",
"ae",
"=",
"CTM_ATTR_ELEMENT_COUNT",
";",
"int",
"vc",
"=",
"intAttribs",
".",
"length",
"/",
"ae",
";",
"float",
"[",
"]",
"values",
"=",
"new",
"float",
"[",
"intAttribs",
".",
"length",
"]",
";",
"int",
"[",
"]",
"prev",
"=",
"new",
"int",
"[",
"ae",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"vc",
";",
"++",
"i",
")",
"{",
"// Calculate inverse delta, and convert to floating point",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"ae",
";",
"++",
"j",
")",
"{",
"int",
"value",
"=",
"intAttribs",
"[",
"i",
"*",
"ae",
"+",
"j",
"]",
"+",
"prev",
"[",
"j",
"]",
";",
"values",
"[",
"i",
"*",
"ae",
"+",
"j",
"]",
"=",
"value",
"*",
"precision",
";",
"prev",
"[",
"j",
"]",
"=",
"value",
";",
"}",
"}",
"return",
"values",
";",
"}"
] |
Calculate inverse derivatives of the vertex attributes.
|
[
"Calculate",
"inverse",
"derivatives",
"of",
"the",
"vertex",
"attributes",
"."
] |
c55a2a2d166a55979190f1bb08214fc84c93008f
|
https://github.com/Danny02/JOpenCTM/blob/c55a2a2d166a55979190f1bb08214fc84c93008f/src/main/java/darwin/jopenctm/compression/MG2Decoder.java#L143-L157
|
145,766
|
Danny02/JOpenCTM
|
src/main/java/darwin/jopenctm/compression/MG2Decoder.java
|
MG2Decoder.restoreUVCoords
|
private float[] restoreUVCoords(float precision, int[] intUVCoords) {
int vc = intUVCoords.length / CTM_UV_ELEMENT_COUNT;
float[] values = new float[intUVCoords.length];
int prevU = 0, prevV = 0;
for (int i = 0; i < vc; ++i) {
// Calculate inverse delta
int u = intUVCoords[i * CTM_UV_ELEMENT_COUNT] + prevU;
int v = intUVCoords[i * CTM_UV_ELEMENT_COUNT + 1] + prevV;
// Convert to floating point
values[i * CTM_UV_ELEMENT_COUNT] = u * precision;
values[i * CTM_UV_ELEMENT_COUNT + 1] = v * precision;
prevU = u;
prevV = v;
}
return values;
}
|
java
|
private float[] restoreUVCoords(float precision, int[] intUVCoords) {
int vc = intUVCoords.length / CTM_UV_ELEMENT_COUNT;
float[] values = new float[intUVCoords.length];
int prevU = 0, prevV = 0;
for (int i = 0; i < vc; ++i) {
// Calculate inverse delta
int u = intUVCoords[i * CTM_UV_ELEMENT_COUNT] + prevU;
int v = intUVCoords[i * CTM_UV_ELEMENT_COUNT + 1] + prevV;
// Convert to floating point
values[i * CTM_UV_ELEMENT_COUNT] = u * precision;
values[i * CTM_UV_ELEMENT_COUNT + 1] = v * precision;
prevU = u;
prevV = v;
}
return values;
}
|
[
"private",
"float",
"[",
"]",
"restoreUVCoords",
"(",
"float",
"precision",
",",
"int",
"[",
"]",
"intUVCoords",
")",
"{",
"int",
"vc",
"=",
"intUVCoords",
".",
"length",
"/",
"CTM_UV_ELEMENT_COUNT",
";",
"float",
"[",
"]",
"values",
"=",
"new",
"float",
"[",
"intUVCoords",
".",
"length",
"]",
";",
"int",
"prevU",
"=",
"0",
",",
"prevV",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"vc",
";",
"++",
"i",
")",
"{",
"// Calculate inverse delta",
"int",
"u",
"=",
"intUVCoords",
"[",
"i",
"*",
"CTM_UV_ELEMENT_COUNT",
"]",
"+",
"prevU",
";",
"int",
"v",
"=",
"intUVCoords",
"[",
"i",
"*",
"CTM_UV_ELEMENT_COUNT",
"+",
"1",
"]",
"+",
"prevV",
";",
"// Convert to floating point",
"values",
"[",
"i",
"*",
"CTM_UV_ELEMENT_COUNT",
"]",
"=",
"u",
"*",
"precision",
";",
"values",
"[",
"i",
"*",
"CTM_UV_ELEMENT_COUNT",
"+",
"1",
"]",
"=",
"v",
"*",
"precision",
";",
"prevU",
"=",
"u",
";",
"prevV",
"=",
"v",
";",
"}",
"return",
"values",
";",
"}"
] |
Calculate inverse derivatives of the UV coordinates.
|
[
"Calculate",
"inverse",
"derivatives",
"of",
"the",
"UV",
"coordinates",
"."
] |
c55a2a2d166a55979190f1bb08214fc84c93008f
|
https://github.com/Danny02/JOpenCTM/blob/c55a2a2d166a55979190f1bb08214fc84c93008f/src/main/java/darwin/jopenctm/compression/MG2Decoder.java#L162-L179
|
145,767
|
Danny02/JOpenCTM
|
src/main/java/darwin/jopenctm/compression/MG2Decoder.java
|
MG2Decoder.restoreNormals
|
private float[] restoreNormals(int[] intNormals, float[] vertices, int[] indices, float normalPrecision) {
// Calculate smooth normals (nominal normals)
float[] smoothNormals = calcSmoothNormals(vertices, indices);
float[] normals = new float[vertices.length];
int vc = vertices.length / CTM_POSITION_ELEMENT_COUNT;
int ne = CTM_NORMAL_ELEMENT_COUNT;
for (int i = 0; i < vc; ++i) {
// Get the normal magnitude from the first of the three normal elements
float magn = intNormals[i * ne] * normalPrecision;
// Get phi and theta (spherical coordinates, relative to the smooth normal).
double thetaScale, theta;
int intPhi = intNormals[i * ne + 1];
double phi = intPhi * (0.5 * PI) * normalPrecision;
if (intPhi == 0) {
thetaScale = 0.0f;
} else if (intPhi <= 4) {
thetaScale = PI / 2.0f;
} else {
thetaScale = (2.0f * PI) / intPhi;
}
theta = intNormals[i * ne + 2] * thetaScale - PI;
// Convert the normal from the angular representation (phi, theta) back to
// cartesian coordinates
double[] n2 = new double[3];
n2[0] = sin(phi) * cos(theta);
n2[1] = sin(phi) * sin(theta);
n2[2] = cos(phi);
float[] basisAxes = makeNormalCoordSys(smoothNormals, i * ne);
double[] n = new double[3];
for (int j = 0; j < 3; ++j) {
n[j] = basisAxes[j] * n2[0]
+ basisAxes[3 + j] * n2[1]
+ basisAxes[6 + j] * n2[2];
}
// Apply normal magnitude, and output to the normals array
for (int j = 0; j < 3; ++j) {
normals[i * ne + j] = (float) (n[j] * magn);
}
}
return normals;
}
|
java
|
private float[] restoreNormals(int[] intNormals, float[] vertices, int[] indices, float normalPrecision) {
// Calculate smooth normals (nominal normals)
float[] smoothNormals = calcSmoothNormals(vertices, indices);
float[] normals = new float[vertices.length];
int vc = vertices.length / CTM_POSITION_ELEMENT_COUNT;
int ne = CTM_NORMAL_ELEMENT_COUNT;
for (int i = 0; i < vc; ++i) {
// Get the normal magnitude from the first of the three normal elements
float magn = intNormals[i * ne] * normalPrecision;
// Get phi and theta (spherical coordinates, relative to the smooth normal).
double thetaScale, theta;
int intPhi = intNormals[i * ne + 1];
double phi = intPhi * (0.5 * PI) * normalPrecision;
if (intPhi == 0) {
thetaScale = 0.0f;
} else if (intPhi <= 4) {
thetaScale = PI / 2.0f;
} else {
thetaScale = (2.0f * PI) / intPhi;
}
theta = intNormals[i * ne + 2] * thetaScale - PI;
// Convert the normal from the angular representation (phi, theta) back to
// cartesian coordinates
double[] n2 = new double[3];
n2[0] = sin(phi) * cos(theta);
n2[1] = sin(phi) * sin(theta);
n2[2] = cos(phi);
float[] basisAxes = makeNormalCoordSys(smoothNormals, i * ne);
double[] n = new double[3];
for (int j = 0; j < 3; ++j) {
n[j] = basisAxes[j] * n2[0]
+ basisAxes[3 + j] * n2[1]
+ basisAxes[6 + j] * n2[2];
}
// Apply normal magnitude, and output to the normals array
for (int j = 0; j < 3; ++j) {
normals[i * ne + j] = (float) (n[j] * magn);
}
}
return normals;
}
|
[
"private",
"float",
"[",
"]",
"restoreNormals",
"(",
"int",
"[",
"]",
"intNormals",
",",
"float",
"[",
"]",
"vertices",
",",
"int",
"[",
"]",
"indices",
",",
"float",
"normalPrecision",
")",
"{",
"// Calculate smooth normals (nominal normals)",
"float",
"[",
"]",
"smoothNormals",
"=",
"calcSmoothNormals",
"(",
"vertices",
",",
"indices",
")",
";",
"float",
"[",
"]",
"normals",
"=",
"new",
"float",
"[",
"vertices",
".",
"length",
"]",
";",
"int",
"vc",
"=",
"vertices",
".",
"length",
"/",
"CTM_POSITION_ELEMENT_COUNT",
";",
"int",
"ne",
"=",
"CTM_NORMAL_ELEMENT_COUNT",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"vc",
";",
"++",
"i",
")",
"{",
"// Get the normal magnitude from the first of the three normal elements",
"float",
"magn",
"=",
"intNormals",
"[",
"i",
"*",
"ne",
"]",
"*",
"normalPrecision",
";",
"// Get phi and theta (spherical coordinates, relative to the smooth normal).",
"double",
"thetaScale",
",",
"theta",
";",
"int",
"intPhi",
"=",
"intNormals",
"[",
"i",
"*",
"ne",
"+",
"1",
"]",
";",
"double",
"phi",
"=",
"intPhi",
"*",
"(",
"0.5",
"*",
"PI",
")",
"*",
"normalPrecision",
";",
"if",
"(",
"intPhi",
"==",
"0",
")",
"{",
"thetaScale",
"=",
"0.0f",
";",
"}",
"else",
"if",
"(",
"intPhi",
"<=",
"4",
")",
"{",
"thetaScale",
"=",
"PI",
"/",
"2.0f",
";",
"}",
"else",
"{",
"thetaScale",
"=",
"(",
"2.0f",
"*",
"PI",
")",
"/",
"intPhi",
";",
"}",
"theta",
"=",
"intNormals",
"[",
"i",
"*",
"ne",
"+",
"2",
"]",
"*",
"thetaScale",
"-",
"PI",
";",
"// Convert the normal from the angular representation (phi, theta) back to",
"// cartesian coordinates",
"double",
"[",
"]",
"n2",
"=",
"new",
"double",
"[",
"3",
"]",
";",
"n2",
"[",
"0",
"]",
"=",
"sin",
"(",
"phi",
")",
"*",
"cos",
"(",
"theta",
")",
";",
"n2",
"[",
"1",
"]",
"=",
"sin",
"(",
"phi",
")",
"*",
"sin",
"(",
"theta",
")",
";",
"n2",
"[",
"2",
"]",
"=",
"cos",
"(",
"phi",
")",
";",
"float",
"[",
"]",
"basisAxes",
"=",
"makeNormalCoordSys",
"(",
"smoothNormals",
",",
"i",
"*",
"ne",
")",
";",
"double",
"[",
"]",
"n",
"=",
"new",
"double",
"[",
"3",
"]",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"3",
";",
"++",
"j",
")",
"{",
"n",
"[",
"j",
"]",
"=",
"basisAxes",
"[",
"j",
"]",
"*",
"n2",
"[",
"0",
"]",
"+",
"basisAxes",
"[",
"3",
"+",
"j",
"]",
"*",
"n2",
"[",
"1",
"]",
"+",
"basisAxes",
"[",
"6",
"+",
"j",
"]",
"*",
"n2",
"[",
"2",
"]",
";",
"}",
"// Apply normal magnitude, and output to the normals array",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"3",
";",
"++",
"j",
")",
"{",
"normals",
"[",
"i",
"*",
"ne",
"+",
"j",
"]",
"=",
"(",
"float",
")",
"(",
"n",
"[",
"j",
"]",
"*",
"magn",
")",
";",
"}",
"}",
"return",
"normals",
";",
"}"
] |
Convert the normals back to cartesian coordinates.
|
[
"Convert",
"the",
"normals",
"back",
"to",
"cartesian",
"coordinates",
"."
] |
c55a2a2d166a55979190f1bb08214fc84c93008f
|
https://github.com/Danny02/JOpenCTM/blob/c55a2a2d166a55979190f1bb08214fc84c93008f/src/main/java/darwin/jopenctm/compression/MG2Decoder.java#L184-L231
|
145,768
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseApplication.java
|
PhaseApplication.getCommandLineOptions
|
@Override
public List<Option> getCommandLineOptions() {
final List<Option> ret = new LinkedList<Option>();
String help;
help = TIME_HELP;
ret.add(new Option(SHORT_OPT_TIME, LONG_OPT_TIME, false, help));
help = WARNINGS_AS_ERRORS;
ret.add(new Option(null, LONG_OPT_PEDANTIC, false, help));
help = SYSTEM_CONFIG_PATH;
Option o = new Option(SHRT_OPT_SYSCFG, LONG_OPT_SYSCFG, true, help);
o.setArgName(ARG_SYSCFG);
ret.add(o);
return ret;
}
|
java
|
@Override
public List<Option> getCommandLineOptions() {
final List<Option> ret = new LinkedList<Option>();
String help;
help = TIME_HELP;
ret.add(new Option(SHORT_OPT_TIME, LONG_OPT_TIME, false, help));
help = WARNINGS_AS_ERRORS;
ret.add(new Option(null, LONG_OPT_PEDANTIC, false, help));
help = SYSTEM_CONFIG_PATH;
Option o = new Option(SHRT_OPT_SYSCFG, LONG_OPT_SYSCFG, true, help);
o.setArgName(ARG_SYSCFG);
ret.add(o);
return ret;
}
|
[
"@",
"Override",
"public",
"List",
"<",
"Option",
">",
"getCommandLineOptions",
"(",
")",
"{",
"final",
"List",
"<",
"Option",
">",
"ret",
"=",
"new",
"LinkedList",
"<",
"Option",
">",
"(",
")",
";",
"String",
"help",
";",
"help",
"=",
"TIME_HELP",
";",
"ret",
".",
"add",
"(",
"new",
"Option",
"(",
"SHORT_OPT_TIME",
",",
"LONG_OPT_TIME",
",",
"false",
",",
"help",
")",
")",
";",
"help",
"=",
"WARNINGS_AS_ERRORS",
";",
"ret",
".",
"add",
"(",
"new",
"Option",
"(",
"null",
",",
"LONG_OPT_PEDANTIC",
",",
"false",
",",
"help",
")",
")",
";",
"help",
"=",
"SYSTEM_CONFIG_PATH",
";",
"Option",
"o",
"=",
"new",
"Option",
"(",
"SHRT_OPT_SYSCFG",
",",
"LONG_OPT_SYSCFG",
",",
"true",
",",
"help",
")",
";",
"o",
".",
"setArgName",
"(",
"ARG_SYSCFG",
")",
";",
"ret",
".",
"add",
"(",
"o",
")",
";",
"return",
"ret",
";",
"}"
] |
Returns a list of phase-agnostic command-line options.
@return List of options
|
[
"Returns",
"a",
"list",
"of",
"phase",
"-",
"agnostic",
"command",
"-",
"line",
"options",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseApplication.java#L162-L180
|
145,769
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseApplication.java
|
PhaseApplication.setOptions
|
private void setOptions(RuntimeConfiguration rc) {
if (hasOption(SHORT_OPT_TIME)) {
rc.setTime(true);
}
if (hasOption(LONG_OPT_DEBUG)) {
rc.setDebug(true);
}
if (hasOption(LONG_OPT_VERBOSE)) {
rc.setVerbose(true);
}
if (hasOption(LONG_OPT_PEDANTIC)) {
rc.setWarningsAsErrors(true);
}
}
|
java
|
private void setOptions(RuntimeConfiguration rc) {
if (hasOption(SHORT_OPT_TIME)) {
rc.setTime(true);
}
if (hasOption(LONG_OPT_DEBUG)) {
rc.setDebug(true);
}
if (hasOption(LONG_OPT_VERBOSE)) {
rc.setVerbose(true);
}
if (hasOption(LONG_OPT_PEDANTIC)) {
rc.setWarningsAsErrors(true);
}
}
|
[
"private",
"void",
"setOptions",
"(",
"RuntimeConfiguration",
"rc",
")",
"{",
"if",
"(",
"hasOption",
"(",
"SHORT_OPT_TIME",
")",
")",
"{",
"rc",
".",
"setTime",
"(",
"true",
")",
";",
"}",
"if",
"(",
"hasOption",
"(",
"LONG_OPT_DEBUG",
")",
")",
"{",
"rc",
".",
"setDebug",
"(",
"true",
")",
";",
"}",
"if",
"(",
"hasOption",
"(",
"LONG_OPT_VERBOSE",
")",
")",
"{",
"rc",
".",
"setVerbose",
"(",
"true",
")",
";",
"}",
"if",
"(",
"hasOption",
"(",
"LONG_OPT_PEDANTIC",
")",
")",
"{",
"rc",
".",
"setWarningsAsErrors",
"(",
"true",
")",
";",
"}",
"}"
] |
Sets the phase-agnostic runtime configuration.
|
[
"Sets",
"the",
"phase",
"-",
"agnostic",
"runtime",
"configuration",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseApplication.java#L244-L257
|
145,770
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseApplication.java
|
PhaseApplication.stageOutput
|
protected void stageOutput(final String output) {
boolean print = getPhaseConfiguration().isVerbose();
if (print) {
output(INDENT + INDENT + output);
}
}
|
java
|
protected void stageOutput(final String output) {
boolean print = getPhaseConfiguration().isVerbose();
if (print) {
output(INDENT + INDENT + output);
}
}
|
[
"protected",
"void",
"stageOutput",
"(",
"final",
"String",
"output",
")",
"{",
"boolean",
"print",
"=",
"getPhaseConfiguration",
"(",
")",
".",
"isVerbose",
"(",
")",
";",
"if",
"(",
"print",
")",
"{",
"output",
"(",
"INDENT",
"+",
"INDENT",
"+",
"output",
")",
";",
"}",
"}"
] |
Prints stage output with two levels of indentation.
@param output Output
|
[
"Prints",
"stage",
"output",
"with",
"two",
"levels",
"of",
"indentation",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseApplication.java#L297-L302
|
145,771
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseApplication.java
|
PhaseApplication.createDirectoryArtifact
|
protected final File createDirectoryArtifact(final File outputDirectory,
final String artifact) {
// Construct artifact path based on output directory
String path = asPath(outputDirectory.getAbsolutePath(), artifact);
final File ret = new File(path);
if (!ret.isDirectory()) {
// Fail if the directory artifact couldn't be created
if (!ret.mkdir()) {
error(DIRECTORY_CREATION_FAILED + ret);
bail(ExitCode.BAD_OUTPUT_DIRECTORY);
}
}
return ret;
}
|
java
|
protected final File createDirectoryArtifact(final File outputDirectory,
final String artifact) {
// Construct artifact path based on output directory
String path = asPath(outputDirectory.getAbsolutePath(), artifact);
final File ret = new File(path);
if (!ret.isDirectory()) {
// Fail if the directory artifact couldn't be created
if (!ret.mkdir()) {
error(DIRECTORY_CREATION_FAILED + ret);
bail(ExitCode.BAD_OUTPUT_DIRECTORY);
}
}
return ret;
}
|
[
"protected",
"final",
"File",
"createDirectoryArtifact",
"(",
"final",
"File",
"outputDirectory",
",",
"final",
"String",
"artifact",
")",
"{",
"// Construct artifact path based on output directory",
"String",
"path",
"=",
"asPath",
"(",
"outputDirectory",
".",
"getAbsolutePath",
"(",
")",
",",
"artifact",
")",
";",
"final",
"File",
"ret",
"=",
"new",
"File",
"(",
"path",
")",
";",
"if",
"(",
"!",
"ret",
".",
"isDirectory",
"(",
")",
")",
"{",
"// Fail if the directory artifact couldn't be created",
"if",
"(",
"!",
"ret",
".",
"mkdir",
"(",
")",
")",
"{",
"error",
"(",
"DIRECTORY_CREATION_FAILED",
"+",
"ret",
")",
";",
"bail",
"(",
"ExitCode",
".",
"BAD_OUTPUT_DIRECTORY",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] |
Creates the directory artifact, failing if the directory couldn't be
created.
@param outputDirectory Phase output directory
@param artifact Directory artifact to be created
|
[
"Creates",
"the",
"directory",
"artifact",
"failing",
"if",
"the",
"directory",
"couldn",
"t",
"be",
"created",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseApplication.java#L331-L344
|
145,772
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseApplication.java
|
PhaseApplication.harness
|
protected static void harness(PhaseApplication phase) {
try {
phase.start();
phase.stop();
phase.end();
} catch (BELRuntimeException bre) {
err.println(bre.getUserFacingMessage());
systemExit(bre.getExitCode());
} catch (OutOfMemoryError oom) {
err.println();
oom.printStackTrace();
long upperlimit = getRuntime().maxMemory();
double ulMB = upperlimit * 9.53674316e-7;
final NumberFormat fmt = new DecimalFormat("#0");
String allocation = fmt.format(ulMB);
err.println("\n(current allocation is " + allocation + " MB)");
systemExit(ExitCode.OOM_ERROR);
}
}
|
java
|
protected static void harness(PhaseApplication phase) {
try {
phase.start();
phase.stop();
phase.end();
} catch (BELRuntimeException bre) {
err.println(bre.getUserFacingMessage());
systemExit(bre.getExitCode());
} catch (OutOfMemoryError oom) {
err.println();
oom.printStackTrace();
long upperlimit = getRuntime().maxMemory();
double ulMB = upperlimit * 9.53674316e-7;
final NumberFormat fmt = new DecimalFormat("#0");
String allocation = fmt.format(ulMB);
err.println("\n(current allocation is " + allocation + " MB)");
systemExit(ExitCode.OOM_ERROR);
}
}
|
[
"protected",
"static",
"void",
"harness",
"(",
"PhaseApplication",
"phase",
")",
"{",
"try",
"{",
"phase",
".",
"start",
"(",
")",
";",
"phase",
".",
"stop",
"(",
")",
";",
"phase",
".",
"end",
"(",
")",
";",
"}",
"catch",
"(",
"BELRuntimeException",
"bre",
")",
"{",
"err",
".",
"println",
"(",
"bre",
".",
"getUserFacingMessage",
"(",
")",
")",
";",
"systemExit",
"(",
"bre",
".",
"getExitCode",
"(",
")",
")",
";",
"}",
"catch",
"(",
"OutOfMemoryError",
"oom",
")",
"{",
"err",
".",
"println",
"(",
")",
";",
"oom",
".",
"printStackTrace",
"(",
")",
";",
"long",
"upperlimit",
"=",
"getRuntime",
"(",
")",
".",
"maxMemory",
"(",
")",
";",
"double",
"ulMB",
"=",
"upperlimit",
"*",
"9.53674316e-7",
";",
"final",
"NumberFormat",
"fmt",
"=",
"new",
"DecimalFormat",
"(",
"\"#0\"",
")",
";",
"String",
"allocation",
"=",
"fmt",
".",
"format",
"(",
"ulMB",
")",
";",
"err",
".",
"println",
"(",
"\"\\n(current allocation is \"",
"+",
"allocation",
"+",
"\" MB)\"",
")",
";",
"systemExit",
"(",
"ExitCode",
".",
"OOM_ERROR",
")",
";",
"}",
"}"
] |
Directs phase application lifecycle.
@param phase Phase application
|
[
"Directs",
"phase",
"application",
"lifecycle",
"."
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseApplication.java#L420-L438
|
145,773
|
netheosgithub/pcs_api
|
java/src/main/java/net/netheos/pcsapi/utils/URIBuilder.java
|
URIBuilder.queryParameters
|
public URIBuilder queryParameters( Map<String, String> queryParams )
{
this.queryParams.clear();
this.queryParams.putAll( queryParams );
return this;
}
|
java
|
public URIBuilder queryParameters( Map<String, String> queryParams )
{
this.queryParams.clear();
this.queryParams.putAll( queryParams );
return this;
}
|
[
"public",
"URIBuilder",
"queryParameters",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"queryParams",
")",
"{",
"this",
".",
"queryParams",
".",
"clear",
"(",
")",
";",
"this",
".",
"queryParams",
".",
"putAll",
"(",
"queryParams",
")",
";",
"return",
"this",
";",
"}"
] |
Set the query parameters
@param queryParams The parameters to use in the URI (not url encoded)
@return The builder
|
[
"Set",
"the",
"query",
"parameters"
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/utils/URIBuilder.java#L86-L91
|
145,774
|
netheosgithub/pcs_api
|
java/src/main/java/net/netheos/pcsapi/utils/URIBuilder.java
|
URIBuilder.addParameter
|
public URIBuilder addParameter( String key, String value )
{
if ( key != null && value != null ) {
queryParams.put( key, value );
}
return this;
}
|
java
|
public URIBuilder addParameter( String key, String value )
{
if ( key != null && value != null ) {
queryParams.put( key, value );
}
return this;
}
|
[
"public",
"URIBuilder",
"addParameter",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"key",
"!=",
"null",
"&&",
"value",
"!=",
"null",
")",
"{",
"queryParams",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Add a single query parameter. Parameter is ignored if it has null value.
@param key The parameter key (not url encoded)
@param value The parameter value (not url encoded)
@return The builder
|
[
"Add",
"a",
"single",
"query",
"parameter",
".",
"Parameter",
"is",
"ignored",
"if",
"it",
"has",
"null",
"value",
"."
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/utils/URIBuilder.java#L115-L122
|
145,775
|
netheosgithub/pcs_api
|
java/src/main/java/net/netheos/pcsapi/utils/URIBuilder.java
|
URIBuilder.build
|
public URI build()
{
StringBuilder builder = new StringBuilder( baseURI.toString() );
builder.append( path.toString() );
if ( queryParams != null && !queryParams.isEmpty() ) {
builder.append( queryParameters() );
}
return URI.create( builder.toString() );
}
|
java
|
public URI build()
{
StringBuilder builder = new StringBuilder( baseURI.toString() );
builder.append( path.toString() );
if ( queryParams != null && !queryParams.isEmpty() ) {
builder.append( queryParameters() );
}
return URI.create( builder.toString() );
}
|
[
"public",
"URI",
"build",
"(",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"baseURI",
".",
"toString",
"(",
")",
")",
";",
"builder",
".",
"append",
"(",
"path",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"queryParams",
"!=",
"null",
"&&",
"!",
"queryParams",
".",
"isEmpty",
"(",
")",
")",
"{",
"builder",
".",
"append",
"(",
"queryParameters",
"(",
")",
")",
";",
"}",
"return",
"URI",
".",
"create",
"(",
"builder",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Build the URI with the given informations
@return The URI
|
[
"Build",
"the",
"URI",
"with",
"the",
"given",
"informations"
] |
20691e52e144014f99ca75cb7dedc7ba0c18586c
|
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/utils/URIBuilder.java#L135-L143
|
145,776
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/tok/Normalizer.java
|
Normalizer.convertNonCanonicalStrings
|
public static void convertNonCanonicalStrings(final List<Token> sentence,
final String lang) {
// System.err.println((int)'’');
for (final Token token : sentence) {
token.setTokenValue(
apostrophe.matcher(token.getTokenValue()).replaceAll("'"));
token.setTokenValue(
ellipsis.matcher(token.getTokenValue()).replaceAll(THREE_DOTS));
token.setTokenValue(
longDash.matcher(token.getTokenValue()).replaceAll("--"));
if (lang.equalsIgnoreCase("en")) {
token.setTokenValue(
oneFourth.matcher(token.getTokenValue()).replaceAll("1\\\\/4"));
token.setTokenValue(
oneThird.matcher(token.getTokenValue()).replaceAll("1\\\\/3"));
token.setTokenValue(
oneHalf.matcher(token.getTokenValue()).replaceAll("1\\\\/2"));
token.setTokenValue(
threeQuarters.matcher(token.getTokenValue()).replaceAll("3\\\\/4"));
token.setTokenValue(
sterling.matcher(token.getTokenValue()).replaceAll("#"));
}
token.setTokenValue(
oneFourth.matcher(token.getTokenValue()).replaceAll("1/4"));
token.setTokenValue(
oneThird.matcher(token.getTokenValue()).replaceAll("1/3"));
token.setTokenValue(
oneHalf.matcher(token.getTokenValue()).replaceAll("1/2"));
token.setTokenValue(
twoThirds.matcher(token.getTokenValue()).replaceAll("2/3"));
token.setTokenValue(
threeQuarters.matcher(token.getTokenValue()).replaceAll("3/4"));
token.setTokenValue(
cents.matcher(token.getTokenValue()).replaceAll("cents"));
}
}
|
java
|
public static void convertNonCanonicalStrings(final List<Token> sentence,
final String lang) {
// System.err.println((int)'’');
for (final Token token : sentence) {
token.setTokenValue(
apostrophe.matcher(token.getTokenValue()).replaceAll("'"));
token.setTokenValue(
ellipsis.matcher(token.getTokenValue()).replaceAll(THREE_DOTS));
token.setTokenValue(
longDash.matcher(token.getTokenValue()).replaceAll("--"));
if (lang.equalsIgnoreCase("en")) {
token.setTokenValue(
oneFourth.matcher(token.getTokenValue()).replaceAll("1\\\\/4"));
token.setTokenValue(
oneThird.matcher(token.getTokenValue()).replaceAll("1\\\\/3"));
token.setTokenValue(
oneHalf.matcher(token.getTokenValue()).replaceAll("1\\\\/2"));
token.setTokenValue(
threeQuarters.matcher(token.getTokenValue()).replaceAll("3\\\\/4"));
token.setTokenValue(
sterling.matcher(token.getTokenValue()).replaceAll("#"));
}
token.setTokenValue(
oneFourth.matcher(token.getTokenValue()).replaceAll("1/4"));
token.setTokenValue(
oneThird.matcher(token.getTokenValue()).replaceAll("1/3"));
token.setTokenValue(
oneHalf.matcher(token.getTokenValue()).replaceAll("1/2"));
token.setTokenValue(
twoThirds.matcher(token.getTokenValue()).replaceAll("2/3"));
token.setTokenValue(
threeQuarters.matcher(token.getTokenValue()).replaceAll("3/4"));
token.setTokenValue(
cents.matcher(token.getTokenValue()).replaceAll("cents"));
}
}
|
[
"public",
"static",
"void",
"convertNonCanonicalStrings",
"(",
"final",
"List",
"<",
"Token",
">",
"sentence",
",",
"final",
"String",
"lang",
")",
"{",
"// System.err.println((int)'’');",
"for",
"(",
"final",
"Token",
"token",
":",
"sentence",
")",
"{",
"token",
".",
"setTokenValue",
"(",
"apostrophe",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"'\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"ellipsis",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"THREE_DOTS",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"longDash",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"--\"",
")",
")",
";",
"if",
"(",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"en\"",
")",
")",
"{",
"token",
".",
"setTokenValue",
"(",
"oneFourth",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"1\\\\\\\\/4\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"oneThird",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"1\\\\\\\\/3\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"oneHalf",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"1\\\\\\\\/2\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"threeQuarters",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"3\\\\\\\\/4\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"sterling",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"#\"",
")",
")",
";",
"}",
"token",
".",
"setTokenValue",
"(",
"oneFourth",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"1/4\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"oneThird",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"1/3\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"oneHalf",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"1/2\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"twoThirds",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"2/3\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"threeQuarters",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"3/4\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"cents",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"cents\"",
")",
")",
";",
"}",
"}"
] |
Converts non-unicode and other strings into their unicode counterparts.
@param sentence
the list of tokens
@param lang
the language
|
[
"Converts",
"non",
"-",
"unicode",
"and",
"other",
"strings",
"into",
"their",
"unicode",
"counterparts",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/tok/Normalizer.java#L82-L117
|
145,777
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/tok/Normalizer.java
|
Normalizer.normalizeQuotes
|
public static void normalizeQuotes(final List<Token> sentence,
final String lang) {
for (final Token token : sentence) {
if (lang.equalsIgnoreCase("en")) {
token.setTokenValue(
leftSingleQuote.matcher(token.getTokenValue()).replaceAll("`"));
token.setTokenValue(
rightSingleQuote.matcher(token.getTokenValue()).replaceAll("'"));
token.setTokenValue(
leftDoubleQuote.matcher(token.getTokenValue()).replaceAll("``"));
token.setTokenValue(
rightDoubleQuote.matcher(token.getTokenValue()).replaceAll("''"));
} else if (lang.equalsIgnoreCase("ca") || lang.equalsIgnoreCase("de")
|| lang.equalsIgnoreCase("es") || lang.equalsIgnoreCase("eu")
|| lang.equalsIgnoreCase("fr") || lang.equalsIgnoreCase("gl")
|| lang.equalsIgnoreCase("it") || lang.equalsIgnoreCase("nl")
|| lang.equalsIgnoreCase("pt") || lang.equalsIgnoreCase("ru")) {
token.setTokenValue(
toAsciiSingleQuote.matcher(token.getTokenValue()).replaceAll("'"));
token.setTokenValue(
toAsciiDoubleQuote.matcher(token.getTokenValue()).replaceAll("\""));
}
}
}
|
java
|
public static void normalizeQuotes(final List<Token> sentence,
final String lang) {
for (final Token token : sentence) {
if (lang.equalsIgnoreCase("en")) {
token.setTokenValue(
leftSingleQuote.matcher(token.getTokenValue()).replaceAll("`"));
token.setTokenValue(
rightSingleQuote.matcher(token.getTokenValue()).replaceAll("'"));
token.setTokenValue(
leftDoubleQuote.matcher(token.getTokenValue()).replaceAll("``"));
token.setTokenValue(
rightDoubleQuote.matcher(token.getTokenValue()).replaceAll("''"));
} else if (lang.equalsIgnoreCase("ca") || lang.equalsIgnoreCase("de")
|| lang.equalsIgnoreCase("es") || lang.equalsIgnoreCase("eu")
|| lang.equalsIgnoreCase("fr") || lang.equalsIgnoreCase("gl")
|| lang.equalsIgnoreCase("it") || lang.equalsIgnoreCase("nl")
|| lang.equalsIgnoreCase("pt") || lang.equalsIgnoreCase("ru")) {
token.setTokenValue(
toAsciiSingleQuote.matcher(token.getTokenValue()).replaceAll("'"));
token.setTokenValue(
toAsciiDoubleQuote.matcher(token.getTokenValue()).replaceAll("\""));
}
}
}
|
[
"public",
"static",
"void",
"normalizeQuotes",
"(",
"final",
"List",
"<",
"Token",
">",
"sentence",
",",
"final",
"String",
"lang",
")",
"{",
"for",
"(",
"final",
"Token",
"token",
":",
"sentence",
")",
"{",
"if",
"(",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"en\"",
")",
")",
"{",
"token",
".",
"setTokenValue",
"(",
"leftSingleQuote",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"`\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"rightSingleQuote",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"'\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"leftDoubleQuote",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"``\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"rightDoubleQuote",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"''\"",
")",
")",
";",
"}",
"else",
"if",
"(",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"ca\"",
")",
"||",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"de\"",
")",
"||",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"es\"",
")",
"||",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"eu\"",
")",
"||",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"fr\"",
")",
"||",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"gl\"",
")",
"||",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"it\"",
")",
"||",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"nl\"",
")",
"||",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"pt\"",
")",
"||",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"ru\"",
")",
")",
"{",
"token",
".",
"setTokenValue",
"(",
"toAsciiSingleQuote",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"'\"",
")",
")",
";",
"token",
".",
"setTokenValue",
"(",
"toAsciiDoubleQuote",
".",
"matcher",
"(",
"token",
".",
"getTokenValue",
"(",
")",
")",
".",
"replaceAll",
"(",
"\"\\\"\"",
")",
")",
";",
"}",
"}",
"}"
] |
Normalizes non-ambiguous quotes according to language and corpus.
@param sentence
the list of tokens
@param lang
the language
|
[
"Normalizes",
"non",
"-",
"ambiguous",
"quotes",
"according",
"to",
"language",
"and",
"corpus",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/tok/Normalizer.java#L127-L151
|
145,778
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/tok/Normalizer.java
|
Normalizer.normalizeDoubleQuotes
|
public static void normalizeDoubleQuotes(final List<Token> sentence,
final String lang) {
boolean isLeft = true;
for (int i = 0; i < sentence.size(); i++) {
if (lang.equalsIgnoreCase("en")) {
final Matcher doubleAsciiQuoteMatcher = doubleAsciiQuote
.matcher(sentence.get(i).getTokenValue());
final Matcher singleAsciiQuoteMatcher = singleAsciiQuote
.matcher(sentence.get(i).getTokenValue());
// if current token is "
if (doubleAsciiQuoteMatcher.find()) {
if (isLeft && i < sentence.size() - 1 && doubleAsciiQuoteAlphaNumeric
.matcher(sentence.get(i + 1).getTokenValue()).find()) {
sentence.get(i).setTokenValue("``");
isLeft = false;
} else if (!isLeft) {
sentence.get(i).setTokenValue("''");
isLeft = true;
}
} else if (singleAsciiQuoteMatcher.find()) {
if (i < sentence.size() - 2
&& sentence.get(i + 1).getTokenValue().matches("[A-Za-z]")
&& sentence.get(i + 2).getTokenValue()
.matches("[^ \t\n\r\u00A0\u00B6]")) {
sentence.get(i).setTokenValue("`");
}
}
}
}
}
|
java
|
public static void normalizeDoubleQuotes(final List<Token> sentence,
final String lang) {
boolean isLeft = true;
for (int i = 0; i < sentence.size(); i++) {
if (lang.equalsIgnoreCase("en")) {
final Matcher doubleAsciiQuoteMatcher = doubleAsciiQuote
.matcher(sentence.get(i).getTokenValue());
final Matcher singleAsciiQuoteMatcher = singleAsciiQuote
.matcher(sentence.get(i).getTokenValue());
// if current token is "
if (doubleAsciiQuoteMatcher.find()) {
if (isLeft && i < sentence.size() - 1 && doubleAsciiQuoteAlphaNumeric
.matcher(sentence.get(i + 1).getTokenValue()).find()) {
sentence.get(i).setTokenValue("``");
isLeft = false;
} else if (!isLeft) {
sentence.get(i).setTokenValue("''");
isLeft = true;
}
} else if (singleAsciiQuoteMatcher.find()) {
if (i < sentence.size() - 2
&& sentence.get(i + 1).getTokenValue().matches("[A-Za-z]")
&& sentence.get(i + 2).getTokenValue()
.matches("[^ \t\n\r\u00A0\u00B6]")) {
sentence.get(i).setTokenValue("`");
}
}
}
}
}
|
[
"public",
"static",
"void",
"normalizeDoubleQuotes",
"(",
"final",
"List",
"<",
"Token",
">",
"sentence",
",",
"final",
"String",
"lang",
")",
"{",
"boolean",
"isLeft",
"=",
"true",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"sentence",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"lang",
".",
"equalsIgnoreCase",
"(",
"\"en\"",
")",
")",
"{",
"final",
"Matcher",
"doubleAsciiQuoteMatcher",
"=",
"doubleAsciiQuote",
".",
"matcher",
"(",
"sentence",
".",
"get",
"(",
"i",
")",
".",
"getTokenValue",
"(",
")",
")",
";",
"final",
"Matcher",
"singleAsciiQuoteMatcher",
"=",
"singleAsciiQuote",
".",
"matcher",
"(",
"sentence",
".",
"get",
"(",
"i",
")",
".",
"getTokenValue",
"(",
")",
")",
";",
"// if current token is \"",
"if",
"(",
"doubleAsciiQuoteMatcher",
".",
"find",
"(",
")",
")",
"{",
"if",
"(",
"isLeft",
"&&",
"i",
"<",
"sentence",
".",
"size",
"(",
")",
"-",
"1",
"&&",
"doubleAsciiQuoteAlphaNumeric",
".",
"matcher",
"(",
"sentence",
".",
"get",
"(",
"i",
"+",
"1",
")",
".",
"getTokenValue",
"(",
")",
")",
".",
"find",
"(",
")",
")",
"{",
"sentence",
".",
"get",
"(",
"i",
")",
".",
"setTokenValue",
"(",
"\"``\"",
")",
";",
"isLeft",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"!",
"isLeft",
")",
"{",
"sentence",
".",
"get",
"(",
"i",
")",
".",
"setTokenValue",
"(",
"\"''\"",
")",
";",
"isLeft",
"=",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"singleAsciiQuoteMatcher",
".",
"find",
"(",
")",
")",
"{",
"if",
"(",
"i",
"<",
"sentence",
".",
"size",
"(",
")",
"-",
"2",
"&&",
"sentence",
".",
"get",
"(",
"i",
"+",
"1",
")",
".",
"getTokenValue",
"(",
")",
".",
"matches",
"(",
"\"[A-Za-z]\"",
")",
"&&",
"sentence",
".",
"get",
"(",
"i",
"+",
"2",
")",
".",
"getTokenValue",
"(",
")",
".",
"matches",
"(",
"\"[^ \\t\\n\\r\\u00A0\\u00B6]\"",
")",
")",
"{",
"sentence",
".",
"get",
"(",
"i",
")",
".",
"setTokenValue",
"(",
"\"`\"",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Normalizes double and ambiguous quotes according to language and corpus.
@param sentence
the list of tokens
@param lang
the language
|
[
"Normalizes",
"double",
"and",
"ambiguous",
"quotes",
"according",
"to",
"language",
"and",
"corpus",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/tok/Normalizer.java#L161-L191
|
145,779
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/tok/NonPeriodBreaker.java
|
NonPeriodBreaker.segmenterExceptions
|
public String[] segmenterExceptions(final String[] lines) {
final List<String> sentences = new ArrayList<>();
for (final String line : lines) {
final String segmentedLine = segmenterNonBreaker(line);
final String[] lineSentences = segmentedLine.split("\n");
for (final String lineSentence : lineSentences) {
sentences.add(lineSentence);
}
}
return sentences.toArray(new String[sentences.size()]);
}
|
java
|
public String[] segmenterExceptions(final String[] lines) {
final List<String> sentences = new ArrayList<>();
for (final String line : lines) {
final String segmentedLine = segmenterNonBreaker(line);
final String[] lineSentences = segmentedLine.split("\n");
for (final String lineSentence : lineSentences) {
sentences.add(lineSentence);
}
}
return sentences.toArray(new String[sentences.size()]);
}
|
[
"public",
"String",
"[",
"]",
"segmenterExceptions",
"(",
"final",
"String",
"[",
"]",
"lines",
")",
"{",
"final",
"List",
"<",
"String",
">",
"sentences",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"String",
"line",
":",
"lines",
")",
"{",
"final",
"String",
"segmentedLine",
"=",
"segmenterNonBreaker",
"(",
"line",
")",
";",
"final",
"String",
"[",
"]",
"lineSentences",
"=",
"segmentedLine",
".",
"split",
"(",
"\"\\n\"",
")",
";",
"for",
"(",
"final",
"String",
"lineSentence",
":",
"lineSentences",
")",
"{",
"sentences",
".",
"add",
"(",
"lineSentence",
")",
";",
"}",
"}",
"return",
"sentences",
".",
"toArray",
"(",
"new",
"String",
"[",
"sentences",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Segment the rest of the text taking into account some exceptions for
periods as sentence breakers. It decides when a period marks an end of
sentence.
@param lines
the segmented sentences so far
@return all the segmented sentences
|
[
"Segment",
"the",
"rest",
"of",
"the",
"text",
"taking",
"into",
"account",
"some",
"exceptions",
"for",
"periods",
"as",
"sentence",
"breakers",
".",
"It",
"decides",
"when",
"a",
"period",
"marks",
"an",
"end",
"of",
"sentence",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/tok/NonPeriodBreaker.java#L188-L198
|
145,780
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/tok/NonPeriodBreaker.java
|
NonPeriodBreaker.segmenterNonBreaker
|
private String segmenterNonBreaker(String line) {
// these are fine because they do not affect offsets
line = line.trim();
line = RuleBasedTokenizer.doubleSpaces.matcher(line).replaceAll(" ");
final StringBuilder sb = new StringBuilder();
String segmentedText = "";
int i;
final String[] words = line.split(" ");
// iterate over the words
for (i = 0; i < words.length - 1; i++) {
final Matcher nonSegmentedWordMatcher = nonSegmentedWords
.matcher(words[i]);
// candidate word to be segmented found:
if (nonSegmentedWordMatcher.find()) {
final String curWord = nonSegmentedWordMatcher.replaceAll("$1");
final String finalPunct = nonSegmentedWordMatcher.replaceAll("$2");
if (!curWord.isEmpty() && curWord.matches("(" + this.NON_BREAKER + ")")
&& finalPunct.isEmpty()) {
// if current word is not empty and is a no breaker and there is not
// final punctuation
} else if (acronym.matcher(words[i]).find()) {
// if acronym
} else if (nextCandidateWord.matcher(words[i + 1]).find()) {
// if next word contains initial punctuation and then uppercase or
// digit do:
if (!(!curWord.isEmpty() && curWord.matches(NON_BREAKER_DIGITS)
&& finalPunct.isEmpty()
&& startDigit.matcher(words[i + 1]).find())) {
// segment unless current word is a non breaker digit and next word
// is not final punctuation or does not start with a number
words[i] = words[i] + "\n";
}
}
}
sb.append(words[i]).append(" ");
segmentedText = sb.toString();
}
// add last index of words array removed for easy look ahead
segmentedText = segmentedText + words[i];
return segmentedText;
}
|
java
|
private String segmenterNonBreaker(String line) {
// these are fine because they do not affect offsets
line = line.trim();
line = RuleBasedTokenizer.doubleSpaces.matcher(line).replaceAll(" ");
final StringBuilder sb = new StringBuilder();
String segmentedText = "";
int i;
final String[] words = line.split(" ");
// iterate over the words
for (i = 0; i < words.length - 1; i++) {
final Matcher nonSegmentedWordMatcher = nonSegmentedWords
.matcher(words[i]);
// candidate word to be segmented found:
if (nonSegmentedWordMatcher.find()) {
final String curWord = nonSegmentedWordMatcher.replaceAll("$1");
final String finalPunct = nonSegmentedWordMatcher.replaceAll("$2");
if (!curWord.isEmpty() && curWord.matches("(" + this.NON_BREAKER + ")")
&& finalPunct.isEmpty()) {
// if current word is not empty and is a no breaker and there is not
// final punctuation
} else if (acronym.matcher(words[i]).find()) {
// if acronym
} else if (nextCandidateWord.matcher(words[i + 1]).find()) {
// if next word contains initial punctuation and then uppercase or
// digit do:
if (!(!curWord.isEmpty() && curWord.matches(NON_BREAKER_DIGITS)
&& finalPunct.isEmpty()
&& startDigit.matcher(words[i + 1]).find())) {
// segment unless current word is a non breaker digit and next word
// is not final punctuation or does not start with a number
words[i] = words[i] + "\n";
}
}
}
sb.append(words[i]).append(" ");
segmentedText = sb.toString();
}
// add last index of words array removed for easy look ahead
segmentedText = segmentedText + words[i];
return segmentedText;
}
|
[
"private",
"String",
"segmenterNonBreaker",
"(",
"String",
"line",
")",
"{",
"// these are fine because they do not affect offsets",
"line",
"=",
"line",
".",
"trim",
"(",
")",
";",
"line",
"=",
"RuleBasedTokenizer",
".",
"doubleSpaces",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\" \"",
")",
";",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"segmentedText",
"=",
"\"\"",
";",
"int",
"i",
";",
"final",
"String",
"[",
"]",
"words",
"=",
"line",
".",
"split",
"(",
"\" \"",
")",
";",
"// iterate over the words",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"words",
".",
"length",
"-",
"1",
";",
"i",
"++",
")",
"{",
"final",
"Matcher",
"nonSegmentedWordMatcher",
"=",
"nonSegmentedWords",
".",
"matcher",
"(",
"words",
"[",
"i",
"]",
")",
";",
"// candidate word to be segmented found:",
"if",
"(",
"nonSegmentedWordMatcher",
".",
"find",
"(",
")",
")",
"{",
"final",
"String",
"curWord",
"=",
"nonSegmentedWordMatcher",
".",
"replaceAll",
"(",
"\"$1\"",
")",
";",
"final",
"String",
"finalPunct",
"=",
"nonSegmentedWordMatcher",
".",
"replaceAll",
"(",
"\"$2\"",
")",
";",
"if",
"(",
"!",
"curWord",
".",
"isEmpty",
"(",
")",
"&&",
"curWord",
".",
"matches",
"(",
"\"(\"",
"+",
"this",
".",
"NON_BREAKER",
"+",
"\")\"",
")",
"&&",
"finalPunct",
".",
"isEmpty",
"(",
")",
")",
"{",
"// if current word is not empty and is a no breaker and there is not",
"// final punctuation",
"}",
"else",
"if",
"(",
"acronym",
".",
"matcher",
"(",
"words",
"[",
"i",
"]",
")",
".",
"find",
"(",
")",
")",
"{",
"// if acronym",
"}",
"else",
"if",
"(",
"nextCandidateWord",
".",
"matcher",
"(",
"words",
"[",
"i",
"+",
"1",
"]",
")",
".",
"find",
"(",
")",
")",
"{",
"// if next word contains initial punctuation and then uppercase or",
"// digit do:",
"if",
"(",
"!",
"(",
"!",
"curWord",
".",
"isEmpty",
"(",
")",
"&&",
"curWord",
".",
"matches",
"(",
"NON_BREAKER_DIGITS",
")",
"&&",
"finalPunct",
".",
"isEmpty",
"(",
")",
"&&",
"startDigit",
".",
"matcher",
"(",
"words",
"[",
"i",
"+",
"1",
"]",
")",
".",
"find",
"(",
")",
")",
")",
"{",
"// segment unless current word is a non breaker digit and next word",
"// is not final punctuation or does not start with a number",
"words",
"[",
"i",
"]",
"=",
"words",
"[",
"i",
"]",
"+",
"\"\\n\"",
";",
"}",
"}",
"}",
"sb",
".",
"append",
"(",
"words",
"[",
"i",
"]",
")",
".",
"append",
"(",
"\" \"",
")",
";",
"segmentedText",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"// add last index of words array removed for easy look ahead",
"segmentedText",
"=",
"segmentedText",
"+",
"words",
"[",
"i",
"]",
";",
"return",
"segmentedText",
";",
"}"
] |
This function implements exceptions for periods as sentence breakers. It
decides when a period induces a new sentence or not.
@param line
the text to be processed
@return segmented text (with newlines included)
|
[
"This",
"function",
"implements",
"exceptions",
"for",
"periods",
"as",
"sentence",
"breakers",
".",
"It",
"decides",
"when",
"a",
"period",
"induces",
"a",
"new",
"sentence",
"or",
"not",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/tok/NonPeriodBreaker.java#L208-L249
|
145,781
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/tok/NonPeriodBreaker.java
|
NonPeriodBreaker.TokenizerNonBreaker
|
public String TokenizerNonBreaker(String line) {
// these are fine because they do not affect offsets
line = line.trim();
line = RuleBasedTokenizer.doubleSpaces.matcher(line).replaceAll(" ");
final StringBuilder sb = new StringBuilder();
String tokenizedText = "";
int i;
final String[] words = line.split(" ");
for (i = 0; i < words.length; i++) {
final Matcher wordDotMatcher = wordDot.matcher(words[i]);
// find anything non-whitespace finishing with a period
if (wordDotMatcher.find()) {
final String curWord = wordDotMatcher.replaceAll("$1");
if (curWord.contains(".") && alphabetic.matcher(curWord).find()
|| curWord.matches("(" + this.NON_BREAKER + ")")
|| i < words.length - 1 && (startLower.matcher(words[i + 1]).find()
|| startPunct.matcher(words[i + 1]).find())) {
// do not tokenize if (word contains a period and is alphabetic) OR
// word is a non breaker OR (word is a non breaker and next is
// (lowercase or starts with punctuation that is end of sentence
// marker))
} else if (curWord.matches(NON_BREAKER_DIGITS) && i < words.length - 1
&& startDigit.matcher(words[i + 1]).find()) {
// do not tokenize if word is a nonbreaker digit AND next word starts
// with a digit
} else {
words[i] = curWord + " .";
}
}
sb.append(words[i]).append(" ");
tokenizedText = sb.toString();
}
return tokenizedText;
}
|
java
|
public String TokenizerNonBreaker(String line) {
// these are fine because they do not affect offsets
line = line.trim();
line = RuleBasedTokenizer.doubleSpaces.matcher(line).replaceAll(" ");
final StringBuilder sb = new StringBuilder();
String tokenizedText = "";
int i;
final String[] words = line.split(" ");
for (i = 0; i < words.length; i++) {
final Matcher wordDotMatcher = wordDot.matcher(words[i]);
// find anything non-whitespace finishing with a period
if (wordDotMatcher.find()) {
final String curWord = wordDotMatcher.replaceAll("$1");
if (curWord.contains(".") && alphabetic.matcher(curWord).find()
|| curWord.matches("(" + this.NON_BREAKER + ")")
|| i < words.length - 1 && (startLower.matcher(words[i + 1]).find()
|| startPunct.matcher(words[i + 1]).find())) {
// do not tokenize if (word contains a period and is alphabetic) OR
// word is a non breaker OR (word is a non breaker and next is
// (lowercase or starts with punctuation that is end of sentence
// marker))
} else if (curWord.matches(NON_BREAKER_DIGITS) && i < words.length - 1
&& startDigit.matcher(words[i + 1]).find()) {
// do not tokenize if word is a nonbreaker digit AND next word starts
// with a digit
} else {
words[i] = curWord + " .";
}
}
sb.append(words[i]).append(" ");
tokenizedText = sb.toString();
}
return tokenizedText;
}
|
[
"public",
"String",
"TokenizerNonBreaker",
"(",
"String",
"line",
")",
"{",
"// these are fine because they do not affect offsets",
"line",
"=",
"line",
".",
"trim",
"(",
")",
";",
"line",
"=",
"RuleBasedTokenizer",
".",
"doubleSpaces",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\" \"",
")",
";",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"tokenizedText",
"=",
"\"\"",
";",
"int",
"i",
";",
"final",
"String",
"[",
"]",
"words",
"=",
"line",
".",
"split",
"(",
"\" \"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"words",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"Matcher",
"wordDotMatcher",
"=",
"wordDot",
".",
"matcher",
"(",
"words",
"[",
"i",
"]",
")",
";",
"// find anything non-whitespace finishing with a period",
"if",
"(",
"wordDotMatcher",
".",
"find",
"(",
")",
")",
"{",
"final",
"String",
"curWord",
"=",
"wordDotMatcher",
".",
"replaceAll",
"(",
"\"$1\"",
")",
";",
"if",
"(",
"curWord",
".",
"contains",
"(",
"\".\"",
")",
"&&",
"alphabetic",
".",
"matcher",
"(",
"curWord",
")",
".",
"find",
"(",
")",
"||",
"curWord",
".",
"matches",
"(",
"\"(\"",
"+",
"this",
".",
"NON_BREAKER",
"+",
"\")\"",
")",
"||",
"i",
"<",
"words",
".",
"length",
"-",
"1",
"&&",
"(",
"startLower",
".",
"matcher",
"(",
"words",
"[",
"i",
"+",
"1",
"]",
")",
".",
"find",
"(",
")",
"||",
"startPunct",
".",
"matcher",
"(",
"words",
"[",
"i",
"+",
"1",
"]",
")",
".",
"find",
"(",
")",
")",
")",
"{",
"// do not tokenize if (word contains a period and is alphabetic) OR",
"// word is a non breaker OR (word is a non breaker and next is",
"// (lowercase or starts with punctuation that is end of sentence",
"// marker))",
"}",
"else",
"if",
"(",
"curWord",
".",
"matches",
"(",
"NON_BREAKER_DIGITS",
")",
"&&",
"i",
"<",
"words",
".",
"length",
"-",
"1",
"&&",
"startDigit",
".",
"matcher",
"(",
"words",
"[",
"i",
"+",
"1",
"]",
")",
".",
"find",
"(",
")",
")",
"{",
"// do not tokenize if word is a nonbreaker digit AND next word starts",
"// with a digit",
"}",
"else",
"{",
"words",
"[",
"i",
"]",
"=",
"curWord",
"+",
"\" .\"",
";",
"}",
"}",
"sb",
".",
"append",
"(",
"words",
"[",
"i",
"]",
")",
".",
"append",
"(",
"\" \"",
")",
";",
"tokenizedText",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"return",
"tokenizedText",
";",
"}"
] |
It decides when periods do not need to be tokenized.
@param line
the sentence to be tokenized
@return line
|
[
"It",
"decides",
"when",
"periods",
"do",
"not",
"need",
"to",
"be",
"tokenized",
"."
] |
c817fa1e40e96ed15fc79d22c3a7c25f1a40d172
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/tok/NonPeriodBreaker.java#L258-L295
|
145,782
|
OpenBEL/openbel-framework
|
org.openbel.framework.core/src/main/java/org/openbel/framework/core/compiler/expansion/ExpansionRule.java
|
ExpansionRule.attachExpansionRuleCitation
|
protected void attachExpansionRuleCitation(Statement statement) {
AnnotationGroup ag = new AnnotationGroup();
Citation citation = getInstance().createCitation(getName());
citation.setType(CitationType.OTHER);
citation.setReference(getName());
ag.setCitation(citation);
statement.setAnnotationGroup(ag);
}
|
java
|
protected void attachExpansionRuleCitation(Statement statement) {
AnnotationGroup ag = new AnnotationGroup();
Citation citation = getInstance().createCitation(getName());
citation.setType(CitationType.OTHER);
citation.setReference(getName());
ag.setCitation(citation);
statement.setAnnotationGroup(ag);
}
|
[
"protected",
"void",
"attachExpansionRuleCitation",
"(",
"Statement",
"statement",
")",
"{",
"AnnotationGroup",
"ag",
"=",
"new",
"AnnotationGroup",
"(",
")",
";",
"Citation",
"citation",
"=",
"getInstance",
"(",
")",
".",
"createCitation",
"(",
"getName",
"(",
")",
")",
";",
"citation",
".",
"setType",
"(",
"CitationType",
".",
"OTHER",
")",
";",
"citation",
".",
"setReference",
"(",
"getName",
"(",
")",
")",
";",
"ag",
".",
"setCitation",
"(",
"citation",
")",
";",
"statement",
".",
"setAnnotationGroup",
"(",
"ag",
")",
";",
"}"
] |
Attach citation for expansion rule
@param statement {@link Statement}
|
[
"Attach",
"citation",
"for",
"expansion",
"rule"
] |
149f80b1d6eabb15ab15815b6f745b0afa9fd2d3
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.core/src/main/java/org/openbel/framework/core/compiler/expansion/ExpansionRule.java#L84-L91
|
145,783
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/swap/SwapFragmentPanel.java
|
SwapFragmentPanel.onSwapToEdit
|
public void onSwapToEdit(final AjaxRequestTarget target, final Form<?> form)
{
swapFragments();
if (target != null)
{
Animate.slideUpAndDown(view, target);
}
else
{
LOGGER.error(
"AjaxRequestTarget is null on method SwapFragmentPanel#onSwapToEdit(AjaxRequestTarget, Form)");
}
modeContext = ModeContext.EDIT_MODE;
}
|
java
|
public void onSwapToEdit(final AjaxRequestTarget target, final Form<?> form)
{
swapFragments();
if (target != null)
{
Animate.slideUpAndDown(view, target);
}
else
{
LOGGER.error(
"AjaxRequestTarget is null on method SwapFragmentPanel#onSwapToEdit(AjaxRequestTarget, Form)");
}
modeContext = ModeContext.EDIT_MODE;
}
|
[
"public",
"void",
"onSwapToEdit",
"(",
"final",
"AjaxRequestTarget",
"target",
",",
"final",
"Form",
"<",
"?",
">",
"form",
")",
"{",
"swapFragments",
"(",
")",
";",
"if",
"(",
"target",
"!=",
"null",
")",
"{",
"Animate",
".",
"slideUpAndDown",
"(",
"view",
",",
"target",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"error",
"(",
"\"AjaxRequestTarget is null on method SwapFragmentPanel#onSwapToEdit(AjaxRequestTarget, Form)\"",
")",
";",
"}",
"modeContext",
"=",
"ModeContext",
".",
"EDIT_MODE",
";",
"}"
] |
Swaps from the view fragment to the edit fragment.
@param target
the target
@param form
the form
|
[
"Swaps",
"from",
"the",
"view",
"fragment",
"to",
"the",
"edit",
"fragment",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/swap/SwapFragmentPanel.java#L125-L138
|
145,784
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/swap/SwapFragmentPanel.java
|
SwapFragmentPanel.onSwapToView
|
public void onSwapToView(final AjaxRequestTarget target, final Form<?> form)
{
if (target != null)
{
Animate.slideUpAndDown(edit, target);
}
else
{
LOGGER.error(
"AjaxRequestTarget is null on method SwapFragmentPanel#onSwapToView(AjaxRequestTarget, Form)");
}
swapFragments();
modeContext = ModeContext.VIEW_MODE;
}
|
java
|
public void onSwapToView(final AjaxRequestTarget target, final Form<?> form)
{
if (target != null)
{
Animate.slideUpAndDown(edit, target);
}
else
{
LOGGER.error(
"AjaxRequestTarget is null on method SwapFragmentPanel#onSwapToView(AjaxRequestTarget, Form)");
}
swapFragments();
modeContext = ModeContext.VIEW_MODE;
}
|
[
"public",
"void",
"onSwapToView",
"(",
"final",
"AjaxRequestTarget",
"target",
",",
"final",
"Form",
"<",
"?",
">",
"form",
")",
"{",
"if",
"(",
"target",
"!=",
"null",
")",
"{",
"Animate",
".",
"slideUpAndDown",
"(",
"edit",
",",
"target",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"error",
"(",
"\"AjaxRequestTarget is null on method SwapFragmentPanel#onSwapToView(AjaxRequestTarget, Form)\"",
")",
";",
"}",
"swapFragments",
"(",
")",
";",
"modeContext",
"=",
"ModeContext",
".",
"VIEW_MODE",
";",
"}"
] |
Swaps from the edit fragment to the view fragment.
@param target
the target
@param form
the form
|
[
"Swaps",
"from",
"the",
"edit",
"fragment",
"to",
"the",
"view",
"fragment",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/swap/SwapFragmentPanel.java#L148-L161
|
145,785
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/swap/SwapFragmentPanel.java
|
SwapFragmentPanel.swapFragments
|
private void swapFragments()
{
final Fragment fragment = view;
view.replaceWith(edit);
view = edit;
edit = fragment;
}
|
java
|
private void swapFragments()
{
final Fragment fragment = view;
view.replaceWith(edit);
view = edit;
edit = fragment;
}
|
[
"private",
"void",
"swapFragments",
"(",
")",
"{",
"final",
"Fragment",
"fragment",
"=",
"view",
";",
"view",
".",
"replaceWith",
"(",
"edit",
")",
";",
"view",
"=",
"edit",
";",
"edit",
"=",
"fragment",
";",
"}"
] |
Swap the fragments.
|
[
"Swap",
"the",
"fragments",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/swap/SwapFragmentPanel.java#L166-L172
|
145,786
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/swap/SwapFragmentPanel.java
|
SwapFragmentPanel.swapFragments
|
protected void swapFragments(final AjaxRequestTarget target, final Form<?> form)
{
if (modeContext.equals(ModeContext.VIEW_MODE))
{
onSwapToEdit(target, form);
}
else
{
onSwapToView(target, form);
}
}
|
java
|
protected void swapFragments(final AjaxRequestTarget target, final Form<?> form)
{
if (modeContext.equals(ModeContext.VIEW_MODE))
{
onSwapToEdit(target, form);
}
else
{
onSwapToView(target, form);
}
}
|
[
"protected",
"void",
"swapFragments",
"(",
"final",
"AjaxRequestTarget",
"target",
",",
"final",
"Form",
"<",
"?",
">",
"form",
")",
"{",
"if",
"(",
"modeContext",
".",
"equals",
"(",
"ModeContext",
".",
"VIEW_MODE",
")",
")",
"{",
"onSwapToEdit",
"(",
"target",
",",
"form",
")",
";",
"}",
"else",
"{",
"onSwapToView",
"(",
"target",
",",
"form",
")",
";",
"}",
"}"
] |
Swaps the fragments.
@param target
the target
@param form
the form
|
[
"Swaps",
"the",
"fragments",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/swap/SwapFragmentPanel.java#L182-L192
|
145,787
|
geomajas/geomajas-project-client-gwt2
|
impl/src/main/java/org/geomajas/gwt2/client/map/render/dom/container/HtmlGroup.java
|
HtmlGroup.add
|
public void add(HtmlObject child) {
asDivPanel().add(child);
if (child instanceof AbstractHtmlObject) {
((AbstractHtmlObject) child).setParent(this);
}
child.setLeft(child.getLeft());
child.setTop(child.getTop());
}
|
java
|
public void add(HtmlObject child) {
asDivPanel().add(child);
if (child instanceof AbstractHtmlObject) {
((AbstractHtmlObject) child).setParent(this);
}
child.setLeft(child.getLeft());
child.setTop(child.getTop());
}
|
[
"public",
"void",
"add",
"(",
"HtmlObject",
"child",
")",
"{",
"asDivPanel",
"(",
")",
".",
"add",
"(",
"child",
")",
";",
"if",
"(",
"child",
"instanceof",
"AbstractHtmlObject",
")",
"{",
"(",
"(",
"AbstractHtmlObject",
")",
"child",
")",
".",
"setParent",
"(",
"this",
")",
";",
"}",
"child",
".",
"setLeft",
"(",
"child",
".",
"getLeft",
"(",
")",
")",
";",
"child",
".",
"setTop",
"(",
"child",
".",
"getTop",
"(",
")",
")",
";",
"}"
] |
Add a new child HtmlObject to the list. Note that using this method children are added to the back of the list,
which means that they are added on top of the visibility stack and thus may obscure other children. Take this
order into account when adding children.
@param child
The actual child to add.
|
[
"Add",
"a",
"new",
"child",
"HtmlObject",
"to",
"the",
"list",
".",
"Note",
"that",
"using",
"this",
"method",
"children",
"are",
"added",
"to",
"the",
"back",
"of",
"the",
"list",
"which",
"means",
"that",
"they",
"are",
"added",
"on",
"top",
"of",
"the",
"visibility",
"stack",
"and",
"thus",
"may",
"obscure",
"other",
"children",
".",
"Take",
"this",
"order",
"into",
"account",
"when",
"adding",
"children",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/impl/src/main/java/org/geomajas/gwt2/client/map/render/dom/container/HtmlGroup.java#L102-L109
|
145,788
|
geomajas/geomajas-project-client-gwt2
|
impl/src/main/java/org/geomajas/gwt2/client/map/render/dom/container/HtmlGroup.java
|
HtmlGroup.insert
|
public void insert(HtmlObject child, int beforeIndex) {
asDivPanel().insertBefore(child, beforeIndex);
if (child instanceof AbstractHtmlObject) {
((AbstractHtmlObject) child).setParent(this);
}
child.setLeft(child.getLeft());
child.setTop(child.getTop());
}
|
java
|
public void insert(HtmlObject child, int beforeIndex) {
asDivPanel().insertBefore(child, beforeIndex);
if (child instanceof AbstractHtmlObject) {
((AbstractHtmlObject) child).setParent(this);
}
child.setLeft(child.getLeft());
child.setTop(child.getTop());
}
|
[
"public",
"void",
"insert",
"(",
"HtmlObject",
"child",
",",
"int",
"beforeIndex",
")",
"{",
"asDivPanel",
"(",
")",
".",
"insertBefore",
"(",
"child",
",",
"beforeIndex",
")",
";",
"if",
"(",
"child",
"instanceof",
"AbstractHtmlObject",
")",
"{",
"(",
"(",
"AbstractHtmlObject",
")",
"child",
")",
".",
"setParent",
"(",
"this",
")",
";",
"}",
"child",
".",
"setLeft",
"(",
"child",
".",
"getLeft",
"(",
")",
")",
";",
"child",
".",
"setTop",
"(",
"child",
".",
"getTop",
"(",
")",
")",
";",
"}"
] |
Insert a new child HtmlObject in the list at a certain index. The position will determine it's place in the
visibility stack, where the first element lies at the bottom and the last element on top.
@param child
The actual child to add.
@param beforeIndex
The position in the list where this child should end up.
|
[
"Insert",
"a",
"new",
"child",
"HtmlObject",
"in",
"the",
"list",
"at",
"a",
"certain",
"index",
".",
"The",
"position",
"will",
"determine",
"it",
"s",
"place",
"in",
"the",
"visibility",
"stack",
"where",
"the",
"first",
"element",
"lies",
"at",
"the",
"bottom",
"and",
"the",
"last",
"element",
"on",
"top",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/impl/src/main/java/org/geomajas/gwt2/client/map/render/dom/container/HtmlGroup.java#L120-L127
|
145,789
|
geomajas/geomajas-project-client-gwt2
|
impl/src/main/java/org/geomajas/gwt2/client/map/render/dom/container/HtmlGroup.java
|
HtmlGroup.remove
|
public boolean remove(HtmlObject child) {
if (child instanceof AbstractHtmlObject) {
((AbstractHtmlObject) child).setParent(null);
}
return asDivPanel().remove(child);
}
|
java
|
public boolean remove(HtmlObject child) {
if (child instanceof AbstractHtmlObject) {
((AbstractHtmlObject) child).setParent(null);
}
return asDivPanel().remove(child);
}
|
[
"public",
"boolean",
"remove",
"(",
"HtmlObject",
"child",
")",
"{",
"if",
"(",
"child",
"instanceof",
"AbstractHtmlObject",
")",
"{",
"(",
"(",
"AbstractHtmlObject",
")",
"child",
")",
".",
"setParent",
"(",
"null",
")",
";",
"}",
"return",
"asDivPanel",
"(",
")",
".",
"remove",
"(",
"child",
")",
";",
"}"
] |
Remove a child element from the list.
@param child
The actual child to remove.
@return Returns true or false indicating whether or not removal was successful.
|
[
"Remove",
"a",
"child",
"element",
"from",
"the",
"list",
"."
] |
bd8d7904e861fa80522eed7b83c4ea99844180c7
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/impl/src/main/java/org/geomajas/gwt2/client/map/render/dom/container/HtmlGroup.java#L136-L141
|
145,790
|
astrapi69/jaulp-wicket
|
jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/parameter/PageParametersExtensions.java
|
PageParametersExtensions.getPageParametersMap
|
public static Map<String, List<StringValue>> getPageParametersMap(final Request request)
{
final Map<String, List<StringValue>> map = new HashMap<>();
addToParameters(request.getRequestParameters(), map);
addToParameters(request.getQueryParameters(), map);
addToParameters(request.getPostParameters(), map);
return map;
}
|
java
|
public static Map<String, List<StringValue>> getPageParametersMap(final Request request)
{
final Map<String, List<StringValue>> map = new HashMap<>();
addToParameters(request.getRequestParameters(), map);
addToParameters(request.getQueryParameters(), map);
addToParameters(request.getPostParameters(), map);
return map;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"List",
"<",
"StringValue",
">",
">",
"getPageParametersMap",
"(",
"final",
"Request",
"request",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"List",
"<",
"StringValue",
">",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"addToParameters",
"(",
"request",
".",
"getRequestParameters",
"(",
")",
",",
"map",
")",
";",
"addToParameters",
"(",
"request",
".",
"getQueryParameters",
"(",
")",
",",
"map",
")",
";",
"addToParameters",
"(",
"request",
".",
"getPostParameters",
"(",
")",
",",
"map",
")",
";",
"return",
"map",
";",
"}"
] |
Gets a map with all parameters. Looks in the query, request and post parameters.
@param request
the request
@return a map with all parameters.
|
[
"Gets",
"a",
"map",
"with",
"all",
"parameters",
".",
"Looks",
"in",
"the",
"query",
"request",
"and",
"post",
"parameters",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/parameter/PageParametersExtensions.java#L159-L166
|
145,791
|
astrapi69/jaulp-wicket
|
jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/parameter/PageParametersExtensions.java
|
PageParametersExtensions.getParameter
|
public static String getParameter(final PageParameters parameters, final String name)
{
return getString(parameters.get(name));
}
|
java
|
public static String getParameter(final PageParameters parameters, final String name)
{
return getString(parameters.get(name));
}
|
[
"public",
"static",
"String",
"getParameter",
"(",
"final",
"PageParameters",
"parameters",
",",
"final",
"String",
"name",
")",
"{",
"return",
"getString",
"(",
"parameters",
".",
"get",
"(",
"name",
")",
")",
";",
"}"
] |
Gets the parameter or returns null if it does not exists or is empty.
@param parameters
the parameters
@param name
the name
@return the parameter or returns null if it does not exists or is empty.
|
[
"Gets",
"the",
"parameter",
"or",
"returns",
"null",
"if",
"it",
"does",
"not",
"exists",
"or",
"is",
"empty",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/parameter/PageParametersExtensions.java#L177-L180
|
145,792
|
astrapi69/jaulp-wicket
|
jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/parameter/PageParametersExtensions.java
|
PageParametersExtensions.toInteger
|
public static Integer toInteger(final StringValue stringValue)
{
Integer value = null;
if (isNotNullOrEmpty(stringValue))
{
try
{
value = stringValue.toInteger();
}
catch (final StringValueConversionException e)
{
LOGGER.error("Error by converting the given StringValue.", e);
}
}
return value;
}
|
java
|
public static Integer toInteger(final StringValue stringValue)
{
Integer value = null;
if (isNotNullOrEmpty(stringValue))
{
try
{
value = stringValue.toInteger();
}
catch (final StringValueConversionException e)
{
LOGGER.error("Error by converting the given StringValue.", e);
}
}
return value;
}
|
[
"public",
"static",
"Integer",
"toInteger",
"(",
"final",
"StringValue",
"stringValue",
")",
"{",
"Integer",
"value",
"=",
"null",
";",
"if",
"(",
"isNotNullOrEmpty",
"(",
"stringValue",
")",
")",
"{",
"try",
"{",
"value",
"=",
"stringValue",
".",
"toInteger",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"StringValueConversionException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Error by converting the given StringValue.\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"value",
";",
"}"
] |
Gets the Integer object or returns null if the given StringValue is null or empty.
@param stringValue
the user id as StringValue object
@return the Integer object or null if the given StringValue is null or empty.
|
[
"Gets",
"the",
"Integer",
"object",
"or",
"returns",
"null",
"if",
"the",
"given",
"StringValue",
"is",
"null",
"or",
"empty",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/parameter/PageParametersExtensions.java#L311-L326
|
145,793
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java
|
AjaxAddableTabbedPanel.newAddTabButtonLabel
|
protected Label newAddTabButtonLabel(final String id, final IModel<String> model)
{
return ComponentFactory.newLabel(id, model);
}
|
java
|
protected Label newAddTabButtonLabel(final String id, final IModel<String> model)
{
return ComponentFactory.newLabel(id, model);
}
|
[
"protected",
"Label",
"newAddTabButtonLabel",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"String",
">",
"model",
")",
"{",
"return",
"ComponentFactory",
".",
"newLabel",
"(",
"id",
",",
"model",
")",
";",
"}"
] |
Factory method for creating the new label of the button.
@param id
the id
@param model
the model
@return the new label of the button.
|
[
"Factory",
"method",
"for",
"creating",
"the",
"new",
"label",
"of",
"the",
"button",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java#L315-L318
|
145,794
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java
|
AjaxAddableTabbedPanel.newCloseLink
|
protected WebMarkupContainer newCloseLink(final String linkId, final int index)
{
return new AjaxFallbackLink<Void>(linkId)
{
private static final long serialVersionUID = 1L;
@Override
public void onClick(final AjaxRequestTarget target)
{
if (target != null)
{
onRemoveTab(target, index);
}
onAjaxUpdate(target);
}
};
}
|
java
|
protected WebMarkupContainer newCloseLink(final String linkId, final int index)
{
return new AjaxFallbackLink<Void>(linkId)
{
private static final long serialVersionUID = 1L;
@Override
public void onClick(final AjaxRequestTarget target)
{
if (target != null)
{
onRemoveTab(target, index);
}
onAjaxUpdate(target);
}
};
}
|
[
"protected",
"WebMarkupContainer",
"newCloseLink",
"(",
"final",
"String",
"linkId",
",",
"final",
"int",
"index",
")",
"{",
"return",
"new",
"AjaxFallbackLink",
"<",
"Void",
">",
"(",
"linkId",
")",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"@",
"Override",
"public",
"void",
"onClick",
"(",
"final",
"AjaxRequestTarget",
"target",
")",
"{",
"if",
"(",
"target",
"!=",
"null",
")",
"{",
"onRemoveTab",
"(",
"target",
",",
"index",
")",
";",
"}",
"onAjaxUpdate",
"(",
"target",
")",
";",
"}",
"}",
";",
"}"
] |
Factory method for links used to close the selected tab.
The created component is attached to the following markup. Label component with id: title
will be added for you by the tabbed panel.
<pre>
<a href="#" wicket:id="link"><span wicket:id="title">[[tab title]]</span></a>
</pre>
Example implementation:
<pre>
protected WebMarkupContainer newCloseLink(String linkId, final int index)
{
return new Link(linkId)
{
private static final long serialVersionUID = 1L;
public void onClick()
{
setSelectedTab(index);
}
};
}
</pre>
@param linkId
component id with which the link should be created
@param index
index of the tab that should be activated when this link is clicked. See
{@link #setSelectedTab(int)}.
@return created link component
|
[
"Factory",
"method",
"for",
"links",
"used",
"to",
"close",
"the",
"selected",
"tab",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java#L392-L409
|
145,795
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java
|
AjaxAddableTabbedPanel.newLink
|
protected WebMarkupContainer newLink(final String linkId, final int index)
{
return new AjaxFallbackLink<Void>(linkId)
{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
public void onClick(final AjaxRequestTarget target)
{
setSelectedTab(index);
if (target != null)
{
target.add(AjaxAddableTabbedPanel.this);
}
onAjaxUpdate(target);
}
};
}
|
java
|
protected WebMarkupContainer newLink(final String linkId, final int index)
{
return new AjaxFallbackLink<Void>(linkId)
{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
public void onClick(final AjaxRequestTarget target)
{
setSelectedTab(index);
if (target != null)
{
target.add(AjaxAddableTabbedPanel.this);
}
onAjaxUpdate(target);
}
};
}
|
[
"protected",
"WebMarkupContainer",
"newLink",
"(",
"final",
"String",
"linkId",
",",
"final",
"int",
"index",
")",
"{",
"return",
"new",
"AjaxFallbackLink",
"<",
"Void",
">",
"(",
"linkId",
")",
"{",
"/** The Constant serialVersionUID. */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"/**\n\t\t\t * {@inheritDoc}\n\t\t\t */",
"@",
"Override",
"public",
"void",
"onClick",
"(",
"final",
"AjaxRequestTarget",
"target",
")",
"{",
"setSelectedTab",
"(",
"index",
")",
";",
"if",
"(",
"target",
"!=",
"null",
")",
"{",
"target",
".",
"add",
"(",
"AjaxAddableTabbedPanel",
".",
"this",
")",
";",
"}",
"onAjaxUpdate",
"(",
"target",
")",
";",
"}",
"}",
";",
"}"
] |
Factory method for links used to switch between tabs.
The created component is attached to the following markup. Label component with id: title
will be added for you by the tabbed panel.
<pre>
<a href="#" wicket:id="link"><span wicket:id="title">[[tab title]]</span></a>
</pre>
Example implementation:
<pre>
protected WebMarkupContainer newLink(String linkId, final int index)
{
return new Link(linkId)
{
private static final long serialVersionUID = 1L;
public void onClick()
{
setSelectedTab(index);
}
};
}
</pre>
@param linkId
component id with which the link should be created
@param index
index of the tab that should be activated when this link is clicked. See
{@link #setSelectedTab(int)}.
@return created link component
|
[
"Factory",
"method",
"for",
"links",
"used",
"to",
"switch",
"between",
"tabs",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java#L463-L486
|
145,796
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java
|
AjaxAddableTabbedPanel.onRemoveTab
|
public void onRemoveTab(final AjaxRequestTarget target, final int index)
{
final int tabSize = getTabs().size();
// there have to be at least one tab on the ajaxTabbedPanel...
if ((2 <= tabSize) && (index < tabSize))
{
setSelectedTab(index);
getTabs().remove(index);
target.add(this);
}
}
|
java
|
public void onRemoveTab(final AjaxRequestTarget target, final int index)
{
final int tabSize = getTabs().size();
// there have to be at least one tab on the ajaxTabbedPanel...
if ((2 <= tabSize) && (index < tabSize))
{
setSelectedTab(index);
getTabs().remove(index);
target.add(this);
}
}
|
[
"public",
"void",
"onRemoveTab",
"(",
"final",
"AjaxRequestTarget",
"target",
",",
"final",
"int",
"index",
")",
"{",
"final",
"int",
"tabSize",
"=",
"getTabs",
"(",
")",
".",
"size",
"(",
")",
";",
"// there have to be at least one tab on the ajaxTabbedPanel...",
"if",
"(",
"(",
"2",
"<=",
"tabSize",
")",
"&&",
"(",
"index",
"<",
"tabSize",
")",
")",
"{",
"setSelectedTab",
"(",
"index",
")",
";",
"getTabs",
"(",
")",
".",
"remove",
"(",
"index",
")",
";",
"target",
".",
"add",
"(",
"this",
")",
";",
"}",
"}"
] |
On remove tab removes the tab of the given index.
@param target
the target
@param index
the index
|
[
"On",
"remove",
"tab",
"removes",
"the",
"tab",
"of",
"the",
"given",
"index",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java#L752-L762
|
145,797
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java
|
AjaxAddableTabbedPanel.onRemoveTab
|
public void onRemoveTab(final AjaxRequestTarget target, final T tab)
{
final int index = getTabs().indexOf(tab);
if (0 <= index)
{
onRemoveTab(target, index);
}
}
|
java
|
public void onRemoveTab(final AjaxRequestTarget target, final T tab)
{
final int index = getTabs().indexOf(tab);
if (0 <= index)
{
onRemoveTab(target, index);
}
}
|
[
"public",
"void",
"onRemoveTab",
"(",
"final",
"AjaxRequestTarget",
"target",
",",
"final",
"T",
"tab",
")",
"{",
"final",
"int",
"index",
"=",
"getTabs",
"(",
")",
".",
"indexOf",
"(",
"tab",
")",
";",
"if",
"(",
"0",
"<=",
"index",
")",
"{",
"onRemoveTab",
"(",
"target",
",",
"index",
")",
";",
"}",
"}"
] |
On remove tab removes the given tab if it does exists.
@param target
the target
@param tab
the tab
|
[
"On",
"remove",
"tab",
"removes",
"the",
"given",
"tab",
"if",
"it",
"does",
"exists",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java#L772-L779
|
145,798
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java
|
AjaxAddableTabbedPanel.setCurrentTab
|
private void setCurrentTab(final int index)
{
if (this.currentTab == index)
{
// already current
return;
}
this.currentTab = index;
final Component component;
if ((currentTab == -1) || tabs.isEmpty() || !getVisiblityCache().isVisible(currentTab))
{
// no tabs or the current tab is not visible
component = newPanel();
}
else
{
// show panel from selected tab
final T tab = tabs.get(currentTab);
component = tab.getPanel(TAB_PANEL_ID);
if (component == null)
{
throw new WicketRuntimeException("ITab.getPanel() returned null. TabbedPanel ["
+ getPath() + "] ITab index [" + currentTab + "]");
}
}
if (!component.getId().equals(TAB_PANEL_ID))
{
throw new WicketRuntimeException(
"ITab.getPanel() returned a panel with invalid id [" + component.getId()
+ "]. You always have to return a panel with id equal to the provided panelId parameter. TabbedPanel ["
+ getPath() + "] ITab index [" + currentTab + "]");
}
addOrReplace(component);
}
|
java
|
private void setCurrentTab(final int index)
{
if (this.currentTab == index)
{
// already current
return;
}
this.currentTab = index;
final Component component;
if ((currentTab == -1) || tabs.isEmpty() || !getVisiblityCache().isVisible(currentTab))
{
// no tabs or the current tab is not visible
component = newPanel();
}
else
{
// show panel from selected tab
final T tab = tabs.get(currentTab);
component = tab.getPanel(TAB_PANEL_ID);
if (component == null)
{
throw new WicketRuntimeException("ITab.getPanel() returned null. TabbedPanel ["
+ getPath() + "] ITab index [" + currentTab + "]");
}
}
if (!component.getId().equals(TAB_PANEL_ID))
{
throw new WicketRuntimeException(
"ITab.getPanel() returned a panel with invalid id [" + component.getId()
+ "]. You always have to return a panel with id equal to the provided panelId parameter. TabbedPanel ["
+ getPath() + "] ITab index [" + currentTab + "]");
}
addOrReplace(component);
}
|
[
"private",
"void",
"setCurrentTab",
"(",
"final",
"int",
"index",
")",
"{",
"if",
"(",
"this",
".",
"currentTab",
"==",
"index",
")",
"{",
"// already current",
"return",
";",
"}",
"this",
".",
"currentTab",
"=",
"index",
";",
"final",
"Component",
"component",
";",
"if",
"(",
"(",
"currentTab",
"==",
"-",
"1",
")",
"||",
"tabs",
".",
"isEmpty",
"(",
")",
"||",
"!",
"getVisiblityCache",
"(",
")",
".",
"isVisible",
"(",
"currentTab",
")",
")",
"{",
"// no tabs or the current tab is not visible",
"component",
"=",
"newPanel",
"(",
")",
";",
"}",
"else",
"{",
"// show panel from selected tab",
"final",
"T",
"tab",
"=",
"tabs",
".",
"get",
"(",
"currentTab",
")",
";",
"component",
"=",
"tab",
".",
"getPanel",
"(",
"TAB_PANEL_ID",
")",
";",
"if",
"(",
"component",
"==",
"null",
")",
"{",
"throw",
"new",
"WicketRuntimeException",
"(",
"\"ITab.getPanel() returned null. TabbedPanel [\"",
"+",
"getPath",
"(",
")",
"+",
"\"] ITab index [\"",
"+",
"currentTab",
"+",
"\"]\"",
")",
";",
"}",
"}",
"if",
"(",
"!",
"component",
".",
"getId",
"(",
")",
".",
"equals",
"(",
"TAB_PANEL_ID",
")",
")",
"{",
"throw",
"new",
"WicketRuntimeException",
"(",
"\"ITab.getPanel() returned a panel with invalid id [\"",
"+",
"component",
".",
"getId",
"(",
")",
"+",
"\"]. You always have to return a panel with id equal to the provided panelId parameter. TabbedPanel [\"",
"+",
"getPath",
"(",
")",
"+",
"\"] ITab index [\"",
"+",
"currentTab",
"+",
"\"]\"",
")",
";",
"}",
"addOrReplace",
"(",
"component",
")",
";",
"}"
] |
Sets the current tab.
@param index
the new current tab
|
[
"Sets",
"the",
"current",
"tab",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java#L787-L824
|
145,799
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/form/dropdown/OptGroupDropDownChoice.java
|
OptGroupDropDownChoice.isNewGroup
|
private boolean isNewGroup(final OptGroup currentOptGroup)
{
return (last == null) || !currentOptGroup.getLabel().equals(last.getLabel());
}
|
java
|
private boolean isNewGroup(final OptGroup currentOptGroup)
{
return (last == null) || !currentOptGroup.getLabel().equals(last.getLabel());
}
|
[
"private",
"boolean",
"isNewGroup",
"(",
"final",
"OptGroup",
"currentOptGroup",
")",
"{",
"return",
"(",
"last",
"==",
"null",
")",
"||",
"!",
"currentOptGroup",
".",
"getLabel",
"(",
")",
".",
"equals",
"(",
"last",
".",
"getLabel",
"(",
")",
")",
";",
"}"
] |
Checks if it is new group.
@param currentOptGroup
the current opt group
@return true, if is new group
|
[
"Checks",
"if",
"it",
"is",
"new",
"group",
"."
] |
85d74368d00abd9bb97659b5794e38c0f8a013d4
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/form/dropdown/OptGroupDropDownChoice.java#L267-L270
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.