Page 1 of 1

How to substitute a character depending on the one or two after it?

Posted: Wed Mar 27, 2019 5:50 pm
by Veolaz
My Version is 11.5 and please help!
For example,
a b -> c b;
a b c -> d b c.

Re: How to substitute a character depending on the one or two after it?

Posted: Wed Mar 27, 2019 9:28 pm
by Bhikkhu Pesala
Moved to support

It is hard to understand why you need this. Please explain.

Perhaps the Randomize Feature will be of interest to you?

Re: How to substitute a character depending on the one or two after it?

Posted: Wed Mar 27, 2019 9:50 pm
by Erwin Denissen
Veolaz wrote: Wed Mar 27, 2019 5:50 pm My Version is 11.5 and please help!
For example,
a b -> c b;
a b c -> d b c.
You need a chained context substitution and single substitution lookups as shown here:
abc-to-dbc.png
abc-to-dbc.png (41.77 KiB) Viewed 2824 times
A basic script that you can import looks like:

Code: Select all

script latn {
  feature ContextualAlternates1;
}

feature ContextualAlternates1 calt {
  lookup ChainingContext1;
}

lookup ChainingContext1 {
  context a (b c);
  sub 0 SingleSubstitution1;
  context a (b);
  sub 0 SingleSubstitution2;
}

lookup SingleSubstitution1 {
  sub a -> d;
}

lookup SingleSubstitution2 {
  sub a -> c;
}

Re: How to substitute a character depending on the one or two after it?

Posted: Thu Mar 28, 2019 12:54 am
by Veolaz
Oh thanks a lot! (๑•̀ㅂ•́)و✧

Re: How to substitute a character depending on the one or two after it?

Posted: Thu Mar 28, 2019 1:27 am
by Veolaz
And what should I do if I want to do like this:
a <any characters> b c -> a <any characters> d c