Пример #1
0
        typoGiven = False
        for k, v in p.items():
            if k not in safeKeys and type(v) == type(""):
                if rd.random() < typoProbability:
                    typoGiven = True
                    idxs = set()
                    numTypos = rd.randint(1, min(2, len(v)))
                    totNumTypos += numTypos

                    while len(idxs) < numTypos:
                        idxs.add(rd.randint(0, len(v) - 1))

                    # print(p[k],'-->',end=' ')
                    newVal = list(p[k])
                    for i in idxs:
                        newVal[i] = K.getTypo(newVal[i])

                    p[k] = "".join(newVal)
                    # print(p[k])

        if typoGiven:
            numPeopleWithTypos += 1

        writer.writerow(p)

toc = time.process_time()

print()
print("Total number of persons: {}".format(totYield))
print("Total number of persons with typos: {}".format(numPeopleWithTypos))
print("Total number of typos: {}".format(totNumTypos))