-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
8f46dd9
commit d3e8718
Showing
6 changed files
with
107 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* this is a test validation method to show how validation could work. | ||
* @param annotation | ||
* @returns {{position: number, length: number, code: string}} | ||
*/ | ||
function validateAnnotation(annotation, guidelines) { | ||
let result = []; | ||
|
||
//Z01 Satzzeichen | ||
let re = /[\(\.,\!\?;\-\)]/g; | ||
while ((match = re.exec(annotation)) != null) { | ||
result.push({ | ||
start: match.index, | ||
length : match[0].length, | ||
code: "Z01" | ||
}); | ||
} | ||
|
||
//G01 | ||
for(let i = 0; i < guidelines.markers.length; i++){ | ||
let marker = guidelines.markers[i].code; | ||
|
||
re = new RegExp("("+ escapeRegex(marker) +")( *("+ escapeRegex(marker) +"))+", "g"); | ||
while ((match = re.exec(annotation)) != null) { | ||
result.push({ | ||
start: match.index, | ||
length : match[0].length, | ||
code: "G01" | ||
}); | ||
} | ||
} | ||
|
||
//R02 Ziffern | ||
re = /[0-9]+/g; | ||
while ((match = re.exec(annotation)) != null) { | ||
result.push({ | ||
start: match.index, | ||
length : match[0].length, | ||
code: "R02" | ||
}); | ||
} | ||
|
||
result = sortValidationResult(result); | ||
return result; | ||
} | ||
|
||
function escapeRegex(regex_str) { | ||
//escape special chars in regex | ||
return regex_str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); | ||
} | ||
|
||
function sortValidationResult(result){ | ||
return result.sort(function(a,b){ | ||
if(a.start == b.start) | ||
return 0; | ||
if(a.start < b.start) | ||
return -1; | ||
if(a.start > b.start) | ||
return 1; | ||
}); | ||
} | ||
|
||
function tidyUpAnnotation(annotation, guidelines) { | ||
let result = annotation; | ||
return result; | ||
} |
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,6 +1,6 @@ | ||
[ | ||
{ | ||
"name": "", | ||
"name": "julian_test", | ||
"id": 45 | ||
} | ||
] |
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