Find all the 2 and 3-letter acronyms in the manuscript and return as a sorted list of tuples
175200
def get_acronyms(manuscript=os.path.expanduser('~/code/nlpia/lane/manuscript')):
    
    acronyms = []
    for f, lines in get_lines(manuscript):
        for line in lines:
            matches = CRE_ACRONYM.finditer(line)
            if matches:
                for m in matches:
                    if m.group('a2'):
                        acronyms.append((m.group('a2'), m.group('s2')))
                    elif m.group('a3'):
                        acronyms.append((m.group('a3'), m.group('s3')))
                    elif m.group('a4'):
                        acronyms.append((m.group('a4'), m.group('s4')))
                    elif m.group('a5'):
                        acronyms.append((m.group('a5'), m.group('s5')))

    return sorted(dict(acronyms).items())
449675
def classnameify(s):
  
  return ''.join(w if w in ACRONYMS else w.title() for w in s.split('_'))
405588
def getInstNamesByIndex(self, *indices):
        """"""
        instNames = []
        for columnName in self._vars.keys():
            instNames.append(
                self.getInstNameByIndex(*(columnName[-1],) + indices)
            )

        return tuple(instNames)
253718
def get_branches(aliases):
    """"""

    ignore = ['pow', 'log10', 'sqrt', 'max']
    branches = []
    for k, v in aliases.items():

        tokens = re.sub('[\(\)\+\*\/\,\=\<\>\&\!\-\|]', ' ', v).split()

        for t in tokens:

            if bool(re.search(r'^\d', t)) or len(t) <= 3:
                continue

            if bool(re.search(r'[a-zA-Z]', t)) and t not in ignore:
                branches += [t]

    return list(set(branches))
1245291
def _compute_oneletter(self):
        
        letters = []
        for i in range(self.width):
            downcase = None
            if self.bits[i] < 0.25:
                letters.append('.')
                continue
            if self.bits[i] < 1.0: downcase = 'True'
            tups = [(self.ll[i][x],x) for x in ACGT if self.ll[i][x] > 0.0]
            if not tups:  #Kludge if all values are negative (can this really happen?)
                tups = [(self.ll[i][x],x) for x in ACGT]
                tups.sort()
                tups.reverse()
                tups = [tups[0]]
                downcase = 'True'
            tups.sort()      #Rank by LL
            tups.reverse()
            bases = [x[1] for x in tups[0:2]]
            bases.sort()
            if len(bases) == 2: L = two2one[''.join(bases)]
            else:               L = bases[0]
            if downcase: L = L.lower()
            letters.append(L)
        self.oneletter = ''.join(letters)
8470
def find_tokens(self, string, **kwargs):
        
        # "The cat purs." => ["The cat purs ."]
        return find_tokens(string,
                punctuation = kwargs.get(  "punctuation", PUNCTUATION),
              abbreviations = kwargs.get("abbreviations", ABBREVIATIONS),
                    replace = kwargs.get(      "replace", replacements),
                  linebreak = r"\n{2,}")
1127451
def multi_keyword(tokens, keyword_parts):
    """"""
    tokens = iter(tokens)
    matched_tokens = []
    limit = len(keyword_parts)

    for idx in six.moves.range(limit):
        try:
            token = next(tokens)
        except StopIteration:
            return

        if (not token or token.name != "symbol" or
                token.value.lower() != keyword_parts[idx]):
            return

        matched_tokens.append(token)

    return TokenMatch(None, token.value, matched_tokens)
522389
def u(d):
    
    if six.PY2:
        if isinstance(d, six.binary_type):
            return d.decode("utf8", "ignore")
        elif isinstance(d, list):
            return [u(x) for x in d]
        elif isinstance(d, tuple):
            return tuple(u(x) for x in d)
        elif isinstance(d, dict):
            return dict( (u(k), u(v)) for k, v in six.iteritems(d))

    return d
213324
def minimal_raw_seqs(self):
        '''  '''
        seqs = [[], []]
        for letter in self.oneletter:
            if one2two.has_key(letter):
                seqs[0].append(one2two[letter][0])
                seqs[1].append(one2two[letter][1])
            else:
                seqs[0].append(letter)
                seqs[1].append(letter)
        if ''.join(seqs[0]) == ''.join(seqs[1]):
            return( [''.join(seqs[0])] )
        else:
            return( [''.join(seqs[0]), ''.join(seqs[0])] )
