<commit_before>#!/usr/bin/env python

import logging
# http://docs.python.org/howto/argparse.html
import argparse
import os
import datetime
import re

import sys
sys.path.append( '.' )
sys.path.append( './lib/' )
import shutil

from patXML import SQLPatent
from patXML import XMLPatent
from patXML import uniasc
from fwork  import *

# setup argparse
parser = argparse.ArgumentParser(description='Specify source directory/directories for xml files to be parsed')
parser.add_argument('--directory','-d', type=str, nargs='+', default='', help='comma separated list of directories relative to $PATENTROOT that parse.py will search for .xml files')
parser.add_argument('--patentroot','-p', type=str, nargs='?', default=os.environ['PATENTROOT'] if os.environ.has_key('PATENTROOT') else '/', help='root directory of all patent files/directories')
parser.add_argument('--xmlregex','-x', type=str, nargs='?', default=r"ipg\d{6}.xml", help='regex used to match xml files in each directory')

# parse arguments and assign values
args = parser.parse_args()
DIRECTORIES = args.directory
XMLREGEX = args.xmlregex
PATENTROOT = args.patentroot

#PATENTROOT = '/var/share/patentdata/patents/2007'
#logfile = PATENTROOT + "/" + 'xml-parsing.log'
logfile = "./" + 'xml-parsing.log'
logging.basicConfig(filename=logfile, level=logging.DEBUG)

t1 = datetime.datetime.now()

#get a listing of all files within the directory that follow the naming pattern
files = [directory+'/'+fi for directory in DIRECTORIES for fi in os.listdir(PATENTROOT+'/'+directory) if re.match(XMLREGEX, fi, re.I) != None]
#files = [x for x in os.listdir(PATENTROOT)
#         if re.match(XMLREGEX, x, re.I)!=None]
print "Total files: %d" % (len(files))
logging.info("Total files: %d" % (len(files)))

tables = ["assignee", "citation", "class", "inventor", "patent", "patdesc", "lawyer", "sciref", "usreldoc"]<commit_msg>cleaning up old comments in parse.py<commit_after>#!/usr/bin/env python

import logging
# http://docs.python.org/howto/argparse.html
import argparse
import os
import datetime
import re

import sys
sys.path.append( '.' )
sys.path.append( './lib/' )
import shutil

from patXML import SQLPatent
from patXML import XMLPatent
from patXML import uniasc
from fwork  import *

# setup argparse
parser = argparse.ArgumentParser(description='Specify source directory/directories for xml files to be parsed')
parser.add_argument('--directory','-d', type=str, nargs='+', default='', help='comma separated list of directories relative to $PATENTROOT that parse.py will search for .xml files')
parser.add_argument('--patentroot','-p', type=str, nargs='?', default=os.environ['PATENTROOT'] if os.environ.has_key('PATENTROOT') else '/', help='root directory of all patent files/directories')
parser.add_argument('--xmlregex','-x', type=str, nargs='?', default=r"ipg\d{6}.xml", help='regex used to match xml files in each directory')

# parse arguments and assign values
args = parser.parse_args()
DIRECTORIES = args.directory
XMLREGEX = args.xmlregex
PATENTROOT = args.patentroot

logfile = "./" + 'xml-parsing.log'
logging.basicConfig(filename=logfile, level=logging.DEBUG)

t1 = datetime.datetime.now()

#get a listing of all files within the directory that follow the naming pattern
files = [directory+'/'+fi for directory in DIRECTORIES for fi in os.listdir(PATENTROOT+'/'+directory) if re.match(XMLREGEX, fi, re.I) != None]
print "Total files: %d" % (len(files))
logging.info("Total files: %d" % (len(files)))

tables = ["assignee", "citation", "class", "inventor", "patent", "patdesc", "lawyer", "sciref", "usreldoc"]
{'fraction_non_alphanumeric': 0.14935790061418203, 'fraction_numerical': 0.002233389168062535, 'mean_word_length': 5.562271062271062, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 15}, '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}}
{'dir': 'git-commits-cleaned', 'id': '2901840', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1171, 'n_words': 337}