Page 1 of 1

New Javascript SCA

Posted: Mon Mar 19, 2012 6:59 pm
by zompist
I've updated the Sound Change Applier, writing it in Javascript like the vocabulary generator.

http://www.zompist.com/sca2.html

Changes (see the help file for details):
  • Supports Unicode
  • Spaces are treated as word boundaries
  • Supports epenthesis
  • Supports metathesis
  • Nonce categories (useful if they’re just for one rule)
  • Extended category substitution, e.g. Mi/Nj/_
  • Gemination and degemination
  • A gloss can be added that isn’t changed by the rules
  • Rules can be written in the form c→g/V_V
  • Rewrite rules allow you to use digraphs, or long category names
I'm sure to have made some ghastly mistake... if you find one post it here.

Re: New Javascript SCA

Posted: Mon Mar 19, 2012 7:11 pm
by Terra
I was just coming here to tell you about an error!

The error: Words are seemingly bolded (to show that they're different from last time) at random.
To reproduce: Open up the page, check "Show differences from last run", click "apply". "leitor" is bolded. Click "apply" again. Now "filha" is bolded.

Unless I misunderstand what that option's supposed to do, I think that it's an error.

Re: New Javascript SCA

Posted: Mon Mar 19, 2012 7:35 pm
by Bristel
It looks good, I'll have to try it out sometime. This will probably be my choice for SCA, as I'm computer illiterate and couldn't figure out the command line ones, and the GUId ones didn't really work on my laptop.

Re: New Javascript SCA

Posted: Mon Mar 19, 2012 7:45 pm
by Terra
It looks good, I'll have to try it out sometime. This will probably be my choice for SCA, as I'm computer illiterate and couldn't figure out the command line ones, and the GUId ones didn't really work on my laptop.
Not wanting to steal Zompist's thunder, but I made a SCA in Javascript not too long ago: http://jc.tech-galaxy.com/ling/sound_ch ... plier.html

It does nearly everything that Zompist's original SCA did. Note the subtle differences in notation.

Re: New Javascript SCA

Posted: Mon Mar 19, 2012 7:52 pm
by Bristel
Terra wrote:
It looks good, I'll have to try it out sometime. This will probably be my choice for SCA, as I'm computer illiterate and couldn't figure out the command line ones, and the GUId ones didn't really work on my laptop.
Not wanting to steal Zompist's thunder, but I made a SCA in Javascript not too long ago: http://jc.tech-galaxy.com/ling/sound_ch ... plier.html

It does nearly everything that Zompist's original SCA did. Note the subtle differences in notation.
You should have posted in it your signature, I didn't know about it.

It looks clean and simple, I like it as well. :)

Re: New Javascript SCA

Posted: Mon Mar 19, 2012 9:27 pm
by dhok
Nonce categories can't contain a predefined category. It's fun to play with, though.

I've also got a problem where it's running lines together. I have an input lexicon of

proto-word
proto-word
proto-word

and it spits out a single line of
wordwordword

For reference, here's my rules:
ŋ/n/_T
ŋ/m/_P
ŋ/n/_Y
T/Č/_I
t/c/_U
ŋ/n/_#
g/ŋ/V_V
i//Č_V
u//VC_#
e/ê/_
o/ô/_
L/S/_
ai/e/_
au/o/_
ae/ê/_
Q/J/ŋ_
J/Ñ/ŋ_
E/A/_NC
E/A/_N#
N//_C
N//_#
C//_²
[aêiô]//V(C)_#
C//_²
V//_²
K/G/V_V
ü//_
and my variables:
V=aeiouāēīōūêô
C=pbtdkgmnŋszrywhčjñšžçf
I=iī
U=uū
T=tdnszh
Č=čjñšžç
P=pb
Y=rywh
L=āēīōū
S=aeiou
N=mnñŋ
Q=ptčksš
J=bdjgzž
Ñ=mnñŋnñ
E=aêeiôou
A=aâêeaôo
K=pbtdkgmnŋszrywhčjñšžçf
G=fvþðxüvnŋhüŕüüüšžñhüüü

Re: New Javascript SCA

