Beispiel #1
0
def test_complexity_garble():
    """

    :return:
    """
    word = generate_word()
    print(word, c.complexity(word))
def entropy_pronounceable_word_all_lower(number_of_words=6):
    """

    :param number_of_words:
    :return:
    number_of_words=4: Worst: 53.7048, 53.7048, 58.4053; Best: 91.3084, 91.3084, 96.0088
    number_of_words=6: Worst: 81.9075, 86.6079, 91.3084; Best: 124.2114, 128.9119, 138.3128
    """
    password = ''.join([generate_word() for _ in range(number_of_words)])
    return entropy.log_entropy(password)
Beispiel #3
0
def generatePronounceableWord(forbid_list, depth=0, just_gen = False):
  gen_word = PronounceableWord().length(3, 24)
  if just_gen:
    gen_word = generate_word()
  if None != forbid_list:
    if gen_word in forbid_list:
      if depth > 4:
        print(depth)
      gen_word = generatePronounceableWord(forbid_list, depth+1)
  return gen_word
def complexity_pronounceable_word_all_lower(number_of_words=6):
    """

    :param number_of_words:
    :return:
    number_of_words=4: Best: 2.16, 2.67, 3.08; Worst: 4.31, 4.51, 4.72
    number_of_words=6: Best: 3.56, 3.58, 3.69; Worst: 5.33, 5.33, 5.74
    """
    password = ''.join([generate_word() for _ in range(number_of_words)])
    return complexity.complexity(password)
Beispiel #5
0
    def sample(cls,
               r_intrans=(2, 6),
               r_trans=(2, 6),
               r_adverb=(2, 6),
               r_noun=(2, 6),
               r_adjective=(2, 6)):
        n_intrans = np.random.randint(*r_intrans)
        n_trans = np.random.randint(*r_trans)
        n_adverb = np.random.randint(*r_adverb)
        n_noun = np.random.randint(*r_noun)
        n_adjective = np.random.randint(*r_adjective)

        intrans = [pronounceable.generate_word() for _ in range(n_intrans)]
        trans = [pronounceable.generate_word() for _ in range(n_trans)]
        adverb = [pronounceable.generate_word() for _ in range(n_adverb)]
        noun = [(pronounceable.generate_word(), rand_weights())
                for _ in range(n_noun)]
        adjective = [(pronounceable.generate_word(), rand_weights())
                     for _ in range(n_adjective)]
        return Vocab(intrans, trans, adverb, noun, adjective)
Beispiel #6
0
 def sample(cls,
            num_intransitive=1,
            num_transitive=1,
            num_adverbs=6,
            num_nouns=3,
            num_color_adjectives=3,
            num_size_adjectives=2):
     """
     Sample random nonce-words and initialize the vocabulary with these.
     """
     # Generate random nonce-words
     intransitive_verbs = [
         pronounceable.generate_word() for _ in range(num_intransitive)
     ]
     transitive_verbs = [
         pronounceable.generate_word() for _ in range(num_transitive)
     ]
     adverbs = [pronounceable.generate_word() for _ in range(num_adverbs)]
     nouns = [pronounceable.generate_word() for _ in range(num_nouns)]
     color_adjectives = [
         pronounceable.generate_word() for _ in range(num_color_adjectives)
     ]
     size_adjectives = [
         pronounceable.generate_word() for _ in range(num_size_adjectives)
     ]
     intransitive_verbs = cls.bind_words_to_meanings(
         intransitive_verbs, cls.INTRANSITIVE_VERBS.copy())
     transitive_verbs = cls.bind_words_to_meanings(
         transitive_verbs, cls.TRANSITIVE_VERBS.copy())
     nouns = cls.bind_words_to_meanings(nouns, cls.NOUNS.copy())
     color_adjectives = cls.bind_words_to_meanings(
         color_adjectives, cls.COLOR_ADJECTIVES.copy())
     size_adjectives = cls.bind_words_to_meanings(
         size_adjectives, cls.SIZE_ADJECTIVES.copy())
     adverbs = cls.bind_words_to_meanings(adverbs, cls.ADVERBS.copy())
     return cls(intransitive_verbs, transitive_verbs, adverbs, nouns,
                color_adjectives, size_adjectives)