summaryrefslogtreecommitdiff
path: root/python/README.md
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-06-12 13:56:42 +0200
committerPatrick Simianer <p@simianer.de>2014-06-12 13:56:42 +0200
commit244971287003d079e46193b8a209c28955f90134 (patch)
tree8beaae6b12b913acb213fc7f2415fd63886192f9 /python/README.md
parent5250fd67a4b8f242068cff87f0a6a4211f8b0fcf (diff)
parentb66e838ed52decc0be1eb5817b2a77c3840db2c5 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'python/README.md')
-rw-r--r--python/README.md28
1 files changed, 27 insertions, 1 deletions
diff --git a/python/README.md b/python/README.md
index 953971d3..03d9f31d 100644
--- a/python/README.md
+++ b/python/README.md
@@ -8,6 +8,14 @@ Build and install pycdec:
Alternatively, run `python setup.py build_ext --inplace` and add the `python/` directory to your `PYTHONPATH`.
+To re-build pycdec from the cython source, modify setup.py in the following ways:
+ * Add this input statement: from Cython.Build import cythonize
+ * Change the source file from cdec/\_cdec.cpp to cdec/\_cdec.pyx
+ * Add language='c++' as a property to ext\_modules (e.g. right after extra\_link\_args)
+ * In the final setup block, change ext\_modules=ext\_modules to ext\_modules=cythonize(ext\_modules)
+
+Then just build and install normally, as described above.
+
## Grammar extractor
Compile a parallel corpus and a word alignment into a suffix array representation:
@@ -23,7 +31,25 @@ Extract grammar rules from the compiled corpus:
cat input.txt | python -m cdec.sa.extract -c extract.ini -g grammars/ -z
This will create per-sentence grammar files in the `grammars` directory and output annotated input suitable for translation with cdec.
-
+
+Extract rules in stream mode:
+
+ python -m cdec.sa.extract -c extract.ini -t -z
+
+This will enable stdio interaction with the following types of lines:
+
+Extract grammar:
+
+ context ||| sentence ||| grammar_file
+
+Learn (online mode, specify context name):
+
+ context ||| sentence ||| reference ||| alignment
+
+Drop (online mode, specify context name):
+
+ context ||| drop
+
## Library usage
A basic demo of pycdec's features is available in `examples/test.py`.