Commit 6409a580fcd358082c3d553547a61984e4e0bda4
1 parent
1f9074bd
- nowa i wreszcie działająca wersja wrappera javowego
git-svn-id: svn://svn.nlp.ipipan.waw.pl/morfeusz/trunk@244 ff4e3ee1-f430-4e82-ade0-24591c43f1fd
Showing
11 changed files
with
261 additions
and
142 deletions
CMakeLists.txt
... | ... | @@ -155,7 +155,7 @@ endif () |
155 | 155 | include (CPack) |
156 | 156 | |
157 | 157 | ##### END initialize some vars ##### |
158 | -file (COPY fsabuilder doTest.sh DESTINATION .) | |
158 | +file (COPY fsabuilder doTest.sh testJavaWrapper.sh DESTINATION .) | |
159 | 159 | |
160 | 160 | #~ configure_file ( |
161 | 161 | #~ "${PROJECT_SOURCE_DIR}/morfeusz/morfeusz2_version.h.in" |
... | ... | @@ -182,24 +182,6 @@ if (UNIX) |
182 | 182 | endforeach() |
183 | 183 | endif() |
184 | 184 | |
185 | -#macro (test_build_and_recognize fname method) | |
186 | -# add_test (TestBuild-${method}-${fname} python fsabuilder/morfeusz_builder --analyzer --input-files testfiles/${fname} -o /tmp/test-${method}-${fname}.fsa --tagset-file=testfiles/polimorf.tagset --segments-file=testfiles/segmenty.dat --serialization-method=${method}) | |
187 | -# add_test (TestBuild4Synth-${method}-${fname} python fsabuilder/morfeusz_builder --generator --input-files testfiles/${fname} -o /tmp/test-synth-${method}-${fname}.fsa --tagset-file=testfiles/polimorf.tagset --serialization-method=${method}) | |
188 | -# add_test (TestRecognize-${method}-${fname} morfeusz/test_recognize_dict /tmp/test-${method}-${fname}.fsa testfiles/${fname}) | |
189 | -# # add_test (TestNOTRecognize-${method}-${fname} fsa/test_not_recognize /tmp/test-${method}-${fname}.fsa testfiles/out_of_dict) | |
190 | -# # add_test (TestSpeed-${method}-${fname} fsa/test_speed /tmp/test-${method}-${fname}.fsa testfiles/speed_test_data) | |
191 | -#endmacro () | |
192 | -# | |
193 | -#macro (test_result_equals inputFilename requiredOutputFilename encoding) | |
194 | -# # add_test (TestBuild4ResultEquals-${dictFilename}-${requiredOutputFilename} python fsabuilder/fsa/morfeusz_builder -i ${dictFilename} -o /tmp/test.fsa --tagset-file=testfiles/polimorf.tagset --output-format=BINARY --serialization-method=SIMPLE) | |
195 | -# add_test (TestResultEquals-${inputFilename}-${requiredOutputFilename} morfeusz/test_result_equals ${inputFilename} ${requiredOutputFilename} ${encoding}) | |
196 | -#endmacro () | |
197 | -# | |
198 | -#test_build_and_recognize(PoliMorfSmall.tab SIMPLE) | |
199 | -#test_build_and_recognize(PoliMorfSmall.tab V1) | |
200 | -#test_build_and_recognize(PoliMorfSmall.tab V2) | |
201 | -# | |
202 | -#test_result_equals (testfiles/test1.txt testfiles/test1.txt.out UTF8) | |
203 | -#test_result_equals (testfiles/test1.txt.ISO8859-2 testfiles/test1.txt.out.ISO8859-2 ISO8859_2) | |
204 | -#test_result_equals (testfiles/test1.txt.CP1250 testfiles/test1.txt.out.CP1250 CP1250) | |
205 | -#test_result_equals (testfiles/test1.txt.CP852 testfiles/test1.txt.out.CP852 CP852) | |
185 | +if (UNIX) | |
186 | + add_test(TestJavaWrapper ./testJavaWrapper.sh "${PROJECT_BINARY_DIR}") | |
187 | +endif () | |
... | ... |
morfeusz/MorfeuszInternal.cpp
... | ... | @@ -463,6 +463,14 @@ namespace morfeusz { |
463 | 463 | strcpy(textCopy, text.c_str()); |
464 | 464 | return new ResultsIteratorImpl(*this, textCopy, textCopy + text.length(), true); |
465 | 465 | } |
466 | + | |
467 | + ResultsIterator* MorfeuszInternal::analyzeWithCopy(const char* text) const { | |
468 | + adjustTokensCounter(); | |
469 | + long n = strlen(text); | |
470 | + char* textCopy = new char[n + 1]; | |
471 | + strcpy(textCopy, text); | |
472 | + return new ResultsIteratorImpl(*this, textCopy, textCopy + n, true); | |
473 | + } | |
466 | 474 | |
467 | 475 | ResultsIterator* MorfeuszInternal::analyze(const char* text) const { |
468 | 476 | adjustTokensCounter(); |
... | ... |
morfeusz/MorfeuszInternal.hpp
... | ... | @@ -87,8 +87,11 @@ namespace morfeusz { |
87 | 87 | const Tagset<std::string>& getDefaultAnalyzerTagset() const; |
88 | 88 | |
89 | 89 | const Tagset<std::string>& getDefaultGeneratorTagset() const; |
90 | + | |
91 | + ResultsIterator* analyzeWithCopy(const char* text) const; | |
90 | 92 | |
91 | 93 | friend class ResultsIteratorImpl; |
94 | + | |
92 | 95 | private: |
93 | 96 | |
94 | 97 | void processOneWord( |
... | ... |
morfeusz/morfeusz2.h
... | ... | @@ -96,6 +96,10 @@ namespace morfeusz { |
96 | 96 | class DLLIMPORT Morfeusz { |
97 | 97 | public: |
98 | 98 | |
99 | + /** | |
100 | + * Returns a string containing library version. | |
101 | + * @return | |
102 | + */ | |
99 | 103 | static std::string getVersion(); |
100 | 104 | |
101 | 105 | /** |
... | ... | @@ -134,7 +138,7 @@ namespace morfeusz { |
134 | 138 | |
135 | 139 | /** |
136 | 140 | * Analyze given text and return the results as iterator. |
137 | - * Use this method for analysis of big texts. | |
141 | + * It does not store results for whole text at once, so may be less memory-consuming for analysis of big texts | |
138 | 142 | * |
139 | 143 | * |
140 | 144 | * @param text - text for morphological analysis. This pointer must not be deleted before returned ResultsIterator object. |
... | ... | @@ -228,6 +232,13 @@ namespace morfeusz { |
228 | 232 | * @return |
229 | 233 | */ |
230 | 234 | virtual const Tagset<std::string>& getDefaultGeneratorTagset() const = 0; |
235 | + | |
236 | + protected: | |
237 | + /** | |
238 | + * Same as analyze(text) but copies the text under the hood. | |
239 | + * Useful for wrappers to other languages. | |
240 | + */ | |
241 | + virtual ResultsIterator* analyzeWithCopy(const char* text) const = 0; | |
231 | 242 | }; |
232 | 243 | |
233 | 244 | class DLLIMPORT ResultsIterator { |
... | ... |
morfeusz/wrappers/java/CMakeLists.txt
... | ... | @@ -16,7 +16,7 @@ add_custom_command ( |
16 | 16 | COMMAND swig -java -c++ -package pl.waw.ipipan.morfeusz -o ${SWIG_JAVA_OUTFILE} -outdir ${JAVA_SRC_DIR} ${CMAKE_SOURCE_DIR}/morfeusz/wrappers/morfeusz.i |
17 | 17 | DEPENDS libmorfeusz |
18 | 18 | ) |
19 | -add_custom_target(generate_java_wrapper ALL | |
19 | +add_custom_target(generate-java-wrapper ALL | |
20 | 20 | DEPENDS ${SWIG_JAVA_OUTFILE}) |
21 | 21 | add_library (libjmorfeusz SHARED ${SWIG_JAVA_OUTFILE}) |
22 | 22 | add_dependencies (libjmorfeusz generate_java_wrapper) |
... | ... | @@ -53,7 +53,33 @@ endif () |
53 | 53 | file(GLOB_RECURSE JAVA_SOURCES ${JAVA_SRC_DIR} "*.java") |
54 | 54 | add_jar (jmorfeusz |
55 | 55 | SOURCES "${JAVA_SOURCES}" |
56 | - DEPENDS libjmorfeusz generate_java_wrapper) | |
56 | + ENTRY_POINT pl/waw/ipipan/morfeusz/app/App | |
57 | + DEPENDS libjmorfeusz generate-java-wrapper) | |
58 | + | |
59 | +#create_javadoc(jmorfeusz_javadoc | |
60 | +# PACKAGES pl.waw.ipipan.morfeusz | |
61 | +# SOURCEPATH "${CMAKE_CURRENT_BINARY_DIR}" | |
62 | +# CLASSPATH "${CMAKE_JAVA_INCLUDE_PATH}" | |
63 | +# WINDOWTITLE "JMorfeusz - Morfeusz Java binding" | |
64 | +# DOCTITLE "<h1>JMorfeusz</h1>" | |
65 | +# AUTHOR TRUE | |
66 | +# USE TRUE | |
67 | +# VERSION TRUE | |
68 | +# DEPENDS jmorfeusz generate_java_wrapper) | |
69 | + | |
70 | +add_custom_target(generate-javadoc ALL | |
71 | + COMMAND javadoc | |
72 | + -d "${CMAKE_CURRENT_BINARY_DIR}/jmorfeusz_javadoc" | |
73 | + -sourcepath "${CMAKE_CURRENT_BINARY_DIR}" | |
74 | + -windowtitle "JMorfeusz - Morfeusz Java binding" | |
75 | + -use | |
76 | + -link http://docs.oracle.com/javase/7/docs/api/ | |
77 | + pl.waw.ipipan.morfeusz | |
78 | + DEPENDS jmorfeusz) | |
79 | + | |
80 | +add_custom_target(package-javadoc ALL | |
81 | + COMMAND mkdir -p "${TARGET_DIR}" && ${CMAKE_COMMAND} -E tar "cfvz" "${TARGET_DIR}/jmorfeusz_javadoc.tgz" "${CMAKE_CURRENT_BINARY_DIR}/jmorfeusz_javadoc" | |
82 | + DEPENDS generate-javadoc) | |
57 | 83 | |
58 | 84 | if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
59 | 85 | add_dependencies(jmorfeusz jmorfeusz-repair-libmorfeusz-link jmorfeusz-repair-libjmorfeusz-id) |
... | ... | @@ -65,4 +91,4 @@ add_custom_target (jmorfeusz-copy-readme |
65 | 91 | |
66 | 92 | add_custom_target(package-java |
67 | 93 | COMMAND mkdir -p "${TARGET_DIR}" && ${CMAKE_COMMAND} -E tar "cfvz" "${TARGET_DIR}/jmorfeusz-${JMORFEUSZ_VERSION}-${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}.tar.gz" "${CMAKE_CURRENT_BINARY_DIR}/*.jar" "${CMAKE_CURRENT_BINARY_DIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}" "${CMAKE_CURRENT_BINARY_DIR}/README" |
68 | - DEPENDS jmorfeusz jmorfeusz-copy-readme libjmorfeusz) | |
94 | + DEPENDS jmorfeusz package-javadoc jmorfeusz-copy-readme libjmorfeusz) | |
... | ... |
morfeusz/wrappers/java/pl/waw/ipipan/morfeusz/app/App.java
... | ... | @@ -14,7 +14,7 @@ public class App { |
14 | 14 | System.getProperty("user.dir")); |
15 | 15 | System.err.println("java.library.path="+System.getProperty("java.library.path")); |
16 | 16 | Morfeusz morfeusz = Morfeusz.createInstance(); |
17 | - ResultsIterator it = morfeusz.analyze("Ala ma kota i żółć."); | |
17 | + ResultsIterator it = morfeusz.analyzeAsIterator("Ala ma kota i żółć."); | |
18 | 18 | while (it.hasNext()) { |
19 | 19 | System.out.println(MorfeuszUtils.getInterpretationString(it.next())); |
20 | 20 | } |
... | ... |
morfeusz/wrappers/morfeusz.i
... | ... | @@ -3,22 +3,22 @@ |
3 | 3 | // set module name with preprocessor |
4 | 4 | // because Mac OS X doesn't seem to recognize jniclassname option |
5 | 5 | #ifdef SWIGJAVA |
6 | -%module MorfeuszWrapper | |
6 | +%module(allprotected="1") MorfeuszWrapper | |
7 | 7 | #else |
8 | -%module morfeusz2 | |
8 | +%module(allprotected="1") morfeusz2 | |
9 | 9 | #endif |
10 | 10 | |
11 | - | |
12 | 11 | %feature("autodoc", "2"); |
13 | 12 | %{ |
14 | 13 | #include "morfeusz2.h" |
15 | -//#include "exceptions.hpp" | |
16 | -//#include "const.hpp" | |
17 | -//#include "Morfeusz.hpp" | |
18 | - | |
19 | -using namespace morfeusz; | |
14 | +#include "MorfeuszInternal.hpp" | |
15 | +#include <vector> | |
20 | 16 | %} |
21 | 17 | |
18 | +#ifdef SWIGJAVA | |
19 | +%include "morfeusz_java.i" | |
20 | +#endif | |
21 | + | |
22 | 22 | %include "std_vector.i" |
23 | 23 | %include "std_string.i" |
24 | 24 | %include "std_except.i" |
... | ... | @@ -29,7 +29,7 @@ using namespace morfeusz; |
29 | 29 | try{ |
30 | 30 | $action |
31 | 31 | } |
32 | - catch(const FileFormatException& e) { | |
32 | + catch(const morfeusz::FileFormatException& e) { | |
33 | 33 | SWIG_exception(SWIG_IOError, const_cast<char*>(e.what())); |
34 | 34 | } |
35 | 35 | catch(const std::exception& e) { |
... | ... | @@ -40,12 +40,8 @@ using namespace morfeusz; |
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | -#ifdef SWIGJAVA | |
44 | -%include "morfeusz_java.i" | |
45 | -#endif | |
46 | - | |
47 | - | |
48 | 43 | namespace morfeusz { |
44 | + | |
49 | 45 | %ignore MorphInterpretation::MorphInterpretation( |
50 | 46 | int startNode, |
51 | 47 | int endNode, |
... | ... | @@ -59,31 +55,26 @@ namespace morfeusz { |
59 | 55 | %ignore MorphInterpretation::createIgn(int startNode, int endNode, const std::string& orth, const Tagset<std::string>& tagset); |
60 | 56 | %ignore MorphInterpretation::createWhitespace(int startNode, int endNode, const std::string& orth, const Tagset<std::string>& tagset); |
61 | 57 | %ignore Morfeusz::analyze(const char*) const; |
62 | - %ignore Morfeusz::analyze(const string&) const; | |
63 | - %ignore Morfeusz::analyze(const string&, std::vector<MorphInterpretation>&) const; | |
64 | - %ignore Morfeusz::generate(const string&, std::vector<MorphInterpretation>&) const; | |
65 | - %ignore Morfeusz::generate(const string&, int, std::vector<MorphInterpretation>&) const; | |
58 | + %ignore Morfeusz::analyze(const std::string&) const; | |
59 | + %ignore Morfeusz::setCharset(Charset); | |
60 | +// %ignore Morfeusz::analyze(const std::string&, std::vector<MorphInterpretation>&) const; | |
61 | +// %ignore Morfeusz::generate(const std::string&, std::vector<MorphInterpretation>&) const; | |
62 | +// %ignore Morfeusz::generate(const std::string&, int, std::vector<MorphInterpretation>&) const; | |
63 | + %ignore Morfeusz::setDebug(bool); | |
66 | 64 | |
67 | 65 | %newobject Morfeusz::createInstance(); |
68 | - %newobject Morfeusz::analyze(const std::string&) const; | |
66 | + %newobject Morfeusz::analyzeAsIterator(const char*) const; | |
69 | 67 | } |
70 | 68 | |
71 | -%template(InterpsList) std::vector<morfeusz::MorphInterpretation>; | |
72 | -%template(StringsList) std::vector<string>; | |
73 | - | |
74 | -// instantiate vector of interpretations | |
75 | -namespace std { | |
76 | - // dirty hack so it will compile without no-arg constructor for MorphInterpretation | |
77 | - %ignore vector<morfeusz::MorphInterpretation>::vector(size_type); | |
78 | - %ignore vector<morfeusz::MorphInterpretation>::resize; | |
79 | - | |
80 | - | |
81 | - //%template(InterpsList) vector<morfeusz::MorphInterpretation>; | |
82 | - //%template(StringsList) vector<string>; | |
83 | - | |
84 | - | |
69 | +%extend morfeusz::Morfeusz { | |
70 | + morfeusz::ResultsIterator* morfeusz::Morfeusz::analyzeAsIterator(const char* text) const { | |
71 | + return dynamic_cast<const morfeusz::MorfeuszInternal*>($self)->analyzeWithCopy(text); | |
72 | + } | |
85 | 73 | } |
86 | 74 | |
75 | +%template(InterpsList) std::vector<morfeusz::MorphInterpretation>; | |
76 | +%template(StringsList) std::vector<std::string>; | |
77 | + | |
87 | 78 | %include "../morfeusz2.h" |
88 | 79 | |
89 | 80 | |
... | ... |
morfeusz/wrappers/morfeusz_java.i
1 | + | |
2 | +%include "morfeusz_javadoc.i" | |
3 | + | |
4 | +%include <stdint.i> | |
5 | +%include <std_except.i> | |
6 | + | |
7 | +// make vector compatible with java.util.List interface | |
8 | + | |
9 | +namespace std { | |
10 | + | |
11 | + template<class T> class vector { | |
12 | + public: | |
13 | + typedef size_t size_type; | |
14 | + typedef T value_type; | |
15 | + typedef const value_type& const_reference; | |
16 | +// vector(); | |
17 | +// vector(size_type n); | |
18 | +// vector(const vector& o); | |
19 | + size_type capacity() const; | |
20 | + void reserve(size_type n); | |
21 | + %rename(isEmpty) empty; | |
22 | + bool empty() const; | |
23 | + void clear(); | |
24 | + void push_back(const value_type& x); | |
25 | + %extend { | |
26 | + const_reference get(int32_t i) const throw (std::out_of_range) { | |
27 | + return $self->at(i); | |
28 | + } | |
29 | + value_type set(int32_t i, const value_type& VECTOR_VALUE_IN) throw (std::out_of_range) { | |
30 | + const T old = $self->at(i); | |
31 | + $self->at(i) = VECTOR_VALUE_IN; | |
32 | + return old; | |
33 | + } | |
34 | + void add(int32_t i, const value_type& VECTOR_VALUE_IN) { | |
35 | + $self->insert($self->begin() + i, VECTOR_VALUE_IN); | |
36 | + } | |
37 | + int32_t size() const { | |
38 | + return $self->size(); | |
39 | + } | |
40 | + void removeRange(int32_t from, int32_t to) { | |
41 | + $self->erase($self->begin()+from, $self->begin()+to); | |
42 | + } | |
43 | + } | |
44 | + }; | |
45 | +} | |
46 | + | |
1 | 47 | %typemap(javaimports) morfeusz::Morfeusz %{ |
2 | 48 | import java.io.IOException; |
49 | +import java.lang.RuntimeException; | |
3 | 50 | import java.util.List; |
51 | +import java.util.Collections; | |
52 | + | |
53 | +/** | |
54 | + * Performs morphological analysis (analyze methods) and syntesis (generate methods). | |
55 | + * | |
56 | + * It is NOT thread-safe | |
57 | + * but it is possible to use separate Morfeusz instance for each concurrent thread. | |
58 | + */ | |
59 | +%} | |
60 | + | |
61 | +%typemap(javaimports) morfeusz::ResultsIterator %{ | |
62 | +import java.util.Iterator; | |
63 | + | |
64 | +/** | |
65 | + * Iterates through morphological analysis and synthesis results. | |
66 | + * | |
67 | + */ | |
4 | 68 | %} |
5 | 69 | |
6 | 70 | %typemap(javaimports) std::vector %{ |
... | ... | @@ -12,7 +76,7 @@ import java.util.AbstractList; |
12 | 76 | try { |
13 | 77 | $action |
14 | 78 | } |
15 | - catch(FileFormatException & e) { | |
79 | + catch(morfeusz::FileFormatException & e) { | |
16 | 80 | jclass clazz = jenv->FindClass("java/io/IOException"); |
17 | 81 | jenv->ThrowNew(clazz, "Invalid file format"); |
18 | 82 | return $null; |
... | ... | @@ -23,40 +87,66 @@ import java.util.AbstractList; |
23 | 87 | try { |
24 | 88 | $action |
25 | 89 | } |
26 | - catch(FileFormatException & e) { | |
90 | + catch(morfeusz::FileFormatException & e) { | |
27 | 91 | jclass clazz = jenv->FindClass("java/io/IOException"); |
28 | 92 | jenv->ThrowNew(clazz, "Invalid file format"); |
29 | 93 | return $null; |
30 | 94 | } |
31 | 95 | } |
32 | 96 | |
97 | +%typemap(javainterfaces) morfeusz::ResultsIterator "Iterator<MorphInterpretation>" | |
33 | 98 | %typemap(javabase) std::vector<morfeusz::MorphInterpretation> "AbstractList<MorphInterpretation>" |
34 | 99 | %typemap(javabase) std::vector<morfeusz::String> "AbstractList<String>" |
100 | +%typemap(javabase) morfeusz::MorfeuszException "RuntimeException" | |
35 | 101 | |
36 | 102 | %typemap(javacode) morfeusz::Morfeusz %{ |
37 | 103 | |
38 | - public List<MorphInterpretation> analyze(String text) { | |
104 | + /** | |
105 | + * Analyze given text and return the results as list. | |
106 | + * | |
107 | + * @param text text for morphological analysis. | |
108 | + * @return list containing the results of morphological analysis | |
109 | + */ | |
110 | + public List<MorphInterpretation> analyzeAsList(String text) { | |
39 | 111 | InterpsList res = new InterpsList(); |
40 | 112 | analyze(text, res); |
41 | - return res; | |
113 | + return Collections.unmodifiableList(res); | |
42 | 114 | } |
43 | - | |
44 | -// public ResultsIterator analyzeAsIterator(String text) { | |
45 | -// ResultsIterator res = analyze(text); | |
46 | -// res.setTextReference(text); | |
47 | -// return res; | |
48 | -// } | |
49 | - | |
50 | - public List<MorphInterpretation> generate(String text) { | |
115 | + | |
116 | + /** | |
117 | + * Perform morphological synthesis on a given lemma. | |
118 | + * | |
119 | + * @param lemma lemma to be synthesized | |
120 | + * @return list containing results of the morphological synthesis | |
121 | + */ | |
122 | + public List<MorphInterpretation> generate(String lemma) { | |
51 | 123 | InterpsList res = new InterpsList(); |
52 | - generate(text, res); | |
53 | - return res; | |
124 | + generate(lemma, res); | |
125 | + return Collections.unmodifiableList(res); | |
54 | 126 | } |
55 | - | |
56 | - public List<MorphInterpretation> generate(String text, int tagnum) { | |
127 | + | |
128 | + /** | |
129 | + * Perform morphological synthesis on a given lemma. | |
130 | + * Limit results to interpretations with the specified tag. | |
131 | + * | |
132 | + * @param lemma lemma to be analyzed | |
133 | + * @param tagnum tag number of result interpretations | |
134 | + * @return list containing results of the morphological synthesis | |
135 | + */ | |
136 | + public List<MorphInterpretation> generate(String lemma, int tagnum) { | |
57 | 137 | InterpsList res = new InterpsList(); |
58 | - generate(text, tagnum, res); | |
59 | - return res; | |
138 | + generate(lemma, tagnum, res); | |
139 | + return Collections.unmodifiableList(res); | |
140 | + } | |
141 | +%} | |
142 | + | |
143 | +%typemap(javacode) morfeusz::ResultsIterator %{ | |
144 | + | |
145 | + /** | |
146 | + * Removing of elements from this iterator is not supported. | |
147 | + */ | |
148 | + public void remove() { | |
149 | + throw new java.lang.UnsupportedOperationException(); | |
60 | 150 | } |
61 | 151 | %} |
62 | 152 | |
... | ... | @@ -70,46 +160,12 @@ import java.util.AbstractList; |
70 | 160 | |
71 | 161 | %typemap(javadestruct, methodname="delete", methodmodifiers="private") SWIGTYPE ""; |
72 | 162 | |
73 | -%javamethodmodifiers morfeusz::Morfeusz::analyze(const std::string&) const "private"; | |
74 | 163 | %javamethodmodifiers morfeusz::Morfeusz::analyze(const std::string&, std::vector<MorphInterpretation>&) const "private"; |
75 | 164 | %javamethodmodifiers morfeusz::Morfeusz::generate(const std::string&, std::vector<MorphInterpretation>&) const "private"; |
76 | 165 | %javamethodmodifiers morfeusz::Morfeusz::generate(const std::string&, int, std::vector<MorphInterpretation>&) const "private"; |
77 | 166 | |
78 | -// ignore size_t std::vector<T>::size() function as it gives "long" return type instead of "int" | |
79 | -%rename("$ignore", regextarget=1, fullname=1) "std::vector<.*>::size$"; | |
80 | - | |
81 | 167 | %typemap(javaclassmodifiers) std::vector "class" |
82 | 168 | |
83 | -%typemap(javacode) std::vector %{ | |
84 | - public int size() { | |
85 | - return getSizeAsInt(); | |
86 | - } | |
87 | -%} | |
88 | - | |
89 | -%extend std::vector { | |
90 | -// T& std::vector::get(int idx) { | |
91 | -// return at(idx); | |
92 | -// } | |
93 | - | |
94 | -// void std::vector::set(int idx, const T& object) { | |
95 | -// (*this)[idx] = object; | |
96 | -// } | |
97 | - | |
98 | - void std::vector::add(int idx, const T& object) { | |
99 | - insert(begin() + idx, object); | |
100 | - } | |
101 | - | |
102 | - T std::vector::remove(int idx) { | |
103 | - T res = this->at(idx); | |
104 | - erase(begin() + idx); | |
105 | - return res; | |
106 | - } | |
107 | - | |
108 | - int getSizeAsInt() const { | |
109 | - return size(); | |
110 | - } | |
111 | -} | |
112 | - | |
113 | 169 | %include "enums.swg" |
114 | 170 | |
115 | 171 | /* Force the generated Java code to use the C enum values rather than making a JNI call */ |
... | ... | @@ -120,3 +176,7 @@ import java.util.AbstractList; |
120 | 176 | System.loadLibrary("jmorfeusz"); |
121 | 177 | } |
122 | 178 | %} |
179 | + | |
180 | +%pragma(java) jniclassimports=%{ | |
181 | +import java.io.IOException; | |
182 | +%} | |
... | ... |
morfeusz/wrappers/morfeusz_javadoc.i
0 → 100644
1 | +%javamethodmodifiers morfeusz::Morfeusz::createInstance() " | |
2 | + /** | |
3 | + * Creates actual instance of Morfeusz class. | |
4 | + * | |
5 | + * @return Morfeusz instance | |
6 | + */ | |
7 | + public"; | |
8 | + | |
9 | +%javamethodmodifiers morfeusz::Morfeusz::getVersion() " | |
10 | + /** | |
11 | + * Returns a string containing library version. | |
12 | + * @return library version string | |
13 | + */ | |
14 | + public"; | |
15 | + | |
16 | +%javamethodmodifiers morfeusz::Morfeusz::analyzeAsIterator(const char*) const " | |
17 | + /** | |
18 | + * Analyze given text and return the results as iterator. | |
19 | + * It does not store results for whole text at once, so may be less memory-consuming for analysis of big texts. | |
20 | + * | |
21 | + * @param text text for morphological analysis. | |
22 | + * @return iterator over morphological analysis results | |
23 | + */ | |
24 | + public"; | |
25 | + | |
26 | +%javamethodmodifiers morfeusz::Morfeusz::setAggl(const std::string&) " | |
27 | + /** | |
28 | + * Set aggl segmentation option value. | |
29 | + * | |
30 | + * @param aggl aggl value | |
31 | + */ | |
32 | + public"; | |
33 | + | |
34 | +%javamethodmodifiers morfeusz::Morfeusz::setPraet(const std::string&) " | |
35 | + /** | |
36 | + * Set praet segmentation option value. | |
37 | + * | |
38 | + * @param praet praet value | |
39 | + */ | |
40 | + public"; | |
41 | + | |
42 | +%javamethodmodifiers morfeusz::Morfeusz::setCaseHandling(CaseHandling) " | |
43 | + /** | |
44 | + * Set case handling. | |
45 | + * | |
46 | + * @param caseHandling case handling policy | |
47 | + */ | |
48 | + public"; | |
49 | + | |
50 | +%javamethodmodifiers morfeusz::Morfeusz::setTokenNumbering(TokenNumbering) " | |
51 | + /** | |
52 | + * Set token numbering policy. | |
53 | + * | |
54 | + * @param numbering token numbering policy | |
55 | + */ | |
56 | + public"; | |
57 | + | |
58 | +%javamethodmodifiers morfeusz::Morfeusz::setWhitespaceHandling(WhitespaceHandling) " | |
59 | + /** | |
60 | + * Set whitespace handling. | |
61 | + * | |
62 | + * @param whitespaceHandling whitespace handling policy | |
63 | + */ | |
64 | + public"; | |
0 | 65 | \ No newline at end of file |
... | ... |
test.sh deleted
1 | -#!/bin/bash | |
2 | - | |
3 | -function doCheckFiles() { | |
4 | - tmpOut=`mktemp` | |
5 | - command=$1 | |
6 | - shift | |
7 | - input=$1 | |
8 | - shift | |
9 | - requiredOutput=$1 | |
10 | - shift | |
11 | - args=$@ | |
12 | - $command $args < $input > $tmpOut | |
13 | - diff=`diff --brief $requiredOutput $tmpOut` | |
14 | - if [ "$diff" != "" ] | |
15 | - then | |
16 | - diff -u $requiredOutput $tmpOut >&2 | |
17 | - echo "#### Output for $input differs from $requiredOutput" >&2 | |
18 | - exit 1 | |
19 | - fi | |
20 | -} | |
21 | - | |
22 | -function checkAnalyzerFiles() { | |
23 | - input=$1 | |
24 | - shift | |
25 | - requiredOutput=$1 | |
26 | - shift | |
27 | - doCheckFiles morfeusz/morfeusz_analyzer $input $requiredOutput $@ | |
28 | -} | |
29 | - | |
30 | -checkAnalyzerFiles testfiles/test.in testfiles/test.out $@ |
testJavaWrapper.sh
0 → 100755