Posted: Mon Mar 19, 2012 9:56 pm
by zompist
What browser are you using? With either IE or Firefox, I get the output

prôþô-wôrd
prôþô-wôrd
prôþô-wôrd

Re: New Javascript SCA

Posted: Mon Mar 19, 2012 10:01 pm
by dhok
zompist wrote:What browser are you using? With either IE or Firefox, I get the output

prôþô-wôrd
prôþô-wôrd
prôþô-wôrd

Hmm what? Sorry, it was an example. My original input was
zaŋkoku
na
teŋsi
no

ni
siōneŋ
wa
siŋwa
ni
nare
.

Wait...huh that's funny, it works fine.

Re: New Javascript SCA

Posted: Mon Mar 19, 2012 10:18 pm
by zompist
Terra wrote:The error: Words are seemingly bolded (to show that they're different from last time) at random.
To reproduce: Open up the page, check "Show differences from last run", click "apply". "leitor" is bolded. Click "apply" again. Now "filha" is bolded.
Should be fixed now, thanks!

(First thing wasn't really an error: there was no previous run, so the first line was different. But I added a check to disable the bolding on the first run. Second error had to do with those pesky rewrite rules.)

Re: New Javascript SCA

Posted: Mon Mar 19, 2012 11:15 pm
by Radius Solis
:!:
Someone has read my pleas!

I'm pretty sure this will now be my SCA of choice. Nice work!

(Looking through the documentation I don't see anything about exception conditions, though... rule exceptions can often be handled in other ways of course, but over the years I've run into a couple that really couldn't without needing a large block of complex rules just to handle the one actual sound change.)

Re: New Javascript SCA

Posted: Mon Mar 19, 2012 11:35 pm
by zompist
Could you describe some of these exceptions?

Re: New Javascript SCA

Posted: Tue Mar 20, 2012 4:13 am
by Radius Solis
They were some years ago so I don't remember most of the specifics, and it may be that the extended categorization would have been sufficient to make them more workable. But it's not hard to imagine issues... the usual workarounds for a rule exception are A) changing the target to something else temporarily under the excepted condition then changing it back after applying the rule, or B) giving only the conditions in which the rule does apply.

But B can be a terrible solution when there would be lots of unexcepted environments, because 1. sometimes the situation is complex enough you couldn't readily identify them all, and 2. if you have to list them all in separate rule lines, their successive application can make them interfere with each other's environments.

And that leaves A, which can be a minor hassle if the target is a category with lots of members and you have to come up with a bunch of unused characters to temporarily represent them all. Or a larger one if you have to preserve features like aspiration and labialization through the switcheroo that had been marked with digraphs and which you otherwise had no need to handle with rewrite rules... and if the original rules situation was already complex enough you can't even tell what members of the category currently exist at that point in the ruleset (this happens!) or you've gotten too original with your sound changes and ended up with multiple exceptions that require nested or overlapping temporary categories to exist at the same time, then we're fast approaching the point where I'd just throw up my hands and apply the damned changes manually. And all of the lack of being able to say "except CC_C". The exception can be that simple and still a headache to get to work in a rules list.

All of that being said, I don't want to overstate my case either. Bad instances have been relatively rare, and it's not that hard to apply changes manually if needed. The SCA2 looks worth its salt and I'll be using it.

Re: New Javascript SCA

Posted: Tue Mar 20, 2012 5:46 am
by Terra
zompist wrote:
Terra wrote:The error: Words are seemingly bolded (to show that they're different from last time) at random.
To reproduce: Open up the page, check "Show differences from last run", click "apply". "leitor" is bolded. Click "apply" again. Now "filha" is bolded.
Should be fixed now, thanks!

(First thing wasn't really an error: there was no previous run, so the first line was different. But I added a check to disable the bolding on the first run. Second error had to do with those pesky rewrite rules.)
It looks fixed now.

Not really an error, but a suggestion: Add a label to the radio buttons and checkboxes so that clicking on their respective description activates/deactivates the button/box. It makes them easier to click.

Re: New Javascript SCA

Posted: Tue Mar 20, 2012 3:37 pm
by Terra
Also, the "show differences" thing gets messed up if you include blank lines in the input, because the output apparently skips them.

Re: New Javascript SCA

Posted: Wed Mar 21, 2012 10:39 am
by zompist
Radius Solis wrote:They were some years ago so I don't remember most of the specifics, and it may be that the extended categorization would have been sufficient to make them more workable. But it's not hard to imagine issues... the usual workarounds for a rule exception are A) changing the target to something else temporarily under the excepted condition then changing it back after applying the rule, or B) giving only the conditions in which the rule does apply.
OK, I understand what you're saying now. This proved to be not so difficult, so it's implemented. E.g.

k/s/_F/#C_

changes k to s in environment _F but not if #C_ also applies.

Re: New Javascript SCA

Posted: Fri Mar 23, 2012 1:43 am
by Radius Solis
zompist wrote: OK, I understand what you're saying now. This proved to be not so difficult, so it's implemented. E.g.

k/s/_F/#C_

changes k to s in environment _F but not if #C_ also applies.
Hooray! And not a day too soon, as I've just run into one in my very first try at using the SCA, so I can give you a real example after all:

I have an epenthesis rule for Mountain Western that generates a glottal stop between a nasal vowel and any unaspirated plosive. Since there had been no way to say:

/ʔ/N_[ptk]/_Ch

I would have had to pick strategy A or B, and A is impossible because there's no initial target to preserve by changing it to something else. And I can't really think of a better way to do B than to apply the rule without the exception, then go back with another rule line and delete the new glottal stops in the excepted environment... but there's a few pre-existing glottal stops in that position too, which I want to keep, so I'd have had to use the preservation strategy for that instead. Not that this is so very hard, but the solution might not be obvious to others. :)

