<jupyter_start><jupyter_text>RDF fixer converter example, Jupyter notebook version<jupyter_code>"""
Created on Sun Apr 18 20:00:00 2021
RDF converter & fixer
Version 2.2 (Apr 20 20:06:00 2021)

@author: <NAME> (DocMinus)

license: MIT License
Copyright (c) 2021 DocMinus
"""
import warnings

warnings.filterwarnings("ignore")
import os
import sys
import argparse
# uncommmet the # before !pip if you haven't installed yet. 
# For testing though not necessary if you run the test in local repository
#!pip install git+https://github.com/DocMinus/chem-rdf-fixer.git
from rdfmodule import rdf_fixer<jupyter_output><empty_output><jupyter_text>Here the files are loaded & converted.* RDF file or path to files as as input.* The corrected file as ends up as _\_fixed.RDF_ output.* As well as tabular _CSV_ output file.* The original file remains untouched* Now the function also returns a zipped list of all file names if desiredThe cmd line demo script is after V2 even more light-weight.Usage:`convert_example.py /home/user/my_rdf_file.rdf`or`convert_example.py /home/user/subdir/`<jupyter_code>def main():

    
    # using parser is a bit overkill in jupyter. But it helps for the command line "emulation" 
    parser = argparse.ArgumentParser()
    parser.add_argument("--input", type=str, help="RDF filename or path containing RDFs", default="")
    args = parser.parse_args('')
    config = vars(args)
    
    # Enter the file or filepath here:
    config["input"] = "./testfiles/reaxys_export.rdf"
    
    if config["input"] == "":
        print("You need to enter a RDF filename or a path with RDF files!")
        sys.exit(1)

    print("Initiating conversion...")
    rdf_fixer.fix(config["input"])
    print("And done.")
    
    print("\nAlternatively:")
    new_files = rdf_fixer.fix(config["input"])
    for file_in, file_ok, file_csv in new_files:
        print(file_in, "\n\t-> ", file_ok, "\n\t-> ", file_csv)   
    
    return None

if __name__ == "__main__":

    main()<jupyter_output>Initiating conversion...
Converting file:  ./testfiles/reaxys_export.rdf
And done.

Alternatively:
Converting file:  ./testfiles/reaxys_export.rdf
./testfiles/reaxys_export.rdf 
	->  ./testfiles/reaxys_export_fixed.rdf 
	->  ./testfiles/reaxys_export.csv
{'fraction_non_alphanumeric': 0.11120957022596367, 'fraction_numerical': 0.014178112538768276, 'mean_word_length': 3.9193899782135078, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '307243', 'license': 'MIT', 'n_tokens_mistral': 784, 'n_tokens_neox': 737, 'n_words': 226, 'path': 'convert_example.ipynb', 'repo_name': 'DocMinus/chem-rdf-fixer', 'size': '2268'}