-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20eac67
commit f5f8f28
Showing
6 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# This Python file uses the following encoding: utf-8 | ||
import sys, re | ||
import codecs | ||
import string | ||
import datetime | ||
from lxml import etree | ||
""" | ||
Dr. Dhaval Patel | ||
26 Jan 2016 | ||
Usage: | ||
python comparwithdb.py | ||
""" | ||
# Function to return timestamp | ||
def timestamp(): | ||
return datetime.datetime.now() | ||
|
||
def triming(lst): | ||
output = [] | ||
for member in lst: | ||
member = member.strip() | ||
output.append(member) | ||
return output | ||
|
||
def compare(inputfile,outputfile): | ||
fout = codecs.open(outputfile,'w','utf-8') | ||
tree = etree.parse(inputfile) | ||
entries = tree.xpath('/forms/f') | ||
verbdetails = [(member.get('form'),member.getchildren()[-2].tag,member.getchildren()[-1].tag,member.find('root').get('name'),member.find('root').get('num')) for member in entries] | ||
verbforms = [a for (a,b,c,d,e) in verbdetails] | ||
amba = open('Data/verbforms_amba.txt').read() | ||
ambaverbforms = amba.split(',') | ||
ambaverbforms = triming(ambaverbforms) | ||
gerard = open('Data/verbforms_gerard.txt').read() | ||
gerardverbforms = gerard.split(',') | ||
gerardverbforms = triming(gerardverbforms) | ||
baseverbforms = ambaverbforms+gerardverbforms | ||
baseverbforms = list(set(baseverbforms)) | ||
print 'Input file has', len(verbforms), 'entries' | ||
print 'Base data has', len(baseverbforms), 'entries' | ||
for (a,b,c,d,e) in verbdetails: | ||
if not a in baseverbforms: | ||
print a,b,c,d,e | ||
fout.write(a+':'+b+':'+c+':'+d+':'+e+'\n') | ||
fout.close() | ||
|
||
compare('generatedforms.xml','suspectforms/latest.txt') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters