Open mrshr3d opened 7 months ago
I am aware of the issue but thank you for raising it. It's a problem with the underlying text tagging library (SpaCy). I have tried developing workarounds but so far without success. But I'll look into it further.
Huh.... I thought I had posted a suggested "dirty" fix but I don't see it here in the chat. Work-around is to pad any em-dashes with spaces before conversion, then removing the spaces after conversion. Though this is simple enough to do to my source text before running it through latin2shaw.
def latin2shaw(text):
+ text = text.replace('โ', ' โ ')
...
+ text_shaw = text_shaw.replace(' โ ', 'โ')
return text_shaw
Confirmed that re-running latin2shaw with the above 2 lines added fixes it:
๐๐ฐ ๐ข๐ฑ๐๐ฉ๐ ๐ ๐๐ณ๐ฅ ๐๐ฒ๐ฅ ๐ข๐ฆ๐๐ฌ๐ ๐ฃ๐ฝ๐ฆ๐ ๐ง๐ฏ๐ฆ๐๐ฆ๐ ๐ฅ๐น: ๐จ๐ ๐ค๐ญ๐๐ ๐๐ฑ๐ฅ ๐ฉ ๐ฎ๐ณ๐ฅ๐๐ค๐ฆ๐ ๐ ๐ค๐ฆ๐๐ฉ๐ค ๐๐ธ๐๐ข๐ฐ๐ค๐, ๐ฏ ๐ ๐๐ฌ๐ฏ๐ ๐ ๐ฉ ๐๐ซ๐ ๐ฅ๐ง๐ฏ๐ฆ ๐๐ถ๐๐ฉ๐ ๐ท๐ค ๐๐ท๐๐ฆ๐ ๐๐ฉ๐๐ง๐๐ผ: ๐๐ฐ ๐ฅ๐ฑ๐ ๐ฌ๐ ๐ ๐ข๐ป๐๐: ยซ๐ข๐บ๐ ๐ ๐ณ๐๐ผ ๐ค๐จ๐๐ผ?โ๐ข๐ฒ, ๐ฒ ๐ฃ๐จ๐๐ฉ๐ฏ๐ ๐ ๐๐ฎ๐ฆ๐ ๐๐ณ๐ ๐ข๐ณ๐ฏ; ยท๐๐ฆ๐ค๐ ๐๐ช๐ ๐ ๐ณ๐๐ผโยท๐๐ฆ๐ค! ๐๐ง๐ ๐ฆ๐ ๐ฃ๐ฝ, ๐ค๐จ๐!โ๐ฃ๐ฝ, ๐๐ซ๐ ๐ฉ๐ฅ ๐ณ๐ ๐จ๐ ๐๐ฆ๐ ๐๐น๐ฏ๐ผโ๐ฏ๐ด, ๐๐ฒ ๐ฉ๐ฅ ๐๐ฉ๐๐ง๐๐ผ ๐๐ป๐๐โ๐๐ฑ ๐๐ด๐ฏ๐ ๐ฎ๐ฐ๐ ๐ฃ๐ญ๐ ๐ฃ๐ฒ ๐ฆ๐ฏ๐ณ๐ ๐๐ง๐โ๐ด! ๐๐ฑ๐ค ๐๐ต ๐ข๐ง๐ค ๐ฆ๐ฏ๐ณ๐; ๐๐ด๐ฏ๐ ๐๐ฐ ๐๐ผ๐๐ฆ๐๐๐ฉ๐ค๐ผโ๐ฃ๐ฝ, ยท๐๐ฆ๐ค! ๐๐จ๐ ๐ฃ๐ด๐ค๐ ๐ ๐๐ฆ๐ ๐ฎ๐ด๐โ๐ข๐ฆ๐ค ๐ ๐ฎ๐ต๐ ๐๐บ?โ๐ฅ๐ฒ๐ฏ๐ ๐๐จ๐ ๐ค๐ต๐ ๐๐ค๐ฑ๐โ๐ด, ๐ฆ๐๐ ๐๐ณ๐ฅ๐ฆ๐ ๐๐ฌ๐ฏ! ๐ฃ๐ง๐๐ ๐๐ฆ๐ค๐ด!ยป (๐ฉ ๐ค๐ฌ๐ ๐๐ฎ๐จ๐)โยซ๐ฏ๐ฌ, ๐ฃ๐ต ๐๐ฆ๐ ๐๐จ๐?โ๐ฆ๐ ๐ข๐ช๐ ยท๐๐ฆ๐ค, ๐ฒ ๐๐จ๐ฏ๐๐ฆโ๐ฃ๐ต๐ ๐ ๐๐ด ๐๐ฌ๐ฏ ๐ ๐๐ฆ๐ฅ๐ฏ๐ฆ?โ๐ฏ๐ฑ, ๐ฒ ๐๐ญ๐ฏ๐! ๐ฟ ๐๐ต ๐ฆ๐!โ๐๐จ๐ ๐ฒ ๐ข๐ด๐ฏ๐, ๐๐ง๐ฏ!โยท๐๐ฆ๐ค๐ ๐ ๐๐ด ๐๐ฌ๐ฏโ๐ฃ๐ฝ, ยท๐๐ฆ๐ค! ๐ ๐ฅ๐ญ๐๐๐ผ ๐๐ง๐ ๐ฟ๐ผ ๐ ๐๐ด ๐๐ฌ๐ฏ ๐ ๐๐ฆ๐ฅ๐ฏ๐ฆ!ยป
Yes, this should work, but it will (I think) mean that if the original text had spaces on either side of the dashes, they will be removed. I believe there is a way to tell the SpaCy tagger to recognise a dash next to punctuation as punctuation but I have so far struggled to make it work. This is what I was thinking to look into again. If that fails, I'll add your suggested workaround.
The issue arises when an em-dash is used between 2 words, and where there are other punctuation marks adjacent to the em-dash. i.e. where the first part before the em-dash is exclaimed or is a question etc.
Merriam-Webter does have examples showing this particular usage of the em-dash here https://www.merriam-webster.com/grammar/em-dash-en-dash-how-to-use
Here is an "OK" sample, where the em-dash is the only character (no other adjacent punctuation):
Within its first year, Mabel and Harry had sampled all of the bakeryโs offeringsโall 62 itemsโand had also decided that the exercise was worth repeating.
๐ข๐ฆ๐๐ฆ๐ฏ ๐ฆ๐๐ ๐๐ป๐๐ ๐๐ฝ, ยท๐ฅ๐ฑ๐๐ฉ๐ค ๐ฏ ยท๐ฃ๐จ๐ฎ๐ฆ ๐ฃ๐จ๐ ๐๐ญ๐ฅ๐๐ฉ๐ค๐ ๐ท๐ค ๐ ๐ ๐๐ฑ๐๐ผ๐ฆ๐ ๐ช๐๐ผ๐ฆ๐๐โ๐ท๐ค 62 ๐ฒ๐๐ฉ๐ฅ๐โ๐ฏ ๐ฃ๐จ๐ ๐ท๐ค๐๐ด ๐๐ฆ๐๐ฒ๐๐ฉ๐ ๐๐จ๐ ๐ ๐ง๐๐๐ผ๐๐ฒ๐ ๐ข๐ช๐ ๐ข๐ป๐ ๐ฎ๐ฆ๐๐ฐ๐๐ฆ๐.
Here is a particular bad sample from Alice:
She waited for some time without hearing anything more: at last came a rumbling of little cartwheels, and the sound of a good many voices all talking together: she made out the words: โWhereโs the other ladder?โWhy, I hadnโt to bring but one; Billโs got the otherโBill! fetch it here, lad!โHere, put โem up at this cornerโNo, tie โem together firstโthey donโt reach half high enough yetโOh! theyโll do well enough; donโt be particularโHere, Bill! catch hold of this ropeโWill the roof bear?โMind that loose slateโOh, itโs coming down! Heads below!โ (a loud crash)โโNow, who did that?โIt was Bill, I fancyโWhoโs to go down the chimney?โNay, I shanโt! You do it!โThat I wonโt, then!โBillโs to go downโHere, Bill! the master says youโre to go down the chimney!โ
๐๐ฐ ๐ข๐ฑ๐๐ฉ๐ ๐ ๐๐ณ๐ฅ ๐๐ฒ๐ฅ ๐ข๐ฆ๐๐ฌ๐ ๐ฃ๐ฝ๐ฆ๐ ๐ง๐ฏ๐ฆ๐๐ฆ๐ ๐ฅ๐น: ๐จ๐ ๐ค๐ญ๐๐ ๐๐ฑ๐ฅ ๐ฉ ๐ฎ๐ณ๐ฅ๐๐ค๐ฆ๐ ๐ ๐ค๐ฆ๐๐ฉ๐ค ๐๐ธ๐๐ข๐ฐ๐ค๐, ๐ฏ ๐ ๐๐ฌ๐ฏ๐ ๐ ๐ฉ ๐๐ซ๐ ๐ฅ๐ง๐ฏ๐ฆ ๐๐ถ๐๐ฉ๐ ๐ท๐ค ๐๐ท๐๐ฆ๐ ๐๐ฉ๐๐ง๐๐ผ: ๐๐ฐ ๐ฅ๐ฑ๐ ๐ฌ๐ ๐ ๐ข๐ป๐๐: ยซ๐ข๐บ๐ ๐ ๐ณ๐๐ผ ladder?โ๐ข๐ฒ, ๐ฒ ๐ฃ๐จ๐๐ฉ๐ฏ๐ ๐ ๐๐ฎ๐ฆ๐ ๐๐ณ๐ ๐ข๐ณ๐ฏ; ยท๐๐ฆ๐ค๐ ๐๐ช๐ ๐ ๐ณ๐๐ผโยท๐๐ฆ๐ค! ๐๐ง๐ ๐ฆ๐ ๐ฃ๐ฝ, lad!โ๐ฃ๐ฝ, ๐๐ซ๐ ๐ฉ๐ฅ ๐ณ๐ ๐จ๐ ๐๐ฆ๐ ๐๐น๐ฏ๐ผโ๐ฏ๐ด, ๐๐ฒ ๐ฉ๐ฅ ๐๐ฉ๐๐ง๐๐ผ ๐๐ป๐๐โ๐๐ฑ ๐๐ด๐ฏ๐ ๐ฎ๐ฐ๐ ๐ฃ๐ญ๐ ๐ฃ๐ฒ ๐ฆ๐ฏ๐ณ๐ ๐๐ง๐โ๐ด! ๐๐ฑ๐ค ๐๐ต ๐ข๐ง๐ค ๐ฆ๐ฏ๐ณ๐; ๐๐ด๐ฏ๐ ๐๐ฐ ๐๐ผ๐๐ฆ๐๐๐ฉ๐ค๐ผโ๐ฃ๐ฝ, ยท๐๐ฆ๐ค! ๐๐จ๐ ๐ฃ๐ด๐ค๐ ๐ ๐๐ฆ๐ ๐ฎ๐ด๐โ๐ข๐ฆ๐ค ๐ ๐ฎ๐ต๐ bear?โ๐ฅ๐ฒ๐ฏ๐ ๐๐จ๐ ๐ค๐ต๐ ๐๐ค๐ฑ๐โ๐ด, ๐ฆ๐๐ ๐๐ณ๐ฅ๐ฆ๐ ๐๐ฌ๐ฏ! ๐ฃ๐ง๐๐ ๐๐ฆ๐ค๐ด!ยป (๐ฉ ๐ค๐ฌ๐ crash)โยป๐ฏ๐ฌ, ๐ฃ๐ต ๐๐ฆ๐ that?โ๐ฆ๐ ๐ข๐ช๐ ยท๐๐ฆ๐ค, ๐ฒ ๐๐จ๐ฏ๐๐ฆโ๐ฃ๐ต๐ ๐ ๐๐ด ๐๐ฌ๐ฏ ๐ chimney?โ๐ฏ๐ฑ, ๐ฒ ๐๐ญ๐ฏ๐! ๐ฟ ๐๐ต it!โ๐๐จ๐ ๐ฒ ๐ข๐ด๐ฏ๐, then!โยท๐๐ฆ๐ค๐ ๐ ๐๐ด ๐๐ฌ๐ฏโ๐ฃ๐ฝ, ยท๐๐ฆ๐ค! ๐ ๐ฅ๐ญ๐๐๐ผ ๐๐ง๐ ๐ฟ๐ผ ๐ ๐๐ด ๐๐ฌ๐ฏ ๐ ๐๐ฆ๐ฅ๐ฏ๐ฆ!ยป