Topics

how can I set symbol pronounciation for special case?


Samuel Kacer
 

Hello,

I find myself reading math a lot and very commonparticular in propositional logic and proofs is to differentiate two variables that are related but different by putting a single quote at the end of one of them. Example:
x and x' (read by symbol to notice the difference)

In math, The secon would be read as "x prime".

If you can see then it is easy to notice the distinction, but since screen readers try to avoid reading irrelevant information, this is skipped by default.

I noticed NVDA allows you to set symbol pronunciation including for special cases like being sentence ending or phrase ending, etc.

What I'd like to achieve is when a single quote is at the end of a word and pronunciation level is most, for NVDA to read it as "word prime". 

I tried several different things, but none of them achieved this.

I know I can make it so single quotes are read at most level, but then it will be read out when it isnt relevant to me. I just want to know about it when it is at the end of a word.

Really appreciate if someone can help with this. 

Thanks,
Sam


 
Edited

Sam,

          I would do this using the speech dictionary and a regular expression for the item.  If I am safe in assuming that the thing with the prime in front of it will always be a single letter, preceded by a space, and you are not using single quotes to enclose phrases (at least not commonly), then try this:

1. NVDA+P,D,D  to open NVDA Preferences, Speech Dictionaries, Default Dictionary
2. Activate the Add Button
3. In pattern, place the following:  ([a-zA-Z])'
4. In replacement, place the following:  \1 prime
5. In comment make whatever note you'd like, I said mathematical prime
6. Don't check the case insensitive checkbox.
7. Activate the Regular Expression radio button.

If you do use single quotes frequently to enclose phrases, e.g., 'this phrase enclosed with single quotes,' I can try to get more sophisticated and use lookback in the regular expression to avoid instance for single quoted phrases.   As the regular expression I gave is currently constructed, it will match only a single character that's a lowercase or uppercase letter followed by the prime single quote.

I tested this in Notepad and its working.

--

Brian - Windows 10 Pro, 64-Bit, Version 1909, Build 18363  

Power is being told you're not loved and not being destroyed by it.

       ~ Madonna

 

 


Sascha Cowley
 

Hi Brian,

The regular expression should be: ([a-zA-Z])'

That is, the second 'z' should be uppercase. As is, that regex will match anything between uppercase A and lowercase z, which includes things like square brackets.


Regards,
Sascha

On 19/04/2020 03:48, Brian Vogel wrote:
Sam,

          I would do this using the speech dictionary and a regular expression for the item.  If I am safe in assuming that the thing with the prime in front of it will always be a single letter, preceded by a space, and you are not using single quotes to enclose phrases (at least not commonly), then try this:

1. NVDA+P,D,D  to open NVDA Preferences, Speech Dictionaries, Default Dictionary
2. Activate the Add Button
3. In pattern, place the following:  ([a-zA-z])'
4. In replacement, place the following:  \1 prime
5. In comment make whatever note you'd like, I said mathematical prime
6. Don't check the case insensitive checkbox.
7. Activate the Regular Expression radio button.

If you do use single quotes frequently to enclose phrases, e.g., 'this phrase enclosed with single quotes,' I can try to get more sophisticated and use lookback in the regular expression to avoid instance for single quoted phrases.   As the regular expression I gave is currently constructed, it will match only a single character that's a lowercase or uppercase letter followed by the prime single quote.

I tested this in Notepad and its working.

--

Brian - Windows 10 Pro, 64-Bit, Version 1909, Build 18363  

Power is being told you're not loved and not being destroyed by it.

       ~ Madonna

 

 


 

Sascha,

          Yep.  Typo.

--

Brian - Windows 10 Pro, 64-Bit, Version 1909, Build 18363  

Science has become just another voice in the room; it has lost its platform.  Now, you simply declare your own truth.

      ~ Dr. Paul A. Offit, in New York Times article, How Anti-Vaccine Sentiment Took Hold in the United States, September 23, 2019

 

 


Sascha Cowley
 

If you wanted to match other alphabetic characters (such as Greek letters), a pattern like this could work: ([^\W\d_])'

On 19/04/2020 08:46, Brian Vogel wrote:
Sascha,

          Yep.  Typo.

--

Brian - Windows 10 Pro, 64-Bit, Version 1909, Build 18363  

Science has become just another voice in the room; it has lost its platform.  Now, you simply declare your own truth.

      ~ Dr. Paul A. Offit, in New York Times article, How Anti-Vaccine Sentiment Took Hold in the United States, September 23, 2019

 

 


Samuel Kacer
 

Thanks for the replies. I didn't actually notice that speech dictionary supported regular expressions.

So, I've been playing with writing several expressions, but nothing satisfactory yet.

To expand a little on what I want, I am I want it to match on a word that ends in single quote, but not if it is enclosed in single quotes or has a letter following it directly. So cases like 'hello' and don't shouldn't match.

What I've got so far is thanks to your examples and some googling is this:
([\w]+)'

This is good in that it will match on any word, however it doesnt take care of the case when the word is enclosed in single quotes or is inside a word like don't.

