Example #1
0
 def get_edge_df_text(infr, edges=None, highlight=True):
     df = infr.get_edge_dataframe(edges)
     df_str = df.to_string()
     if highlight:
         df_str = ut.highlight_regex(df_str, ut.regex_word(SAME), color='blue')
         df_str = ut.highlight_regex(df_str, ut.regex_word(POSTV), color='blue')
         df_str = ut.highlight_regex(df_str, ut.regex_word(DIFF), color='red')
         df_str = ut.highlight_regex(df_str, ut.regex_word(NEGTV), color='red')
         df_str = ut.highlight_regex(df_str, ut.regex_word(INCMP), color='yellow')
     return df_str
Example #2
0
 def print_df(df, lbl):
     df_str = df.to_string()
     df_str = ut.highlight_regex(df_str, ut.regex_word(str(aid1)), color='blue')
     df_str = ut.highlight_regex(df_str, ut.regex_word(str(aid2)), color='red')
     if nid1 not in {aid1, aid2}:
         df_str = ut.highlight_regex(df_str, ut.regex_word(str(nid1)), color='darkblue')
     if nid2 not in {aid1, aid2}:
         df_str = ut.highlight_regex(df_str, ut.regex_word(str(nid2)), color='darkred')
     print('\n\n=====')
     print(lbl)
     print('=====')
     print(df_str)
Example #3
0
def fix_section_common_errors(tex_fpath, dryrun=True):
    # Read in text and ensure ascii format
    text = ut.read_from(tex_fpath)

    new_text = text
    # Fix all capitals
    search_repl_list = constants_tex_fixes.CAPITAL_LIST
    for repl in search_repl_list:
        pattern = ut.regex_word(re.escape(repl))
        new_text = re.sub(pattern, repl, new_text, flags=re.IGNORECASE)
    #new_text = re.sub(pattern, fix_capitalization, text, flags=re.MULTILINE)

    if not dryrun:
        ut.write_to(tex_fpath, new_text)
    else:
        ut.print_difftext(ut.get_textdiff(text, new_text, 0))