summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Chahuneau <vchahune@cs.cmu.edu>2013-08-26 20:12:32 -0400
committerVictor Chahuneau <vchahune@cs.cmu.edu>2013-08-26 20:12:32 -0400
commitca9b58716214148eeaeaa3076e1a1dc8f8bb5892 (patch)
treebfa2fd84c86e0fdd499110e86fd464b391379df1
parent9d5071692ceab8d09c2bfdba24f6b927ec84b7f9 (diff)
Improve the package structure of pycdec
This change should not break anything, but now you can run: python setup.py build_ext --inplace and use the cleaner: PYTHONPATH=/path/to/cdec/python python -m ...
-rw-r--r--python/README.md9
-rw-r--r--python/cdec/__init__.py (renamed from python/pkg/cdec/__init__.py)0
-rw-r--r--python/cdec/_cdec.cpp (renamed from python/src/_cdec.cpp)0
-rw-r--r--python/cdec/_cdec.pyx (renamed from python/src/_cdec.pyx)0
-rw-r--r--python/cdec/configobj.py (renamed from python/pkg/cdec/configobj.py)0
-rw-r--r--python/cdec/decoder.pxd (renamed from python/src/decoder.pxd)0
-rw-r--r--python/cdec/grammar.pxd (renamed from python/src/grammar.pxd)0
-rw-r--r--python/cdec/grammar.pxi (renamed from python/src/grammar.pxi)0
-rw-r--r--python/cdec/hypergraph.pxd (renamed from python/src/hypergraph.pxd)0
-rw-r--r--python/cdec/hypergraph.pxi (renamed from python/src/hypergraph.pxi)0
-rw-r--r--python/cdec/kbest.pxd (renamed from python/src/kbest.pxd)0
-rw-r--r--python/cdec/lattice.pxd (renamed from python/src/lattice.pxd)0
-rw-r--r--python/cdec/lattice.pxi (renamed from python/src/lattice.pxi)0
-rw-r--r--python/cdec/mteval.pxd (renamed from python/src/mteval.pxd)0
-rw-r--r--python/cdec/mteval.pxi (renamed from python/src/mteval.pxi)0
-rw-r--r--python/cdec/observer.h (renamed from python/src/observer.h)0
-rw-r--r--python/cdec/py_scorer.h (renamed from python/src/py_scorer.h)0
-rw-r--r--python/cdec/sa/__init__.py (renamed from python/pkg/cdec/sa/__init__.py)0
-rw-r--r--python/cdec/sa/_sa.c (renamed from python/src/sa/_sa.c)0
-rw-r--r--python/cdec/sa/_sa.pxd (renamed from python/src/sa/_sa.pxd)0
-rw-r--r--python/cdec/sa/_sa.pyx (renamed from python/src/sa/_sa.pyx)0
-rw-r--r--python/cdec/sa/alignment.pxi (renamed from python/src/sa/alignment.pxi)1
-rw-r--r--python/cdec/sa/bilex.pxi (renamed from python/src/sa/bilex.pxi)0
-rw-r--r--python/cdec/sa/compile.py (renamed from python/pkg/cdec/sa/compile.py)0
-rw-r--r--python/cdec/sa/data_array.pxi (renamed from python/src/sa/data_array.pxi)0
-rw-r--r--python/cdec/sa/extract.py (renamed from python/pkg/cdec/sa/extract.py)0
-rw-r--r--python/cdec/sa/extractor.py (renamed from python/pkg/cdec/sa/extractor.py)0
-rw-r--r--python/cdec/sa/features.pxi (renamed from python/src/sa/features.pxi)0
-rw-r--r--python/cdec/sa/features.py (renamed from python/pkg/cdec/sa/features.py)0
-rw-r--r--python/cdec/sa/float_list.pxi (renamed from python/src/sa/float_list.pxi)0
-rw-r--r--python/cdec/sa/int_list.pxi (renamed from python/src/sa/int_list.pxi)0
-rw-r--r--python/cdec/sa/lcp.pxi (renamed from python/src/sa/lcp.pxi)0
-rw-r--r--python/cdec/sa/precomputation.pxi (renamed from python/src/sa/precomputation.pxi)0
-rw-r--r--python/cdec/sa/rule.pxi (renamed from python/src/sa/rule.pxi)1
-rw-r--r--python/cdec/sa/rulefactory.pxi (renamed from python/src/sa/rulefactory.pxi)0
-rw-r--r--python/cdec/sa/str_map.pxi (renamed from python/src/sa/str_map.pxi)0
-rw-r--r--python/cdec/sa/strmap.cc (renamed from python/src/sa/strmap.cc)0
-rw-r--r--python/cdec/sa/strmap.h (renamed from python/src/sa/strmap.h)0
-rw-r--r--python/cdec/sa/suffix_array.pxi (renamed from python/src/sa/suffix_array.pxi)0
-rw-r--r--python/cdec/sa/sym.pxi (renamed from python/src/sa/sym.pxi)0
-rw-r--r--python/cdec/sa/veb.pxi (renamed from python/src/sa/veb.pxi)0
-rw-r--r--python/cdec/score.py (renamed from python/pkg/cdec/score.py)0
-rw-r--r--python/cdec/utils.pxd (renamed from python/src/utils.pxd)0
-rw-r--r--python/cdec/vectors.pxi (renamed from python/src/vectors.pxi)0
-rw-r--r--python/setup.py.in10
l---------python/src/cdec.sa._sa.pxd1
46 files changed, 10 insertions, 12 deletions
diff --git a/python/README.md b/python/README.md
index bea6190a..953971d3 100644
--- a/python/README.md
+++ b/python/README.md
@@ -1,4 +1,4 @@
-pycdec is a Python interface to cdec
+pycdec is a Python interface to cdec
## Installation
@@ -6,6 +6,8 @@ Build and install pycdec:
python setup.py install
+Alternatively, run `python setup.py build_ext --inplace` and add the `python/` directory to your `PYTHONPATH`.
+
## Grammar extractor
Compile a parallel corpus and a word alignment into a suffix array representation:
@@ -18,13 +20,14 @@ Or, if your parallel corpus is in a single-file format (with source and target s
Extract grammar rules from the compiled corpus:
- cat input.txt | python -m cdec.sa.extract -c extract.ini -g grammars/
+ 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.
## Library usage
-A basic demo of pycdec's features is available in `test.py`
+A basic demo of pycdec's features is available in `examples/test.py`.
+Other examples are given in [the paper](http://victor.chahuneau.fr/pub/pycdec/) describing pycdec.
More documentation will come as the API becomes stable.
diff --git a/python/pkg/cdec/__init__.py b/python/cdec/__init__.py
index 8e10f340..8e10f340 100644
--- a/python/pkg/cdec/__init__.py
+++ b/python/cdec/__init__.py
diff --git a/python/src/_cdec.cpp b/python/cdec/_cdec.cpp
index ae36b773..ae36b773 100644
--- a/python/src/_cdec.cpp
+++ b/python/cdec/_cdec.cpp
diff --git a/python/src/_cdec.pyx b/python/cdec/_cdec.pyx
index 47d0c739..47d0c739 100644
--- a/python/src/_cdec.pyx
+++ b/python/cdec/_cdec.pyx
diff --git a/python/pkg/cdec/configobj.py b/python/cdec/configobj.py
index c1f6e6df..c1f6e6df 100644
--- a/python/pkg/cdec/configobj.py
+++ b/python/cdec/configobj.py
diff --git a/python/src/decoder.pxd b/python/cdec/decoder.pxd
index b68b836e..b68b836e 100644
--- a/python/src/decoder.pxd
+++ b/python/cdec/decoder.pxd
diff --git a/python/src/grammar.pxd b/python/cdec/grammar.pxd
index 0ffe80fa..0ffe80fa 100644
--- a/python/src/grammar.pxd
+++ b/python/cdec/grammar.pxd
diff --git a/python/src/grammar.pxi b/python/cdec/grammar.pxi
index d523e4d2..d523e4d2 100644
--- a/python/src/grammar.pxi
+++ b/python/cdec/grammar.pxi
diff --git a/python/src/hypergraph.pxd b/python/cdec/hypergraph.pxd
index 1e150bbc..1e150bbc 100644
--- a/python/src/hypergraph.pxd
+++ b/python/cdec/hypergraph.pxd
diff --git a/python/src/hypergraph.pxi b/python/cdec/hypergraph.pxi
index 4a709d32..4a709d32 100644
--- a/python/src/hypergraph.pxi
+++ b/python/cdec/hypergraph.pxi
diff --git a/python/src/kbest.pxd b/python/cdec/kbest.pxd
index 44ecfbab..44ecfbab 100644
--- a/python/src/kbest.pxd
+++ b/python/cdec/kbest.pxd
diff --git a/python/src/lattice.pxd b/python/cdec/lattice.pxd
index 8ad710e5..8ad710e5 100644
--- a/python/src/lattice.pxd
+++ b/python/cdec/lattice.pxd
diff --git a/python/src/lattice.pxi b/python/cdec/lattice.pxi
index 8000b61e..8000b61e 100644
--- a/python/src/lattice.pxi
+++ b/python/cdec/lattice.pxi
diff --git a/python/src/mteval.pxd b/python/cdec/mteval.pxd
index 33a6b7a5..33a6b7a5 100644
--- a/python/src/mteval.pxd
+++ b/python/cdec/mteval.pxd
diff --git a/python/src/mteval.pxi b/python/cdec/mteval.pxi
index 436a1e01..436a1e01 100644
--- a/python/src/mteval.pxi
+++ b/python/cdec/mteval.pxi
diff --git a/python/src/observer.h b/python/cdec/observer.h
index 05f3c9be..05f3c9be 100644
--- a/python/src/observer.h
+++ b/python/cdec/observer.h
diff --git a/python/src/py_scorer.h b/python/cdec/py_scorer.h
index 22dc9fee..22dc9fee 100644
--- a/python/src/py_scorer.h
+++ b/python/cdec/py_scorer.h
diff --git a/python/pkg/cdec/sa/__init__.py b/python/cdec/sa/__init__.py
index 14ba5ecb..14ba5ecb 100644
--- a/python/pkg/cdec/sa/__init__.py
+++ b/python/cdec/sa/__init__.py
diff --git a/python/src/sa/_sa.c b/python/cdec/sa/_sa.c
index 2e565e22..2e565e22 100644
--- a/python/src/sa/_sa.c
+++ b/python/cdec/sa/_sa.c
diff --git a/python/src/sa/_sa.pxd b/python/cdec/sa/_sa.pxd
index f1cd8e29..f1cd8e29 100644
--- a/python/src/sa/_sa.pxd
+++ b/python/cdec/sa/_sa.pxd
diff --git a/python/src/sa/_sa.pyx b/python/cdec/sa/_sa.pyx
index 4716d174..4716d174 100644
--- a/python/src/sa/_sa.pyx
+++ b/python/cdec/sa/_sa.pyx
diff --git a/python/src/sa/alignment.pxi b/python/cdec/sa/alignment.pxi
index f66f0fbf..295697f9 100644
--- a/python/src/sa/alignment.pxi
+++ b/python/cdec/sa/alignment.pxi
@@ -88,7 +88,6 @@ cdef class Alignment:
def write_enhanced(self, char* filename):
with open(filename, "w") as f:
- sent_num = 1
for link in self.links:
f.write("%d " % link)
f.write("\n")
diff --git a/python/src/sa/bilex.pxi b/python/cdec/sa/bilex.pxi
index 44bc0ce6..44bc0ce6 100644
--- a/python/src/sa/bilex.pxi
+++ b/python/cdec/sa/bilex.pxi
diff --git a/python/pkg/cdec/sa/compile.py b/python/cdec/sa/compile.py
index d4cd8387..d4cd8387 100644
--- a/python/pkg/cdec/sa/compile.py
+++ b/python/cdec/sa/compile.py
diff --git a/python/src/sa/data_array.pxi b/python/cdec/sa/data_array.pxi
index 2a8ea921..2a8ea921 100644
--- a/python/src/sa/data_array.pxi
+++ b/python/cdec/sa/data_array.pxi
diff --git a/python/pkg/cdec/sa/extract.py b/python/cdec/sa/extract.py
index b6502c52..b6502c52 100644
--- a/python/pkg/cdec/sa/extract.py
+++ b/python/cdec/sa/extract.py
diff --git a/python/pkg/cdec/sa/extractor.py b/python/cdec/sa/extractor.py
index acc13cbc..acc13cbc 100644
--- a/python/pkg/cdec/sa/extractor.py
+++ b/python/cdec/sa/extractor.py
diff --git a/python/src/sa/features.pxi b/python/cdec/sa/features.pxi
index 9b9ecf3c..9b9ecf3c 100644
--- a/python/src/sa/features.pxi
+++ b/python/cdec/sa/features.pxi
diff --git a/python/pkg/cdec/sa/features.py b/python/cdec/sa/features.py
index c8fc1cca..c8fc1cca 100644
--- a/python/pkg/cdec/sa/features.py
+++ b/python/cdec/sa/features.py
diff --git a/python/src/sa/float_list.pxi b/python/cdec/sa/float_list.pxi
index b98e444f..b98e444f 100644
--- a/python/src/sa/float_list.pxi
+++ b/python/cdec/sa/float_list.pxi
diff --git a/python/src/sa/int_list.pxi b/python/cdec/sa/int_list.pxi
index 46d434e7..46d434e7 100644
--- a/python/src/sa/int_list.pxi
+++ b/python/cdec/sa/int_list.pxi
diff --git a/python/src/sa/lcp.pxi b/python/cdec/sa/lcp.pxi
index 8e86e611..8e86e611 100644
--- a/python/src/sa/lcp.pxi
+++ b/python/cdec/sa/lcp.pxi
diff --git a/python/src/sa/precomputation.pxi b/python/cdec/sa/precomputation.pxi
index a3527f47..a3527f47 100644
--- a/python/src/sa/precomputation.pxi
+++ b/python/cdec/sa/precomputation.pxi
diff --git a/python/src/sa/rule.pxi b/python/cdec/sa/rule.pxi
index 4f0ea74f..7fde3e06 100644
--- a/python/src/sa/rule.pxi
+++ b/python/cdec/sa/rule.pxi
@@ -49,7 +49,6 @@ cdef class Phrase:
return tuple(norm)
def strhandle(self):
- strs = []
norm = []
cdef int i, j, s
i = 1
diff --git a/python/src/sa/rulefactory.pxi b/python/cdec/sa/rulefactory.pxi
index 10bb9737..10bb9737 100644
--- a/python/src/sa/rulefactory.pxi
+++ b/python/cdec/sa/rulefactory.pxi
diff --git a/python/src/sa/str_map.pxi b/python/cdec/sa/str_map.pxi
index 3a8439a4..3a8439a4 100644
--- a/python/src/sa/str_map.pxi
+++ b/python/cdec/sa/str_map.pxi
diff --git a/python/src/sa/strmap.cc b/python/cdec/sa/strmap.cc
index 5040477e..5040477e 100644
--- a/python/src/sa/strmap.cc
+++ b/python/cdec/sa/strmap.cc
diff --git a/python/src/sa/strmap.h b/python/cdec/sa/strmap.h
index a218a4c0..a218a4c0 100644
--- a/python/src/sa/strmap.h
+++ b/python/cdec/sa/strmap.h
diff --git a/python/src/sa/suffix_array.pxi b/python/cdec/sa/suffix_array.pxi
index de4adcd9..de4adcd9 100644
--- a/python/src/sa/suffix_array.pxi
+++ b/python/cdec/sa/suffix_array.pxi
diff --git a/python/src/sa/sym.pxi b/python/cdec/sa/sym.pxi
index f253aec0..f253aec0 100644
--- a/python/src/sa/sym.pxi
+++ b/python/cdec/sa/sym.pxi
diff --git a/python/src/sa/veb.pxi b/python/cdec/sa/veb.pxi
index 40af3a68..40af3a68 100644
--- a/python/src/sa/veb.pxi
+++ b/python/cdec/sa/veb.pxi
diff --git a/python/pkg/cdec/score.py b/python/cdec/score.py
index 657b4547..657b4547 100644
--- a/python/pkg/cdec/score.py
+++ b/python/cdec/score.py
diff --git a/python/src/utils.pxd b/python/cdec/utils.pxd
index 687d3ac0..687d3ac0 100644
--- a/python/src/utils.pxd
+++ b/python/cdec/utils.pxd
diff --git a/python/src/vectors.pxi b/python/cdec/vectors.pxi
index 46f58fd4..46f58fd4 100644
--- a/python/src/vectors.pxi
+++ b/python/cdec/vectors.pxi
diff --git a/python/setup.py.in b/python/setup.py.in
index 925cb196..ce1eb2ed 100644
--- a/python/setup.py.in
+++ b/python/setup.py.in
@@ -2,7 +2,7 @@ from distutils.core import setup
from distutils.extension import Extension
import re
-INC = ['..', 'src/', '../decoder', '../utils', '../mteval']
+INC = ['..', 'cdec/', '../decoder', '../utils', '../mteval']
LIB = ['../decoder', '../utils', '../mteval', '../training/utils', '../klm/lm', '../klm/util', '../klm/util/double-conversion', '../klm/search']
# Set automatically by configure
@@ -14,20 +14,18 @@ LDFLAGS = [opt.replace('-R', '-Wl,-rpath,') for opt in LDFLAGS]
ext_modules = [
Extension(name='cdec._cdec',
- sources=['src/_cdec.cpp'],
+ sources=['cdec/_cdec.cpp'],
include_dirs=INC,
library_dirs=LIB,
libraries=['cdec', 'utils', 'mteval', 'training_utils', 'klm', 'klm_util', 'klm_util_double', 'ksearch'] + LIBS,
extra_compile_args=CPPFLAGS,
extra_link_args=LDFLAGS),
Extension(name='cdec.sa._sa',
- sources=['src/sa/_sa.c', 'src/sa/strmap.cc'])
+ sources=['cdec/sa/_sa.c', 'cdec/sa/strmap.cc'])
]
setup(
name='cdec',
ext_modules=ext_modules,
- requires=['configobj'],
- packages=['cdec', 'cdec.sa'],
- package_dir={'': 'pkg'}
+ packages=['cdec', 'cdec.sa']
)
diff --git a/python/src/cdec.sa._sa.pxd b/python/src/cdec.sa._sa.pxd
deleted file mode 120000
index 3613f643..00000000
--- a/python/src/cdec.sa._sa.pxd
+++ /dev/null
@@ -1 +0,0 @@
-sa/_sa.pxd \ No newline at end of file