I've tried inverted character classes like this:
[^']([\w]+)'[^a-zA-Z]

But, that doesn't seem to do what I would expect.

Does anyone have any ideas?

Thanks,
Sam


Samuel Kacer
 

Also, does anyone know what particular flavor of regex does NVDA use? I noticed it parentheses are treated differently than I am used to and ^ doesnt seem to match beginning of string.

Like if I have regex ^ foo^foo, it will match foo even if it isnt at beginning of the line.


Tyler Spivey
 

It uses Python's re module. You'll have to read the code which handles the speech dictionaries to figure out how it works.

Why don't you just write an addon to do what you want?


On 4/19/2020 12:31 AM, Samuel Kacer wrote:
Also, does anyone know what particular flavor of regex does NVDA use? I noticed it parentheses are treated differently than I am used to and ^ doesnt seem to match beginning of string.

Like if I have regex ^ foo^foo, it will match foo even if it isnt at beginning of the line.


Robert Doc Wright godfearer
 


You have one possible problem facing you. Names ending in (s) like Frances uses an apostrophy at the end to show possession, i.e. Frances'.
this is what I found in a Google search:
 
Word: Insert prime and double prime characters
1. If you have a separate number pad, then press Alt+8242 (press and hold the Alt key while you type 8242) for prime, or Alt+8243 for double prime.
 
******
If we don't take time to think before we speak we may find ourselves in a situation where our speech becomes a bit stinky!

----- Original Message -----
Sent: Saturday, April 18, 2020 11:31 AM
Subject: [nvda] how can I set symbol pronounciation for special case?

Hello,

I find myself reading math a lot and very commonparticular in propositional logic and proofs is to differentiate two variables that are related but different by putting a single quote at the end of one of them. Example:
x and x' (read by symbol to notice the difference)

In math, The secon would be read as "x prime".

If you can see then it is easy to notice the distinction, but since screen readers try to avoid reading irrelevant information, this is skipped by default.

I noticed NVDA allows you to set symbol pronunciation including for special cases like being sentence ending or phrase ending, etc.

What I'd like to achieve is when a single quote is at the end of a word and pronunciation level is most, for NVDA to read it as "word prime". 

I tried several different things, but none of them achieved this.

I know I can make it so single quotes are read at most level, but then it will be read out when it isnt relevant to me. I just want to know about it when it is at the end of a word.

Really appreciate if someone can help with this. 

Thanks,
Sam


Samuel Kacer
 

Thanks, Tyler. I've started looking through doc for python RE. Not sure how I would go about making an addon for this... Is there a place I could hook into to filter/transform the text being sent to the synthesizer?

I've gotten closer. Now my regex will exclude the case when it is being used as an apostrophe such as in contractions like don't and I'll. But still cant figure out how to exclude the case when the single quotes are being used to enclose a word such as the case in a python string literal.

Here is the regex:
(\w+)'(\s|$)

i've tried to exclude the enclosing case by prepending a \s to the beginning of the regex so it wont match unless there is a whitespace character before the string of word characters, but that doesn't work. Also tried putting a \b at the beginning so it would match if the string of word characters start at a word boundary, but that doesnt work either...

If anyone has any more ideas, they are appreciated


Samuel Kacer
 

Hello,Hi Robert, that's a good point. I think in that special case I would be okay with it, since it is relatively rare and as long as I got the regex to exclude the enclosing case like 'hello, world' then that would be good enough for me.

I will keep in mind writing the special prime and double prime characters, but alas my problem is reading other people's stuff that just use the plain apostrophe character.


 

Sam,

            Although I am certain that a regular expression could be crafted to work in virtually all cases where you need it, and not where you don't, is that really worth the effort?   I would imagine that you know when you are dealing with documents where you need the prime or double prime to be read, and I doubt that many, if any, of them are going to have single quote enclosed quoted strings or possessives for plurals for words ending in S.

             It would be relatively easy to put regular expression that will work when reading these mathematical documents in either the Voice dictionary, and use a specific voice you don't typically use when reading these documents, or even to keep the regex in a plain text file and toss an entry into the temporary dictionary (which is more work, but it is an option).

             I have written some insanely complex regex-es in my lifetime, but only when it was the only option because there was no way I could put any sort of "scoping rule" on the material that might be handed along for processing by same.  You likely have the luxury of knowing exactly when you're dealing with the material in question, and there are easier ways to get the result you want than spending lots and lots of time to get the magic, perfect, will work on any document regex if that's really not the easiest thing to get that result.
--

Brian - Windows 10 Pro, 64-Bit, Version 1909, Build 18363  

Science has become just another voice in the room; it has lost its platform.  Now, you simply declare your own truth.

      ~ Dr. Paul A. Offit, in New York Times article, How Anti-Vaccine Sentiment Took Hold in the United States, September 23, 2019

 

 


 

On Sun, Apr 19, 2020 at 05:54 AM, Samuel Kacer wrote:
but alas my problem is reading other people's stuff that just use the plain apostrophe character.
And, believe me, unless the person preparing a document is preparing it for professional publication, they aren't going to be using the dedicated characters.

Even some who are won't, and will allow the editors to take care of that when working through the manuscript.
 
--

Brian - Windows 10 Pro, 64-Bit, Version 1909, Build 18363  

Science has become just another voice in the room; it has lost its platform.  Now, you simply declare your own truth.

      ~ Dr. Paul A. Offit, in New York Times article, How Anti-Vaccine Sentiment Took Hold in the United States, September 23, 2019