Re: New Javascript SCA

Posted: Fri Mar 23, 2012 3:53 am
by Cedh
Radius Solis wrote:I have an epenthesis rule for Mountain Western that generates a glottal stop between a nasal vowel and any unaspirated plosive. Since there had been no way to say:

/ʔ/N_[ptk]/_Ch

I would have had to pick strategy A or B, and A is impossible because there's no initial target to preserve by changing it to something else. And I can't really think of a better way to do B than to apply the rule without the exception, then go back with another rule line and delete the new glottal stops in the excepted environment... but there's a few pre-existing glottal stops in that position too, which I want to keep, so I'd have had to use the preservation strategy for that instead. Not that this is so very hard, but the solution might not be obvious to others. :)
Another strategy, which I've been using regularly with sound change appliers, would be to explicitly mark the environment before applying the change itself:
/;/N_[ptk]
;//_[ptk]h
/ʔ/_;
;//_

Of course, being able to state the exception in a single rule is much better. :)

Re: New Javascript SCA

Posted: Fri Mar 23, 2012 9:43 pm
by Radius Solis
cedh audmanh wrote: Another strategy, which I've been using regularly with sound change appliers, would be to explicitly mark the environment before applying the change itself:
/;/N_[ptk]
;//_[ptk]h
/ʔ/_;
;//_
That's another way, yes. But the last two lines look combinable into:
;/ʔ/_
Which would need one less line than my solution did.

Re: New Javascript SCA

Posted: Sat Mar 24, 2012 4:56 am
by Cedh
Radius Solis wrote:the last two lines look combinable into:
;/ʔ/_
In this case, yes, but for some other types of sound changes it's better to remove ; separately so I've become accustomed to always writing it that way.

Re: New Javascript SCA

Posted: Sat Mar 24, 2012 2:53 pm
by Rin
Zompist,

This is great! Trying to get the old SCA to work was driving me nuts, and so I was just about ready to use ZoundsIPA when you posted this.

Cheers, mate!

Re: New Javascript SCA

Posted: Fri Apr 20, 2012 8:14 pm
by Richard W
Terra wrote:Not wanting to steal Zompist's thunder, but I made a SCA in Javascript not too long ago: http://jc.tech-galaxy.com/ling/sound_ch ... plier.html
I suspect many of us did, in my case far too long ago (2004) - http://homepage.ntlworld.com/richard.wo ... 5d_rom.htm .