Edits to GREL Help text in-tool (#3649)

Improvements to GREL Help text in-tool and minor updates to GREL reference. Plus removal of pointless tests

Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu>
Co-authored-by: Owen Stephens <owen@ostephens.com>
This commit is contained in:
allanaaa 2021-02-18 12:52:32 -05:00 committed by GitHub
parent c5f3d700a3
commit 713a8f5b72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
201 changed files with 182 additions and 2002 deletions

View File

@ -1,4 +1,4 @@
---
---
id: grelfunctions
title: GREL functions
sidebar_label: GREL functions
@ -6,9 +6,9 @@ sidebar_label: GREL functions
## Reading this reference
For the reference below, the function is given in full-length notation and the in-text examples are written in dot notation. Shorthands are used to indicate the kind of [data type](exploring#data-types) used in each function: s for string, b for boolean, n for number, d for date, a for array, p for a regex pattern, and o for any data type, as well as “null” and “error” data types.
For the reference below, the function is given in full-length notation and the in-text examples are written in dot notation. Shorthands are used to indicate the kind of [data type](exploring#data-types) used in each function: s for string, b for boolean, n for number, d for date, a for array, p for a regex pattern, and o for object (meaning any data type), as well as “null” and “error” data types.
If a function can take more than one kind of data as input or can output more than one kind of data, that is indicated with more than one letter (as with “s or a”) or with o for object.
If a function can take more than one kind of data as input or can output more than one kind of data, that is indicated with more than one letter (as with “s or a”) or with o for object, meaning it can take any type of data (string, boolean, date, number, etc.).
We also use shorthands for substring (“sub”) and separator string (“sep”).
Optional arguments will say “(optional)”.
@ -170,9 +170,9 @@ For example, if `value` is “hello 123456 goodbye”, the following would occur
Returns a string converted to a number. Will attempt to convert other formats into a string, then into a number. If the value is already a number, it will return the number.
###### split(s, s or p sep)
###### split(s, s or p sep, b preserveTokens (optional))
Returns the array of strings obtained by splitting s by sep. The separator can be either a string or a regex pattern. For example, `"fire, water, earth, air".split(",")` returns an array of 4 strings: [ "fire", " water", " earth", " air" ]. Note that the space characters are retained but the separator is removed.
Returns the array of strings obtained by splitting s by sep. The separator can be either a string or a regex pattern. For example, `"fire, water, earth, air".split(",")` returns an array of 4 strings: [ "fire", " water", " earth", " air" ]. Note that the space characters are retained but the separator is removed. If you include “true” for the preserveTokens boolean, empty segments are preserved.
###### splitByLengths(s, n1, n2, ...)
@ -226,9 +226,9 @@ Returns the [SHA-1 hash](https://en.wikipedia.org/wiki/SHA-1) of an object. If f
Returns a phonetic encoding of a string, based on an available phonetic algorithm. See the [section on phonetic clustering](cellediting#clustering-methods) for more information. Can be one of the following supported phonetic methods: [metaphone, doublemetaphone, metaphone3](https://www.wikipedia.org/wiki/Metaphone), [soundex](https://en.wikipedia.org/wiki/Soundex), [cologne](https://en.wikipedia.org/wiki/Cologne_phonetics). Quotes are required around your encoding method. For example, `"Ruth Prawer Jhabvala".phonetic("metaphone")` outputs the string “R0PRWRJHBFL”.
###### reinterpret(s, s encoder)
###### reinterpret(s, s encoderTarget, s encoderSource)
Returns s reinterpreted through the given character encoder. You must supply one of the [supported encodings](http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html). Note that quotes are required around your character encoder.
Returns s reinterpreted through the given character encoders. You must supply one of the [supported encodings](http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html) for each of the original source and the target output. Note that quotes are required around your character encoder.
When an OpenRefine project is started, data is imported and interpreted. A specific character encoding is identified or manually selected at that time (such as UTF-8). You can reinterpret a column into another specificed encoding using this function. This function may not fix your data; it may be better to use this in conjunction with new projects to test the interpretation, and pre-format your data as needed.
@ -333,9 +333,6 @@ Returns the [inner HTML](https://developer.mozilla.org/en-US/docs/Web/API/Elemen
###### innerXml(element)
Returns the inner XML elements of an XML element. Does not return the text directly inside your chosen XML element - only the contents of its children. To select the direct text, use ownText(). To select both, use xmlText(). Use it in conjunction with parseXml() and select() to provide an element.
###### outerHtml(element)
Returns the [outer HTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML) of an HTML element. outerHtml includes the start and end tags of the current element. Use it in conjunction with parseHtml() and select() to provide an element.
###### ownText(element)
Returns the text directly inside the selected XML or HTML element only, ignoring text inside children elements (for this, use innerXml()). Use it in conjunction with a parser and select() to provide an element.
@ -468,13 +465,13 @@ Some of these math functions don't recognize integers when supplied as the first
|Function|Use|Example|
|-|-|-|
|`abs(n)`|Returns the absolute value of a number.|`abs(-6)` returns 6.|
|`acos(n)`|Returns the arc cosine of an angle, in the range 0 through PI.|`acos(0.345)` returns 1.218557541697832.|
|`asin(n)`|Returns the arc sine of an angle in the range of -PI/2 through [PI](https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#PI)/2.|`asin(0.345)` returns 0.35223878509706474.|
|`acos(n)`|Returns the arc cosine of an angle, in the range 0 through [PI](https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#PI).|`acos(0.345)` returns 1.218557541697832.|
|`asin(n)`|Returns the arc sine of an angle in the range of -PI/2 through PI/2.|`asin(0.345)` returns 0.35223878509706474.|
|`atan(n)`|Returns the arc tangent of an angle in the range of -PI/2 through PI/2.|`atan(0.345)` returns 0.3322135507465967.|
|`atan2(n1, n2)`|Converts rectangular coordinates (n1, n2) to polar (r, theta). Returns number theta.|`atan2(0.345,0.6)` returns 0.5218342798144103.|
|`atan2(n1, n2)`|Converts rectangular coordinates (n1, n2) to polar (r, theta). Returns number theta.|`atan2(0.345,0.6)` returns 0.5218342798144103.|
|`ceil(n)`|Returns the ceiling of a number.|`3.7.ceil()` returns 4 and `-3.7.ceil()` returns -3.|
|`combin(n1, n2)`|Returns the number of combinations for n2 elements as divided into n1.|`combin(20,2)` returns 190.|
|`cos(n)`|Returns the trigonometric cosine of an angle.|`cos(5)` returns 0.28366218546322625.|
|`cos(n)`|Returns the trigonometric cosine of a value.|`cos(5)` returns 0.28366218546322625.|
|`cosh(n)`|Returns the hyperbolic cosine of a value.|`cosh(5)` returns 74.20994852478785.|
|`degrees(n)`|Converts an angle from radians to degrees.|`degrees(5)` returns 286.4788975654116.|
|`even(n)`|Rounds the number up to the nearest even integer.|`even(5)` returns 6.|
@ -482,7 +479,7 @@ Some of these math functions don't recognize integers when supplied as the first
|`fact(n)`|Returns the factorial of a number, starting from 1.|`fact(5)` returns 120.|
|`factn(n1, n2)`|Returns the factorial of n1, starting from n2.|`factn(10,3)` returns 280.|
|`floor(n)`|Returns the floor of a number.|`3.7.floor()` returns 3 and `-3.7.floor()` returns -4.|
|`gcd(n1, n2)`|Returns the greatest common denominator of the two numbers.|`gcd(95,135)` returns 5.|
|`gcd(n1, n2)`|Returns the greatest common denominator of two numbers.|`gcd(95,135)` returns 5.|
|`lcm(n1, n2)`|Returns the least common multiple of two numbers.|`lcm(95,135)` returns 2565.|
|`ln(n)`|Returns the natural logarithm of n.|`ln(5)` returns 1.6094379124341003.|
|`log(n)`|Returns the base 10 logarithm of n.|`log(5)` returns 0.6989700043360189.|
@ -494,7 +491,7 @@ Some of these math functions don't recognize integers when supplied as the first
|`pow(n1, n2)`|Returns n1 raised to the power of n2. Note: value.pow(3)` will work, whereas `2.pow(3)` will not work.|`pow(2, 3)` returns 8 (2 cubed) and `pow(3, 2)` returns 9 (3 squared). The square root of any numeric value can be called with `value.pow(0.5)`.|
|`quotient(n1, n2)`|Returns the integer portion of a division (truncated, not rounded), when supplied with a numerator and denominator.|`quotient(9,2)` returns 4.|
|`radians(n)`|Converts an angle in degrees to radians.|`radians(10)` returns 0.17453292519943295.|
|`randomNumber(n lower_bound, n upper_bound)`|Returns a random integer in the interval between the lower and upper bounds (inclusively). Will output a different random number in each cell in a column.|
|`randomNumber(n lowerBound, n upperBound)`|Returns a random integer in the interval between the lower and upper bounds (inclusively). Will output a different random number in each cell in a column.|
|`round(n)`|Rounds a number to the nearest integer.|`3.7.round()` returns 4 and `-3.7.round()` returns -4.|
|`sin(n)`|Returns the trigonometric sine of an angle.|`sin(10)` returns -0.5440211108893698.|
|`sinh(n)`|Returns the hyperbolic sine of an angle.|`sinh(10)` returns 11013.232874703393.|
@ -525,7 +522,7 @@ Returns a boolean indicating whether o has a member field called [name](expressi
###### coalesce(o1, o2, o3, ...)
Returns the first non-null from a series of objects. For example, `coalesce(value, "")` would return an empty string “” if `value` was null, but otherwise return `value`.
###### cross(cell, s projectName, s columnName)
###### cross(cell, s projectName (optional), s columnName (optional))
Returns an array of zero or more rows in the project projectName for which the cells in their column columnName have the same content as the cell in your chosen column. For example, if two projects contained matching names, and you wanted to pull addresses for people by their names from a project called “People” you would apply the following expression to your column of names:
```
cell.cross("People","Name").cells["Address"].value[0]
@ -535,4 +532,6 @@ This would match your current column to the “Name” column in “People” an
You may need to do some data preparation with cross(), such as using trim() on your key columns or deduplicating values.
The first argument will be interpreted as `cell.value` if set to `cell`. If you omit projectName and columnName, they will default to the current project and index column (number 0).
Recipes and more examples for using cross() can be found [on our wiki](https://github.com/OpenRefine/OpenRefine/wiki/Recipes#combining-datasets).

View File

@ -58,12 +58,12 @@ public class Coalesce implements Function {
@Override
public String getDescription() {
return "Returns the first non-null from a series of values";
return "Returns the first non-null from a series of objects (meaning any data type - string, date, number, boolean, etc.).";
}
@Override
public String getParams() {
return "two or more objects";
return "o1, o2, ...";
}
@Override

View File

@ -98,7 +98,7 @@ public class Cross implements Function {
return "Looks up the given value in the target column of the target project, returns an array of matched rows. Two values match if and only if they have the same string representation. " +
"The first argument will be interpreted as cell.value if set to cell. " +
"The second argument will be interpreted as the current project name if omitted or set to \"\". " +
"The third argument will be interpreted as the index (starts from 0) column if omitted or set to \"\"";
"The third argument will be interpreted as the index (starts from 0) column if omitted or set to \"\".";
}
@Override

View File

@ -85,7 +85,7 @@ public class FacetCount implements Function {
@Override
public String getDescription() {
return "Returns the facet count corresponding to the given choice value";
return "Returns the facet count corresponding to the given choice value, by looking for the facetExpression in the choiceValue in columnName.";
}
@Override

View File

@ -153,9 +153,9 @@ public class Get implements Function {
@Override
public String getDescription() {
return
"If o has fields, returns the field named 'from' of o. " +
"If o is an array, returns o[from, to]. " +
"if o is a string, returns o.substring(from, to)"
"If o has named fields, returns the field named 'from' of o. " +
"If o is an array, returns a sub-array o[from, to]. " +
"if o is a string, returns o.substring(from, to)."
;
}

View File

@ -61,7 +61,7 @@ public class HasField implements Function {
@Override
public String getDescription() {
return "Returns whether o has field name";
return "Returns a boolean indicating whether o has a member field called name.";
}
@Override

View File

@ -61,7 +61,7 @@ public class Jsonize implements Function {
@Override
public String getParams() {
return "value";
return "o";
}
@Override

View File

@ -70,12 +70,12 @@ public class Length implements Function {
@Override
public String getDescription() {
return "Returns the length of o";
return "Returns the length of string s as a number, or the size of array a, meaning the number of objects inside it. Arrays can be empty, in which case length() will return 0.";
}
@Override
public String getParams() {
return "array or string o";
return "array a or string s";
}
@Override

View File

@ -124,19 +124,17 @@ public class Slice implements Function {
@Override
public String getDescription() {
return
"If o is an array, returns o[from, to]. " +
"if o is a string, returns o.substring(from, to)"
;
return "Given a string, returns the substring starting from character index from, and up to character index to. If the to argument is omitted, will output to the end of s. Remember character indices start from zero. Given an array, returns a sub-array from the first index provided up to and including the last index provided. If the to value is omitted, it is understood to be the end of the array. Slice only.";
}
@Override
public String getParams() {
return "o, number from, optional number to";
return "string s or array a, number from, number to (optional)";
}
@Override
public String getReturns() {
return "Depends on actual arguments";
return "string, array, or array item (number, string, etc.)";
}
}

View File

@ -196,12 +196,12 @@ public class ToDate implements Function {
@Override
public String getDescription() {
return "Returns o converted to a date object, you can hint if the day or the month is listed first, or give an ordered list of possible formats using this syntax: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html";
return "Returns the inputted object converted to a date object. Without arguments, it returns the ISO 8601 extended format. With arguments, you can control the output format. With monthFirst: set false if the date is formatted with the day before the month. With formatN: attempt to parse the date using an ordered list of possible formats. Supply formats based on the SimpleDateFormat syntax: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html.";
}
@Override
public String getParams() {
return "o, boolean month_first / format1, format2, ... (all optional)";
return "o, boolean monthFirst, string format1, string format2, ...)";
}
@Override

View File

@ -74,7 +74,7 @@ public class ToNumber implements Function {
@Override
public String getDescription() {
return "Returns o converted to a number";
return "Returns a string converted to a number. Will attempt to convert other formats into a string, then into a number. If the value is already a number, it will return the number.";
}
@Override

View File

@ -70,12 +70,12 @@ public class ToString implements Function {
@Override
public String getDescription() {
return "Returns o converted to a string";
return "Takes any value type (string, number, date, boolean, error, null) and gives a string version of that value. You can convert numbers to strings with rounding, using an optional string format. See https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html. You can also convert dates to strings using date parsing syntax. See https://docs.openrefine.org/manual/grelfunctions/#date-functions.";
}
@Override
public String getParams() {
return "o, string format (optional)";
return "object o, string format (optional)";
}
@Override

View File

@ -72,7 +72,7 @@ public class Type implements Function {
@Override
public String getDescription() {
return "Returns the type of o as a string ('string', 'date', 'number', 'array', 'boolean' or a class name)";
return "Returns a string with the data type of o, such as undefined, string, number, boolean, etc.";
}
@Override

View File

@ -74,7 +74,7 @@ public class InArray implements Function {
@Override
public String getDescription() {
return "Checks if array a contains string s";
return "Returns true if the array contains the desired string, and false otherwise. Will not convert data types.";
}
@Override

View File

@ -95,7 +95,7 @@ public class Join implements Function {
@Override
public String getDescription() {
return "Returns the string obtained by joining the array a with the separator sep";
return "Joins the items in the array with sep, and returns it all as a string.";
}
@Override

View File

@ -81,7 +81,7 @@ public class Reverse implements Function {
@Override
public String getDescription() {
return "Reverses array a";
return "Reverses array a.";
}
@Override

View File

@ -85,7 +85,7 @@ public class Sort implements Function {
@Override
public String getDescription() {
return "Sorts array a";
return "Sorts the array in ascending order. Sorting is case-sensitive, uppercase first and lowercase second.";
}
@Override

View File

@ -73,7 +73,7 @@ public class Uniques implements Function {
@Override
public String getDescription() {
return "Returns array a with duplicates removed";
return "Returns the array with duplicates removed. Case-sensitive.";
}
@Override

View File

@ -56,12 +56,12 @@ public class And implements Function {
@Override
public String getDescription() {
return "AND two or more booleans to yield a boolean";
return "Uses the logical operator AND on two or more booleans to output a boolean. Evaluates multiple statements into booleans, then returns true if all of the statements are true. For example, (1 < 3).and(1 < 0) returns false because one condition is true and one is false.";
}
@Override
public String getParams() {
return "boolean a, boolean b";
return "boolean a, boolean b, ...";
}
@Override

View File

@ -56,7 +56,7 @@ public class Not implements Function {
@Override
public String getDescription() {
return "Returns the opposite of b";
return "Uses the logical operator NOT on a boolean to output a boolean. For example, not(1 > 7) returns true because 1 > 7 itself is false.";
}
@Override

View File

@ -56,12 +56,12 @@ public class Or implements Function {
@Override
public String getDescription() {
return "OR two or more booleans to yield a boolean";
return "Uses the logical operator OR on two or more booleans to output a boolean. For example, (1 < 3).or(1 > 7) returns true because at least one of the conditions (the first one) is true.";
}
@Override
public String getParams() {
return "boolean a, boolean b";
return "boolean a, boolean b, ...";
}
@Override

View File

@ -43,12 +43,12 @@ public class Xor implements Function {
@Override
public String getDescription() {
return "XORs two or more boolean values";
return "Uses the logical operator XOR (exclusive-or) on two or more booleans to output a boolean. Evaluates multiple statements, then returns true if only one of them is true. For example, (1 < 3).xor(1 < 7) returns false because more than one of the conditions is true.";
}
@Override
public String getParams() {
return "boolean a, boolean b";
return "boolean a, boolean b, ...";
}
@Override

View File

@ -139,12 +139,12 @@ public class DatePart implements Function {
@Override
public String getDescription() {
return "Returns part of a date";
return "Returns part of a date. The data type returned depends on the unit. See https://docs.openrefine.org/manual/grelfunctions/#datepartd-s-timeunit for a table. ";
}
@Override
public String getParams() {
return "date d, string part";
return "date d, string timeUnit";
}
@Override

View File

@ -86,12 +86,12 @@ public class Inc implements Function {
@Override
public String getDescription() {
return "Returns a date changed by the given amount in the given unit of time";
return "Returns a date changed by the given amount in the given unit of time, in quotes. See https://docs.openrefine.org/manual/grelfunctions/#incd-n-s-timeunit for a table. The default unit is 'hour'. A positive value increases the date, and a negative value moves it back in time.";
}
@Override
public String getParams() {
return "date d, number value, string unit (default to 'hour')";
return "date d, number n, string unit";
}
@Override

View File

@ -51,7 +51,7 @@ public class Now implements Function {
@Override
public String getDescription() {
return "Returns the current time";
return "Returns the current time according to your system clock, in the ISO 8601 extended format (converted to UTC). For example, 10:53am (and 00 seconds) on November 26th 2020 in EST returns [date 2020-11-26T15:53:00Z].";
}
@Override

View File

@ -60,17 +60,17 @@ public class InnerHtml implements Function {
@Override
public String getDescription() {
return "The innerHtml of an HTML element";
return "Returns the inner HTML of an HTML element. This will include text and children elements within the element selected. Use it in conjunction with parseHtml() and select() to provide an element.";
}
@Override
public String getParams() {
return "Element e";
return "element e";
}
@Override
public String getReturns() {
return "String innerHtml";
return "string innerHtml";
}
}

View File

@ -56,7 +56,7 @@ public class ParseHtml implements Function {
@Override
public String getDescription() {
return "Parses a string as HTML";
return "Given a cell full of HTML-formatted text, parseHtml() simplifies HTML tags (such as by removing ' /' at the end of self-closing tags), closes any unclosed tags, and inserts linebreaks and indents for cleaner code. A cell cannot store the output of parseHtml() unless you convert it with toString(): for example, value.parseHtml().toString().";
}
@Override

View File

@ -51,12 +51,12 @@ public class ACos implements Function {
@Override
public String getDescription() {
return "Returns the arc cosine of an angle, in the range 0 through PI";
return "Returns the arc cosine of an angle, in the range 0 through PI.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -51,12 +51,12 @@ public class ASin implements Function {
@Override
public String getDescription() {
return "Returns the arc sine of an angle in the range of -PI/2 through PI/2";
return "Returns the arc sine of an angle in the range of -PI/2 through PI/2.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -51,12 +51,12 @@ public class ATan implements Function {
@Override
public String getDescription() {
return "Returns the arc tangent of an angle in the range of -PI/2 through PI/2";
return "Returns the arc tangent of an angle in the range of -PI/2 through PI/2.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -52,12 +52,12 @@ public class ATan2 implements Function {
@Override
public String getDescription() {
return "Converts rectangular coordinates (x, y) to polar (r, theta)";
return "Converts rectangular coordinates (n1, n2) to polar (r, theta). Returns number theta.";
}
@Override
public String getParams() {
return "number x, number y";
return "number n1, number n2";
}
@Override

View File

@ -51,12 +51,12 @@ public class Abs implements Function {
@Override
public String getDescription() {
return "Returns the absolute value of a number";
return "Returns the absolute value of a number.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -51,12 +51,12 @@ public class Ceil implements Function {
@Override
public String getDescription() {
return "Returns the ceiling of a number";
return "Returns the ceiling of a number.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -85,12 +85,12 @@ public class Combin implements Function {
@Override
public String getDescription() {
return "Returns the number of combinations for n elements as divided into k";
return "Returns the number of combinations for n2 elements as divided into n1.";
}
@Override
public String getParams() {
return "number d";
return "number n1, number n2";
}
@Override

View File

@ -51,12 +51,12 @@ public class Cos implements Function {
@Override
public String getDescription() {
return "Returns the trigonometric cosine of an angle";
return "Returns the trigonometric cosine of an angle.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -51,12 +51,12 @@ public class Cosh implements Function {
@Override
public String getDescription() {
return "Returns the hyperbolic cosine of a value";
return "Returns the hyperbolic cosine of a value.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -56,7 +56,7 @@ public class Degrees implements Function {
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -56,12 +56,12 @@ public class Even implements Function {
@Override
public String getDescription() {
return "Rounds the number up to the nearest even integer";
return "Rounds the number up to the nearest even integer.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -49,7 +49,7 @@ public class Exp implements Function {
@Override
public String getDescription() {
return "Returns e^n";
return "Returns e to the power of n.";
}
@Override

View File

@ -51,12 +51,12 @@ public class Fact implements Function {
@Override
public String getDescription() {
return "Returns the factorial of a number";
return "Returns the factorial of a number, starting from 1.";
}
@Override
public String getParams() {
return "number i";
return "number n";
}
@Override

View File

@ -78,12 +78,12 @@ public class FactN implements Function {
@Override
public String getDescription() {
return "Returns the factorial of a number";
return "Returns the factorial of n1, starting from n2.";
}
@Override
public String getParams() {
return "number i";
return "number n1, number n2";
}
@Override

View File

@ -51,12 +51,12 @@ public class Floor implements Function {
@Override
public String getDescription() {
return "Returns the floor of a number as an integer";
return "Returns the floor of a number.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -56,12 +56,12 @@ public class GreatestCommonDenominator implements Function {
@Override
public String getDescription() {
return "Returns the greatest common denominator of the two numbers";
return "Returns the greatest common denominator of two numbers.";
}
@Override
public String getParams() {
return "number d, number e";
return "number n1, number n2";
}
@Override

View File

@ -68,12 +68,12 @@ public class LeastCommonMultiple implements Function {
@Override
public String getDescription() {
return "Returns the greatest common denominator of the two numbers";
return "Returns the greatest common denominator of two numbers.";
}
@Override
public String getParams() {
return "number d, number e";
return "number n1, number n2";
}
@Override

View File

@ -51,7 +51,7 @@ public class Ln implements Function {
@Override
public String getDescription() {
return "Returns the natural log of n";
return "Returns the natural logarithm of n.";
}
@Override

View File

@ -51,7 +51,7 @@ public class Log implements Function {
@Override
public String getDescription() {
return "Returns the base 10 log of n";
return "Returns the base 10 logarithm of n.";
}
@Override

View File

@ -55,12 +55,12 @@ public class Max implements Function {
@Override
public String getDescription() {
return "Returns the greater of two numbers";
return "Returns the greater of two numbers.";
}
@Override
public String getParams() {
return "number a, number b";
return "number n1, number n2";
}
@Override

View File

@ -55,12 +55,12 @@ public class Min implements Function {
@Override
public String getDescription() {
return "Returns the smaller of two numbers";
return "Returns the smaller of two numbers.";
}
@Override
public String getParams() {
return "number a, number b";
return "number n1, number n2";
}
@Override

View File

@ -56,12 +56,12 @@ public class Mod implements Function {
@Override
public String getDescription() {
return "Returns a modulus b";
return "Returns n1 modulus n2.";
}
@Override
public String getParams() {
return "number a, number b";
return "number n1, number n2";
}
@Override

View File

@ -61,12 +61,12 @@ public class Multinomial implements Function {
@Override
public String getDescription() {
return "Calculates the multinomial of a series of numbers";
return "Calculates the multinomial of one number or a series of numbers.";
}
@Override
public String getParams() {
return "one or more numbers";
return "number n1, number n2, ...";
}
@Override

View File

@ -56,12 +56,12 @@ public class Odd implements Function {
@Override
public String getDescription() {
return "Rounds the number up to the nearest even integer";
return "Rounds the number up to the nearest odd integer.";
}
@Override
public String getParams() {
return "number d";
return "number n1";
}
@Override

View File

@ -52,12 +52,12 @@ public class Pow implements Function {
@Override
public String getDescription() {
return "Returns a^b";
return "Returns n1 raised to the power of n2.";
}
@Override
public String getParams() {
return "number a, number b";
return "number n1, number n2";
}
@Override

View File

@ -52,7 +52,7 @@ public class Quotient implements Function {
@Override
public String getDescription() {
return "Returns the integer portion of a division";
return "Returns the integer portion of a division (truncated, not rounded), when supplied with a numerator and denominator.";
}
@Override

View File

@ -51,12 +51,12 @@ public class Radians implements Function {
@Override
public String getDescription() {
return "Converts an angle in degrees to radians";
return "Converts an angle in degrees to radians.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -55,12 +55,12 @@ public class RandomNumber implements Function {
@Override
public String getDescription() {
return "Returns a pseudo-random integer between the lower and upper bound (inclusive)";
return "Returns a random integer in the interval between the lower and upper bounds (inclusively). Will output a different random number in each cell in a column.";
}
@Override
public String getParams() {
return "number lower bound, number upper bound";
return "number lowerBound, number upperBound";
}
@Override

View File

@ -51,7 +51,7 @@ public class Round implements Function {
@Override
public String getDescription() {
return "Returns n rounded";
return "Rounds a number to the nearest integer.";
}
@Override

View File

@ -51,12 +51,12 @@ public class Sin implements Function {
@Override
public String getDescription() {
return "Returns the trigonometric sine of an angle";
return "Returns the trigonometric sine of an angle.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -51,12 +51,12 @@ public class Sinh implements Function {
@Override
public String getDescription() {
return "Returns the hyperbolic sine of an angle";
return "Returns the hyperbolic sine of an angle.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -80,7 +80,7 @@ public class Sum implements Function {
@Override
public String getDescription() {
return "Sums numbers in array a";
return "Return the sum of the numbers in the array. Ignores non-number items. Returns 0 if the array does not contain numbers.";
}
@Override

View File

@ -51,12 +51,12 @@ public class Tan implements Function {
@Override
public String getDescription() {
return "Returns the trigonometric tangent of an angle";
return "Returns the trigonometric tangent of an angle.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -51,12 +51,12 @@ public class Tanh implements Function {
@Override
public String getDescription() {
return "Returns the hyperbolic tangent of a value";
return "Returns the hyperbolic tangent of an angle.";
}
@Override
public String getParams() {
return "number d";
return "number n";
}
@Override

View File

@ -55,12 +55,12 @@ public class Chomp implements Function {
@Override
public String getDescription() {
return "Removes separator from the end of str if it's there, otherwise leave it alone.";
return "Returns a copy of string s with string sep remoed from the end if s ends with sep; otherwies, returns s.";
}
@Override
public String getParams() {
return "string str, string separator";
return "string s, string sep";
}
@Override

View File

@ -62,12 +62,12 @@ public class Contains implements Function {
}
@Override
public String getDescription() {
return "Returns whether s contains frag";
return "Returns a boolean indicating whether s contains sub, which is either a substring or a regex pattern. For example, \"food\".contains(\"oo\") returns true.";
}
@Override
public String getParams() {
return "string s, string frag";
return "string s, string or pattern sub";
}
@Override

View File

@ -99,7 +99,7 @@ public class Diff implements Function {
@Override
public String getDescription() {
return "For strings, returns the portion where they differ. For dates, it returns the difference in given time units";
return "For strings, takes two strings and compares them, returning a string. Returns the remainder of o2 starting with the first character where they differ. For dates, returns the difference in given time units. See the time unit table at https://docs.openrefine.org/manual/grelfunctions/#datepartd-s-timeunit.";
}
@Override

View File

@ -55,7 +55,7 @@ public class EndsWith implements Function {
@Override
public String getDescription() {
return "Returns whether s ends with sub";
return "Returns a boolean indicating whether s ends with sub. For example, \"food\".endsWith(\"ood\") returns true, whereas \"food\".endsWith(\"odd\") returns false.";
}
@Override

View File

@ -84,7 +84,7 @@ public class Escape implements Function {
@Override
public String getDescription() {
return "Escapes a string depending on the given escaping mode.";
return "Escapes s in the given escaping mode. The mode can be one of: 'html', 'xml', csv', 'url', 'javascript'. Note that quotes are required around your mode.";
}
@Override

View File

@ -65,17 +65,17 @@ public class Find implements Function {
return allMatches.toArray(new String[0]);
}
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a string or a regexp");
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a string or a regex");
}
@Override
public String getDescription() {
return "Returns all the occurrences of match given regular expression or simple string";
return "Outputs an array of all consecutive substrings inside string s that match the substring or regex pattern p. You can supply a substring by putting it in quotes.";
}
@Override
public String getParams() {
return "string or regexp";
return "string s, substring or regex p";
}
@Override

View File

@ -55,7 +55,7 @@ public class Fingerprint implements Function {
@Override
public String getDescription() {
return "Returns the fingerprint of s, a derived string that aims to be a more canonical form of it (this is mostly useful for finding clusters of strings related to the same information).";
return "Returns the fingerprint of s, a string that is the first step in fingerprint clustering methods: it will trim whitespaces, convert all characters to lowercase, remove punctuation, sort words alphabetically, etc.";
}
@Override

View File

@ -55,7 +55,7 @@ public class IndexOf implements Function {
@Override
public String getDescription() {
return "Returns the index of sub first ocurring in s";
return "Returns the first character index of sub as it first occurs in s; or, returns -1 if s does not contain sub. For example, \"internationalization\".indexOf(\"nation\") returns 5.";
}
@Override

View File

@ -55,7 +55,7 @@ public class LastIndexOf implements Function {
@Override
public String getDescription() {
return "Returns the index of sub last ocurring in s";
return "Returns the first character index of sub as it last occurs in s; or, returns -1 if s does not contain sub. For example, \"parallel\".lastIndexOf(\"a\") returns 3 (pointing at the second 'a').";
}
@Override

View File

@ -55,7 +55,7 @@ public class MD5 implements Function {
@Override
public String getDescription() {
return "Returns the MD5 hash of s";
return "Returns the MD5 hash of an object. If fed something other than a string (array, number, date, etc.), md5() will convert it to a string and deliver the hash of the string.";
}
@Override

View File

@ -71,17 +71,17 @@ public class Match implements Function {
return null;
}
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a regexp");
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects regex");
}
@Override
public String getDescription() {
return "Returns an array of the groups matching the given regular expression";
return "Attempts to match the string s in its entirety against the regex pattern p and, if the pattern is found, outputs an array of all capturing groups (found in order).";
}
@Override
public String getParams() {
return "regexp";
return "string s, regex p";
}
@Override

View File

@ -78,7 +78,7 @@ public class NGram implements Function {
@Override
public String getDescription() {
return "Returns an array of the word ngrams of s";
return "Returns an array of the word n-grams of s. That is, it lists all the possible consecutive combinations of n words in the string.";
}
@Override

View File

@ -74,7 +74,7 @@ public class NGramFingerprint implements Function {
@Override
public String getDescription() {
return "Returns the n-gram fingerprint of s";
return "Returns the n-gram fingerprint of s.";
}
@Override

View File

@ -61,7 +61,7 @@ public class ParseJson implements Function {
@Override
public String getDescription() {
return "Parses a string as JSON";
return "Parses a string as JSON.";
}
@Override

View File

@ -100,12 +100,12 @@ public class Partition implements Function {
@Override
public String getDescription() {
return
"Returns an array of strings [a,frag,b] where a is the string part before the first occurrence of frag in s and b is what's left. If omitFragment is true, frag is not returned.";
"Returns an array of strings [ a, fragment, z ] where a is the substring within s before the first occurrence of fragment, and z is the substring after fragment. Fragment can be a string or a regex. If omitFragment is true, frag is not returned.";
}
@Override
public String getParams() {
return "string s, string or regex frag, optional boolean omitFragment";
return "string s, string or regex fragment, optional boolean omitFragment";
}
@Override

View File

@ -101,7 +101,7 @@ public class Phonetic implements Function {
@Override
public String getDescription() {
return "Returns the a phonetic encoding of s (optionally indicating which encoding to use')";
return "Returns a phonetic encoding of a string, based on an available phonetic algorithm. Can be one of the following supported phonetic methods: metaphone, doublemetaphone, metaphone3, soundex, cologne. Defaults to 'metaphone3'.";
}
@Override

View File

@ -101,12 +101,12 @@ public class RPartition implements Function {
@Override
public String getDescription() {
return
"Returns an array of strings [a,frag,b] where a is the string part before the last occurrence of frag in s and b is what's left. If omitFragment is true, frag is not returned.";
"Returns an array of strings [ a, fragment, z ] where a is the substring within s before the last occurrence of fragment, and z is the substring after the last instance of fragment. If omitFragment is true, frag is not returned.";
}
@Override
public String getParams() {
return "string s, string or regex frag, optional boolean omitFragment";
return "string s, string or regex fragment, optional boolean omitFragment";
}
@Override

View File

@ -97,7 +97,7 @@ public class Reinterpret implements Function {
@Override
public String getDescription() {
return "Returns s reinterpreted using a target encoding and optional source encoding.";
return "Returns s reinterpreted through the given character encoders. You must supply one of the supported encodings for each of the original source and the target output: https://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html. Note that quotes are required around character encoders.";
}
@Override

View File

@ -65,12 +65,12 @@ public class Replace implements Function {
@Override
public String getDescription() {
return "Returns the string obtained by replacing f with r in s";
return "Returns the string obtained by replacing the find string with the replace string in the inputted string. For example, 'The cow jumps over the moon and moos'.replace('oo', 'ee') returns the string 'The cow jumps over the meen and mees'. Find can be a regex pattern.";
}
@Override
public String getParams() {
return "string s, string or regex f, string r";
return "string s, string or regex find, string replace";
}
@Override

View File

@ -60,12 +60,12 @@ public class ReplaceChars implements Function {
@Override
public String getDescription() {
return "Returns the string obtained by replacing all chars in f with the char in s at that same position";
return "Returns the string obtained by replacing a character in s, identified by find, with the corresponding character identified in replace. You cannot use this to replace a single character with more than one character.";
}
@Override
public String getParams() {
return "string s, string f, string r";
return "string s, string find, string replace";
}
@Override

View File

@ -55,7 +55,7 @@ public class SHA1 implements Function {
@Override
public String getDescription() {
return "Returns the SHA-1 hash of s";
return "Returns the SHA-1 hash of an object. If fed something other than a string (array, number, date, etc.), sha1() will convert it to a string and deliver the hash of the string.";
}
@Override

View File

@ -102,7 +102,7 @@ public class SmartSplit implements Function {
@Override
public String getDescription() {
return "Returns the array of strings obtained by splitting s with separator sep. Handles quotes properly. Guesses tab or comma separator if \"sep\" is not given.";
return "Returns the array of strings obtained by splitting s by sep, or by guessing either tab or comma separation if there is no sep given. Handles quotes properly and understands cancelled characters. The separator can be either a string or a regex pattern.";
}
@Override

View File

@ -75,12 +75,12 @@ public class Split implements Function {
@Override
public String getDescription() {
return "Returns the array of strings obtained by splitting s with separator sep. If preserveAllTokens is true, then empty segments are preserved.";
return "Returns the array of strings obtained by splitting s by sep. The separator can be either a string or a regex pattern. If preserveTokens is true, empty segments are preserved.";
}
@Override
public String getParams() {
return "string s, string or regex sep, optional boolean preserveAllTokens";
return "string s, string or regex sep, optional boolean preserveTokens";
}
@Override

View File

@ -57,7 +57,7 @@ public class SplitByCharType implements Function {
@Override
public String getDescription() {
return "Returns an array of strings obtained by splitting s grouping consecutive chars by their unicode type";
return "Returns an array of strings obtained by splitting s into groups of consecutive characters each time the characters change Unicode categories.";
}
@Override

View File

@ -69,12 +69,12 @@ public class SplitByLengths implements Function {
@Override
public String getDescription() {
return "Returns the array of strings obtained by splitting s into substrings with the given lengths";
return "Returns the array of strings obtained by splitting s into substrings with the given lengths. For example, \"internationalization\".splitByLengths(5, 6, 3) returns an array of 3 strings: [ \"inter\", \"nation\", \"ali\" ]. Excess characters are discarded.";
}
@Override
public String getParams() {
return "string s, number n, ...";
return "string s, number n1, number n2, ...";
}
@Override

View File

@ -54,7 +54,7 @@ public class StartsWith implements Function {
}
@Override
public String getDescription() {
return "Returns whether s starts with sub";
return "Returns a boolean indicating whether s starts with sub. For example, \"food\".startsWith(\"foo\") returns true, whereas \"food\".startsWith(\"bar\") returns false.";
}
@Override

View File

@ -52,7 +52,7 @@ public class ToLowercase implements Function {
@Override
public String getDescription() {
return "Returns s converted to lowercase";
return "Returns string s converted to all lowercase characters.";
}
@Override

View File

@ -63,7 +63,7 @@ public class ToTitlecase implements Function {
@Override
public String getDescription() {
return "Returns s converted to titlecase";
return "Returns string s converted into titlecase: a capital letter starting each word, and the rest of the letters lowercase. For example, 'Once upon a midnight DREARY'.toTitlecase() returns the string 'Once Upon A Midnight Dreary'.";
}
@Override

View File

@ -52,7 +52,7 @@ public class ToUppercase implements Function {
@Override
public String getDescription() {
return "Returns s converted to uppercase";
return "Returns string s converted to all uppercase characters.";
}
@Override

View File

@ -53,7 +53,7 @@ public class Trim implements Function {
}
@Override
public String getDescription() {
return "Returns copy of the string, with leading and trailing whitespace omitted.";
return "Returns a copy of string s with leading and trailing whitespace removed.";
}
@Override

View File

@ -75,7 +75,7 @@ public class Unescape implements Function {
@Override
public String getDescription() {
return "Unescapes all escaped parts of the string depending on the given escaping mode.";
return "Unescapes s in the given escaping mode. The mode can be one of: 'html', 'xml', 'csv', 'url', 'javascript'. Note that quotes are required around your mode. ";
}
@Override

View File

@ -55,7 +55,7 @@ public class Unicode implements Function {
@Override
public String getDescription() {
return "Returns an array of strings describing each character of s in their full unicode notation";
return "Returns an array of strings describing each character of s in their full unicode notation.";
}
@Override

View File

@ -92,7 +92,7 @@ public class UnicodeType implements Function {
@Override
public String getDescription() {
return "Returns an array of strings describing each character of s in their full unicode notation";
return "Returns an array of strings describing each character of s by their unicode type.";
}
@Override

View File

@ -70,17 +70,17 @@ public class InnerXml implements Function {
@Override
public String getDescription() {
return "The innerXml/innerHtml of an XML/HTML element";
return "Returns the inner XML elements of an XML element. Does not return the text directly inside your chosen XML element - only the contents of its children. Use it in conjunction with parseXml() and select() to provide an element.";
}
@Override
public String getParams() {
return "Element e";
return "element e";
}
@Override
public String getReturns() {
return "String innerXml/innerHtml";
return "string innerXml";
}
}

View File

@ -61,17 +61,17 @@ public class OwnText implements Function {
@Override
public String getDescription() {
return "Gets the text owned by this XML/HTML element only; does not get the combined text of all children.";
return "Returns the text directly inside the selected XML or HTML element only, ignoring text inside children elements (for this, use innerXml()). Use it in conjunction with a parser and select() to provide an element.";
}
@Override
public String getParams() {
return "Element e";
return "element e";
}
@Override
public String getReturns() {
return "String ownText";
return "string ownText";
}
}

View File

@ -68,7 +68,7 @@ public class ParseXml implements Function {
@Override
public String getDescription() {
return "Parses a string as XML";
return "Given a cell full of XML-formatted text, parseXml() returns a full XML document and adds any missing closing tags.";
}
@Override

View File

@ -63,12 +63,12 @@ public class SelectXml implements Function {
@Override
public String getDescription() {
return "Selects an element from an XML or HTML elementn using selector syntax.";
return "Returns an array of all the desired elements from an HTML or XML document, if the element exists. Elements are identified using the Jsoup selector syntax: https://jsoup.org/apidocs/org/jsoup/select/Selector.html.";
}
@Override
public String getParams() {
return "Element e, String s";
return "string s, element e";
}
@Override

View File

@ -61,16 +61,16 @@ public class WholeText implements Function {
@Override
public String getDescription() {
return "Selects the (unencoded) text of an element and its children, including any newlines and spaces, and returns unencoded, un-normalized text";
return "Selects the (unencoded) text of an element and its children, including any new lines and spaces, and returns a string of unencoded, un-normalized text. Use it in conjunction with parseHtml() and select() to provide an element.";
}
@Override
public String getParams() {
return "Element e";
return "element e";
}
@Override
public String getReturns() {
return "String text";
return "string";
}
}

View File

@ -63,17 +63,17 @@ public class XmlAttr implements Function {
@Override
public String getDescription() {
return "Selects a value from an attribute on an XML or HTML Element";
return "Returns a string from an attribute on an XML or HTML element. Use it in conjunction with parseHtml() or parseXml() to point to an element first.";
}
@Override
public String getParams() {
return "Element e, String s";
return "string s, element e";
}
@Override
public String getReturns() {
return "String attribute Value";
return "string attribute value";
}
}

Some files were not shown because too many files have changed in this diff Show More