From 1bc233887fa0a65709c9763b403e70f32b3c4615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20M=C3=B6rbitz?= Date: Tue, 19 Nov 2019 09:49:44 +0100 Subject: [PATCH 1/6] Add Dockerfile --- Dockerfile | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b2eb330 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,65 @@ +FROM ubuntu:bionic + +# Change versions of dependencies here +ARG EIGEN_REVISION=9e6bc1d +ARG OPENFST_VERSION=1.7.5 +ARG PYNINI_VERSION=2.0.9 +ARG GF_VERSION=3.10-2 + +# @Python: read files in UTF-8 encoding! +ENV LANG=C.UTF-8 + +# Install build environment and most dependencies via apt +ENV DEBIAN_FRONTEND noninteractive +RUN apt update \ + && apt -y install build-essential cmake git graphviz libncurses5-dev libre2-dev mercurial python-dev python3-dev python3-numpy python3-pip wget zlib1g-dev \ + && apt -y autoremove \ + && apt -y clean \ + && rm -rf /var/lib/apt/lists/* + +# Install eigen from source +RUN hg clone https://bitbucket.org/eigen/eigen/ -r "$EIGEN_REVISION" +RUN mkdir eigen/build +WORKDIR eigen/build +RUN cmake .. +RUN make install +WORKDIR / + +# Install disco-dop from source +RUN git clone --recursive --branch=chart-exposure https://github.com/kilian-gebhardt/disco-dop +WORKDIR disco-dop +RUN pip3 install -r requirements.txt +RUN make install +WORKDIR / + +# Install OpenFST from source +RUN wget "http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-$OPENFST_VERSION.tar.gz" +RUN tar -xf "openfst-$OPENFST_VERSION.tar.gz" +WORKDIR "openfst-$OPENFST_VERSION" +RUN ./configure --enable-bin --enable-compact-fsts --enable-compress --enable-const-fsts --enable-far --enable-linear-fsts --enable-lookahead-fsts --enable-mpdt --enable-ngram-fsts --enable-pdt --enable-python PYTHON=python3 +RUN make +RUN make install +WORKDIR / + +# Install Pynini from source +RUN wget "http://www.openfst.org/twiki/pub/GRM/PyniniDownload/pynini-$PYNINI_VERSION.tar.gz" +RUN tar -xf "pynini-$PYNINI_VERSION.tar.gz" +WORKDIR "pynini-$PYNINI_VERSION" +RUN python3 setup.py install +WORKDIR / + +# Install Grammatical Framework custom package +RUN wget "http://www.grammaticalframework.org/download/gf_${GF_VERSION}_amd64.deb" +RUN dpkg -i "gf_${GF_VERSION}_amd64.deb" + +# Install Boost from source +ARG BOOST_VERSION=1.69.0 +RUN wget "https://dl.bintray.com/boostorg/release/$BOOST_VERSION/source/boost_$(echo $BOOST_VERSION | sed 's/\./_/g').tar.gz" +RUN tar -xf "boost_$(echo $BOOST_VERSION | sed 's/\./_/g').tar.gz" +RUN cd "boost_$(echo $BOOST_VERSION | sed 's/\./_/g')" && ./bootstrap.sh --with-libraries= && ./b2 install || true + +# Build Panda parser +ADD . /panda-parser +WORKDIR panda-parser +RUN pip3 install -r requirements.txt +RUN python3 setup.py build_ext --inplace From 5fafce4ccd49bb3b957d7b812db7b717026f8c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20M=C3=B6rbitz?= Date: Tue, 19 Nov 2019 09:50:00 +0100 Subject: [PATCH 2/6] parser/fst/lazy_composition.h: fix string usage --- parser/fst/lazy_composition.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parser/fst/lazy_composition.h b/parser/fst/lazy_composition.h index 79c360d..c9d8df0 100644 --- a/parser/fst/lazy_composition.h +++ b/parser/fst/lazy_composition.h @@ -3,7 +3,7 @@ using namespace fst; -StdVectorFst construct_fa(std::vector sequence, const StdFst & fst) { +StdVectorFst construct_fa(std::vector sequence, const StdFst & fst) { StdVectorFst fsa; fsa.SetInputSymbols(fst.InputSymbols()); fsa.SetOutputSymbols(fst.InputSymbols()); @@ -47,4 +47,4 @@ std::vector lazy_compose_(const StdVectorFst & fst_a, const StdFst & f } } return rules; -} \ No newline at end of file +} From 41a43098536a387764ac1ad69361fed99ec1b0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20M=C3=B6rbitz?= Date: Tue, 19 Nov 2019 09:52:26 +0100 Subject: [PATCH 3/6] setup.py: add /usr/local/include to eigen includes --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 849a2f7..96eb72b 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ # change if eigen is installed in the user-local directory # $COMPUTE_ROOT/usr/include/eigen3, compute_root = "" -eigen_include = [compute_root + "/usr/include/eigen3", compute_root + "/usr/include"] +eigen_include = [compute_root + "/usr/include/eigen3", compute_root + "/usr/local/include/eigen3", compute_root + "/usr/include"] add_include = [compute_root + "/usr/local/include"] # Schick Parser (mainly implemented by Timo Schick according to construction From be764068bf64d71b2ae822890a83dfeabc310a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20M=C3=B6rbitz?= Date: Tue, 19 Nov 2019 16:53:35 +0100 Subject: [PATCH 4/6] requirements.txt: add nltk dependency --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index b3f7a31..2cb6ab9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ backports-abc>=0.4 Cython>=0.25.2 graphviz>=0.5.1 +nltk>=3.4.5 # openfst>=1.5.1.post6 # pgf>=1.0 pickleshare>=0.7.4 From f8003f3f60af2cb45b797fc157bbaba24138fa31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20M=C3=B6rbitz?= Date: Tue, 19 Nov 2019 16:53:48 +0100 Subject: [PATCH 5/6] Dockerfile: build GF from source (for Python 3) --- Dockerfile | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b2eb330..1755f6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM ubuntu:bionic ARG EIGEN_REVISION=9e6bc1d ARG OPENFST_VERSION=1.7.5 ARG PYNINI_VERSION=2.0.9 -ARG GF_VERSION=3.10-2 +ARG GF_VERSION=3.10 # @Python: read files in UTF-8 encoding! ENV LANG=C.UTF-8 @@ -12,7 +12,7 @@ ENV LANG=C.UTF-8 # Install build environment and most dependencies via apt ENV DEBIAN_FRONTEND noninteractive RUN apt update \ - && apt -y install build-essential cmake git graphviz libncurses5-dev libre2-dev mercurial python-dev python3-dev python3-numpy python3-pip wget zlib1g-dev \ + && apt -y install autoconf build-essential cmake git graphviz libncurses5-dev libre2-dev libtool mercurial python-dev python3-dev python3-numpy python3-pip wget zlib1g-dev \ && apt -y autoremove \ && apt -y clean \ && rm -rf /var/lib/apt/lists/* @@ -29,6 +29,7 @@ WORKDIR / RUN git clone --recursive --branch=chart-exposure https://github.com/kilian-gebhardt/disco-dop WORKDIR disco-dop RUN pip3 install -r requirements.txt +RUN sed -i 's/install --user/install/' Makefile RUN make install WORKDIR / @@ -49,8 +50,16 @@ RUN python3 setup.py install WORKDIR / # Install Grammatical Framework custom package -RUN wget "http://www.grammaticalframework.org/download/gf_${GF_VERSION}_amd64.deb" -RUN dpkg -i "gf_${GF_VERSION}_amd64.deb" +RUN wget "https://github.com/GrammaticalFramework/gf-core/archive/GF-$GF_VERSION.tar.gz" +RUN tar -xf "GF-$GF_VERSION.tar.gz" +WORKDIR "gf-core-GF-$GF_VERSION/src/runtime/c" +RUN bash setup.sh configure +RUN bash setup.sh build +RUN bash setup.sh install +WORKDIR "/gf-core-GF-$GF_VERSION/src/runtime/python" +RUN python3 setup.py build +RUN python3 setup.py install +WORKDIR / # Install Boost from source ARG BOOST_VERSION=1.69.0 From e557477a89aafe5f88c3e3f723e6c3d73bb971c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20M=C3=B6rbitz?= Date: Wed, 29 Apr 2020 12:32:47 +0200 Subject: [PATCH 6/6] INSTALL: add docker section --- INSTALL.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index 815c507..6e5f286 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,5 +1,15 @@ # INSTALL GUIDE +## Via Docker + +Build an image, the current directory is added as the top layer. + +`docker build --tag=panda-parser .` + +Obtain a shell in the container. + +`docker run --rm -it panda-parser bash` + ## General prerequisites `python3.5` or newer, `sqlite3`, `pip3`, `re2` (`libre2-dev` on ubuntu)