def get_pronunciation_he(phrase, text): sections = scraper.parse_text_for_sections(text) for k, v in sections.iteritems(): if k in phrase['txs'].keys(): m = re.search(r'\|tr=(.*?)\}\}', v[0]) if m and re.search(r'\|', m.group(1)): m = None if not m: m = re.search(r'\|tr=(.*?)\|', v[0]) if m: pron = m.group(1) pron = pron.replace(u'í', u'í') return {'pron': pron}
def process_text(base, text): # Extract sections from the text sections = scraper.parse_text_for_sections(text) # Initialize a document to insert txs = {} for k in sections: if k in valid_section_keys: translations = get_translations(sections[k]) if translations != []: txs[k] = translations rank = rank_map[base] if txs != {} and rank is not None: return txs