Skip to content

CJK Character Descriptions and Definitions #635

@nvaccessAuto

Description

@nvaccessAuto

Reported by m11chen on 2010-04-27 08:09
Specific to the Chinese language (possibly also Japanese and Korean), allows for the review previous/current/next character script to initiate a query of a database containing definitions and nouns constructed from the character. This is important to blind users of the Chinese language in order to distinguish different characters with the same pronunciation.

I have made a very crude implementation of this functionality in the default.py appModule by tagging the character with five "" characters and then defining the correspondingly desired speech information in the builtin.dic speech dictionary.

Here are the changes I made to the review previous/current/next character scripts. Note that I also defined a "chtNounConstruct" variable in the config file for toggling on/off the functionality. The appended builtin.dic is a bit large, so I did not include it here.

def script_review_previousCharacter(self,keyPress):
    lineInfo=api.getReviewPosition().copy()
    lineInfo.expand(textInfos.UNIT_LINE)
    charInfo=api.getReviewPosition().copy()
    charInfo.expand(textInfos.UNIT_CHARACTER)
    charInfo.collapse()
    res=charInfo.move(textInfos.UNIT_CHARACTER,-1)
    if res==0 or charInfo.compareEndPoints(lineInfo,"startToStart")<0:
        speech.speakMessage(_("left"))
        reviewInfo=api.getReviewPosition().copy()
        reviewInfo.expand(textInfos.UNIT_CHARACTER)
        if config.conf[= reviewInfo._get_text()
            speech.speakMessage(_(c + "_____"))
        else:
            speech.speakTextInfo(reviewInfo,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET)
    else:
        api.setReviewPosition(charInfo.copy())
        charInfo.expand(textInfos.UNIT_CHARACTER)
        if config.conf["speech"]("speech"]["chtNounConstruct"]:
            c)[= charInfo._get_text()
            speech.speakMessage(_(c + "_____"))
        else:
            speech.speakTextInfo(charInfo,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET)
script_review_previousCharacter.__doc__=_("Moves the review cursor to the previous character of the current navigator object and speaks it")

def script_review_currentCharacter(self,keyPress):
    info=api.getReviewPosition().copy()
    info.expand(textInfos.UNIT_CHARACTER)
    if scriptHandler.getLastScriptRepeatCount()==0:
        if config.conf["speech"]("chtNounConstruct"]:
            c)[= info._get_text()
            speech.speakMessage(_(c + "_____"))
        else:
            speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET)
    elif scriptHandler.getLastScriptRepeatCount()==1:
        if config.conf["speech"]("chtNounConstruct"]:
            c)[= info._get_text()
            speech.speakMessage(_(c + "_____"))
    else:
        try:
            c = ord(info._get_text())
            speech.speakMessage("%d," % c)
            speech.speakSpelling(hex(c))
        except:
            speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET)
script_review_currentCharacter.__doc__=_("Reports the character at the current review cursor pressed twice will toggle on and off between phonetic spelling of alphabet or Chinese noun construct functionality pressed three times will report decimal and hexadecimal representation of the character encoding")

def script_review_nextCharacter(self,keyPress):
    lineInfo=api.getReviewPosition().copy()
    lineInfo.expand(textInfos.UNIT_LINE)
    charInfo=api.getReviewPosition().copy()
    charInfo.expand(textInfos.UNIT_CHARACTER)
    charInfo.collapse()
    res=charInfo.move(textInfos.UNIT_CHARACTER,1)
    if res==0 or charInfo.compareEndPoints(lineInfo,"endToEnd")>=0:
        speech.speakMessage(_("right"))
        reviewInfo=api.getReviewPosition().copy()
        reviewInfo.expand(textInfos.UNIT_CHARACTER)
        if config.conf["speech"]("chtNounConstruct"]:
            config.conf["speech"]["chtNounConstruct"]=False
            speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET)
        else:
            config.conf["speech"]["chtNounConstruct"]=True
            c)[= reviewInfo._get_text()
            speech.speakMessage(_(c + "_____"))
        else:
            speech.speakTextInfo(reviewInfo,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET)
    else:
        api.setReviewPosition(charInfo.copy())
        charInfo.expand(textInfos.UNIT_CHARACTER)
        if config.conf["speech"]("chtNounConstruct"]:
            c)["chtNounConstruct"]:
            c = charInfo._get_text()
            speech.speakMessage(_(c + "_____"))
        else:
            speech.speakTextInfo(charInfo,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET)
script_review_nextCharacter.__doc__=_("Moves the review cursor to the next character of the current navigator object and speaks it")

Here are the 26 English alphabets and a few of the first chinese characters appended to the builtin.dic file for demonstration.

Phonetic spelling of alphabet

A_____ alpha 0 0
B_____ bravo 0 0
C_____ charlie 0 0
D_____ delta 0 0
E_____ echo 0 0
F_____ fox trot 0 0
G_____ golf 0 0
H_____ hotel 0 0
I_____ india 0 0
J_____ juliet 0 0
K_____ kilo 0 0
L_____ lima 0 0
M_____ mike 0 0
N_____ november 0 0
O_____ oscar 0 0
P_____ papa 0 0
Q_____ quebec 0 0
R_____ romeo 0 0
S_____ sierra 0 0
T_____ tango 0 0
U_____ uniform 0 0
V_____ victor 0 0
W_____ whiskey 0 0
X_____ x ray 0 0
Y_____ yankee 0 0
Z_____ zulu 0 0

Chinese character definition and noun construction

一_____ 一 數字 一言九鼎 一帆風順;第一名 百密一疏 百聞不如一見 0 0
乙_____ 乙 天干的第二位 乙等 乙醇 乙醚 乙等特考;太乙 聚乙烯 0 0
厂_____ 厂 山邊可以居住人的崖洞 0 0
匚_____ 匚 古代一種盛物的器具 0 0
刀_____ 刀 刀子 刀槍不入;菜刀 瑞士刀 0 0
乂_____ 乂 乂安 ; 俊乂 0 0
卜_____ 卜 卜卦 卜筮;占卜 求神問卜 賣卜測字 0 0
入_____ 入 入門 入迷 入埸券;進入 出入口 羊入虎口 0 0

I am not an expert programmer, so I am guessing this kind of crude implementation would not be on-par with what the NVDA Project expects from its contributers. If someone could reorganize the described functionality into something more acceptable, that would be great.

Thanks.

Blocked by #55

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions