You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
577 B

  1. import re
  2. import string
  3. def get_key_choices():
  4. selectKey, shortKey = [c for c in string.ascii_lowercase], [c for c in string.ascii_lowercase]
  5. checkKey = 'ctrl shift'
  6. shortKey += [ck + ' ' + sk for ck in checkKey.split() for sk in selectKey]
  7. shortKey += [checkKey + ' ' + sk for sk in selectKey]
  8. shortKey += ['']
  9. KEY_CHOICES = ((u, c) for u, c in zip(shortKey, shortKey))
  10. return KEY_CHOICES
  11. def extract_label(tag):
  12. ptn = re.compile(r'(B|I|E|S)-(.+)')
  13. m = ptn.match(tag)
  14. if m:
  15. return m.groups()[1]
  16. else:
  17. return tag