Skip to content

Commit

Permalink
table transposed
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@353 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Oct 16, 2008
1 parent f5fd624 commit dd5817a
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions topics/presentation/metrics/bgfover.py
Expand Up @@ -9,6 +9,7 @@
bottom = "count(/*/*[not(*//nonterminal)]/nonterminal[not(text()=../preceding-sibling::*/nonterminal/text())])"

names = []
tnames = []

bgfns = 'http://planet-sl.org/bgf'
ET._namespace_map[bgfns] = 'bgf'
Expand All @@ -20,17 +21,11 @@ def runxpath(filename,xpathexpr):
tmp.close()
return res

def fillinline(path,xexpr):
s = ''
for x in names:
s += '&'+runxpath(path+x+'.bgf',xexpr)
return s+'\\\\'

if __name__ == "__main__":
if len(sys.argv) != 3:
print 'This tool generates an overview of a bunch of BGF sources.'
print 'This tool generates an overview of a bunch of BGF sources and targets.'
print 'Usage:'
print ' xbgfover <lcf> <bgfs-path>'
print ' bgfover <lcf> <bgfs-path>'
sys.exit(1)
lcf = ET.parse(sys.argv[1])
for x in lcf.findall('/source'):
Expand All @@ -39,19 +34,18 @@ def fillinline(path,xexpr):
srclen = len(names)
for x in lcf.findall('/target'):
name = x.findtext('name')
names.append(name)
tnames.append(name)
path = sys.argv[2]
if path[-1]!='/':
path += '/'
print '\\begin{tabular}{l|'+('c|'*srclen)+'|'+('c|'*(len(names)-srclen))+'}'
print '\\begin{tabular}{l|c|c|c|c}'
print '&\\textbf{Total}&\\textbf{Total}&\\textbf{Top}&\\textbf{Bottom}\\\\'
print '&\\textbf{productions}&\\textbf{nonterminals}&\\textbf{nonterminals}&\\textbf{nonterminals}\\\\\\hline\\hline'
for x in names:
print '&\\textbf{'+x+'}'
print '\\\\\\hline'
print 'Total productions: ',fillinline(path,productions)
print 'Total nonterminals: ',fillinline(path,nonterminals)
print 'Top nonterminals: ',fillinline(path,top)
print 'Bottom nonterminals:',fillinline(path,bottom)
print '\\emph{'+x+'}&'+runxpath(path+x+'.bgf',productions)+'&'+runxpath(path+x+'.bgf',nonterminals)+'&'+runxpath(path+x+'.bgf',top)+'&'+runxpath(path+x+'.bgf',bottom)+'\\\\\\hline'
print '\\hline'
for x in tnames:
print '\\emph{'+x+'}&'+runxpath(path+x+'.bgf',productions)+'&'+runxpath(path+x+'.bgf',nonterminals)+'&'+runxpath(path+x+'.bgf',top)+'&'+runxpath(path+x+'.bgf',bottom)+'\\\\\\hline'
print '\\end{tabular}'
sys.exit(0)

0 comments on commit dd5817a

Please sign in to comment.