digitallinguistics / transliterate

A small JavaScript library for transliterating strings between different orthographies
MIT License
9 stars 0 forks source link

advanced transliteration #24

Closed dwhieb closed 5 years ago

dwhieb commented 7 years ago

First, change the function to accept arguments, and validate those arguments:

Now that you've verified that the user has given you the arguments they're supposed to, you can start working with them.

The string argument is the string that the user wants to convert to another writing system.

The substitution argument is supposed to be an object with a list of replacements to make, so that the properties are the string to replace, and the values of those properties are the strings to replace them with. For example, the following substitutions object:

const substitutions = {
  ch: 'c',
  c:  'k',
  i:  'e',
};

would make the substitutions we talked about in our last meeting. So it would change chitimacha is cool to cetemaca es kool.

The rest of the steps from here are up to you. You'll fill in the rest of the function so that it performs the tasks we discussed in our meeting:

I'd suggest writing the part that does the simple substitutions first. Then once that's working, you can add the parts that handle the input-output problem.

Be sure to run your code a lot to see what the output is, and check whether anything is breaking.

If you have questions or need help as you go, sync your code to GitHub and open an issue for me. Good luck!