commit 691e8e776f1992457b2f922e0a8e580406728c79 parent 2c2d4e1bfa8e22343ee71bcf6833c00e02a63261 Author: Antoine Amarilli <a3nm@a3nm.net> Date: Wed, 2 May 2012 00:10:25 +0200 oops, forgot file Diffstat:
nature.py | | | 24 | ++++++++++++++++++++++++ |
1 file changed, 24 insertions(+), 0 deletions(-)
diff --git a/nature.py b/nature.py @@ -0,0 +1,24 @@ +import os + +def nature_count(x): + # for uppercased words, only one occurrence should be allowed + if x.lower() != x: + return 1 + try: + return count[x] + except KeyError: + # return a reasonable overapproximation + return 9 + +count = {} + +f = open(os.path.join(os.path.dirname( + os.path.realpath(__file__)), 'occurrences')) + +while True: + l = f.readline() + if not l: + break + l = l.rstrip().split(' ') + count[l[0]] = int(l[1]) +