Commit 4d0979ef0e88d5160672828d2a4ad4e59a930628
Committed by
Marcin Woliński

1 parent
550a5fd1
zmiany dostosowujące do kompilacji na ubuntu 18 wraz z wrapperami dla obu pythonów
Showing
36 changed files
with
1067 additions
and
141 deletions
CMakeLists.txt
... | ... | @@ -132,9 +132,9 @@ endif () |
132 | 132 | ### Compilation and linking flags |
133 | 133 | |
134 | 134 | if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
135 | - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -Wall -pedantic -Wcast-align -Wextra -Wmissing-noreturn -Wconversion -Wcast-qual -Wcast-align -Wno-write-strings") | |
135 | + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic -Wcast-align -Wextra -Wmissing-noreturn -Wconversion -Wcast-qual -Wcast-align -Wno-write-strings") | |
136 | 136 | elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND CMAKE_CROSSCOMPILING) |
137 | - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -O2") | |
137 | + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O2") | |
138 | 138 | set (CMAKE_SHARED_LIBRARY_PREFIX "") |
139 | 139 | # here is some magic - must statically link libstdc++ and libgcc |
140 | 140 | # but exclude libgcc_eh.a as it causes "multiple definition of (...)" errors |
... | ... | @@ -184,7 +184,7 @@ endif () |
184 | 184 | include (CPack) |
185 | 185 | |
186 | 186 | ##### END initialize some vars ##### |
187 | -file (COPY fsabuilder doTest.sh testJavaWrapper.sh testPythonWrapper.sh morfeusz/wrappers/python/test.py DESTINATION .) | |
187 | +file (COPY fsabuilder doTest.sh testJavaWrapper.sh testPythonWrapper.sh morfeusz/wrappers/python2/test2.py morfeusz/wrappers/python3/test3.py DESTINATION .) | |
188 | 188 | |
189 | 189 | ###### add main sources ######## |
190 | 190 | |
... | ... |
buildAll.sh
... | ... | @@ -37,6 +37,8 @@ function build { |
37 | 37 | os=$1 |
38 | 38 | arch=$2 |
39 | 39 | embedded=$3 |
40 | + python_ver=$4 | |
41 | + shift | |
40 | 42 | shift |
41 | 43 | shift |
42 | 44 | shift |
... | ... | @@ -49,8 +51,9 @@ function build { |
49 | 51 | |
50 | 52 | echo "Will use $toolchain toolchain" |
51 | 53 | |
52 | - rm -rf $buildDir | |
54 | + # rm -rf $buildDir | |
53 | 55 | #~ rm -rf $targetDir |
56 | + rm -f $buildDir/CMakeCache.txt | |
54 | 57 | mkdir -p $buildDir |
55 | 58 | mkdir -p $targetDir |
56 | 59 | cd $buildDir |
... | ... | @@ -87,6 +90,7 @@ function build { |
87 | 90 | -D CPACK_GENERATOR=DEB \ |
88 | 91 | -D DICT_VERSION=$DICT_VERSION" |
89 | 92 | fi |
93 | + CMAKE_ARGS="$CMAKE_ARGS -D PY=$python_ver" | |
90 | 94 | cmake $CMAKE_ARGS $srcDir 2>&1 |
91 | 95 | echo "building $toolchain" >&2 |
92 | 96 | make |
... | ... | @@ -97,6 +101,11 @@ function build { |
97 | 101 | mv "$f" "`echo $f | sed -r 's/Linux-amd64.deb$/amd64.deb/' | sed -r 's/Linux-i386.deb/i386.deb/'`" |
98 | 102 | done |
99 | 103 | |
104 | + for f in `find "$targetDir" -name "*-Linux-*.egg"` | |
105 | + do | |
106 | + mv "$f" "`echo $f | sed -r 's/Linux-amd64.egg$/linux-x86_64.egg/' | sed -r 's/Linux-i386.egg$/linux-i686.egg/'`" | |
107 | + done | |
108 | + | |
100 | 109 | if [ "$os" = Linux -a "$embedded" = false ]; then |
101 | 110 | "$srcDir/createDictionaryDeb.sh" "$DICT_DIR" "${DEFAULT_DICT_NAME}" "${DICT_VERSION}" "${targetDir}" |
102 | 111 | fi |
... | ... | @@ -110,22 +119,161 @@ function log { |
110 | 119 | stdbuf -oL sed -e $"s/^/$os-$arch:\t/" | tee "log/$os-$arch.out" |
111 | 120 | } |
112 | 121 | |
122 | +function buildegg { | |
123 | + os=$1 | |
124 | + arch=$2 | |
125 | + embedded=$3 | |
126 | + python_ver=$4 | |
127 | + | |
128 | + srcDir=`pwd` | |
129 | + buildDir=buildall/$os-$arch-$embedded/morfeusz/wrappers/python$python_ver | |
130 | + if [ "$python_ver" = 2 ] | |
131 | + then | |
132 | + eggName=morfeusz2-0.4.0-py2.7 | |
133 | + eggDir=$buildDir/$eggName | |
134 | + pythonIncl=python27 | |
135 | + if [ "$os-$arch" == "Windows-amd64" ] | |
136 | + then | |
137 | + pythonDir=$CROSSMORFEUSZ_ROOT/windows64/Python27 | |
138 | + elif [ "$os-$arch" == "Windows-i386" ] | |
139 | + then | |
140 | + pythonDir=$CROSSMORFEUSZ_ROOT/windows32/Python27 | |
141 | + elif [ "$os-$arch" == "Linux-i386" ] | |
142 | + then | |
143 | + pythonDir=$CROSSMORFEUSZ_ROOT/linux32/python/include/python2.7 | |
144 | + elif [ "$os-$arch" == "Darwin-amd64" ] | |
145 | + then | |
146 | + pythonIncl=python2.7 | |
147 | + pythonDir=$CROSSMORFEUSZ_ROOT/darwin64/Python.framework/Headers | |
148 | + pythonLib=$CROSSMORFEUSZ_ROOT/darwin64/Python.framework/Versions/2.7/lib | |
149 | + fi | |
150 | + else | |
151 | + eggName=morfeusz2-0.4.0-py3.6 | |
152 | + eggDir=$buildDir/$eggName | |
153 | + pythonIncl=python36 | |
154 | + if [ "$os-$arch" == "Windows-amd64" ] | |
155 | + then | |
156 | + pythonDir=$CROSSMORFEUSZ_ROOT/windows64/Python36 | |
157 | + elif [ "$os-$arch" == "Windows-i386" ] | |
158 | + then | |
159 | + pythonDir=$CROSSMORFEUSZ_ROOT/windows32/Python36-32 | |
160 | + elif [ "$os-$arch" == "Linux-i386" ] | |
161 | + then | |
162 | + pythonDir=$CROSSMORFEUSZ_ROOT/linux32/python3/include/python3.4m | |
163 | + elif [ "$os-$arch" == "Darwin-amd64" ] | |
164 | + then | |
165 | + pythonIncl=python3.6 | |
166 | + pythonDir=$CROSSMORFEUSZ_ROOT/darwin64/Python3.framework/Versions/3.6/Headers | |
167 | + pythonLib=$CROSSMORFEUSZ_ROOT/darwin64/Python3.framework/Versions/3.6/lib | |
168 | + fi | |
169 | + fi | |
170 | + | |
171 | + targetDir=$srcDir/target | |
172 | + echo "$srcDir" | |
173 | + echo "$buildDir" | |
174 | + echo "$eggDir" | |
175 | + echo "$pythonDir" | |
176 | + if [ "$os-$arch" == "Windows-amd64" ] | |
177 | + then | |
178 | + gcc_command="x86_64-w64-mingw32-gcc -pthread -static-libgcc -static-libstdc++ -std=c++98 -DNDEBUG -DMS_WIN64 -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -fPIC -I$srcDir/morfeusz -I$buildDir/../../.. -I$pythonDir/include -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o" | |
179 | + echo "$gcc_command" | |
180 | + eval $gcc_command | |
181 | + gpp_command="x86_64-w64-mingw32-g++ -pthread -static-libgcc -static-libstdc++ -DMS_WIN64 -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security $buildDir/swigPYTHON.o -L$buildDir/../.. -L$pythonDir/libs -lmorfeusz2 -l$pythonIncl -o $eggDir/_morfeusz2.pyd" | |
182 | + echo "$gpp_command" | |
183 | + eval $gpp_command | |
184 | + elif [ "$os-$arch" == "Windows-i386" ] | |
185 | + then | |
186 | + gcc_command="i686-w64-mingw32-gcc -pthread -static-libgcc -static-libstdc++ -std=c++98 -DNDEBUG -DMS_WIN64 -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -fPIC -I$srcDir/morfeusz -I$buildDir/../../.. -I$pythonDir/include -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o" | |
187 | + echo "$gcc_command" | |
188 | + eval $gcc_command | |
189 | + gpp_command="i686-w64-mingw32-g++ -pthread -static-libgcc -static-libstdc++ -DMS_WIN64 -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security $buildDir/swigPYTHON.o -L$buildDir/../.. -L$pythonDir/libs -lmorfeusz2 -l$pythonIncl -o $eggDir/_morfeusz2.pyd" | |
190 | + echo "$gpp_command" | |
191 | + eval $gpp_command | |
192 | + elif [ "$os-$arch" == "Linux-i386" ] | |
193 | + then | |
194 | + gcc_command="x86_64-linux-gnu-gcc -m32 -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I$srcDir/morfeusz -I$buildDir/../../.. -I$pythonDir -I$pythonDir/.. -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o" | |
195 | + echo "$gcc_command" | |
196 | + eval $gcc_command | |
197 | + gpp_command="x86_64-linux-gnu-g++ -m32 -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 $buildDir/swigPYTHON.o -L$buildDir/../.. -lmorfeusz2 -o $eggDir/_morfeusz2.so" | |
198 | + echo "$gpp_command" | |
199 | + eval $gpp_command | |
200 | + elif [ "$os-$arch" == "Darwin-amd64" ] | |
201 | + then | |
202 | + gcc_command="/home/zil/crossmorfeusz/darwin64/x86_64-apple-darwin9/bin/x86_64-apple-darwin9-gcc -std=c++98 -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -O2 -Wformat -D_FORTIFY_SOURCE=2 -fPIC -I$srcDir/morfeusz -I$buildDir/../../.. -I$pythonDir -I$pythonDir/.. -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o" | |
203 | + echo "$gcc_command" | |
204 | + eval $gcc_command | |
205 | + gpp_command="/home/zil/crossmorfeusz/darwin64/x86_64-apple-darwin9/bin/x86_64-apple-darwin9-g++ -std=c++98 -Wall -O3 -DNDEBUG -dynamiclib -Wl,-headerpad_max_install_names -install_name _morfeusz2.so $buildDir/swigPYTHON.o -L$buildDir/../.. -L$pythonLib -lmorfeusz2 -l$pythonIncl -o $eggDir/_morfeusz2.so" | |
206 | + echo "$gpp_command" | |
207 | + eval $gpp_command | |
208 | + fi | |
209 | + | |
210 | + | |
211 | + if [ "$os" == "Windows" ] | |
212 | + then | |
213 | + cp $buildDir/../../morfeusz2.dll $eggDir/ | |
214 | + elif [ "$os" == "Linux" ] | |
215 | + then | |
216 | + cp $buildDir/../../libmorfeusz2.so $eggDir/ | |
217 | + elif [ "$os" == "Darwin" ] | |
218 | + then | |
219 | + cp $buildDir/../../libmorfeusz2.dylib $eggDir/ | |
220 | + fi | |
221 | + | |
222 | + cp $buildDir/morfeusz2.py $eggDir/ | |
223 | + cd $buildDir/$eggName | |
224 | + if [ "$os-$arch" == "Windows-amd64" ] | |
225 | + then | |
226 | + zip -r $eggName-win-amd64.zip ./* | |
227 | + cp $eggName-win-amd64.zip $targetDir/$eggName-win-amd64.egg | |
228 | + elif [ "$os-$arch" == "Windows-i386" ] | |
229 | + then | |
230 | + zip -r $eggName-win32.zip ./* | |
231 | + cp $eggName-win32.zip $targetDir/$eggName-win32.egg | |
232 | + elif [ "$os-$arch" == "Linux-i386" ] | |
233 | + then | |
234 | + zip -r $eggName-linux-i686.zip ./* | |
235 | + cp $eggName-linux-i686.zip $targetDir/$eggName-linux-i686.egg | |
236 | + elif [ "$os-$arch" == "Darwin-amd64" ] | |
237 | + then | |
238 | + zip -r $eggName-macosx-10.9-x86_64.zip ./* | |
239 | + cp $eggName-macosx-10.9-x86_64.zip $targetDir/$eggName-macosx-10.9-x86_64.egg | |
240 | + fi | |
241 | + | |
242 | +} | |
243 | + | |
113 | 244 | export -f build |
114 | 245 | export -f log |
246 | +export -f buildegg | |
115 | 247 | |
116 | -rm -rf log target | |
117 | -mkdir -p log | |
248 | +rm -rf log target buildall | |
249 | +mkdir -p log buildall | |
118 | 250 | |
119 | 251 | buildDictionaries 2>&1 | log All all |
120 | 252 | |
121 | 253 | { |
122 | - echo "build Linux amd64 true package package-java package-python package-builder 2>&1 | log Linux-tgz amd64" | |
123 | - echo "build Linux amd64 false lib-deb bin-deb dev-deb dictionary-deb java-deb 2>&1 | log Linux-deb amd64" | |
124 | - echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true package package-java 2>&1 | log Linux-tgz i386" | |
125 | - echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 false lib-deb bin-deb java-deb 2>&1 | log Linux-deb i386" | |
126 | - echo "build Windows amd64 true package package-java 2>&1 | log Windows amd64" | |
127 | - echo "build Windows i386 true package package-java 2>&1 | log Windows i386" | |
128 | - echo "build Darwin amd64 true package package-java 2>&1 | log Darwin amd64" | |
129 | -} | xargs -n1 -P2 -d$'\n' bash -c | |
254 | + # echo "build Linux amd64 true 2 package package-java package-python2 package-builder 2>&1 | log Linux-tgz2 amd64; \ | |
255 | + # build Linux amd64 true 3 package-python3 2>&1 | log Linux-tgz3 amd64" | |
256 | + # echo "build Linux amd64 false 0 lib-deb bin-deb dev-deb dictionary-deb java-deb 2>&1 | log Linux-deb amd64" | |
257 | + # echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true 2 package package-java py2morfeusz 2>&1 | log Linux-tgz i386; \ | |
258 | + # buildegg Linux i386 true 2 2>&1 | log Linux i386; \ | |
259 | + # LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true 3 py3morfeusz 2>&1 | log Linux-tgz i386; \ | |
260 | + # buildegg Linux i386 true 3 2>&1 | log Linux i386" | |
261 | + # echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 false 0 lib-deb bin-deb java-deb 2>&1 | log Linux-deb i386" | |
262 | + # echo "build Windows amd64 true 2 package package-java py2morfeusz 2>&1 | log Windows amd64; \ | |
263 | + # buildegg Windows amd64 true 2 2>&1 | log Windows amd64; \ | |
264 | + # build Windows amd64 true 3 py3morfeusz 2>&1 | log Windows amd64; \ | |
265 | + # buildegg Windows amd64 true 3 2>&1 | log Windows amd64" | |
266 | + # echo "build Windows i386 true 2 package package-java py2morfeusz 2>&1 | log Windows i386; \ | |
267 | + # buildegg Windows i386 true 2 2>&1 | log Windows i386; \ | |
268 | + # build Windows i386 true 3 py3morfeusz 2>&1 | log Windows i386 \ | |
269 | + # buildegg Windows i386 true 3 2>&1 | log Windows i386" | |
270 | + echo "build Darwin amd64 true 2 package package-java py2morfeusz 2>&1 | log Darwin amd64; \ | |
271 | + buildegg Darwin amd64 true 2 2>&1 | log Darwin amd64; \ | |
272 | + build Darwin amd64 true 3 py3morfeusz 2>&1 | log Darwin amd64; \ | |
273 | + buildegg Darwin amd64 true 3 2>&1 | log Darwin amd64" | |
274 | + # echo "build Darwin amd64 true 2 package package-java py2morfeusz 2>&1 | log Darwin amd64" | |
275 | + # echo "buildegg Darwin amd64 true 2 2>&1 | log Darwin amd64" | |
276 | + | |
277 | +} | xargs -n1 -P4 -d$'\n' bash -c | |
130 | 278 | |
131 | 279 | |
... | ... |
input/dodatki.tab
... | ... | @@ -51,8 +51,8 @@ boć boć comp |
51 | 51 | ; ; interp |
52 | 52 | … … interp |
53 | 53 | * * interp |
54 | -§ paragraf brev:npun | |
55 | -% procent brev:npun | |
54 | +§ § interp | |
55 | +% % interp | |
56 | 56 | “ “ interp |
57 | 57 | ' ' interp |
58 | 58 | ‘ ‘ interp |
... | ... | @@ -103,63 +103,34 @@ inż inżynier brev:pun |
103 | 103 | :-| :-| emo |
104 | 104 | >:-) >:-) emo |
105 | 105 | to to pred |
106 | -A A brev:pun | |
107 | 106 | a A brev:pun |
108 | -B B brev:pun | |
109 | 107 | b B brev:pun |
110 | -C C brev:pun | |
111 | 108 | c C brev:pun |
112 | -D D brev:pun | |
113 | 109 | d D brev:pun |
114 | -E E brev:pun | |
115 | 110 | e E brev:pun |
116 | -F F brev:pun | |
117 | 111 | f F brev:pun |
118 | -G G brev:pun | |
119 | 112 | g G brev:pun |
120 | -H H brev:pun | |
121 | 113 | h H brev:pun |
122 | -I I brev:pun | |
123 | 114 | i I brev:pun |
124 | -J J brev:pun | |
125 | 115 | j J brev:pun |
126 | -K K brev:pun | |
127 | 116 | k K brev:pun |
128 | -L L brev:pun | |
129 | 117 | l L brev:pun |
130 | -M M brev:pun | |
131 | 118 | m M brev:pun |
132 | -N N brev:pun | |
133 | 119 | n N brev:pun |
134 | -O O brev:pun | |
135 | 120 | o O brev:pun |
136 | -P P brev:pun | |
137 | 121 | p P brev:pun |
138 | -Q Q brev:pun | |
139 | 122 | q Q brev:pun |
140 | -R R brev:pun | |
141 | 123 | r R brev:pun |
142 | -S S brev:pun | |
143 | 124 | s S brev:pun |
144 | -T T brev:pun | |
145 | 125 | t T brev:pun |
146 | -U U brev:pun | |
147 | 126 | u U brev:pun |
148 | -V V brev:pun | |
149 | 127 | v V brev:pun |
150 | -W W brev:pun | |
151 | 128 | w W brev:pun |
152 | -X X brev:pun | |
153 | 129 | x X brev:pun |
154 | -Y Y brev:pun | |
155 | 130 | y Y brev:pun |
156 | -Z Z brev:pun | |
157 | 131 | z Z brev:pun |
158 | -Ż Ż brev:pun | |
159 | 132 | ż Ż brev:pun |
160 | -Ch Ch brev:pun | |
161 | 133 | ch Ch brev:pun |
162 | -St St brev:pun | |
163 | 134 | st St brev:pun |
164 | 135 | aero aero+ prefa |
165 | 136 | aero aero+ prefs |
... | ... |
input/segmenty.dat
... | ... | @@ -221,7 +221,8 @@ moze_interp( nie > dywiz > subst ) !weak |
221 | 221 | moze_interp( cyfry ) |
222 | 222 | |
223 | 223 | # Liczby zawierające kropki lub przecinki wewnątrz: |
224 | -moze_interp( (cyfry > (kropka|przecinek) >)+ cyfry ) | |
224 | +moze_interp( cyfry > ((kropka|przecinek) > cyfry)>+ ) | |
225 | + | |
225 | 226 | |
226 | 227 | # Liczby rzymskie |
227 | 228 | #define one_to_three(rdig) (rdig>{0,2} rdig) |
... | ... |
morfeusz/IdResolverImpl.cpp
... | ... | @@ -54,6 +54,10 @@ namespace morfeusz { |
54 | 54 | charsetConverter(&UTF8CharsetConverter::getInstance()) { |
55 | 55 | |
56 | 56 | } |
57 | + | |
58 | + IdResolverImpl::~IdResolverImpl(){ | |
59 | + | |
60 | + } | |
57 | 61 | |
58 | 62 | IdResolverImpl::IdResolverImpl(const unsigned char* ptr, const CharsetConverter* charsetConverter) |
59 | 63 | : tagsetId(), |
... | ... |
morfeusz/IdResolverImpl.hpp
... | ... | @@ -22,6 +22,8 @@ namespace morfeusz { |
22 | 22 | IdResolverImpl(const unsigned char* ptr, const CharsetConverter* charsetConverter); |
23 | 23 | |
24 | 24 | IdResolverImpl(); |
25 | + | |
26 | + ~IdResolverImpl(); | |
25 | 27 | |
26 | 28 | void setCharsetConverter(const CharsetConverter* charsetConverter); |
27 | 29 | |
... | ... | @@ -41,8 +43,8 @@ namespace morfeusz { |
41 | 43 | size_t getNamesCount() const; |
42 | 44 | size_t getLabelsCount() const; |
43 | 45 | |
44 | - virtual ~IdResolverImpl() { | |
45 | - } | |
46 | + // virtual ~IdResolverImpl() { | |
47 | + // } | |
46 | 48 | |
47 | 49 | struct IdStringMapping { |
48 | 50 | std::vector<std::string> id2String; |
... | ... |
morfeusz/wrappers/CMakeLists.txt
1 | 1 | add_subdirectory (java) |
2 | -add_subdirectory (python) | |
3 | -add_subdirectory (perl) | |
4 | 2 | \ No newline at end of file |
3 | +add_subdirectory (perl) | |
4 | + | |
5 | +if (${PY}) | |
6 | + if(${PY} EQUAL "2") | |
7 | + add_subdirectory (python2) | |
8 | + elseif(${PY} EQUAL "3") | |
9 | + add_subdirectory (python3) | |
10 | + endif() | |
11 | +endif() | |
5 | 12 | \ No newline at end of file |
... | ... |
morfeusz/wrappers/morfeusz.i
morfeusz/wrappers/morfeusz_java.i
... | ... | @@ -21,7 +21,7 @@ namespace std { |
21 | 21 | %rename(isEmpty) empty; |
22 | 22 | bool empty() const; |
23 | 23 | void clear(); |
24 | - void push_back(const value_type& x); | |
24 | + //void push_back(const value_type& x); | |
25 | 25 | %extend { |
26 | 26 | const_reference get(int32_t i) const throw (std::out_of_range) { |
27 | 27 | return $self->at(i); |
... | ... | @@ -34,6 +34,10 @@ namespace std { |
34 | 34 | void add(int32_t i, const value_type& VECTOR_VALUE_IN) { |
35 | 35 | $self->insert($self->begin() + i, VECTOR_VALUE_IN); |
36 | 36 | } |
37 | + bool add(const value_type& VECTOR_VALUE_IN) { | |
38 | + $self->push_back(VECTOR_VALUE_IN); | |
39 | + return true; | |
40 | + } | |
37 | 41 | int32_t size() const { |
38 | 42 | return $self->size(); |
39 | 43 | } |
... | ... | @@ -75,6 +79,11 @@ namespace std { |
75 | 79 | $self->insert(it, VECTOR_VALUE_IN); |
76 | 80 | } |
77 | 81 | |
82 | + bool add(const value_type& VECTOR_VALUE_IN) { | |
83 | + $self->push_back(VECTOR_VALUE_IN); | |
84 | + return true; | |
85 | + } | |
86 | + | |
78 | 87 | value_type remove(int32_t i, const value_type& VECTOR_VALUE_IN) throw (std::out_of_range) { |
79 | 88 | std::list<T>::iterator it = $self->begin(); |
80 | 89 | std::advance(it, i); |
... | ... |
morfeusz/wrappers/morfeusz_python.i renamed to morfeusz/wrappers/morfeusz_python2.i
morfeusz/wrappers/morfeusz_python3.i
0 → 100644
1 | + | |
2 | +%exception { | |
3 | + try{ | |
4 | + $action | |
5 | + } | |
6 | + catch(const std::ios_base::failure& e) { | |
7 | + SWIG_exception(SWIG_IOError, const_cast<char*>(e.what())); | |
8 | + } | |
9 | + catch(const morfeusz::FileFormatException& e) { | |
10 | + SWIG_exception(SWIG_IOError, const_cast<char*>(e.what())); | |
11 | + } | |
12 | + catch(const std::invalid_argument& e) { | |
13 | + SWIG_exception(SWIG_ValueError, const_cast<char*>(e.what())); | |
14 | + } | |
15 | + catch(const std::exception& e) { | |
16 | + SWIG_exception(SWIG_RuntimeError, const_cast<char*>(e.what())); | |
17 | + } | |
18 | + catch(const std::string& e) { | |
19 | + SWIG_exception(SWIG_RuntimeError, const_cast<char*>(e.c_str())); | |
20 | + } | |
21 | + catch(...) { | |
22 | + SWIG_exception(SWIG_RuntimeError, "Unknown exception"); | |
23 | + } | |
24 | +} | |
25 | + | |
26 | +%exception morfeusz::Morfeusz::setDictionary { | |
27 | + try{ | |
28 | + $action | |
29 | + } | |
30 | + catch(const std::ios_base::failure& e) { | |
31 | + SWIG_exception(SWIG_IOError, const_cast<char*>(e.what())); | |
32 | + } | |
33 | + catch(const morfeusz::MorfeuszException& e) { | |
34 | + SWIG_exception(SWIG_IOError, const_cast<char*>(e.what())); | |
35 | + } | |
36 | + catch(const std::invalid_argument& e) { | |
37 | + SWIG_exception(SWIG_ValueError, const_cast<char*>(e.what())); | |
38 | + } | |
39 | + catch(const std::string& e) { | |
40 | + SWIG_exception(SWIG_RuntimeError, const_cast<char*>(e.c_str())); | |
41 | + } | |
42 | + catch(...) { | |
43 | + SWIG_exception(SWIG_RuntimeError, "Unknown exception"); | |
44 | + } | |
45 | +} | |
46 | + | |
47 | +%ignore morfeusz::MorfeuszException; | |
48 | +%ignore morfeusz::FileFormatException; | |
49 | + | |
50 | +%rename (_generateByTagId) morfeusz::Morfeusz::generate(const std::string&, int, std::vector<std::string>&); | |
51 | + | |
52 | +%extend morfeusz::ResultsIterator { | |
53 | + morfeusz::ResultsIterator& morfeusz::ResultsIterator::__iter__() { | |
54 | + return *($self); | |
55 | + } | |
56 | +}; | |
57 | + | |
58 | +%rename (_Morfeusz) morfeusz::Morfeusz; | |
59 | + | |
60 | +//%ignore morfeusz::Morfeusz::createInstance(morfeusz::MorfeuszUsage); | |
61 | +%extend morfeusz::Morfeusz { | |
62 | + std::vector<morfeusz::MorphInterpretation> morfeusz::Morfeusz::_generateByTagId(const std::string& lemma, int tagId) const { | |
63 | + std::vector<morfeusz::MorphInterpretation> res; | |
64 | + $self->generate(lemma, tagId, res); | |
65 | + return res; | |
66 | + } | |
67 | +}; | |
68 | + | |
69 | +%feature("shadow") morfeusz::ResultsIterator::next %{ | |
70 | +def next(self): | |
71 | + if self.hasNext(): | |
72 | + return $action(self) | |
73 | + else: | |
74 | + raise StopIteration | |
75 | +%} | |
76 | + | |
77 | +%feature("shadow") morfeusz::Morfeusz::_analyseAsIterator %{ | |
78 | + | |
79 | +def analyse_iter(self, text): | |
80 | + """ | |
81 | + Analyse given text and return an iterator over MorphInterpretation objects as a result. | |
82 | + """ | |
83 | + return $action(self, text) | |
84 | +%} | |
85 | + | |
86 | +%feature("shadow") morfeusz::Morfeusz::analyse %{ | |
87 | +def analyse(self, text): | |
88 | + """ | |
89 | + Analyse given text and return a list of MorphInterpretation objects. | |
90 | + """ | |
91 | + res = InterpsList() | |
92 | + $action(self, text, res) | |
93 | + return res | |
94 | +%} | |
95 | + | |
96 | +%feature("shadow") morfeusz::Morfeusz::setAggl %{ | |
97 | +def setAggl(self, optionString): | |
98 | + """ | |
99 | + Select agglutination rules option | |
100 | + """ | |
101 | + $action(self, optionString) | |
102 | +%} | |
103 | + | |
104 | +%feature("shadow") morfeusz::Morfeusz::setPraet %{ | |
105 | +def setPraet(self, optionString): | |
106 | + """ | |
107 | + Select past tense segmentation | |
108 | + """ | |
109 | + $action(self, optionString) | |
110 | +%} | |
111 | + | |
112 | +%feature("shadow") morfeusz::Morfeusz::setCaseHandling %{ | |
113 | +def setCaseHandling(self, option): | |
114 | + """ | |
115 | + Set case handling option (valid options are CONDITIONALLY_CASE_SENSITIVE, STRICTLY_CASE_SENSITIVE, IGNORE_CASE) | |
116 | + """ | |
117 | + $action(self, option) | |
118 | +%} | |
119 | + | |
120 | +%feature("shadow") morfeusz::Morfeusz::setTokenNumbering %{ | |
121 | +def setTokenNumbering(self, option): | |
122 | + """ | |
123 | + Set token numbering option (valid options are SEPARATE_NUMBERING, CONTINUOUS_NUMBERING) | |
124 | + """ | |
125 | + $action(self, option) | |
126 | +%} | |
127 | + | |
128 | +%feature("shadow") morfeusz::Morfeusz::setWhitespaceHandling %{ | |
129 | +def setWhitespaceHandling(self, option): | |
130 | + """ | |
131 | + Set whitespace handling handling option (valid options are SKIP_WHITESPACES, KEEP_WHITESPACES, APPEND_WHITESPACES) | |
132 | + """ | |
133 | + $action(self, option) | |
134 | +%} | |
135 | + | |
136 | +%feature("shadow") morfeusz::Morfeusz::setDictionary %{ | |
137 | +def setDictionary(self, dictName): | |
138 | + """ | |
139 | + Set dictionary to be used by this instance (by name) | |
140 | + """ | |
141 | + $action(self, dictName) | |
142 | +%} | |
143 | + | |
144 | +%feature("shadow") morfeusz::Morfeusz::createInstance(morfeusz::MorfeuszUsage) %{ | |
145 | +@staticmethod | |
146 | +def _createInstance(usage): | |
147 | + return $action(usage) | |
148 | +%} | |
149 | + | |
150 | +%feature("shadow") morfeusz::Morfeusz::createInstance(const std::string&, morfeusz::MorfeuszUsage) %{ | |
151 | +@staticmethod | |
152 | +def createInstance(dictName=None, usage=BOTH_ANALYSE_AND_GENERATE): | |
153 | + """ | |
154 | + Creates new instance of Morfeusz class. Usage may be BOTH_ANALYZE_AND_GENERATE (default), ONLY_ANALYSE and ONLY_GENERATE. | |
155 | + """ | |
156 | + if dictName is None: | |
157 | + return Morfeusz._createInstance(usage) | |
158 | + else: | |
159 | + return $action(dictName, usage) | |
160 | +%} | |
161 | + | |
162 | +%feature("shadow") morfeusz::Morfeusz::_generateByTagId %{ | |
163 | +def _generateByTagId(self, lemma, tagId): | |
164 | + res = InterpsList() | |
165 | + $action(self, lemma, tagId, res) | |
166 | + return res | |
167 | +%} | |
168 | + | |
169 | +%feature("shadow") morfeusz::Morfeusz::generate %{ | |
170 | +def generate(self, lemma, tagId=None): | |
171 | + """ | |
172 | + Perform morphological synthesis on given text and return a list of MorphInterpretation objects. | |
173 | + """ | |
174 | + if tagId is not None: | |
175 | + return self._generateByTagId(lemma, tagId) | |
176 | + else: | |
177 | + res = InterpsList() | |
178 | + $action(self, lemma, res) | |
179 | + return res | |
180 | +%} | |
181 | + | |
182 | +%rename (_orth) morfeusz::MorphInterpretation::orth; | |
183 | + | |
184 | +%extend morfeusz::MorphInterpretation { | |
185 | + %pythoncode %{ | |
186 | + @property | |
187 | + def orth(self): | |
188 | + return self._orth | |
189 | + | |
190 | + @orth.setter | |
191 | + def orth(self, val): | |
192 | + self._orth = val | |
193 | + %} | |
194 | +}; | |
195 | + | |
196 | +%rename (_lemma) morfeusz::MorphInterpretation::lemma; | |
197 | + | |
198 | +%extend morfeusz::MorphInterpretation { | |
199 | + %pythoncode %{ | |
200 | + @property | |
201 | + def lemma(self): | |
202 | + return self._lemma | |
203 | + | |
204 | + @lemma.setter | |
205 | + def lemma(self, val): | |
206 | + self._lemma = val | |
207 | + %} | |
208 | +}; | |
209 | + | |
210 | +%feature("shadow") morfeusz::MorphInterpretation::getTag %{ | |
211 | +def getTag(self, morfeusz): | |
212 | + """ | |
213 | + Returns tag as string. | |
214 | + """ | |
215 | + return $action(self, morfeusz) | |
216 | +%} | |
217 | + | |
218 | +%feature("shadow") morfeusz::MorphInterpretation::getName %{ | |
219 | +def getName(self, morfeusz): | |
220 | + """ | |
221 | + Returns this interpretation named entity as unicode | |
222 | + """ | |
223 | + name = $action(self, morfeusz) | |
224 | + return name.split('|') if name else [] | |
225 | +%} | |
226 | + | |
227 | +%feature("shadow") morfeusz::MorphInterpretation::getLabelsAsString %{ | |
228 | +def getLabelsAsUnicode(self, morfeusz): | |
229 | + """ | |
230 | + Returns this interpretation labels as string | |
231 | + """ | |
232 | + return $action(self, morfeusz) | |
233 | +%} | |
234 | + | |
235 | +%feature("shadow") morfeusz::MorphInterpretation::getLabels %{ | |
236 | +def getLabels(self, morfeusz): | |
237 | + """ | |
238 | + Returns this interpretation labels as a list of strings | |
239 | + """ | |
240 | + return [l for l in $action(self, morfeusz)] | |
241 | +%} | |
242 | + | |
243 | +%feature("shadow") morfeusz::MorphInterpretation::createIgn %{ | |
244 | +@staticmethod | |
245 | +def createIgn(startNode, endNode, orth, lemma): | |
246 | + """ | |
247 | + Creates unknown interpretation | |
248 | + """ | |
249 | + return $action(self, startNode, endNode, orth, lemma) | |
250 | +%} | |
251 | + | |
252 | +%feature("shadow") morfeusz::MorphInterpretation::createWhitespace %{ | |
253 | +@staticmethod | |
254 | +def createWhitespace(startNode, endNode, orth): | |
255 | + """ | |
256 | + Creates whitespace interpretation | |
257 | + """ | |
258 | + return $action(self, startNode, endNode, orth) | |
259 | +%} | |
260 | + | |
261 | +%feature("shadow") morfeusz::IdResolver::getTag %{ | |
262 | +def getTag(self, tagId): | |
263 | + return $action(self, tagId) | |
264 | +%} | |
265 | + | |
266 | +%feature("shadow") morfeusz::IdResolver::getTagId %{ | |
267 | +def getTagId(self, tag): | |
268 | + return $action(self, tag) | |
269 | +%} | |
270 | + | |
271 | +%feature("shadow") morfeusz::IdResolver::getName %{ | |
272 | +def getName(self, nameId): | |
273 | + return $action(self, nameId) | |
274 | +%} | |
275 | + | |
276 | +%feature("shadow") morfeusz::IdResolver::getNameId %{ | |
277 | +def getNameId(self, name): | |
278 | + return $action(self, name) | |
279 | +%} | |
280 | + | |
281 | +%feature("shadow") morfeusz::IdResolver::getLabelsAsString %{ | |
282 | +def getLabelsAsUnicode(self, labelsId): | |
283 | + return $action(self, labelsId) | |
284 | +%} | |
285 | + | |
286 | +%feature("shadow") morfeusz::IdResolver::getLabels %{ | |
287 | +def getLabels(self, labelsId): | |
288 | + return [l for l in $action(self, labelsId)] | |
289 | +%} | |
290 | + | |
291 | +%feature("shadow") morfeusz::IdResolver::getLabelsId %{ | |
292 | +def getLabelsId(self, labelsStr): | |
293 | + return $action(self, labelsStr) | |
294 | +%} | |
295 | + | |
296 | +%pythoncode %{ | |
297 | +import collections | |
298 | +import os.path | |
299 | + | |
300 | +# skopiowane, bo kod sie wkleja na poczatku zamiast na koncu | |
301 | +CONTINUOUS_NUMBERING = _morfeusz2.CONTINUOUS_NUMBERING | |
302 | +CONDITIONALLY_CASE_SENSITIVE = _morfeusz2.CONDITIONALLY_CASE_SENSITIVE | |
303 | +SKIP_WHITESPACES = _morfeusz2.SKIP_WHITESPACES | |
304 | +ANALYSE_ONLY = _morfeusz2.ANALYSE_ONLY | |
305 | +GENERATE_ONLY = _morfeusz2.GENERATE_ONLY | |
306 | +BOTH_ANALYSE_AND_GENERATE = _morfeusz2.BOTH_ANALYSE_AND_GENERATE | |
307 | + | |
308 | +__version__ = _morfeusz2._Morfeusz_getVersion() | |
309 | + | |
310 | +__copyright__ = _morfeusz2._Morfeusz_getCopyright() | |
311 | + | |
312 | +GENDERS = ['m1', 'm2', 'm3', 'f', 'n'] | |
313 | + | |
314 | + | |
315 | +class Morfeusz(_object): | |
316 | + def __init__(self, dict_name=None, dict_path=None, | |
317 | + analyse=True, generate=True, expand_dag=False, | |
318 | + expand_tags=False, expand_dot=True, expand_underscore=True, | |
319 | + aggl=None, praet=None, separate_numbering=True, | |
320 | + case_handling=CONDITIONALLY_CASE_SENSITIVE, | |
321 | + whitespace=SKIP_WHITESPACES): | |
322 | + """ | |
323 | + case_handling options: | |
324 | + CONDITIONALLY_CASE_SENSITIVE, STRICTLY_CASE_SENSITIVE, IGNORE_CASE | |
325 | + whitespace options: | |
326 | + SKIP_WHITESPACES, KEEP_WHITESPACES, APPEND_WHITESPACES | |
327 | + """ | |
328 | + if analyse and generate: | |
329 | + usage = BOTH_ANALYSE_AND_GENERATE | |
330 | + elif analyse: | |
331 | + usage = ANALYSE_ONLY | |
332 | + elif generate: | |
333 | + usage = GENERATE_ONLY | |
334 | + else: | |
335 | + raise ValueError( | |
336 | + 'At least one of "analyse" and "generate" must be True') | |
337 | + self.expand_dag = expand_dag | |
338 | + self.expand_tags = expand_tags | |
339 | + self.expand_dot = expand_dot | |
340 | + self.expand_underscore = expand_underscore | |
341 | + if dict_path: | |
342 | + self.add_dictionary_path(dict_path) | |
343 | + if dict_name: | |
344 | + m = _Morfeusz.createInstance(dict_name, usage) | |
345 | + else: | |
346 | + m = _Morfeusz.createInstance(usage) | |
347 | + self._morfeusz_obj = m | |
348 | + if aggl: | |
349 | + m.setAggl(aggl) | |
350 | + if praet: | |
351 | + m.setPraet(praet) | |
352 | + if not separate_numbering: | |
353 | + m.setTokenNumbering(CONTINUOUS_NUMBERING) | |
354 | + m.setCaseHandling(case_handling) | |
355 | + m.setWhitespaceHandling(whitespace) | |
356 | + | |
357 | + def add_dictionary_path(self, dict_path): | |
358 | + dict_paths = _morfeusz2._Morfeusz_dictionarySearchPaths_get() | |
359 | + if dict_path not in dict_paths: | |
360 | + _morfeusz2._Morfeusz_dictionarySearchPaths_set( | |
361 | + (dict_path,) + dict_paths) | |
362 | + | |
363 | + def _expand_tag(self, tag): | |
364 | + chunks = [ | |
365 | + GENDERS if chunk == '_' and self.expand_underscore | |
366 | + else chunk.split('.') | |
367 | + for chunk in tag.split(':') | |
368 | + ] | |
369 | + | |
370 | + if not self.expand_dot: | |
371 | + yield ':'.join('.'.join(values) for values in chunks) | |
372 | + return | |
373 | + | |
374 | + def expand_chunks(i): | |
375 | + if i >= len(chunks): | |
376 | + yield () | |
377 | + else: | |
378 | + tail = tuple(expand_chunks(i + 1)) | |
379 | + for chunk_variant in chunks[i]: | |
380 | + for tail_variant in tail: | |
381 | + yield (chunk_variant,) + tail_variant | |
382 | + | |
383 | + for x in expand_chunks(0): | |
384 | + yield ':'.join(x) | |
385 | + | |
386 | + def _expand_interp(self, interp): | |
387 | + tags = self._expand_tag(interp[2]) | |
388 | + for tag in tags: | |
389 | + yield (interp[0], interp[1], tag, interp[3], interp[4]) | |
390 | + | |
391 | + @staticmethod | |
392 | + def _dag_to_list(interps): | |
393 | + dag = collections.defaultdict(list) | |
394 | + for start, end, interp in interps: | |
395 | + dag[start].append((interp, end)) | |
396 | + def expand_dag(start): | |
397 | + nexts = dag[start] | |
398 | + if not nexts: | |
399 | + yield [] | |
400 | + else: | |
401 | + for head, end in nexts: | |
402 | + for tail in expand_dag(end): | |
403 | + yield [head] + tail | |
404 | + return list(expand_dag(0)) | |
405 | + | |
406 | + def _interp2tuple(self, i): | |
407 | + m = self._morfeusz_obj | |
408 | + return i.orth, i.lemma, i.getTag(m), i.getName(m), i.getLabels(m) | |
409 | + | |
410 | + def analyse(self, text): | |
411 | + m = self._morfeusz_obj | |
412 | + interps = m.analyse(text) | |
413 | + interp_tuples = [ | |
414 | + (i.startNode, i.endNode, self._interp2tuple(i)) for i in interps] | |
415 | + | |
416 | + def expand_interps(): | |
417 | + for start, end, interp in interp_tuples: | |
418 | + for exp_interp in self._expand_interp(interp): | |
419 | + yield start, end, exp_interp | |
420 | + | |
421 | + if self.expand_tags: | |
422 | + interp_tuples = list(expand_interps()) | |
423 | + if self.expand_dag: | |
424 | + interp_tuples = self._dag_to_list(interp_tuples) | |
425 | + return interp_tuples | |
426 | + | |
427 | + def generate(self, lemma, tag_id=None): | |
428 | + m = self._morfeusz_obj | |
429 | + interps = m.generate(lemma, tag_id) | |
430 | + interp_tuples = [self._interp2tuple(i) for i in interps] | |
431 | + | |
432 | + def expand_interps(): | |
433 | + for interp in interp_tuples: | |
434 | + for exp_interp in self._expand_interp(interp): | |
435 | + yield exp_interp | |
436 | + | |
437 | + if self.expand_tags: | |
438 | + interp_tuples = list(expand_interps()) | |
439 | + return interp_tuples | |
440 | + | |
441 | + def dict_id(self): | |
442 | + return self._morfeusz_obj.getDictID() | |
443 | + | |
444 | + def dict_copyright(self): | |
445 | + return self._morfeusz_obj.getDictCopyright() | |
446 | +%} | |
447 | + | |
448 | +%include "std_vector.i" | |
449 | +%include "std_string.i" | |
450 | +%include "std_list.i" | |
451 | +%include "std_set.i" | |
452 | +%include "std_except.i" | |
453 | +%include "exception.i" | |
454 | +%include "typemaps.i" | |
... | ... |
morfeusz/wrappers/morfeuszpy2.i
0 → 100644
1 | + | |
2 | +// XXX | |
3 | +// set module name with preprocessor | |
4 | +// because Mac OS X doesn't seem to recognize jniclassname option | |
5 | +#ifdef SWIGJAVA | |
6 | +%module(allprotected="1") MorfeuszWrapper | |
7 | +#else | |
8 | +%module(allprotected="1") morfeusz2 | |
9 | +#endif | |
10 | + | |
11 | +//%feature("autodoc", "2"); | |
12 | +%{ | |
13 | +#include "morfeusz2.h" | |
14 | +#include "MorfeuszImpl.hpp" | |
15 | +#include <vector> | |
16 | +#include <list> | |
17 | +%} | |
18 | + | |
19 | +#ifdef SWIGJAVA | |
20 | +%include "morfeusz_java.i" | |
21 | +#endif | |
22 | + | |
23 | +#ifdef SWIGPYTHON | |
24 | +%include "morfeusz_python2.i" | |
25 | +#endif | |
26 | + | |
27 | + | |
28 | + | |
29 | +#ifdef SWIGPERL | |
30 | +%include "morfeusz_perl.i" | |
31 | +#endif | |
32 | + | |
33 | +%include "morfeusz_common.i" | |
34 | + | |
35 | +%include "../morfeusz2.h" | |
... | ... |
morfeusz/wrappers/morfeuszpy3.i
0 → 100644
1 | + | |
2 | +// XXX | |
3 | +// set module name with preprocessor | |
4 | +// because Mac OS X doesn't seem to recognize jniclassname option | |
5 | +#ifdef SWIGJAVA | |
6 | +%module(allprotected="1") MorfeuszWrapper | |
7 | +#else | |
8 | +%module(allprotected="1") morfeusz2 | |
9 | +#endif | |
10 | + | |
11 | +//%feature("autodoc", "2"); | |
12 | +%{ | |
13 | +#include "morfeusz2.h" | |
14 | +#include "MorfeuszImpl.hpp" | |
15 | +#include <vector> | |
16 | +#include <list> | |
17 | +%} | |
18 | + | |
19 | +#ifdef SWIGJAVA | |
20 | +%include "morfeusz_java.i" | |
21 | +#endif | |
22 | + | |
23 | +#ifdef SWIGPYTHON | |
24 | +%include "morfeusz_python3.i" | |
25 | +#endif | |
26 | + | |
27 | + | |
28 | + | |
29 | +#ifdef SWIGPERL | |
30 | +%include "morfeusz_perl.i" | |
31 | +#endif | |
32 | + | |
33 | +%include "morfeusz_common.i" | |
34 | + | |
35 | +%include "../morfeusz2.h" | |
... | ... |
morfeusz/wrappers/python/CMakeLists.txt deleted
1 | - | |
2 | -# SWIG | |
3 | -#set(CMAKE_SWIG_OUTDIR swig) | |
4 | -#~ FIND_PACKAGE (SWIG REQUIRED) | |
5 | -FIND_PACKAGE (PythonLibs) | |
6 | -#~ INCLUDE (${SWIG_USE_FILE}) | |
7 | - | |
8 | -set (PYMORFEUSZ_VERSION "0.4.0") | |
9 | - | |
10 | -# SWIG Java | |
11 | -INCLUDE_DIRECTORIES (${PYTHON_INCLUDE_PATH}) | |
12 | -INCLUDE_DIRECTORIES (../..) | |
13 | - | |
14 | - | |
15 | -set (SWIG_PYTHON_OUTFILE_CXX "${CMAKE_CURRENT_BINARY_DIR}/swigPYTHON.cpp") | |
16 | -set (SWIG_PYTHON_OUTFILE_PY "${CMAKE_CURRENT_BINARY_DIR}/morfeusz2.py") | |
17 | -add_custom_command ( | |
18 | - OUTPUT "${SWIG_PYTHON_OUTFILE_CXX}" "${SWIG_PYTHON_OUTFILE_PY}" | |
19 | - COMMAND swig -python -c++ -o "${SWIG_PYTHON_OUTFILE_CXX}" "${CMAKE_SOURCE_DIR}/morfeusz/wrappers/morfeusz.i" | |
20 | - DEPENDS libmorfeusz | |
21 | -) | |
22 | -add_custom_target (generate_python_wrapper ALL | |
23 | - DEPENDS "${SWIG_PYTHON_OUTFILE_CXX}" "${SWIG_PYTHON_OUTFILE_PY}") | |
24 | - | |
25 | -set (SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in") | |
26 | -set (SETUP_PY_TMP "${CMAKE_CURRENT_BINARY_DIR}/setupTmp.py") | |
27 | -set (SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py") | |
28 | -set (DEPS "${SWIG_PYTHON_OUTFILE_CXX}" "${SWIG_PYTHON_OUTFILE_PY}") | |
29 | -set (OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build") | |
30 | - | |
31 | -configure_file (${SETUP_PY_IN} ${SETUP_PY}) | |
32 | - | |
33 | -add_custom_target (generate_python_setup_file | |
34 | - DEPENDS ${SETUP_PY}) | |
35 | - | |
36 | -add_custom_command (OUTPUT ${OUTPUT} | |
37 | - COMMAND python | |
38 | - ARGS ${SETUP_PY} build | |
39 | - DEPENDS generate_python_wrapper generate_python_setup_file libmorfeusz) | |
40 | - | |
41 | -add_custom_target (build_python_wrapper | |
42 | - DEPENDS ${OUTPUT}) | |
43 | - | |
44 | -add_custom_target (pymorfeusz | |
45 | - DEPENDS generate_python_wrapper generate_python_setup_file libmorfeusz build_python_wrapper) | |
46 | - | |
47 | -if (UNIX) | |
48 | - add_custom_target (install-python | |
49 | - COMMAND python ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX} | |
50 | - DEPENDS pymorfeusz | |
51 | - ) | |
52 | - add_custom_target (package-python-bin | |
53 | - COMMAND python ${SETUP_PY} bdist_egg -d "${TARGET_DIR}" --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}" | |
54 | - DEPENDS pymorfeusz | |
55 | - ) | |
56 | - set (PACKAGE_DEPENDS "package-python-bin") | |
57 | - | |
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 () | |
74 | - add_custom_target (package-python | |
75 | - DEPENDS pymorfeusz ${PACKAGE_DEPENDS}) | |
76 | -elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND NOT CMAKE_CROSSCOMPILING) | |
77 | - add_custom_target (package-python-win-installer | |
78 | - COMMAND python ${SETUP_PY} bdist_wininst -d ${TARGET_DIR} --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}" | |
79 | - DEPENDS pymorfeusz | |
80 | - ) | |
81 | - list (APPEND PACKAGE_DEPENDS package-python-win-installer) | |
82 | - add_custom_target (package-python | |
83 | - DEPENDS pymorfeusz ${PACKAGE_DEPENDS}) | |
84 | -endif () |
morfeusz/wrappers/python2/CMakeLists.txt
0 → 100644
1 | + | |
2 | +# SWIG | |
3 | +#set(CMAKE_SWIG_OUTDIR swig) | |
4 | +#~ FIND_PACKAGE (SWIG REQUIRED) | |
5 | +FIND_PACKAGE (PythonLibs 2.7 EXACT) | |
6 | +#~ INCLUDE (${SWIG_USE_FILE}) | |
7 | + | |
8 | +set (PY2MORFEUSZ_VERSION "0.4.0") | |
9 | + | |
10 | +# SWIG Java | |
11 | +INCLUDE_DIRECTORIES (${PYTHON_INCLUDE_PATH}) | |
12 | +INCLUDE_DIRECTORIES (../..) | |
13 | + | |
14 | + | |
15 | +set (SWIG_PYTHON_OUTFILE_CXX "${CMAKE_CURRENT_BINARY_DIR}/swigPYTHON.cpp") | |
16 | +set (SWIG_PYTHON_OUTFILE_PY "${CMAKE_CURRENT_BINARY_DIR}/morfeusz2.py") | |
17 | +add_custom_command ( | |
18 | + OUTPUT "${SWIG_PYTHON_OUTFILE_CXX}" "${SWIG_PYTHON_OUTFILE_PY}" | |
19 | + COMMAND swig -python -c++ -o "${SWIG_PYTHON_OUTFILE_CXX}" "${CMAKE_SOURCE_DIR}/morfeusz/wrappers/morfeuszpy2.i" | |
20 | + DEPENDS libmorfeusz | |
21 | +) | |
22 | +add_custom_target (generate_python2_wrapper ALL | |
23 | + DEPENDS "${SWIG_PYTHON_OUTFILE_CXX}" "${SWIG_PYTHON_OUTFILE_PY}") | |
24 | + | |
25 | +set (SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in") | |
26 | +set (SETUP_PY_TMP "${CMAKE_CURRENT_BINARY_DIR}/setupTmp.py") | |
27 | +set (SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py") | |
28 | +set (DEPS "${SWIG_PYTHON_OUTFILE_CXX}" "${SWIG_PYTHON_OUTFILE_PY}") | |
29 | +set (OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build") | |
30 | + | |
31 | +configure_file (${SETUP_PY_IN} ${SETUP_PY}) | |
32 | + | |
33 | +file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/morfeusz2-0.4.0-py2.7" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") | |
34 | + | |
35 | +add_custom_target (generate_python2_setup_file | |
36 | + DEPENDS ${SETUP_PY}) | |
37 | + | |
38 | +add_custom_command (OUTPUT ${OUTPUT} | |
39 | + COMMAND python2 | |
40 | + ARGS ${SETUP_PY} build | |
41 | + DEPENDS generate_python2_wrapper generate_python2_setup_file libmorfeusz) | |
42 | + | |
43 | +add_custom_target (build_python2_wrapper | |
44 | + DEPENDS ${OUTPUT}) | |
45 | + | |
46 | +add_custom_target (py2morfeusz | |
47 | + DEPENDS generate_python2_wrapper generate_python2_setup_file libmorfeusz build_python2_wrapper) | |
48 | + | |
49 | +if (UNIX) | |
50 | + add_custom_target (install-python2 | |
51 | + COMMAND python2 ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX} | |
52 | + DEPENDS py2morfeusz | |
53 | + ) | |
54 | + add_custom_target (package-python2-bin | |
55 | + COMMAND python2 ${SETUP_PY} bdist_egg -d "${TARGET_DIR}" --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}" | |
56 | + DEPENDS py2morfeusz | |
57 | + ) | |
58 | + set (PACKAGE_DEPENDS "package-python2-bin") | |
59 | + | |
60 | + if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") | |
61 | + add_custom_target (package-python2-deb-sdist | |
62 | + COMMAND python2 ${SETUP_PY} --command-packages=stdeb.command sdist_dsc --depends "${CPACK_DEBIAN_PACKAGE_NAME}" --copyright-file "${PROJECT_SOURCE_DIR}/License.txt" | |
63 | + DEPENDS py2morfeusz | |
64 | + ) | |
65 | + add_custom_target (package-python2-deb-build | |
66 | + COMMAND debuild -us -uc | |
67 | + WORKING_DIRECTORY deb_dist/morfeusz2-${PY2MORFEUSZ_VERSION} | |
68 | + DEPENDS package-python2-deb-sdist | |
69 | + ) | |
70 | + add_custom_target(package-python2-deb | |
71 | + COMMAND mkdir -p "${TARGET_DIR}" && cp ${CMAKE_CURRENT_BINARY_DIR}/deb_dist/python-morfeusz2*.deb "${TARGET_DIR}" | |
72 | + DEPENDS package-python2-deb-build | |
73 | + ) | |
74 | + list (APPEND PACKAGE_DEPENDS package-python2-deb) | |
75 | + endif () | |
76 | + add_custom_target (package-python2 | |
77 | + DEPENDS py2morfeusz ${PACKAGE_DEPENDS}) | |
78 | +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND NOT CMAKE_CROSSCOMPILING) | |
79 | + add_custom_target (package-python2-win-egg | |
80 | + COMMAND python2 ${SETUP_PY} bdist_egg -d ${TARGET_DIR} --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}" | |
81 | + DEPENDS py2morfeusz | |
82 | + ) | |
83 | + add_custom_target (package-python2-win-installer | |
84 | + COMMAND python2 ${SETUP_PY} bdist_wininst -d ${TARGET_DIR} --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}" | |
85 | + DEPENDS py2morfeusz | |
86 | + ) | |
87 | + list (APPEND PACKAGE_DEPENDS package-python2-win-installer) | |
88 | + add_custom_target (package-python2 | |
89 | + DEPENDS py2morfeusz ${PACKAGE_DEPENDS}) | |
90 | +endif () | |
... | ... |
morfeusz/wrappers/python2/morfeusz2-0.4.0-py2.7/EGG-INFO/PKG-INFO
0 → 100644
morfeusz/wrappers/python2/morfeusz2-0.4.0-py2.7/EGG-INFO/SOURCES.txt
0 → 100644
morfeusz/wrappers/python2/morfeusz2-0.4.0-py2.7/EGG-INFO/dependency_links.txt
0 → 100644
No preview for this file type
morfeusz/wrappers/python2/morfeusz2-0.4.0-py2.7/EGG-INFO/native_libs.txt
0 → 100644
1 | +_morfeusz2.so | |
... | ... |
morfeusz/wrappers/python2/morfeusz2-0.4.0-py2.7/EGG-INFO/not-zip-safe
0 → 100644
No preview for this file type
morfeusz/wrappers/python2/morfeusz2-0.4.0-py2.7/EGG-INFO/top_level.txt
0 → 100644
morfeusz/wrappers/python/setup.py.in renamed to morfeusz/wrappers/python2/setup.py.in
100644 → 100755
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | from setuptools import setup, Extension |
3 | 3 | |
4 | + | |
5 | + | |
4 | 6 | morfeusz2 = Extension('_morfeusz2', |
5 | 7 | libraries=['morfeusz2'], |
6 | 8 | library_dirs=['${CMAKE_CURRENT_BINARY_DIR}/../..'], |
... | ... | @@ -12,7 +14,7 @@ if __name__ == '__main__': |
12 | 14 | author='${CPACK_PACKAGE_VENDOR}', |
13 | 15 | author_email='${CPACK_PACKAGE_CONTACT}', |
14 | 16 | description='Python bindings for Morfeusz', |
15 | - version='${PYMORFEUSZ_VERSION}', | |
17 | + version='${PY2MORFEUSZ_VERSION}', | |
16 | 18 | package_dir={ '': '${CMAKE_CURRENT_BINARY_DIR}'}, |
17 | 19 | py_modules = ['morfeusz2'], |
18 | 20 | ext_modules = [morfeusz2]) |
... | ... |
morfeusz/wrappers/python/test.py renamed to morfeusz/wrappers/python2/test2.py
... | ... | @@ -9,7 +9,7 @@ import sys |
9 | 9 | class TestSequenceFunctions(unittest.TestCase): |
10 | 10 | |
11 | 11 | def setUp(self): |
12 | - self.morfeusz = morfeusz2.Morfeusz.createInstance() | |
12 | + self.morfeusz = morfeusz2.Morfeusz() | |
13 | 13 | |
14 | 14 | def testAnalyzeAsList(self): |
15 | 15 | res = self.morfeusz.analyse("Aaaa żżżż"); |
... | ... |
morfeusz/wrappers/python3/CMakeLists.txt
0 → 100644
1 | + | |
2 | +# SWIG | |
3 | +#set(CMAKE_SWIG_OUTDIR swig) | |
4 | +#~ FIND_PACKAGE (SWIG REQUIRED) | |
5 | +FIND_PACKAGE (PythonLibs 3.0 REQUIRED) | |
6 | +#~ INCLUDE (${SWIG_USE_FILE}) | |
7 | + | |
8 | +set (PY3MORFEUSZ_VERSION "0.4.0") | |
9 | + | |
10 | +# SWIG Java | |
11 | +INCLUDE_DIRECTORIES (${PYTHON_INCLUDE_PATH}) | |
12 | +INCLUDE_DIRECTORIES (../..) | |
13 | + | |
14 | + | |
15 | +set (SWIG_PYTHON_OUTFILE_CXX "${CMAKE_CURRENT_BINARY_DIR}/swigPYTHON.cpp") | |
16 | +set (SWIG_PYTHON_OUTFILE_PY "${CMAKE_CURRENT_BINARY_DIR}/morfeusz2.py") | |
17 | +add_custom_command ( | |
18 | + OUTPUT "${SWIG_PYTHON_OUTFILE_CXX}" "${SWIG_PYTHON_OUTFILE_PY}" | |
19 | + COMMAND swig -python -py3 -c++ -o "${SWIG_PYTHON_OUTFILE_CXX}" "${CMAKE_SOURCE_DIR}/morfeusz/wrappers/morfeuszpy3.i" | |
20 | + DEPENDS libmorfeusz | |
21 | +) | |
22 | +add_custom_target (generate_python3_wrapper ALL | |
23 | + DEPENDS "${SWIG_PYTHON_OUTFILE_CXX}" "${SWIG_PYTHON_OUTFILE_PY}") | |
24 | + | |
25 | +set (SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in") | |
26 | +set (SETUP_PY_TMP "${CMAKE_CURRENT_BINARY_DIR}/setupTmp.py") | |
27 | +set (SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py") | |
28 | +set (DEPS "${SWIG_PYTHON_OUTFILE_CXX}" "${SWIG_PYTHON_OUTFILE_PY}") | |
29 | +set (OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build") | |
30 | + | |
31 | +configure_file (${SETUP_PY_IN} ${SETUP_PY}) | |
32 | + | |
33 | +file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/morfeusz2-0.4.0-py3.6" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") | |
34 | + | |
35 | +add_custom_target (generate_python3_setup_file | |
36 | + DEPENDS ${SETUP_PY}) | |
37 | + | |
38 | +add_custom_command (OUTPUT ${OUTPUT} | |
39 | + COMMAND python3 | |
40 | + ARGS ${SETUP_PY} build | |
41 | + DEPENDS generate_python3_wrapper generate_python3_setup_file libmorfeusz) | |
42 | + | |
43 | +add_custom_target (build_python3_wrapper | |
44 | + DEPENDS ${OUTPUT}) | |
45 | + | |
46 | +add_custom_target (py3morfeusz | |
47 | + DEPENDS generate_python3_wrapper generate_python3_setup_file libmorfeusz build_python3_wrapper) | |
48 | + | |
49 | +if (UNIX) | |
50 | + add_custom_target (install-python3 | |
51 | + COMMAND python3 ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX} | |
52 | + DEPENDS py3morfeusz | |
53 | + ) | |
54 | + add_custom_target (package-python3-bin | |
55 | + COMMAND python3 ${SETUP_PY} bdist_egg -d "${TARGET_DIR}" --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}" | |
56 | + DEPENDS py3morfeusz | |
57 | + ) | |
58 | + set (PACKAGE_DEPENDS "package-python3-bin") | |
59 | + | |
60 | + if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") | |
61 | + add_custom_target (package-python3-deb-sdist | |
62 | + COMMAND python3 ${SETUP_PY} --command-packages=stdeb.command sdist_dsc --depends "${CPACK_DEBIAN_PACKAGE_NAME}" --copyright-file "${PROJECT_SOURCE_DIR}/License.txt" | |
63 | + DEPENDS py3morfeusz | |
64 | + ) | |
65 | + add_custom_target (package-python3-deb-build | |
66 | + COMMAND debuild -us -uc | |
67 | + WORKING_DIRECTORY deb_dist/morfeusz2-${PY3MORFEUSZ_VERSION} | |
68 | + DEPENDS package-python3-deb-sdist | |
69 | + ) | |
70 | + add_custom_target(package-python3-deb | |
71 | + COMMAND mkdir -p "${TARGET_DIR}" && cp ${CMAKE_CURRENT_BINARY_DIR}/deb_dist/python3-morfeusz2*.deb "${TARGET_DIR}" | |
72 | + DEPENDS package-python3-deb-build | |
73 | + ) | |
74 | + list (APPEND PACKAGE_DEPENDS package-python3-deb) | |
75 | + endif () | |
76 | + add_custom_target (package-python3 | |
77 | + DEPENDS py3morfeusz ${PACKAGE_DEPENDS}) | |
78 | +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND NOT CMAKE_CROSSCOMPILING) | |
79 | + add_custom_target (package-python3-win-installer | |
80 | + COMMAND python3 ${SETUP_PY} bdist_wininst -d ${TARGET_DIR} --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}" | |
81 | + DEPENDS py3morfeusz | |
82 | + ) | |
83 | + list (APPEND PACKAGE_DEPENDS package-python3-win-installer) | |
84 | + add_custom_target (package-python3 | |
85 | + DEPENDS py3morfeusz ${PACKAGE_DEPENDS}) | |
86 | +endif () | |
... | ... |
morfeusz/wrappers/python3/morfeusz2-0.4.0-py3.6/EGG-INFO/PKG-INFO
0 → 100644
morfeusz/wrappers/python3/morfeusz2-0.4.0-py3.6/EGG-INFO/SOURCES.txt
0 → 100644
morfeusz/wrappers/python3/morfeusz2-0.4.0-py3.6/EGG-INFO/dependency_links.txt
0 → 100644
No preview for this file type
morfeusz/wrappers/python3/morfeusz2-0.4.0-py3.6/EGG-INFO/native_libs.txt
0 → 100644
1 | +_morfeusz2.so | |
... | ... |
morfeusz/wrappers/python3/morfeusz2-0.4.0-py3.6/EGG-INFO/not-zip-safe
0 → 100644
No preview for this file type
morfeusz/wrappers/python3/morfeusz2-0.4.0-py3.6/EGG-INFO/top_level.txt
0 → 100644
morfeusz/wrappers/python3/setup.py.in
0 → 100644
1 | +# -*- coding: utf-8 -*- | |
2 | +from setuptools import setup, Extension | |
3 | + | |
4 | +morfeusz2 = Extension('_morfeusz2', | |
5 | + libraries=['morfeusz2'], | |
6 | + library_dirs=['${CMAKE_CURRENT_BINARY_DIR}/../..'], | |
7 | + include_dirs=['${CMAKE_CURRENT_SOURCE_DIR}/../..', '${PROJECT_BINARY_DIR}'], | |
8 | + sources=['${SWIG_PYTHON_OUTFILE_CXX}']) | |
9 | + | |
10 | +if __name__ == '__main__': | |
11 | + setup(name='morfeusz2', | |
12 | + author='${CPACK_PACKAGE_VENDOR}', | |
13 | + author_email='${CPACK_PACKAGE_CONTACT}', | |
14 | + description='Python bindings for Morfeusz', | |
15 | + version='${PY3MORFEUSZ_VERSION}', | |
16 | + package_dir={ '': '${CMAKE_CURRENT_BINARY_DIR}'}, | |
17 | + py_modules = ['morfeusz2'], | |
18 | + ext_modules = [morfeusz2]) | |
... | ... |
morfeusz/wrappers/python3/test3.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | |
2 | +import morfeusz2 | |
3 | + | |
4 | +import unittest | |
5 | +import tempfile | |
6 | +import os | |
7 | +import sys | |
8 | + | |
9 | +class TestSequenceFunctions(unittest.TestCase): | |
10 | + | |
11 | + def setUp(self): | |
12 | + self.morfeusz = morfeusz2.Morfeusz() | |
13 | + | |
14 | + def testAnalyzeAsList(self): | |
15 | + res = self.morfeusz.analyse("Aaaa żżżż"); | |
16 | + self.assertEquals(2, len(res)); | |
17 | + self.assertEquals(u"Aaaa", res[0].orth); | |
18 | + self.assertEquals(u"żżżż", res[1].orth); | |
19 | + try: | |
20 | + res[2]; | |
21 | + fail(); | |
22 | + except IndexError: | |
23 | + pass | |
24 | + | |
25 | + def testAnalyzeAsIterator(self): | |
26 | + res = list(self.morfeusz.analyse_iter("Aaaa żżżż")); | |
27 | + self.assertEquals(2, len(res)); | |
28 | + self.assertEquals(u"Aaaa", res[0].orth); | |
29 | + self.assertEquals(u"żżżż", res[1].orth); | |
30 | + try: | |
31 | + res[2]; | |
32 | + fail(); | |
33 | + except IndexError: | |
34 | + pass | |
35 | + | |
36 | + def testInvalidAgglOption(self): | |
37 | + try: | |
38 | + self.morfeusz.setAggl('XXXXYYYYZZZZ') | |
39 | + self.fail() | |
40 | + except RuntimeError: | |
41 | + pass | |
42 | + | |
43 | + def testInvalidPraetOption(self): | |
44 | + try: | |
45 | + self.morfeusz.setPraet('XXXXYYYYZZZZ') | |
46 | + self.fail() | |
47 | + except RuntimeError: | |
48 | + pass | |
49 | + | |
50 | + def testInvalidGenerate(self): | |
51 | + try: | |
52 | + self.morfeusz.generate("AAAA BBBB") | |
53 | + self.fail() | |
54 | + except RuntimeError: | |
55 | + pass | |
56 | + | |
57 | + def testValidCaseHandling(self): | |
58 | + self.morfeusz.setCaseHandling(morfeusz2.IGNORE_CASE) | |
59 | + | |
60 | + def testInvalidCaseHandling(self): | |
61 | + try: | |
62 | + self.morfeusz.setCaseHandling(0) | |
63 | + self.fail() | |
64 | + except ValueError: | |
65 | + pass | |
66 | + | |
67 | + def testInvalidTokenNumbering(self): | |
68 | + try: | |
69 | + self.morfeusz.setTokenNumbering(0) | |
70 | + self.fail() | |
71 | + except ValueError: | |
72 | + pass | |
73 | + | |
74 | + def testInvalidWhitespaceHandling(self): | |
75 | + try: | |
76 | + self.morfeusz.setWhitespaceHandling(0) | |
77 | + self.fail() | |
78 | + except ValueError: | |
79 | + pass | |
80 | + | |
81 | + def testNonExistingDictionaryFile(self): | |
82 | + try: | |
83 | + self.morfeusz.setDictionary("1P4sEBuWv") | |
84 | + self.fail() | |
85 | + except IOError: | |
86 | + pass | |
87 | + | |
88 | + def testInvalidDictionaryFile(self): | |
89 | + dirpath = tempfile.mkdtemp() | |
90 | + dictName = '6J1vMiqY' | |
91 | + path = os.path.join(dirpath, dictName + '-a.dict') | |
92 | + with open(path, "a+") as f: | |
93 | + f.write('ee2rmtsq') | |
94 | + try: | |
95 | + self.morfeusz.setDictionary(dictName) | |
96 | + self.fail() | |
97 | + except IOError: | |
98 | + pass | |
99 | + | |
100 | +if __name__ == '__main__': | |
101 | + unittest.main() | |
102 | + | |
... | ... |
toolchains/Toolchain-Darwin-amd64.cmake
... | ... | @@ -10,6 +10,11 @@ set (CMAKE_SYSTEM_PROCESSOR "x86_64") |
10 | 10 | |
11 | 11 | set (JAVA_ROOT ${DARWIN64_ROOT}/JavaVM.framework) |
12 | 12 | set (PYTHON_ROOT ${DARWIN64_ROOT}/Python.framework/Versions/2.7) |
13 | +if(${PY}) | |
14 | + if(${PY} EQUAL "3") | |
15 | + set (PYTHON_ROOT ${DARWIN64_ROOT}/Python3.framework/Versions/3.6) | |
16 | + endif() | |
17 | +endif() | |
13 | 18 | |
14 | 19 | set (INSTALL_NAME_TOOL /usr/x86_64-apple-darwin9/bin/x86_64-apple-darwin9-install_name_tool) |
15 | 20 | |
... | ... |
toolchains/Toolchain-Linux-i386.cmake
... | ... | @@ -10,6 +10,11 @@ set (CMAKE_SYSTEM_PROCESSOR "x86") |
10 | 10 | |
11 | 11 | set (JAVA_ROOT ${CROSSMORFEUSZ_ROOT}/linux32/jdk1.7.0_45) |
12 | 12 | set (PYTHON_ROOT ${CROSSMORFEUSZ_ROOT}/linux32/python) |
13 | +if(${PY}) | |
14 | + if(${PY} EQUAL "3") | |
15 | + set (PYTHON_ROOT ${CROSSMORFEUSZ_ROOT}/linux32/python3) | |
16 | + endif() | |
17 | +endif() | |
13 | 18 | |
14 | 19 | # here is the target environment located |
15 | 20 | set (CMAKE_FIND_ROOT_PATH ${JAVA_ROOT} ${PYTHON_ROOT}) |
... | ... |
toolchains/Toolchain-Windows-amd64.cmake
... | ... | @@ -10,6 +10,11 @@ set (CMAKE_SYSTEM_PROCESSOR "x86_64") |
10 | 10 | # here is the target environment located |
11 | 11 | set (WIN64_ROOT ${CROSSMORFEUSZ_ROOT}/windows64) |
12 | 12 | set (PYTHON_ROOT ${WIN64_ROOT}/Python27) |
13 | +if(${PY}) | |
14 | + if(${PY} EQUAL "3") | |
15 | + set (PYTHON_ROOT ${WIN64_ROOT}/Python36) | |
16 | + endif() | |
17 | +endif() | |
13 | 18 | set (JAVA_ROOT ${WIN64_ROOT}/Java/jdk1.7.0_45) |
14 | 19 | set (CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 ${JAVA_ROOT} ${PYTHON_ROOT}) |
15 | 20 | set (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${PYTHON_ROOT}/libs) |
... | ... |
toolchains/Toolchain-Windows-i386.cmake
... | ... | @@ -10,6 +10,11 @@ set (CMAKE_SYSTEM_PROCESSOR "x86") |
10 | 10 | # here is the target environment located |
11 | 11 | set (WIN32_ROOT ${CROSSMORFEUSZ_ROOT}/windows32) |
12 | 12 | set (PYTHON_ROOT ${WIN32_ROOT}/Python27) |
13 | +if(${PY}) | |
14 | + if(${PY} EQUAL "3") | |
15 | + set (PYTHON_ROOT ${WIN32_ROOT}/Python36-32) | |
16 | + endif() | |
17 | +endif() | |
13 | 18 | set (JAVA_ROOT ${WIN32_ROOT}/Java/jdk1.7.0_45) |
14 | 19 | set (CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 ${JAVA_ROOT} ${PYTHON_ROOT}) |
15 | 20 | set (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${PYTHON_ROOT}/libs) |
... | ... |