Exemple #1
0
def yb4char(char, sentence, idx):
    yb = LD_Yun.get(char)
    if yb is None: return '@'
    if len(yb) > 1:
        print '“%s”中的第%d个字,“%s”字没有找到适当的解释'%(sentence, idx+1, char)
        chc = 1
        for k, v in yb.items():
            print '%d. %s(%s韵)'%(chc, '其它' if k[0]=='*' else k, v)
            chc += 1
        chc = int(raw_input('选择适意(1~%d):'%len(yb)))
        yun = yb.items()[chc-1][1]
    else:
        yun = yb.get('*')
    return yun
Exemple #2
0
def yb4char(char, sentence, idx):
    yb = LD_Yun.get(char)
    if yb is None:
        return "@"
    if len(yb) > 1:
        print "“%s”中的第%d个字,“%s”字没有找到适当的解释" % (sentence, idx + 1, char)
        chc = 1
        for k, v in yb.items():
            print "%d. %s(%s韵)" % (chc, "其它" if k[0] == "*" else k, v)
            chc += 1
        chc = int(raw_input("选择适意(1~%d):" % len(yb)))
        yun = yb.items()[chc - 1][1]
    else:
        yun = yb.get("*")
    return yun
Exemple #3
0
def pz4char(char, sentence, idx):
    yb = LD_Yun.get(char)
    if yb is None: return '@'
    if len(yb) > 1:
        print '“%s”中的第%d个字,‘%s’字没有找到适当的解释'%(sentence, idx+1, char)
        chc = 1
        for k, v in yb.items():
            print '%d. %s(%s韵)'%(chc, '其它' if k[0]=='*' else k, v)
            chc += 1
        chc = int(raw_input('选择适意(1~%d):'%len(yb)))
        yun = yb.items()[chc-1][1]
    else:
        yun = yb.get('*')
#     if yun is None: 
#     
#         exit(1)
    diao = LD_YunBu2YinDiao.get(yun)
    if diao is None: return '@'
    return '_' if diao[3:] == '平' else '*'
Exemple #4
0
def pz4char(char, sentence, idx):
    yb = LD_Yun.get(char)
    if yb is None:
        return "@"
    if len(yb) > 1:
        print "“%s”中的第%d个字,‘%s’字没有找到适当的解释" % (sentence, idx + 1, char)
        chc = 1
        for k, v in yb.items():
            print "%d. %s(%s韵)" % (chc, "其它" if k[0] == "*" else k, v)
            chc += 1
        chc = int(raw_input("选择适意(1~%d):" % len(yb)))
        yun = yb.items()[chc - 1][1]
    else:
        yun = yb.get("*")
    #     if yun is None:
    #
    #         exit(1)
    diao = LD_YunBu2YinDiao.get(yun)
    if diao is None:
        return "@"
    return "_" if diao[3:] == "平" else "*"
Exemple #5
0
    parser.add_argument('--cipai',
                        '-c',
                        default=None,
                        help='词牌名,新体诗也自作词牌,如“五绝”、“七律”等')
    parser.add_argument('--yun', '-y', default=None, help='提示汉字所属韵部')
    parser.add_argument('--yunbu', '-Y', default=None, help='查找韵部所属内容')
    args = parser.parse_args()

    if args.sourceCode != 'GBK':
        gbkContent = map(lambda x: x.decode(args.sourceCode).encode('GBK'),
                         args.content)
    else:
        gbkContent = args.content

    if args.yun is not None:
        yunb = LD_Yun.get(args.yun)
        if yunb:
            if len(yunb) == 1:
                yunb = yunb.items()[0][1]
                print '%s: %s\n\n%s' % (args.yun, yunb,
                                        LD_PingShuiYunBiao[yunb].replace(
                                            args.yun, '>\033[0;31m%s\033[m<' %
                                            args.yun).replace(':', '\n\n'))
            else:
                no = 1
                for k, v in yunb.items():
                    print '%d. %s: %s(%s韵)' % (no, args.yun,
                                               '原意' if k[0] == '*' else k, v)
                    no += 1
        else:
            print '平水韵表中不存在这个文字“%s”' % args.yun
Exemple #6
0
    ''')
    
    parser.add_argument('content', metavar='N', type=str, nargs='*', help='诗句的内容,每句以空格分隔')
    parser.add_argument('--sourceCode', '-s', default='GBK', help='输入文件的编码方式,默认为“GBK”')
    parser.add_argument('--cipai', '-c', default=None, help='词牌名,新体诗也自作词牌,如“五绝”、“七律”等')
    parser.add_argument('--yun', '-y', default=None, help='提示汉字所属韵部')
    parser.add_argument('--yunbu', '-Y', default=None, help='查找韵部所属内容')
    args = parser.parse_args()
    
    if args.sourceCode != 'GBK':
        gbkContent = map(lambda x:x.decode(args.sourceCode).encode('GBK'), args.content)
    else:
        gbkContent = args.content
    
    if args.yun is not None:
        yunb = LD_Yun.get(args.yun)
        if yunb:
            if len(yunb) == 1:
                yunb = yunb.items()[0][1]
                print '%s: %s\n\n%s'%(args.yun, yunb, LD_PingShuiYunBiao[yunb].replace(args.yun,'>\033[0;31m%s\033[m<'%args.yun).replace(':','\n\n'))
            else:
                no = 1
                for k,v in yunb.items():
                    print '%d. %s: %s(%s韵)'%(no, args.yun, '原意'if k[0]=='*'else k, v)
                    no += 1
        else:
            print '平水韵表中不存在这个文字“%s”'%args.yun

    if args.yunbu is not None:
        yunb = LD_PingShuiYunBiao.get(args.yunbu)
        if yunb: