123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #! /usr/bin/python
- ## This script extracts requested scores from evalb file for every sentence.
- ##
- ## Current version: 1.1
- ##
- ## Changes:
- ## version 1.1:
- ## - The main part of the code was separated out into evalproc.py module
- ## to be reused elsewhere.
- ##
- import evalbproc
- import sys, optparse
- ##======================================================================
- ## main
- def main(argv=None):
- if argv is None:
- argv = sys.argv
-
- parser = optparse.OptionParser(usage="%prog <EVALB FILE> [options]" +
- "\nExtracts requested scores from evalb file for every sentence.", version="%prog 1.0")
- parser.add_option("-a", "--all", help="extract all columns", dest="extAll", action="store_true")
- parser.add_option("-n", help="include sentence number in the output", dest="extSentenceNo", action="store_true")
- parser.add_option("-p", "--precision", help="extract precision", dest="extPrecision", action="store_true")
- parser.add_option("-r", "--recall", help="extract recall", dest="extRecall", action="store_true")
- parser.add_option("-f", "--fscore", help="extract (colculate) f-score", dest="extFScore", action="store_true")
- (opts, posArgs) = parser.parse_args()
-
- if len(posArgs) < 1:
- parser.error("At least 1 argument is required")
-
- # processing options
- if opts.extAll:
- opts.extSentenceNo = True
- opts.extPrecision = True
- opts.extRecall = True
- opts.extFScore = True
-
- ## calling the extractor
- ## The last parameter makes the function to print the output into
- ## stdout. So, the return value of the function is not needed here.
- evalbproc.extractSentenceScores(posArgs[0], opts.extSentenceNo, opts.extPrecision, opts.extRecall, opts.extFScore)
-
- ##======================================================================
- ## calling main
- if __name__ == "__main__":
- sys.exit(main())
|