Example #1
0
def measure(gdt,x,y):
 if synch[y][0].split('.')[0]!=x.split('.')[0]:
  z=synch[y][0]
 else:
  z=synch[y][1]
 nm,sm = mismatches.mismatches(gdt,'bgf/'+x+'.bgf','bgf/'+z+'.bgf')
 return nm+sm,str(nm)+'\t'+str(sm)+'\t'+str(nm+sm)
Example #2
0
def measure(gdt, x, y):
    if synch[y][0].split('.')[0] != x.split('.')[0]:
        z = synch[y][0]
    else:
        z = synch[y][1]
    nm, sm = mismatches.mismatches(gdt, 'bgf/' + x + '.bgf',
                                   'bgf/' + z + '.bgf')
    return nm + sm, str(nm) + '\t' + str(sm) + '\t' + str(nm + sm)
Example #3
0
def main(xbgfFile, bgfFile, xbgf, gdt, synch):
    xbgfDir = '/'.join(xbgfFile.split('/')[:-1])
    if xbgfDir == '':
        xbgfDir = './'
    elif xbgfDir[-1] != '/':
        xbgfDir += '/'
    print 'Slicing...'
    sliced = slicing.sliceFile(xbgfDir, xbgfDir,
                               xbgfFile.split('/')[-1].replace('.xbgf', ''))
    print 'Runnning...'
    pnm, psm = mismatches.mismatches(gdt, bgfFile, synch)
    print 'Mismatches originally:', pnm, '+', psm, '...', len(
        sliced), 'steps to go'
    cx = ''
    for p in sliced:
        run = xbgf + ' ' + xbgfDir + p + '.xbgf ' + bgfFile + cx + ' ' + bgfFile + cx + '_ | grep "XBGF"'  #1> /dev/null 2> /dev/null'
        if os.system(run):
            print 'Error running', p, '!'
            print run
            sys.exit(2)
        nm, sm = mismatches.mismatches(gdt, bgfFile + cx + '_', synch)
        print 'Mismatches:', nm, '+', sm
        if nm > pnm:
            print 'Observed increase in name mismatches!'
        if sm > psm:
            print 'Observed increase in structural mismatches!'
        if nm + sm > pnm + psm:
            print 'The number of mismatches went up from', pnm + psm, 'to', nm + sm
            sys.exit(3)
        cx += '_'
        pnm, psm = nm, sm
    print 'Cleaning up...'
    s = 'rm -f '
    for c in range(1, len(cx)):
        s += bgfFile + '_' * c + ' '
    print s
    s = 'rm -f '
    for c in sliced:
        s += xbgfDir + c + '.xbgf '
    if os.system(s):
        print 'Error cleaning up sliced XBGFs!'
    return
Example #4
0
def main(xbgfFile,bgfFile,xbgf,gdt,synch):
 xbgfDir = '/'.join(xbgfFile.split('/')[:-1])
 if xbgfDir == '':
  xbgfDir = './'
 elif xbgfDir[-1]!='/':
  xbgfDir += '/'
 print 'Slicing...'
 sliced = slicing.sliceFile(xbgfDir,xbgfDir,xbgfFile.split('/')[-1].replace('.xbgf',''))
 print 'Runnning...'
 pnm,psm = mismatches.mismatches(gdt,bgfFile,synch)
 print 'Mismatches originally:',pnm,'+',psm,'...',len(sliced),'steps to go'
 cx = ''
 for p in sliced:
  run = xbgf+' '+xbgfDir+p+'.xbgf '+bgfFile+cx+' '+bgfFile+cx+'_ | grep "XBGF"'#1> /dev/null 2> /dev/null'
  if os.system(run):
   print 'Error running',p,'!'
   print run
   sys.exit(2)
  nm,sm = mismatches.mismatches(gdt,bgfFile+cx+'_',synch)
  print 'Mismatches:',nm,'+',sm
  if nm>pnm:
   print 'Observed increase in name mismatches!'
  if sm>psm:
   print 'Observed increase in structural mismatches!'
  if nm+sm>pnm+psm:
   print 'The number of mismatches went up from',pnm+psm,'to',nm+sm
   sys.exit(3)
  cx += '_'
  pnm,psm=nm,sm
 print 'Cleaning up...'
 s = 'rm -f '
 for c in range(1,len(cx)):
  s += bgfFile+'_'*c+' '
 print s
 s = 'rm -f '
 for c in sliced:
  s += xbgfDir+c+'.xbgf '
 if os.system(s):
  print 'Error cleaning up sliced XBGFs!'
 return
Example #5
0
#!/usr/bin/python
# wiki: Grammar Diff Tool
import os
import sys
import string
import mismatches

if __name__ == "__main__":
    if len(sys.argv) == 4:
        pnm, psm = mismatches.mismatches(sys.argv[3], sys.argv[1], sys.argv[2])
        print 'Mismatches:', pnm, '+', psm, '=', pnm + psm
    else:
        print '''This is the shortest possible version of Grammar Diff Tool.

Usage:'''
        print ' ', sys.argv[0], '<bgf1>', '<bgf2>', '<comparator>'
        sys.exit(1)
Example #6
0
#!/usr/bin/python
# wiki: Grammar Diff Tool
import os
import sys
import string
import mismatches

if __name__ == "__main__":
 if len(sys.argv) == 4:
  pnm,psm = mismatches.mismatches(sys.argv[3],sys.argv[1],sys.argv[2])
  print 'Mismatches:',pnm,'+',psm,'=',pnm+psm
 else:
  print '''This is the shortest possible version of Grammar Diff Tool.

Usage:'''
  print ' ',sys.argv[0],'<bgf1>','<bgf2>','<comparator>'
  sys.exit(1)