Capitalization in spellchecking

So I have a problem and I couldn’t really find an answer on this forum.
I work with pretty large scripts for a company that makes voiceovers. My employer asked me to capitalize stressed letters in long words (e.g. "i have tachycArdia also known as tachyarrhYthmia’’) because it makes voice actors’ job a bit easier. So when I’m done translating a script, i need to spellcheck it. And, of course, I run into some problems with this seemingly random capitalization. Can I make my spellcheck just skip words with capital letters in the middle or make it not case-sensitive?
Hopefully, someone knows how to make spellchecking a bit easier in this case.

I would make it as follows: instead of capitalizing a stressed letter, create a dedicated character style with everything as in the basic style with UPPERCASE set for the font effect and apply the style to stressed letters. I will attach a sample file.
stressed sample.odt (8.6 KB)

1 Like

Maybe you can use next macro before running spellcheck. It walks through all words in the document and it tests the validity for the Spelling. If the word is invalid, then it tests one for the caPITALIzation (function testWord). If the word is caPITALized, then it puts one to the List Of Ignored Words. Then you can run Spelling and it will not show these words as invalid.

You can delete the added words from: Tools/ Spelling …/ Options → in the User-defined Dictionaries select standard and press button Edit.

Sub addWordToDic 'test the invalid words from the spellchecker and add some of ones (tested by regexp) to the List Of Ignored Words
	dim oDoc as object, oVCur as object, oCur as object, document as object, dispatcher as object, b as boolean, s$, i%, oCurEnd as object
	dim oLoc as object, oLsm as object, oSpeller as object, bValid as boolean, args as new com.sun.star.beans.PropertyValue, oDics as object, oDic as object, sDic$
	
	oDoc=ThisComponent
	document=oDoc.CurrentController.Frame
	dispatcher=createUnoService("com.sun.star.frame.DispatchHelper")
	oCur=oDoc.Text.createTextCursor
	oCur.goToEnd(false)
	oVCur=oDoc.CurrentController.ViewCursor 'visible cursor
	oLsm=createUnoService("com.sun.star.linguistic2.LinguServiceManager")
	oSpeller=createUnoService("com.sun.star.linguistic2.SpellChecker") 'spellchecker
	oDics=createUnoService ("com.sun.star.linguistic2.DictionaryList") 'list of the dictionaries

	'xray oDics.Dictionaries 'list of the dictionaries
	'sDic="List Of Ignored Words" 'name of the dictionary for ignored words for en/US
	sDic="standard.dic" 'the simpliest use for all languages
	oDic=oDics.getDictionaryByName(sDic) 'use the dictionary
	
	dispatcher.executeDispatch(document, ".uno:GoToStartOfDoc", "", 0, array()) 'visible cursor to the start of the document
	do 'walk through all words in document
		dispatcher.executeDispatch(document, ".uno:SelectWord", "", 0, array()) 'select word
		s=oVCur.string 'current word
		oLoc=oVCur.CharLocale
		if oLoc.Language="" AND oLoc.Country="" then 'if CharLocale is "" then use your preferred Locale
			oLoc.Language="en" : oLoc.Country="US"
		end if
		bValid=oSpeller.isValid(s, oLoc, array()) 'validity of the from the spellchecker
		if NOT bValid then 'word in not valid
			if testWord(s, oLoc)=true then ' test the word for leTTErs
				oDic.add(s, false, "") 'add word to the dictionary
			end if
		end if
		dispatcher.executeDispatch(document, ".uno:GoToNextWord", "", 0, array())	
		oVCur.collapseToEnd
		i=oDoc.Text.compareRegionEnds(oVCur, oCur) 'check if the visible cursor is at the end of the document
		if i<1 then b=true
	loop while b=false
End Sub

Function testWord(s$, oLoc as object) as boolean 'test the word
	dim oSearch as object, oParam as object, oFOund as object, i&
	oSearch=CreateUnoService("com.sun.star.util.TextSearch") 'search for the string
	oParam=CreateUnoStruct("com.sun.star.util.SearchOptions")
	With oParam 'parametry pro textové hledání
		.algorithmType=com.sun.star.util.SearchAlgorithms.REGEXP 'regular expressions
		.locale=oLoc
		.searchString="[a-z]+[A-Z]+[a-z]*?"
	End With
	oSearch.setOptions(oParam)
	oFound=oSearch.searchForward(s,0,len(s))
	i=oFound.subRegExpressions
	testWord=iif(i>0, true, false)
End Function