From a3490906db9f9626535135e8539b55628a40bfc5 Mon Sep 17 00:00:00 2001
From: "Silas S. Brown" <ssb22@cam.ac.uk>
Date: Mon, 10 May 2010 16:12:28 +0000
Subject: [PATCH] Gradint update

git-svn-id: http://svn.code.sf.net/p/e-guidedog/code/ssb22/gradint@763 29193198-4895-4776-b068-10539e920549
---
 gradint-build/Makefile          |  2 +-
 gradint-build/src/booktime.py   |  2 +-
 gradint-build/src/filescan.py   |  2 +-
 gradint-build/src/frontend.py   |  5 ++++-
 gradint-build/src/lessonplan.py |  2 +-
 gradint-build/src/loop.py       |  2 +-
 gradint-build/src/makeevent.py  |  2 +-
 gradint-build/src/play.py       |  2 +-
 gradint-build/src/recording.py  |  2 +-
 gradint-build/src/sequence.py   |  2 +-
 gradint-build/src/synth.py      | 10 +++++++---
 gradint-build/src/system.py     |  2 +-
 gradint-build/src/top.py        |  2 +-
 gradint-build/src/users.py      |  2 +-
 gradint-build/thindown.py       |  2 +-
 15 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/gradint-build/Makefile b/gradint-build/Makefile
index aab66dc..b50f434 100644
--- a/gradint-build/Makefile
+++ b/gradint-build/Makefile
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/booktime.py b/gradint-build/src/booktime.py
index 5640a83..c206d76 100644
--- a/gradint-build/src/booktime.py
+++ b/gradint-build/src/booktime.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/filescan.py b/gradint-build/src/filescan.py
index 2d1af78..815f52c 100644
--- a/gradint-build/src/filescan.py
+++ b/gradint-build/src/filescan.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/frontend.py b/gradint-build/src/frontend.py
index 4d873a0..7b8cd52 100644
--- a/gradint-build/src/frontend.py
+++ b/gradint-build/src/frontend.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
@@ -1108,9 +1108,12 @@ def sanityCheck(text,language,pauseOnError=0): # text is utf-8; returns error me
         if ret: waitOnMessage(ret)
         return ret
     if language=="zh":
+        allDigits = True
         for t in text:
             if ord(t)>127: return # got hanzi or tone marks
             if t in "12345": return # got tone numbers
+            if t not in "0123456789. ": allDigits = False
+        if allDigits: return
         return "Pinyin needs tones.  Please go back and add tone numbers to "+text+"."+cond(startBrowser("http://www.pristine.com.tw/lexicon.php?query="+fix_pinyin(text,[]).replace("1","1 ").replace("2","2 ").replace("3","3 ").replace("4","4 ").replace("5"," ").replace("  "," ").strip(wsp).replace(" ","+"))," Gradint has pointed your web browser at an online dictionary that might help.","")
 
 def check_for_slacking():
diff --git a/gradint-build/src/lessonplan.py b/gradint-build/src/lessonplan.py
index 719dc31..3edcaa3 100644
--- a/gradint-build/src/lessonplan.py
+++ b/gradint-build/src/lessonplan.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/loop.py b/gradint-build/src/loop.py
index 30a913b..666e740 100644
--- a/gradint-build/src/loop.py
+++ b/gradint-build/src/loop.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/makeevent.py b/gradint-build/src/makeevent.py
index de14847..a4f8e5c 100644
--- a/gradint-build/src/makeevent.py
+++ b/gradint-build/src/makeevent.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/play.py b/gradint-build/src/play.py
index 73b636f..41ed5da 100644
--- a/gradint-build/src/play.py
+++ b/gradint-build/src/play.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/recording.py b/gradint-build/src/recording.py
index 3b528df..fbc913b 100644
--- a/gradint-build/src/recording.py
+++ b/gradint-build/src/recording.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/sequence.py b/gradint-build/src/sequence.py
index 03fd20e..6043bfa 100644
--- a/gradint-build/src/sequence.py
+++ b/gradint-build/src/sequence.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/synth.py b/gradint-build/src/synth.py
index ff7b926..bcee4bf 100644
--- a/gradint-build/src/synth.py
+++ b/gradint-build/src/synth.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
@@ -672,13 +672,17 @@ def read_chinese_number(num):
     nums=num.split(".")
     if len(nums)==1: # normal number
         columns=("yi4 qian1 bai3 shi2 wan4 qian1 bai3 shi2".split()+[""])
+        has_wan = not ("00000000"+num)[-8:-4]=="0000"
         if len(num)>len(columns) or (num and num[0]=="0"): return "".join([digits[ord(d)-ord("0")] for d in num]) # far too many digits, or something starting with 0 - read one at a time
         r=[]
         for d,c,i in zip(list(num),columns[-len(num):],range(len(num))):
             if d=="0":
-                if c and not (r and r[-1]=="ling2"): r.append("ling2") # else nothing
-            elif d=="1" and c=="shi2" and i==0: r.append(c)
+                if c=="wan4" and has_wan: r.append(c)
+                elif c and not (r and r[-1]=="ling2"): r.append("ling2")
+                # else nothing
+            elif d=="1" and c=="shi2" and (i==0 or (r and r[-1]=="ling2")): r.append(c) # 10, 1010
             else: r.append(digits[ord(d)-ord("0")]+c)
+        if len(r)>1 and r[-1]=="ling2": del r[-1] # e.g. 100
         return "".join(r)
     elif len(nums)==2: # read digits after the point one at a time
         rVal = [read_chinese_number(nums[0]),"dian3"]
diff --git a/gradint-build/src/system.py b/gradint-build/src/system.py
index d47749e..c477d73 100644
--- a/gradint-build/src/system.py
+++ b/gradint-build/src/system.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/top.py b/gradint-build/src/top.py
index 8e54c06..a6e810d 100644
--- a/gradint-build/src/top.py
+++ b/gradint-build/src/top.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-program_name = "gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+."
+program_name = "gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+."
 
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
diff --git a/gradint-build/src/users.py b/gradint-build/src/users.py
index 19dfa50..b017500 100644
--- a/gradint-build/src/users.py
+++ b/gradint-build/src/users.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/thindown.py b/gradint-build/thindown.py
index 6144880..0e072be 100644
--- a/gradint-build/thindown.py
+++ b/gradint-build/thindown.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9956 (c) 2002-2010 Silas S. Brown. GPL v3+.
+# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
-- 
GitLab