projects
/
cipher-tools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
bac2325
)
Now using the built-in functools.lru_cache instead of my own memo function
author
Neil Smith
<neil.git@njae.me.uk>
Sun, 3 Nov 2013 11:42:51 +0000
(11:42 +0000)
committer
Neil Smith
<neil.git@njae.me.uk>
Sun, 3 Nov 2013 11:42:51 +0000
(11:42 +0000)
segment.py
patch
|
blob
|
history
diff --git
a/segment.py
b/segment.py
index 08bc0aa84244bf222655defba7b4a0773f87ebcf..712895b6b0d7f1563ee4149fe7d94445a3931233 100644
(file)
--- a/
segment.py
+++ b/
segment.py
@@
-4,19
+4,10
@@
import collections
from math import log10
import itertools
import sys
+from functools import lru_cache
sys.setrecursionlimit(1000000)
-def memo(f):
- "Memoize function f."
- table = {}
- def fmemo(*args):
- if args not in table:
- table[args] = f(*args)
- return table[args]
- fmemo.memo = table
- return fmemo
-
-@memo
+@lru_cache()
def segment(text):
"""Return a list of words that is the best segmentation of text.
"""