Commit 007a1589aed0172601eb9795b3e38aedf68eef96
1 parent
e147486d
- małe zmiany, żeby się poprawnie skompilowało na windowsie
git-svn-id: svn://svn.nlp.ipipan.waw.pl/morfeusz/morfeusz@64 ff4e3ee1-f430-4e82-ade0-24591c43f1fd
Showing
4 changed files
with
38 additions
and
19 deletions
morfeusz/Toolchain-win32.cmake
... | ... | @@ -6,11 +6,15 @@ SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) |
6 | 6 | SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres) |
7 | 7 | |
8 | 8 | # here is the target environment located |
9 | -SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32 ) | |
9 | +set (WIN32_ROOT /mnt/storage/crossmorfeusz/windows32) | |
10 | +set (PYTHON_ROOT ${WIN32_ROOT}/Python27) | |
11 | +set (JAVA_ROOT ${WIN32_ROOT}/Java/jdk1.7.0_45) | |
12 | +set (CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 ${JAVA_ROOT} ${PYTHON_ROOT}) | |
13 | +set (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${PYTHON_ROOT}/libs) | |
10 | 14 | |
11 | 15 | # adjust the default behaviour of the FIND_XXX() commands: |
12 | 16 | # search headers and libraries in the target environment, search |
13 | 17 | # programs in the host environment |
14 | 18 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) |
15 | 19 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) |
16 | 20 | -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
21 | +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | |
17 | 22 | \ No newline at end of file |
... | ... |
morfeusz/fsa/simplefsa_impl.hpp
... | ... | @@ -8,14 +8,16 @@ |
8 | 8 | #ifndef SIMPLEFSA_IMPL_HPP |
9 | 9 | #define SIMPLEFSA_IMPL_HPP |
10 | 10 | |
11 | -#pragma pack(push, 1) /* push current alignment to stack */ | |
11 | +#include <iostream> | |
12 | + | |
13 | +//#pragma pack(push, 1) /* push current alignment to stack */ | |
12 | 14 | |
13 | 15 | struct StateData { |
14 | - unsigned transitionsNum : 7; | |
15 | - unsigned accepting : 1; | |
16 | + unsigned char transitionsNum; | |
17 | + bool accepting; | |
16 | 18 | }; |
17 | 19 | |
18 | -#pragma pack(pop) /* restore original alignment from stack */ | |
20 | +//#pragma pack(pop) /* restore original alignment from stack */ | |
19 | 21 | |
20 | 22 | template <class T> |
21 | 23 | SimpleFSA<T>::SimpleFSA(const unsigned char* ptr, const Deserializer<T>& deserializer) |
... | ... | @@ -27,20 +29,29 @@ SimpleFSA<T>::~SimpleFSA() { |
27 | 29 | |
28 | 30 | } |
29 | 31 | |
30 | -static unsigned int decodeOffset(const unsigned char* ptr) { | |
32 | +static inline unsigned int decodeOffset(const unsigned char* ptr) { | |
31 | 33 | unsigned int res = 0; |
32 | 34 | res = ptr[0] << 16 | ptr[1] << 8 | ptr[2]; |
33 | 35 | return res; |
34 | 36 | } |
35 | 37 | |
38 | +static inline StateData decodeStateData(const unsigned char* ptr) { | |
39 | + static const unsigned char acceptingFlag = 128; | |
40 | + static const unsigned char transitionsNumMask = 127; | |
41 | + StateData res; | |
42 | + res.transitionsNum = (*ptr) & transitionsNumMask; | |
43 | + res.accepting = (*ptr) & acceptingFlag; | |
44 | + return res; | |
45 | +} | |
46 | + | |
36 | 47 | template <class T> |
37 | 48 | void SimpleFSA<T>::proceedToNext(const char c, State<T>& state) const { |
38 | 49 | const unsigned char* fromPointer = this->initialStatePtr + state.getOffset(); |
39 | - long transitionsTableOffset = sizeof (StateData); | |
50 | + long transitionsTableOffset = 1; | |
40 | 51 | if (state.isAccepting()) { |
41 | 52 | transitionsTableOffset += state.getValueSize(); |
42 | 53 | } |
43 | - StateData stateData = *reinterpret_cast<const StateData*>(fromPointer); | |
54 | + StateData stateData = decodeStateData(fromPointer); | |
44 | 55 | const unsigned char* foundTransition = fromPointer + transitionsTableOffset; |
45 | 56 | bool found = false; |
46 | 57 | for (unsigned int i = 0; i < stateData.transitionsNum; i++, foundTransition += 4) { |
... | ... | @@ -52,14 +63,13 @@ void SimpleFSA<T>::proceedToNext(const char c, State<T>& state) const { |
52 | 63 | // const_cast<Counter*>(&counter)->increment(foundTransition - transitionsStart + 1); |
53 | 64 | if (!found) { |
54 | 65 | state.setNextAsSink(); |
55 | - } | |
56 | - else { | |
66 | + } else { | |
57 | 67 | unsigned int offset = decodeOffset(foundTransition + 1); |
58 | 68 | const unsigned char* nextStatePointer = this->initialStatePtr + offset; |
59 | - const StateData* nextStateData = reinterpret_cast<const StateData*>(nextStatePointer); | |
60 | - if (nextStateData->accepting) { | |
69 | + StateData nextStateData = decodeStateData(nextStatePointer); | |
70 | + if (nextStateData.accepting) { | |
61 | 71 | T object; |
62 | - long size = this->deserializer.deserialize(nextStatePointer + sizeof (StateData), object); | |
72 | + long size = this->deserializer.deserialize(nextStatePointer + 1, object); | |
63 | 73 | state.setNext(offset, object, size); |
64 | 74 | } else { |
65 | 75 | state.setNext(offset); |
... | ... |
morfeusz/python/CMakeLists.txt
... | ... | @@ -19,8 +19,8 @@ SWIG_LINK_LIBRARIES(morfeusz libmorfeusz) |
19 | 19 | |
20 | 20 | #set (CMAKE_SHARED_LINKER_FLAGS "") |
21 | 21 | #set (CMAKE_EXE_LINKER_FLAGS "") |
22 | -if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") | |
23 | - set (CMAKE_CXX_FLAGS "-D MS_WIN64 -O2") | |
24 | -else () | |
25 | - set (CMAKE_CXX_FLAGS "-O2") | |
26 | -endif () | |
27 | 22 | \ No newline at end of file |
23 | +#if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") | |
24 | +# set (CMAKE_CXX_FLAGS "-D MS_WIN64 -O2") | |
25 | +#else () | |
26 | +# set (CMAKE_CXX_FLAGS "-O2") | |
27 | +#endif () | |
28 | 28 | \ No newline at end of file |
... | ... |
nbproject/configurations.xml
... | ... | @@ -17,6 +17,9 @@ |
17 | 17 | <in>test_recognize.cpp</in> |
18 | 18 | <in>test_speed.cpp</in> |
19 | 19 | </df> |
20 | + <df name="java"> | |
21 | + <in>dupa</in> | |
22 | + </df> | |
20 | 23 | <in>FlexionGraph.cpp</in> |
21 | 24 | <in>Morfeusz.cpp</in> |
22 | 25 | <in>MorphDeserializer.cpp</in> |
... | ... | @@ -336,6 +339,8 @@ |
336 | 339 | </incDir> |
337 | 340 | </ccTool> |
338 | 341 | </item> |
342 | + <item path="morfeusz/java/dupa" ex="false" tool="3" flavor2="0"> | |
343 | + </item> | |
339 | 344 | <item path="morfeusz/main.cpp" ex="false" tool="1" flavor2="4"> |
340 | 345 | <ccTool> |
341 | 346 | <incDir> |
... | ... |