summaryrefslogtreecommitdiff
path: root/python/src/sa/_cdec_sa.pyx
diff options
context:
space:
mode:
authorVictor Chahuneau <vchahune@cs.cmu.edu>2012-07-27 01:16:03 -0400
committerVictor Chahuneau <vchahune@cs.cmu.edu>2012-07-27 01:16:03 -0400
commit8fdc3681fb7551e7faeff9f720102cdd417ba077 (patch)
tree1129d2b79a3255c249e181141814cb92b52b4d4d /python/src/sa/_cdec_sa.pyx
parent0aac9fd78f1c8b9ba3d91d702f592288075cbbde (diff)
[python] Fork of the suffix-array extractor with surface improvements
Available as the cdec.sa module, with commande-line helpers: python -m cdec.sa.compile -f ... -e ... -a ... -o sa-out/ -c extract.ini python -m cdec.sa.extract -c extract.ini -g grammars-out/ < input.txt > input.sgml + renamed cdec.scfg -> cdec.sa + Python README
Diffstat (limited to 'python/src/sa/_cdec_sa.pyx')
-rw-r--r--python/src/sa/_cdec_sa.pyx29
1 files changed, 29 insertions, 0 deletions
diff --git a/python/src/sa/_cdec_sa.pyx b/python/src/sa/_cdec_sa.pyx
new file mode 100644
index 00000000..710f8cb4
--- /dev/null
+++ b/python/src/sa/_cdec_sa.pyx
@@ -0,0 +1,29 @@
+import logging
+import resource
+import gzip
+
+cdef float monitor_cpu():
+ return (resource.getrusage(resource.RUSAGE_SELF).ru_utime+
+ resource.getrusage(resource.RUSAGE_SELF).ru_stime)
+
+def gzip_or_text(char* filename):
+ if filename.endswith('.gz'):
+ return gzip.GzipFile(filename)
+ else:
+ return open(filename)
+
+logger = logging.getLogger('cdec.sa')
+
+include "float_list.pxi"
+include "int_list.pxi"
+include "str_map.pxi"
+include "data_array.pxi"
+include "alignment.pxi"
+include "bilex.pxi"
+include "veb.pxi"
+include "lcp.pxi"
+include "sym.pxi"
+include "rule.pxi"
+include "precomputation.pxi"
+include "suffix_array.pxi"
+include "rulefactory.pxi"