diff --git a/.gitignore b/.gitignore index 3b4738aea..e12a5f7e5 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ tester .* data/ceeaus data/breast-cancer +biicode.conf +bii/ +bin/ diff --git a/CMakeLists.txt b/CMakeLists.txt index cc7533dff..4c9b30c52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,6 @@ include(FindZLIB) include_directories(include/) - set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/deps/findicu) find_package(Threads REQUIRED) find_package(ICU COMPONENTS data i18n uc REQUIRED) @@ -174,6 +173,11 @@ if(ICU_VERSION VERSION_LESS "4.4") -DMETA_ICU_NO_TEMP_SUBSTRING) endif() +if(BIICODE) + include(contrib/biicode/CMakeLists.txt) + return() +ENDIF() + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) link_libraries(cpptoml meta-definitions) diff --git a/contrib/biicode/CMakeLists.txt b/contrib/biicode/CMakeLists.txt new file mode 100644 index 000000000..5f4b5f3ed --- /dev/null +++ b/contrib/biicode/CMakeLists.txt @@ -0,0 +1,8 @@ +message(STATUS "Setting up biicode block...") +set(UNIT_TEST_EXE skystrife_meta_src_test_tools_unit-test) +include(src/test/unit_tests.cmake) +ADD_BIICODE_TARGETS() +target_link_libraries(${BII_LIB_TARGET} PUBLIC meta-definitions + ${ICU_LIBRARIES} + ${ZLIB_LIBRARIES} + ${CMAKE_THREAD_LIB_INIT}) diff --git a/contrib/biicode/README.md b/contrib/biicode/README.md new file mode 100644 index 000000000..db53ececd --- /dev/null +++ b/contrib/biicode/README.md @@ -0,0 +1,22 @@ +# Biicode Integration +MeTA can be built using biicode. To do so, symlink the biicode.conf file to +the project's root directory like so (from the project root): + +```bash +ln -s contrib/biicode/biicode.conf . +``` + +Then, configure and build with the following: + +```bash +bii init -L +bii configure +bii build +``` + +After placing the sample config.toml in the `bin/` directory, you can run +the unit tests: + +```bash +bii test +``` diff --git a/contrib/biicode/biicode.conf b/contrib/biicode/biicode.conf new file mode 100644 index 000000000..181df00e5 --- /dev/null +++ b/contrib/biicode/biicode.conf @@ -0,0 +1,60 @@ +# Biicode configuration file + +[requirements] + skystrife/cpptoml: 0 + +[parent] + # The parent version of this block. Must match folder name. E.g. + # user/block # No version number means not published yet + # You can change it to publish to a different track, and change version, e.g. + # user/block(track): 7 + skystrife/meta: 0 + +[paths] + # Local directories to look for headers (within block) + # / + include + # should put porter2_stemmer on biicode as well... + deps/porter2_stemmer + +[dependencies] + # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) + # hello.h + hello_imp.cpp hello_imp2.cpp + # *.h + *.cpp + include/analyzers/* + src/analyzers/* src/corpus/* + include/classify/* + src/classify/* src/index/* + include/corpus/* + src/corpus/* src/io/* + include/index/* + src/index/* src/analyzers/* + include/io/* + src/io/* src/util/* + include/lm/* + src/lm/* src/corpus/* + include/parser/* + src/parser/* src/io/* src/sequence/* src/util/* + include/sequence/* + src/sequence/* src/io/* src/utf/* + include/topics/* + src/topics/* src/index/* + CMakeLists.txt + deps/findicu/FindICU.cmake src/test/unit_tests.cmake contrib/biicode/CMakeLists.txt + +[mains] + # Manual adjust of files that define an executable + # !main.cpp # Do not build executable from this file + # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) + !deps/* + +[tests] + # Manual adjust of files that define a CTest test + # test/* pattern to evaluate this test/ folder sources like tests + +[hooks] + # These are defined equal to [dependencies],files names matching bii*stage*hook.py + # will be launched as python scripts at stage = {post_process, clean} + # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py + +[includes] + # Mapping of include patterns to external blocks + # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h + cpptoml.h: skystrife/cpptoml/include + +[data] + # Manually define data files dependencies, that will be copied to bin for execution + # By default they are copied to bin/user/block/... which should be taken into account + # when loading from disk such data + # image.cpp + image.jpg # code should write open("user/block/image.jpg") + diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile new file mode 100644 index 000000000..a3c13db0d --- /dev/null +++ b/contrib/docker/Dockerfile @@ -0,0 +1,20 @@ +FROM debian:jessie + +MAINTAINER Maciej Szymkiewicz "matthew.szymkiewicz@gmail.com" + +ENV METADIR /opt/meta +RUN mkdir -p $METADIR + +RUN apt-get update && apt-get -y install cmake libicu-dev git g++ && apt-get clean + +WORKDIR $METADIR +RUN git clone --depth 1 https://github.com/meta-toolkit/meta.git . +RUN git submodule update --init --recursive +RUN mkdir $METADIR/build + +WORKDIR $METADIR/build +RUN cp $METADIR/config.toml . +RUN cmake $METADIR -DCMAKE_BUILD_TYPE=Release && make +RUN ctest --output-on-failure + +RUN apt-get -y purge git && apt-get -y autoremove diff --git a/contrib/vagrant/README.md b/contrib/vagrant/README.md new file mode 100644 index 000000000..48a6ef145 --- /dev/null +++ b/contrib/vagrant/README.md @@ -0,0 +1,22 @@ +# Vagrant + +Build the latest version of the MeTA toolkit using [Vagrant](https://www.vagrantup.com/). Ubuntu 14.04 is used as a base Vagrant box. This project was initially made for [Text Retrieval and Search Engines](https://www.coursera.org/course/textretrieval) Coursera course. + +## Instructions + +1. Install Vagrant +2. Run Vagrant + ``` + vagrant up + ``` + +3. Check that everything is OK + ``` + vagrant ssh + cd meta/build + ctest --output-on-failure + ``` + +## Notes + +Only VirtualBox provider was tested. diff --git a/contrib/vagrant/Vagrantfile b/contrib/vagrant/Vagrantfile new file mode 100644 index 000000000..97544e188 --- /dev/null +++ b/contrib/vagrant/Vagrantfile @@ -0,0 +1,11 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure(2) do |config| + config.vm.box = "ubuntu/trusty64" + config.vm.provision :shell, path: "bootstrap.sh", privileged: false + + config.vm.provider "virtualbox" do |v| + v.cpus = 2 + end +end diff --git a/contrib/vagrant/bootstrap.sh b/contrib/vagrant/bootstrap.sh new file mode 100644 index 000000000..245575075 --- /dev/null +++ b/contrib/vagrant/bootstrap.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# this might take a while +sudo apt-get update +sudo apt-get install -y software-properties-common + +# add the ppa for cmake +sudo add-apt-repository -y ppa:george-edison55/cmake-3.x +sudo apt-get update + +# install dependencies +sudo apt-get install -y cmake libicu-dev git g++ g++-4.8 + +# clone the project +git clone https://github.com/meta-toolkit/meta.git +cd meta/ + +# uncomment to build exact version +# git reset --hard v1.3.2 + +# set up submodules +git submodule update --init --recursive + +# set up a build directory +mkdir build +cd build +cp ../config.toml . + +# configure and build the project +cmake ../ -DCMAKE_BUILD_TYPE=Release +make \ No newline at end of file diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index cfce3096d..9cf1b4b05 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -17,58 +17,5 @@ add_library(meta-testing analyzer_test.cpp parser_test.cpp) target_link_libraries(meta-testing meta-index meta-classify meta-parser-io) -add_test(analyzers unit-test analyzers) -set_tests_properties(analyzers PROPERTIES TIMEOUT 10 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(stemmers unit-test stemmers) -set_tests_properties(stemmers PROPERTIES TIMEOUT 10 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(parallel unit-test parallel) -set_tests_properties(parallel PROPERTIES TIMEOUT 30 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(inverted-index unit-test inverted-index) -set_tests_properties(inverted-index PROPERTIES TIMEOUT 30 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(forward-index unit-test forward-index) -set_tests_properties(forward-index PROPERTIES TIMEOUT 30 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(string-list unit-test string-list) -set_tests_properties(string-list PROPERTIES TIMEOUT 10 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(vocabulary-map unit-test vocabulary-map) -set_tests_properties(vocabulary-map PROPERTIES TIMEOUT 10 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(libsvm-parser unit-test libsvm-parser) -set_tests_properties(libsvm-parser PROPERTIES TIMEOUT 10 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(classifiers unit-test classifiers) -set_tests_properties(classifiers PROPERTIES TIMEOUT 80 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(rankers unit-test rankers) -set_tests_properties(rankers PROPERTIES TIMEOUT 75 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(ir-eval unit-test ir-eval) -set_tests_properties(ir-eval PROPERTIES TIMEOUT 10 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(compression unit-test compression) -set_tests_properties(compression PROPERTIES TIMEOUT 10 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(graph unit-test graph) -set_tests_properties(graph PROPERTIES TIMEOUT 10 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -add_test(parser unit-test parser) -set_tests_properties(parser PROPERTIES TIMEOUT 10 WORKING_DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +set(UNIT_TEST_EXE unit-test) +include(unit_tests.cmake) diff --git a/src/test/unit_tests.cmake b/src/test/unit_tests.cmake new file mode 100644 index 000000000..11abacb23 --- /dev/null +++ b/src/test/unit_tests.cmake @@ -0,0 +1,55 @@ +add_test(analyzers ${UNIT_TEST_EXE} analyzers) +set_tests_properties(analyzers PROPERTIES TIMEOUT 10 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(stemmers ${UNIT_TEST_EXE} stemmers) +set_tests_properties(stemmers PROPERTIES TIMEOUT 10 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(parallel ${UNIT_TEST_EXE} parallel) +set_tests_properties(parallel PROPERTIES TIMEOUT 30 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(inverted-index ${UNIT_TEST_EXE} inverted-index) +set_tests_properties(inverted-index PROPERTIES TIMEOUT 30 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(forward-index ${UNIT_TEST_EXE} forward-index) +set_tests_properties(forward-index PROPERTIES TIMEOUT 30 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(string-list ${UNIT_TEST_EXE} string-list) +set_tests_properties(string-list PROPERTIES TIMEOUT 10 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(vocabulary-map ${UNIT_TEST_EXE} vocabulary-map) +set_tests_properties(vocabulary-map PROPERTIES TIMEOUT 10 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(libsvm-parser ${UNIT_TEST_EXE} libsvm-parser) +set_tests_properties(libsvm-parser PROPERTIES TIMEOUT 10 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(classifiers ${UNIT_TEST_EXE} classifiers) +set_tests_properties(classifiers PROPERTIES TIMEOUT 80 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(rankers ${UNIT_TEST_EXE} rankers) +set_tests_properties(rankers PROPERTIES TIMEOUT 75 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(ir-eval ${UNIT_TEST_EXE} ir-eval) +set_tests_properties(ir-eval PROPERTIES TIMEOUT 10 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(compression ${UNIT_TEST_EXE} compression) +set_tests_properties(compression PROPERTIES TIMEOUT 10 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(graph ${UNIT_TEST_EXE} graph) +set_tests_properties(graph PROPERTIES TIMEOUT 10 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +add_test(parser ${UNIT_TEST_EXE} parser) +set_tests_properties(parser PROPERTIES TIMEOUT 10 WORKING_DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})