Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECMA/JavaScript Callbacks #86

Open
kkynde opened this issue Jul 20, 2023 · 1 comment
Open

ECMA/JavaScript Callbacks #86

kkynde opened this issue Jul 20, 2023 · 1 comment

Comments

@kkynde
Copy link

kkynde commented Jul 20, 2023

Offspring of issue #85:
The documentation on ECMA/JavaScript Callbacks https://collatex.net/doc/ 6.1 is curiously short (empty, so to speak). I imagine that an argument should be given to --script (cf. 6. The Command Line Interface), e.g. an ECMA/JavaScript file with "functions to be plugged into the alignment algorithm" ... but how should these functions be ?

Karsten Kynde

@kkynde
Copy link
Author

kkynde commented Jul 26, 2023

This is an attempt to answer my own question. I should be grateful if some authorized person would confirm, correct or - even better - complete my research - read educated guesswork:

The command line takes the option --script func.js, containing a JavaScript function

function compare( base, witness ) {
if( base==witness ) return 0
else if( x<y ) return -1
else return 1
}

where the arguments are both string type values and the value returned is as for the Java String.compareTo().

Changes in upper- and lowercasing are by default ignored during alignment ( @rhdekker in #85 ), but if the objective is to alter this into an exact match, the above function will make no difference. This is because the arguments for compare() has already been normalized, i.e. to lower case and stripped of leading spaces. But don't panic, we can invent yet a function

function normalize( x ) {
return x ;
}

and behold, no normalization takes place. In fact, the first function compare() is now superfluous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant