import sys
from shoebox.interlineartext import InterlinearTextParser

def usage() :
    sys.stderr.write("%s <FILE>\n" % sys.argv[0])
    sys.exit(0)

def tally(txt) :
    totalParagraphs = 0
    totalLines = 0
    print "Par.\tLine"
    for p in txt.getParagraphs() :
        totalParagraphs = totalParagraphs + 1
        numberLines = len(p.getLines())
        totalLines = totalLines + numberLines
        print "%i\t%i" % (totalParagraphs, numberLines)
    print "---\t---"
    print "%i\t%i" % (totalParagraphs, totalLines)
    
def main() :
    filepath = None
    try :
        filepath = sys.argv[1]
    except :
        usage()
    itp = InterlinearTextParser(filepath)
    txt = itp.parse()
    tally(txt)
    
main()

