Commits

Anonymous committed b31c537

[svn] Renamed and better documented the script to dump rater responses. It now gives
a sensible usage message.

Comments (0)

Files changed (2)

eval/dumpEvaluationData.py

-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#----------------------------------------------------------------------------#
-# dumpEvaluationData.py
-# Lars Yencken <lars.yencken@gmail.com>
-# vim: ts=4 sw=4 sts=4 et tw=78:
-# Fri Jan 19 16:51:43 JST 2007
-#
-#----------------------------------------------------------------------------#
-
-import os, sys, optparse
-
-from tools.common import sopen
-from eval import models
-
-#----------------------------------------------------------------------------#
-# PUBLIC
-#----------------------------------------------------------------------------#
- 
-def dumpEvaluationData(outputFile):
-    """ Dump the evaluation data to the given file.
-    """
-    kanaUsers = _getCompletedUsers('KanaUser')
-
-    kanaStream = sopen(outputFile + 'kana', 'w')
-    for user in kanaUsers:
-        print >> kanaStream, "USER %d" % user.id
-        for response in user.kanareadingresponse_set.all():
-            print >> kanaStream, '%s\t%s' % (
-                    response.kanaStimulus.word,
-                    response.response,
-                )
-    kanaStream.close()
-
-    pinyinUsers = _getCompletedUsers('PinyinUser')
-
-    pinyinStream = sopen(outputFile + 'pinyin', 'w')
-    for user in pinyinUsers:
-        print >> pinyinStream, "USER %d" % user.id
-        for response in user.pinyinreadingresponse_set.all():
-            print >> pinyinStream, '%s\t%s' % (
-                    response.pinyinStimulus.word,
-                    response.response,
-                )
-    pinyinStream.close()
-
-    return
-
-#----------------------------------------------------------------------------#
-# PRIVATE
-#----------------------------------------------------------------------------#
-
-def _getCompletedUsers(userTable):
-    """ 
-    """
-    finishedUsers = []
-    for user in getattr(models, userTable).objects.all():
-        if user.endTime is not None \
-            and not user.testing\
-            and not user.error:
-            finishedUsers.append(user)
-
-    return finishedUsers
-
-#----------------------------------------------------------------------------#
-# MODULE EPILOGUE
-#----------------------------------------------------------------------------#
-
-def _createOptionParser():
-    """ Creates an option parser instance to handle command-line options.
-    """
-    usage = \
-"""%prog [options] outputFile
-
-Default usage message."""
-
-    parser = optparse.OptionParser(usage)
-
-    parser.add_option('--debug', action='store_true', dest='debug',
-            default=False, help='Enables debugging mode [False]')
-
-    return parser
-
-#----------------------------------------------------------------------------#
-
-def main(argv):
-    """ The main method for this module.
-    """
-    parser = _createOptionParser()
-    (options, args) = parser.parse_args(argv)
-
-    try:
-        [outputFile] = args
-    except:
-        parser.print_help()
-        sys.exit(1)
-
-    # Avoid psyco in debugging mode, since it merges stack frames.
-    if not options.debug:
-        try:
-            import psyco
-            psyco.profile()
-        except:
-            pass
-
-    dumpEvaluationData(outputFile)
-    
-    return
-
-#----------------------------------------------------------------------------#
-
-if __name__ == '__main__':
-    main(sys.argv[1:])
-
-#----------------------------------------------------------------------------#
-  
-# vim: ts=4 sw=4 sts=4 et tw=78:
-

eval/dumpResponses.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#----------------------------------------------------------------------------#
+# dumpResponses.py
+# Lars Yencken <lars.yencken@gmail.com>
+# vim: ts=4 sw=4 sts=4 et tw=78:
+# Fri Jan 19 16:51:43 JST 2007
+#
+#----------------------------------------------------------------------------#
+
+import os, sys, optparse
+
+from tools.common import sopen
+from eval import models
+
+#----------------------------------------------------------------------------#
+# PUBLIC
+#----------------------------------------------------------------------------#
+ 
+def dumpEvaluationData(outputFile):
+    """ Dump the evaluation data to the given file.
+    """
+    kanaUsers = _getCompletedUsers('KanaUser')
+
+    kanaStream = sopen(outputFile + '_kana', 'w')
+    for user in kanaUsers:
+        print >> kanaStream, "USER %d" % user.id
+        for response in user.kanareadingresponse_set.all():
+            print >> kanaStream, '%s\t%s' % (
+                    response.kanaStimulus.word,
+                    response.response,
+                )
+    kanaStream.close()
+
+    pinyinUsers = _getCompletedUsers('PinyinUser')
+
+    pinyinStream = sopen(outputFile + '_pinyin', 'w')
+    for user in pinyinUsers:
+        print >> pinyinStream, "USER %d" % user.id
+        for response in user.pinyinreadingresponse_set.all():
+            print >> pinyinStream, '%s\t%s' % (
+                    response.pinyinStimulus.word,
+                    response.response,
+                )
+    pinyinStream.close()
+
+    return
+
+#----------------------------------------------------------------------------#
+# PRIVATE
+#----------------------------------------------------------------------------#
+
+def _getCompletedUsers(userTable):
+    """ 
+    """
+    finishedUsers = []
+    for user in getattr(models, userTable).objects.all():
+        if user.endTime is not None \
+            and not user.testing\
+            and not user.error:
+            finishedUsers.append(user)
+
+    return finishedUsers
+
+#----------------------------------------------------------------------------#
+# MODULE EPILOGUE
+#----------------------------------------------------------------------------#
+
+def _createOptionParser():
+    """ Creates an option parser instance to handle command-line options.
+    """
+    usage = \
+"""%prog [options] outputPrefix
+
+Writes the evaluation responses for each participant to the given output file
+in a human-readable format. The pinyin and kana responses will be put in
+files named (outputPrefix)_pinyin and (outputPrefix)_kana respectively."""
+
+    parser = optparse.OptionParser(usage)
+
+    parser.add_option('--debug', action='store_true', dest='debug',
+            default=False, help='Enables debugging mode [False]')
+
+    return parser
+
+#----------------------------------------------------------------------------#
+
+def main(argv):
+    """ The main method for this module.
+    """
+    parser = _createOptionParser()
+    (options, args) = parser.parse_args(argv)
+
+    try:
+        [outputFile] = args
+    except:
+        parser.print_help()
+        sys.exit(1)
+
+    # Avoid psyco in debugging mode, since it merges stack frames.
+    if not options.debug:
+        try:
+            import psyco
+            psyco.profile()
+        except:
+            pass
+
+    dumpEvaluationData(outputFile)
+    
+    return
+
+#----------------------------------------------------------------------------#
+
+if __name__ == '__main__':
+    main(sys.argv[1:])
+
+#----------------------------------------------------------------------------#
+  
+# vim: ts=4 sw=4 sts=4 et tw=78:
+