I have everything pretty much set up for what I need. Can you provide a Regular Expression code for allowing TA to read fractions correctly? Such as 7/8, 1/2, 5/8.
Thanks
Fractions
Moderator: Jim Bretti
-
- Posts: 1558
- Joined: Wed Oct 29, 2003 11:07 am
- Contact:
Re: Fractions
To really pronounce the fractions correctly I think you're going to need several regular expressions. Maybe someone else will have some better ideas, but here is what I'm thinking.
1/2, 1/3 and 2/3 would probably work best with one dictionary entry for each fraction. So for these you could use regular expressions or simple text matches, but here are regular expression:
\b1/2\b
one half
\b1/3\b
one third
\b2/3\b
two thirds
Now add another expression, after the above expressions, to handle all fractions of the form 1/n. Should be able to pronounce these as 1 nth, like this:
\b1/(\d{1,2})\b
1 $1th
At this point, if the numerator is > 1, the extra 's' makes things tricky. (2 5ths, 3 7ths, etc). In general I could not get a string like 2 5ths to be pronounced correctly. So I needed individual expressions to substitute the words fourths, fifths, sixths, and so on, like this:
\b([2-9])/4\b
$1 fourths
\b([2-9])/5\b
$1 fifths
So maybe start off with these, and experiment some. You may be able find a way to consolidate the fourths / fifths / sixths expressions. It may depend on the voice you're using as well.
1/2, 1/3 and 2/3 would probably work best with one dictionary entry for each fraction. So for these you could use regular expressions or simple text matches, but here are regular expression:
\b1/2\b
one half
\b1/3\b
one third
\b2/3\b
two thirds
Now add another expression, after the above expressions, to handle all fractions of the form 1/n. Should be able to pronounce these as 1 nth, like this:
\b1/(\d{1,2})\b
1 $1th
At this point, if the numerator is > 1, the extra 's' makes things tricky. (2 5ths, 3 7ths, etc). In general I could not get a string like 2 5ths to be pronounced correctly. So I needed individual expressions to substitute the words fourths, fifths, sixths, and so on, like this:
\b([2-9])/4\b
$1 fourths
\b([2-9])/5\b
$1 fifths
So maybe start off with these, and experiment some. You may be able find a way to consolidate the fourths / fifths / sixths expressions. It may depend on the voice you're using as well.
Jim Bretti
NextUp.com
NextUp.com
Re: Fractions
I normally pronounce fractions like n1/n2 as "n1 over n2"
For this a simple regex suffices :
regular expression (\d+)[/](\d+)
pronounce as $1 over $2
Hope this helps!
Quantum aka DaveH
For this a simple regex suffices :
regular expression (\d+)[/](\d+)
pronounce as $1 over $2
Hope this helps!
Quantum aka DaveH
Quantum aka DaveH