示例#1
0
            for i in range(cnt):
                newskel += "_?" + subst
        comp = {newskel: 1}
        skels = [newskel]
        subst = {}
    uniq = len(skels)
    wurcsseq = "WURCS=2.0/%s,%s,%s/" % (uniq, total, "0+")
    wurcsseq += "".join(map(lambda sk: "[%s]" % (sk, ), skels)) + "/"
    inds = []
    for i, sk in enumerate(skels):
        inds.extend([str(i + 1)] * comp[sk])
    wurcsseq += "-".join(inds)
    wurcsseq += "/"
    wurcsseq = gtc.fixcompwurcs(wurcsseq, subst)
    thehash = hashlib.sha256(wurcsseq).hexdigest().lower()
    hash, acc, error = gtc.gethashedseq(seq=wurcsseq)
    if not hash:
        hash = gtc.register(wurcsseq)
        if hash:
            print lineno + 1, l0, hash
        else:
            print lineno + 1, l0, None, wurcsseq, thehash
        time.sleep(60)
    elif not acc:
        if error:
            print lineno + 1, l0, repr(error)
        else:
            print lineno + 1, l0, hash
    else:
        print lineno + 1, l0, acc
示例#2
0
        if wurcsorder.get(skel) < 0:
            subst[skel] = cnt
        else:
            comp[skel] = cnt
    if badsym:
        print lineno + 1, "Bad symbol!"
        continue
    skels = sorted(comp, key=wurcsorder.get)
    total = sum(comp.values())
    if total == 0:
        continue
    uniq = len(skels)
    wurcsseq = "WURCS=2.0/%s,%s,%s/" % (uniq, total, "0+")
    wurcsseq += "".join(map(lambda sk: "[%s]" % (sk, ), skels)) + "/"
    inds = []
    for i, sk in enumerate(skels):
        inds.extend([str(i + 1)] * comp[sk])
    wurcsseq += "-".join(inds)
    wurcsseq += "/"
    wurcsseq = gtc.fixcompwurcs(wurcsseq, subst)
    thehash = hashlib.sha256(wurcsseq).hexdigest().lower()
    hash, acc = gtc.gethashedseq(seq=wurcsseq)
    if not hash:
        gtc.register(wurcsseq)
        print lineno + 1, l, None, wurcsseq, thehash
        time.sleep(60)
    elif not acc:
        print lineno + 1, l, hash
    else:
        print lineno + 1, l, acc