Commit 15ccd105da1ec3827478854e953a3ea2b16a08f9
1 parent
376c587a
- zmiana nazwy pakietu javowego z pl.waw.ipipan.morfeusz na pl.sgjp.morfeusz
- różne poprawki w README, testach wrappera pythonowego (ustawianie PYTHONPATH) i w wrapperze Javowym (javadoc dla aggl i praet) git-svn-id: svn://svn.nlp.ipipan.waw.pl/morfeusz/trunk@267 ff4e3ee1-f430-4e82-ade0-24591c43f1fd
Showing
9 changed files
with
64 additions
and
52 deletions
README
@@ -50,7 +50,9 @@ Testing | @@ -50,7 +50,9 @@ Testing | ||
50 | To compile and run tests you must have cppunit library installed. | 50 | To compile and run tests you must have cppunit library installed. |
51 | To test if everything is working type: | 51 | To test if everything is working type: |
52 | 52 | ||
53 | -make build-tests | 53 | +make |
54 | +make package-java ### to also test Java wrapper | ||
55 | +make package-python ### to also test Python wrapper | ||
54 | make test | 56 | make test |
55 | 57 | ||
56 | If some tests fail, you can see errors by invoking: | 58 | If some tests fail, you can see errors by invoking: |
morfeusz/wrappers/java/CMakeLists.txt
@@ -11,11 +11,11 @@ include_directories (${CMAKE_SOURCE_DIR}/morfeusz) | @@ -11,11 +11,11 @@ include_directories (${CMAKE_SOURCE_DIR}/morfeusz) | ||
11 | set (SWIG_JAVA_OUTFILE "${CMAKE_CURRENT_BINARY_DIR}/swigJAVA.cpp") | 11 | set (SWIG_JAVA_OUTFILE "${CMAKE_CURRENT_BINARY_DIR}/swigJAVA.cpp") |
12 | file (COPY pl DESTINATION .) | 12 | file (COPY pl DESTINATION .) |
13 | 13 | ||
14 | -set (JAVA_SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/pl/waw/ipipan/morfeusz") | 14 | +set (JAVA_SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/pl/sgjp/morfeusz") |
15 | 15 | ||
16 | add_custom_command ( | 16 | add_custom_command ( |
17 | OUTPUT ${SWIG_JAVA_OUTFILE} | 17 | OUTPUT ${SWIG_JAVA_OUTFILE} |
18 | - COMMAND swig -java -c++ -package pl.waw.ipipan.morfeusz -o ${SWIG_JAVA_OUTFILE} -outdir ${JAVA_SRC_DIR} ${CMAKE_SOURCE_DIR}/morfeusz/wrappers/morfeusz.i | 18 | + COMMAND swig -java -c++ -package pl.sgjp.morfeusz -o ${SWIG_JAVA_OUTFILE} -outdir ${JAVA_SRC_DIR} ${CMAKE_SOURCE_DIR}/morfeusz/wrappers/morfeusz.i |
19 | DEPENDS libmorfeusz | 19 | DEPENDS libmorfeusz |
20 | ) | 20 | ) |
21 | add_custom_target(generate-java-wrapper ALL | 21 | add_custom_target(generate-java-wrapper ALL |
@@ -56,7 +56,7 @@ endif () | @@ -56,7 +56,7 @@ endif () | ||
56 | file(GLOB_RECURSE JAVA_SOURCES "${JAVA_SRC_DIR}" "${JAVA_SRC_DIR}/*.java") | 56 | file(GLOB_RECURSE JAVA_SOURCES "${JAVA_SRC_DIR}" "${JAVA_SRC_DIR}/*.java") |
57 | add_jar (jmorfeusz | 57 | add_jar (jmorfeusz |
58 | SOURCES "${JAVA_SOURCES}" | 58 | SOURCES "${JAVA_SOURCES}" |
59 | - ENTRY_POINT pl/waw/ipipan/morfeusz/app/App | 59 | + ENTRY_POINT pl/sgjp/morfeusz/app/App |
60 | DEPENDS libjmorfeusz generate-java-wrapper) | 60 | DEPENDS libjmorfeusz generate-java-wrapper) |
61 | 61 | ||
62 | add_custom_target(generate-javadoc | 62 | add_custom_target(generate-javadoc |
@@ -66,7 +66,7 @@ add_custom_target(generate-javadoc | @@ -66,7 +66,7 @@ add_custom_target(generate-javadoc | ||
66 | -windowtitle "JMorfeusz - Morfeusz Java binding" | 66 | -windowtitle "JMorfeusz - Morfeusz Java binding" |
67 | -use | 67 | -use |
68 | -link http://docs.oracle.com/javase/7/docs/api/ | 68 | -link http://docs.oracle.com/javase/7/docs/api/ |
69 | - pl.waw.ipipan.morfeusz | 69 | + pl.sgjp.morfeusz |
70 | DEPENDS jmorfeusz) | 70 | DEPENDS jmorfeusz) |
71 | 71 | ||
72 | add_custom_target(package-javadoc | 72 | add_custom_target(package-javadoc |
morfeusz/wrappers/java/JMorfeuszTest.java
@@ -10,11 +10,11 @@ import static org.junit.Assert.*; | @@ -10,11 +10,11 @@ import static org.junit.Assert.*; | ||
10 | import org.junit.Before; | 10 | import org.junit.Before; |
11 | import org.junit.BeforeClass; | 11 | import org.junit.BeforeClass; |
12 | import org.junit.Test; | 12 | import org.junit.Test; |
13 | -import pl.waw.ipipan.morfeusz.Morfeusz; | ||
14 | -import pl.waw.ipipan.morfeusz.MorfeuszUsage; | ||
15 | -import pl.waw.ipipan.morfeusz.MorfeuszException; | ||
16 | -import pl.waw.ipipan.morfeusz.MorphInterpretation; | ||
17 | -import pl.waw.ipipan.morfeusz.ResultsIterator; | 13 | +import pl.sgjp.morfeusz.Morfeusz; |
14 | +import pl.sgjp.morfeusz.MorfeuszUsage; | ||
15 | +import pl.sgjp.morfeusz.MorfeuszException; | ||
16 | +import pl.sgjp.morfeusz.MorphInterpretation; | ||
17 | +import pl.sgjp.morfeusz.ResultsIterator; | ||
18 | 18 | ||
19 | /** | 19 | /** |
20 | * | 20 | * |
morfeusz/wrappers/java/pl/waw/ipipan/morfeusz/app/App.java renamed to morfeusz/wrappers/java/pl/sgjp/morfeusz/app/App.java
1 | -package pl.waw.ipipan.morfeusz.app; | 1 | +package pl.sgjp.morfeusz.app; |
2 | 2 | ||
3 | -import pl.waw.ipipan.morfeusz.Morfeusz; | ||
4 | -import pl.waw.ipipan.morfeusz.MorfeuszUsage; | ||
5 | -import pl.waw.ipipan.morfeusz.ResultsIterator; | 3 | +import pl.sgjp.morfeusz.Morfeusz; |
4 | +import pl.sgjp.morfeusz.MorfeuszUsage; | ||
5 | +import pl.sgjp.morfeusz.ResultsIterator; | ||
6 | 6 | ||
7 | /** | 7 | /** |
8 | * Hello world! | 8 | * Hello world! |
morfeusz/wrappers/java/pl/waw/ipipan/morfeusz/app/MorfeuszUtils.java renamed to morfeusz/wrappers/java/pl/sgjp/morfeusz/app/MorfeuszUtils.java
1 | -package pl.waw.ipipan.morfeusz.app; | 1 | +package pl.sgjp.morfeusz.app; |
2 | 2 | ||
3 | import java.io.ByteArrayOutputStream; | 3 | import java.io.ByteArrayOutputStream; |
4 | import java.io.PrintStream; | 4 | import java.io.PrintStream; |
5 | -import pl.waw.ipipan.morfeusz.MorphInterpretation; | ||
6 | -import pl.waw.ipipan.morfeusz.Morfeusz; | 5 | +import pl.sgjp.morfeusz.MorphInterpretation; |
6 | +import pl.sgjp.morfeusz.Morfeusz; | ||
7 | 7 | ||
8 | /** | 8 | /** |
9 | * | 9 | * |
morfeusz/wrappers/morfeusz_java.i
@@ -135,6 +135,9 @@ import java.util.ArrayList; | @@ -135,6 +135,9 @@ import java.util.ArrayList; | ||
135 | %} | 135 | %} |
136 | 136 | ||
137 | %rename(_dictionarySearchPaths) morfeusz::Morfeusz::dictionarySearchPaths; | 137 | %rename(_dictionarySearchPaths) morfeusz::Morfeusz::dictionarySearchPaths; |
138 | +%rename(_getAvailableAgglOptions) morfeusz::Morfeusz::getAvailableAgglOptions; | ||
139 | +%rename(_getAvailablePraetOptions) morfeusz::Morfeusz::getAvailablePraetOptions; | ||
140 | + | ||
138 | %rename(_getLabels) morfeusz::IdResolver::getLabels; | 141 | %rename(_getLabels) morfeusz::IdResolver::getLabels; |
139 | %ignore morfeusz::FileFormatException; | 142 | %ignore morfeusz::FileFormatException; |
140 | 143 | ||
@@ -148,7 +151,7 @@ import java.util.ArrayList; | @@ -148,7 +151,7 @@ import java.util.ArrayList; | ||
148 | return $null; | 151 | return $null; |
149 | } | 152 | } |
150 | catch(morfeusz::MorfeuszException & e) { | 153 | catch(morfeusz::MorfeuszException & e) { |
151 | - jclass clazz = jenv->FindClass("pl/waw/ipipan/morfeusz/MorfeuszException"); | 154 | + jclass clazz = jenv->FindClass("pl/sgjp/morfeusz/MorfeuszException"); |
152 | jenv->ThrowNew(clazz, e.what()); | 155 | jenv->ThrowNew(clazz, e.what()); |
153 | return $null; | 156 | return $null; |
154 | } | 157 | } |
@@ -164,22 +167,6 @@ import java.util.ArrayList; | @@ -164,22 +167,6 @@ import java.util.ArrayList; | ||
164 | } | 167 | } |
165 | } | 168 | } |
166 | 169 | ||
167 | -//%javaexception("java.io.IOException") morfeusz::Morfeusz::setGeneratorDictionary { | ||
168 | -// try { | ||
169 | -// $action | ||
170 | -// } | ||
171 | -// catch(morfeusz::FileFormatException & e) { | ||
172 | -// jclass clazz = jenv->FindClass("java/io/IOException"); | ||
173 | -// jenv->ThrowNew(clazz, "Invalid file format"); | ||
174 | -// return $null; | ||
175 | -// } | ||
176 | -// catch(std::ios_base::failure & e) { | ||
177 | -// jclass clazz = jenv->FindClass("java/io/IOException"); | ||
178 | -// jenv->ThrowNew(clazz, e.what()); | ||
179 | -// return $null; | ||
180 | -// } | ||
181 | -//} | ||
182 | - | ||
183 | %javaexception("java.util.NoSuchElementException") morfeusz::ResultsIterator::next { | 170 | %javaexception("java.util.NoSuchElementException") morfeusz::ResultsIterator::next { |
184 | try { | 171 | try { |
185 | $action | 172 | $action |
@@ -196,7 +183,7 @@ import java.util.ArrayList; | @@ -196,7 +183,7 @@ import java.util.ArrayList; | ||
196 | $action | 183 | $action |
197 | } | 184 | } |
198 | catch(const morfeusz::MorfeuszException& e) { | 185 | catch(const morfeusz::MorfeuszException& e) { |
199 | - jclass clazz = jenv->FindClass("pl/waw/ipipan/morfeusz/MorfeuszException"); | 186 | + jclass clazz = jenv->FindClass("pl/sgjp/morfeusz/MorfeuszException"); |
200 | jenv->ThrowNew(clazz, e.what()); | 187 | jenv->ThrowNew(clazz, e.what()); |
201 | return $null; | 188 | return $null; |
202 | } | 189 | } |
@@ -272,6 +259,24 @@ import java.util.ArrayList; | @@ -272,6 +259,24 @@ import java.util.ArrayList; | ||
272 | public static List<String> getDictionarySearchPaths() { | 259 | public static List<String> getDictionarySearchPaths() { |
273 | return get_dictionarySearchPaths(); | 260 | return get_dictionarySearchPaths(); |
274 | } | 261 | } |
262 | + | ||
263 | + /** | ||
264 | + * Get list of possible agglutination rules. | ||
265 | + * | ||
266 | + * @return modifiable list of paths | ||
267 | + */ | ||
268 | + public List<String> getAvailableAgglOptions() { | ||
269 | + return java.util.Collections.unmodifiableList(_getAvailableAgglOptions()); | ||
270 | + } | ||
271 | + | ||
272 | + /** | ||
273 | + * Get list of possible past-tense segmentation rules. | ||
274 | + * | ||
275 | + * @return modifiable list of paths | ||
276 | + */ | ||
277 | + public List<String> getAvailablePraetOptions() { | ||
278 | + return java.util.Collections.unmodifiableList(_getAvailablePraetOptions()); | ||
279 | + } | ||
275 | %} | 280 | %} |
276 | 281 | ||
277 | %typemap(javacode) morfeusz::ResultsIterator %{ | 282 | %typemap(javacode) morfeusz::ResultsIterator %{ |
@@ -307,6 +312,8 @@ import java.util.ArrayList; | @@ -307,6 +312,8 @@ import java.util.ArrayList; | ||
307 | 312 | ||
308 | // should be overwritten by getDictionarySearchPaths() in typemap(javacode) | 313 | // should be overwritten by getDictionarySearchPaths() in typemap(javacode) |
309 | %javamethodmodifiers morfeusz::Morfeusz::dictionarySearchPaths "private"; | 314 | %javamethodmodifiers morfeusz::Morfeusz::dictionarySearchPaths "private"; |
315 | +%javamethodmodifiers morfeusz::Morfeusz::getAvailableAgglOptions "private"; | ||
316 | +%javamethodmodifiers morfeusz::Morfeusz::getAvailablePraetOptions "private"; | ||
310 | 317 | ||
311 | // should be overwritten by getLabels() in typemap(javacode) | 318 | // should be overwritten by getLabels() in typemap(javacode) |
312 | %javamethodmodifiers morfeusz::IdResolver::getLabels "private"; | 319 | %javamethodmodifiers morfeusz::IdResolver::getLabels "private"; |
morfeusz/wrappers/python/CMakeLists.txt
@@ -44,7 +44,7 @@ add_custom_target (build_python_wrapper | @@ -44,7 +44,7 @@ add_custom_target (build_python_wrapper | ||
44 | add_custom_target (pymorfeusz | 44 | add_custom_target (pymorfeusz |
45 | DEPENDS generate_python_wrapper generate_python_setup_file libmorfeusz build_python_wrapper) | 45 | DEPENDS generate_python_wrapper generate_python_setup_file libmorfeusz build_python_wrapper) |
46 | 46 | ||
47 | -if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") | 47 | +if (UNIX) |
48 | add_custom_target (install-python | 48 | add_custom_target (install-python |
49 | COMMAND python ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX} | 49 | COMMAND python ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX} |
50 | DEPENDS pymorfeusz | 50 | DEPENDS pymorfeusz |
@@ -55,20 +55,22 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") | @@ -55,20 +55,22 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") | ||
55 | ) | 55 | ) |
56 | set (PACKAGE_DEPENDS "package-python-bin") | 56 | set (PACKAGE_DEPENDS "package-python-bin") |
57 | 57 | ||
58 | - add_custom_target (package-python-deb-sdist | ||
59 | - COMMAND python ${SETUP_PY} --command-packages=stdeb.command sdist_dsc --depends "${CPACK_DEBIAN_PACKAGE_NAME}" --copyright-file "${PROJECT_SOURCE_DIR}/License.txt" | ||
60 | - DEPENDS pymorfeusz | ||
61 | - ) | ||
62 | - add_custom_target (package-python-deb-build | ||
63 | - COMMAND debuild -us -uc | ||
64 | - WORKING_DIRECTORY deb_dist/morfeusz2-${PYMORFEUSZ_VERSION} | ||
65 | - DEPENDS package-python-deb-sdist | ||
66 | - ) | ||
67 | - add_custom_target(package-python-deb | ||
68 | - COMMAND mkdir -p "${TARGET_DIR}" && cp ${CMAKE_CURRENT_BINARY_DIR}/deb_dist/python-morfeusz2*.deb "${TARGET_DIR}" | ||
69 | - DEPENDS package-python-deb-build | ||
70 | - ) | ||
71 | - list (APPEND PACKAGE_DEPENDS package-python-deb) | 58 | + if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
59 | + add_custom_target (package-python-deb-sdist | ||
60 | + COMMAND python ${SETUP_PY} --command-packages=stdeb.command sdist_dsc --depends "${CPACK_DEBIAN_PACKAGE_NAME}" --copyright-file "${PROJECT_SOURCE_DIR}/License.txt" | ||
61 | + DEPENDS pymorfeusz | ||
62 | + ) | ||
63 | + add_custom_target (package-python-deb-build | ||
64 | + COMMAND debuild -us -uc | ||
65 | + WORKING_DIRECTORY deb_dist/morfeusz2-${PYMORFEUSZ_VERSION} | ||
66 | + DEPENDS package-python-deb-sdist | ||
67 | + ) | ||
68 | + add_custom_target(package-python-deb | ||
69 | + COMMAND mkdir -p "${TARGET_DIR}" && cp ${CMAKE_CURRENT_BINARY_DIR}/deb_dist/python-morfeusz2*.deb "${TARGET_DIR}" | ||
70 | + DEPENDS package-python-deb-build | ||
71 | + ) | ||
72 | + list (APPEND PACKAGE_DEPENDS package-python-deb) | ||
73 | + endif () | ||
72 | add_custom_target (package-python | 74 | add_custom_target (package-python |
73 | DEPENDS pymorfeusz ${PACKAGE_DEPENDS}) | 75 | DEPENDS pymorfeusz ${PACKAGE_DEPENDS}) |
74 | elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND NOT CMAKE_CROSSCOMPILING) | 76 | elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND NOT CMAKE_CROSSCOMPILING) |
test-darwin.sh
@@ -5,7 +5,7 @@ set -exo pipefail | @@ -5,7 +5,7 @@ set -exo pipefail | ||
5 | cd morfeusz | 5 | cd morfeusz |
6 | echo 'Ala ma kota i żółć' | DYLD_LIBRARY_PATH=. ./morfeusz | 6 | echo 'Ala ma kota i żółć' | DYLD_LIBRARY_PATH=. ./morfeusz |
7 | cd ../jmorfeusz | 7 | cd ../jmorfeusz |
8 | -DYLD_LIBRARY_PATH=../morfeusz:. java -cp *.jar pl.waw.ipipan.morfeusz.app.App | 8 | +DYLD_LIBRARY_PATH=../morfeusz:. java -cp *.jar pl.sgjp.morfeusz.app.App |
9 | cd ../pymorfeusz | 9 | cd ../pymorfeusz |
10 | DYLD_LIBRARY_PATH=../morfeusz:. python test.py | 10 | DYLD_LIBRARY_PATH=../morfeusz:. python test.py |
11 | cd .. | 11 | cd .. |
testPythonWrapper.sh
@@ -2,5 +2,6 @@ | @@ -2,5 +2,6 @@ | ||
2 | echo "testing python wrapper" | 2 | echo "testing python wrapper" |
3 | PROJECT_BINARY_DIR=$1 | 3 | PROJECT_BINARY_DIR=$1 |
4 | export LD_LIBRARY_PATH="$PROJECT_BINARY_DIR/morfeusz:$PROJECT_BINARY_DIR/morfeusz/wrappers/python/build/lib.linux-x86_64-2.7" | 4 | export LD_LIBRARY_PATH="$PROJECT_BINARY_DIR/morfeusz:$PROJECT_BINARY_DIR/morfeusz/wrappers/python/build/lib.linux-x86_64-2.7" |
5 | -export PYTHONPATH="$PROJECT_BINARY_DIR/morfeusz/wrappers/python/build/lib.linux-x86_64-2.7" | 5 | +export PYTHONPATH=`find "$PROJECT_BINARY_DIR" -name _morfeusz2.so -print -quit | xargs dirname` |
6 | +echo $PYTHONPATH | ||
6 | python test.py | 7 | python test.py |