-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
145 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
import GeeProcess from '../processgraph/process.js'; | ||
import text_position from './text_position.js'; | ||
|
||
export default class text_begins extends GeeProcess { | ||
|
||
executeSync(node) { | ||
let data = node.getArgumentAsStringEE('data'); | ||
let pattern = node.getArgumentAsStringEE('pattern'); | ||
const case_sensitive = node.getArgument('case_sensitive'); | ||
if (!case_sensitive) { | ||
data = data.toLowerCase(); | ||
pattern = pattern.toLowerCase(); | ||
} | ||
return data.index(pattern).eq(0); | ||
const data = node.getArgumentAsStringEE('data'); | ||
const pattern = node.getArgumentAsStringEE('pattern'); | ||
const case_sensitive = node.getArgumentAsNumberEE('case_sensitive', true); | ||
return text_position.process(data, pattern, case_sensitive).eq(0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
import GeeProcess from '../processgraph/process.js'; | ||
import text_position from './text_position.js'; | ||
|
||
export default class text_contains extends GeeProcess { | ||
|
||
executeSync(node) { | ||
let data = node.getArgumentAsStringEE('data'); | ||
let pattern = node.getArgumentAsStringEE('pattern'); | ||
const case_sensitive = node.getArgument('case_sensitive'); | ||
if (!case_sensitive) { | ||
data = data.toLowerCase(); | ||
pattern = pattern.toLowerCase(); | ||
} | ||
return data.index(pattern).gte(0); | ||
const data = node.getArgumentAsStringEE('data'); | ||
const pattern = node.getArgumentAsStringEE('pattern'); | ||
const case_sensitive = node.getArgumentAsNumberEE('case_sensitive', true); | ||
return text_position.process(data, pattern, case_sensitive).gte(0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import GeeProcess from '../processgraph/process.js'; | ||
import text_position from './text_position.js'; | ||
|
||
export default class text_ends extends GeeProcess { | ||
|
||
executeSync(node) { | ||
let data = node.getArgumentAsStringEE('data'); | ||
let pattern = node.getArgumentAsStringEE('pattern'); | ||
const case_sensitive = node.getArgument('case_sensitive'); | ||
if (!case_sensitive) { | ||
data = data.toLowerCase(); | ||
pattern = pattern.toLowerCase(); | ||
} | ||
const data = node.getArgumentAsStringEE('data'); | ||
const pattern = node.getArgumentAsStringEE('pattern'); | ||
const case_sensitive = node.getArgumentAsNumberEE('case_sensitive', true); | ||
const expectedPos = data.length().subtract(pattern.length()); | ||
return data.index(pattern).eq(expectedPos); | ||
return text_position.process(data, pattern, case_sensitive).eq(expectedPos); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import GeeProcess from '../processgraph/process.js'; | ||
import If from './if.js'; | ||
|
||
export default class text_position extends GeeProcess { | ||
|
||
process(data, pattern, case_sensitive) { | ||
data = If.process(case_sensitive.eq(0), data.toLowerCase(), data); | ||
pattern = If.process(case_sensitive.eq(0), pattern.toLowerCase(), pattern); | ||
return data.index(pattern); | ||
} | ||
|
||
executeSync(node) { | ||
const data = node.getArgumentAsStringEE('data'); | ||
const pattern = node.getArgumentAsStringEE('pattern'); | ||
const case_sensitive = node.getArgumentAsNumberEE('case_sensitive', true); | ||
return this.process(data, pattern, case_sensitive); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{ | ||
"id": "text_position", | ||
"summary": "First position of a text in another text", | ||
"description": "Checks where the text (also known as *string*) specified for `pattern` is positioned in the text specified for `data` for the first time. No-data values are passed through.", | ||
"categories": [ | ||
"texts" | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "data", | ||
"description": "Text in which to find something in.", | ||
"schema": { | ||
"type": [ | ||
"string", | ||
"null" | ||
] | ||
} | ||
}, | ||
{ | ||
"name": "pattern", | ||
"description": "Text to find in `data`. Regular expressions are not supported.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "case_sensitive", | ||
"description": "Case sensitive comparison can be disabled by setting this parameter to `false`.", | ||
"schema": { | ||
"type": "boolean" | ||
}, | ||
"default": true, | ||
"optional": true | ||
} | ||
], | ||
"returns": { | ||
"description": "A value >= 0 that indicates the position of the text, `-1` if the text was not found.", | ||
"schema": { | ||
"type": [ | ||
"integer", | ||
"null" | ||
], | ||
"minimum": -1 | ||
} | ||
}, | ||
"examples": [ | ||
{ | ||
"arguments": { | ||
"data": "Lorem ipsum dolor sit amet", | ||
"pattern": "openEO" | ||
}, | ||
"returns": -1 | ||
}, | ||
{ | ||
"arguments": { | ||
"data": "Lorem ipsum dolor sit amet", | ||
"pattern": "ipsum dolor" | ||
}, | ||
"returns": 6 | ||
}, | ||
{ | ||
"arguments": { | ||
"data": "Lorem ipsum dolor sit amet", | ||
"pattern": "Ipsum Dolor" | ||
}, | ||
"returns": -1 | ||
}, | ||
{ | ||
"arguments": { | ||
"data": "Lorem ipsum dolor sit amet", | ||
"pattern": "SIT", | ||
"case_sensitive": false | ||
}, | ||
"returns": 18 | ||
}, | ||
{ | ||
"arguments": { | ||
"data": "ÄÖÜ", | ||
"pattern": "ö", | ||
"case_sensitive": false | ||
}, | ||
"returns": 1 | ||
}, | ||
{ | ||
"arguments": { | ||
"data": null, | ||
"pattern": "null" | ||
}, | ||
"returns": null | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters