def create_word(
    seed: int,
    word: str,
    lemma: str,
    tag: str,
    candidates: Sequence[Mapping[str, str]],
) -> Tuple[str, str, str]:
  """Samples a new (word, lemma, root) tuple within a log likelihood bucket."""
  morphology = random.Random(seed).choice(candidates)
  root = morphology[ROOT]
  if tag == 'VBP':
    return morphology['VB'], morphology['VB'], root
  if tag.startswith('V'):
    return morphology[tag], morphology['VB'], root
  if tag.startswith('N'):
    return morphology[tag], morphology['NN'], root
  adj = morphology['JJ']
  if tag in ('JJ', 'RB'):
    return adj, adj, root
  if tag in ('JJR', 'RBR'):
    if len(adj) > 6 or random.Random(f'{adj}:{seed}').random() < 0.25:
      return f'more {adj}', adj, root
    return _make_comparative(adj), adj, root
  raise ValueError(f'Cannot resolve {tag} for word {word}/{lemma}.')
Samples a new (word, lemma, root) tuple within a log likelihood bucket.
language/wino_dict/utils.py