summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-07-15 11:04:30 +0800
committerPeng Wu <alexepico@gmail.com>2011-07-15 11:04:30 +0800
commitcfb98a4a366374a15b706cb9ed40c7026551334c (patch)
tree02fabe699deae7f56f73f5209fe6d75588887c1c
parent173d474cec4eccaea016c7d44f71bf250de6323f (diff)
downloadtrainer-cfb98a4a366374a15b706cb9ed40c7026551334c.zip
trainer-cfb98a4a366374a15b706cb9ed40c7026551334c.tar.gz
trainer-cfb98a4a366374a15b706cb9ed40c7026551334c.tar.xz
write main for reduce.py
-rw-r--r--lib/myconfig.py4
-rwxr-xr-x[-rw-r--r--]reduce.py11
2 files changed, 11 insertions, 4 deletions
diff --git a/lib/myconfig.py b/lib/myconfig.py
index 29d7ae3..e1dc5b6 100644
--- a/lib/myconfig.py
+++ b/lib/myconfig.py
@@ -41,7 +41,7 @@ class MyConfig:
return m_trainer_dir + os.sep + 'finals'
#about 1,200 Chinese characters
- m_minimum_chinese_characters = 1,200
+ m_minimum_chinese_characters = 1200
m_minimum_file_size = m_minimum_chinese_characters * 3 + \
m_minimum_chinese_characters / 2
@@ -62,7 +62,7 @@ class MyConfig:
m_index_postfix = '.index'
def getIndexPostfix(self):
- return m_index_postfix
+ return self.m_index_postfix
m_text_postfix = '.text'
diff --git a/reduce.py b/reduce.py
index 1aa0f39..96ed368 100644..100755
--- a/reduce.py
+++ b/reduce.py
@@ -2,6 +2,7 @@
import os
import os.path
import sys
+from argparse import ArgumentParser
from myconfig import MyConfig
@@ -45,6 +46,12 @@ def iterateSubDirectory(oldroot, newroot, level):
iterateSubDirectory(olddir, newdir, level - 1)
-#test case
if __name__ == '__main__':
- pass
+ parser = ArgumentParser(description='Reduce the categories.')
+ parser.add_argument('--level', action='store', nargs=1, default=2)
+ parser.add_argument('origdir', action='store')
+ parser.add_argument('destdir', action='store')
+
+ args = parser.parse_args()
+ iterateSubDirectory(args.origdir, args.destdir, int(args.level[0]))
+ print('done')