1277473
def find_prototypes(code):
    

    prots = []
    lines = code.split('\n')
    for line in lines:
        m = re.match("\s*" + re_func_prot, line)
        if m is not None:
            rtype, name, args = m.groups()[:3]
            if args == 'void' or args.strip() == '':
                args = []
            else:
                args = [tuple(arg.strip().split(' '))
                        for arg in args.split(',')]
            prots.append((name, args, rtype))

    return prots
727939
def contents_list_pairs(self):
        ''''''
        return (tuple(getattr(self.generator, name) for name in names)
                for names in self.info.get('contents_lists', []))
500811
def alphabet(cl):
    
    if not getattr(cl.model_admin, 'alphabet_filter', False):
        return
    field_name = cl.model_admin.alphabet_filter
    alpha_field = '%s__istartswith' % field_name
    alpha_lookup = cl.params.get(alpha_field, '')

    letters_used = _get_available_letters(field_name, cl.model.objects.all())
    all_letters = list(_get_default_letters(cl.model_admin) | letters_used)
    all_letters.sort()

    choices = [{
        'link': cl.get_query_string({alpha_field: letter}),
        'title': letter,
        'active': letter == alpha_lookup,
        'has_entries': letter in letters_used, } for letter in all_letters]
    all_letters = [{
        'link': cl.get_query_string(None, [alpha_field]),
        'title': _('All'),
        'active': '' == alpha_lookup,
        'has_entries': True
    }, ]
    return {'choices': all_letters + choices}
1329036
def get_texts_and_labels(sentence_chunk):
    """"""
    words = sentence_chunk.split('\n')
    texts = []
    labels = []
    for word in words:
        word = word.strip()
        if len(word) > 0:
            toks = word.split('\t')
            texts.append(toks[0].strip())
            labels.append(toks[-1].strip())
    return texts, labels
65286
def findClosestPronunciation(inputIsleWordList, aPron):
    '''
    
    '''
    
    retList = _findBestPronunciation(inputIsleWordList, aPron)
    isleWordList = retList[0]
    bestIndex = retList[3]
    
    return isleWordList[bestIndex]
816607
def get_doc_entries(target: typing.Callable) -> list:
    

    raw = get_docstring(target)

    if not raw:
        return []

    raw_lines = [
        line.strip()
        for line in raw.replace('\r', '').split('\n')
    ]

    def compactify(compacted: list, entry: str) -> list:
        chars = entry.strip()

        if not chars:
            return compacted

        if len(compacted) < 1 or chars.startswith(':'):
            compacted.append(entry.rstrip())
        else:
            compacted[-1] = '{}\n{}'.format(compacted[-1], entry.rstrip())

        return compacted

    return [
        textwrap.dedent(block).strip()
        for block in functools.reduce(compactify, raw_lines, [])
    ]
610355
def getPageFontList(self, pno):
        
        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")
        if self.isPDF:
            return self._getPageInfo(pno, 1)
        return []
1285932
def __extract_lemmas(self, doc, m, phrase):
        

        ph_start = m['start']
        ph_end = m['end']
        start_index = None
        for ind, word in enumerate(doc['words']):
            if word['start'] == ph_start:
                start_index = ind
                break
        end_index = None
        for ind, word in enumerate(doc['words']):
            if word['end'] == ph_end:
                end_index = ind
                break
        if start_index is not None and end_index is not None:
            
            lem = []
                
            for i in doc['words'][start_index:end_index + 1]:
                word_lem = []
                for idx, j in enumerate(i['analysis']):
                    if i['analysis'][idx]['partofspeech'] in ['A', 'D', 'C', 'J']:
                        if i['analysis'][idx]['lemma'] not in word_lem:
                            word_lem.append(i['analysis'][idx]['lemma'])
                word_lem_str = '|'.join(word_lem)          
                lem.append(word_lem_str)

        else:
            raise Exception('Something went really wrong')
        return lem