فهرست منبع

Do not output debug info by default

Xi Ruoyao 5 سال پیش
والد
کامیت
5577ddb988
1فایلهای تغییر یافته به همراه4 افزوده شده و 1 حذف شده
  1. 4 1
      wordfreq.py

+ 4 - 1
wordfreq.py

@@ -50,6 +50,8 @@ def main():
     parser.add_argument("-o", "--output", help = "output image file name")
     parser.add_argument("-f", "--fontpath",
             help = "the path to the TTF/OTF fonts to use")
+    parser.add_argument("-d", "--debug", type=bool, default=False,
+            help = "if you want to dump debug information")
     args = parser.parse_args()
     if not args.jobs is None:
         jieba.enable_parallel(args.jobs)
@@ -61,7 +63,8 @@ def main():
     c = cnt(words, args.parts)
     if not args.top is None:
         c = dict(c.most_common(args.top))
-    print(c)
+    if args.debug:
+        print(c)
     wc = WordCloud(font_path = args.fontpath).generate_from_frequencies(c)
     wc.to_image().save(args.output)