Commit f10d9d64259c0ed7bb0a3162e132425f3d151236
1 parent
d4f524a2
- dodanie porządniejszej dokumentacji w Pythonie + różne drobne poprawki w wrapperze
git-svn-id: svn://svn.nlp.ipipan.waw.pl/morfeusz/trunk@301 ff4e3ee1-f430-4e82-ade0-24591c43f1fd
Showing
4 changed files
with
126 additions
and
16 deletions
deploy.sh
0 → 100755
morfeusz/wrappers/java/CMakeLists.txt
... | ... | @@ -61,7 +61,7 @@ add_jar (jmorfeusz |
61 | 61 | |
62 | 62 | add_custom_target(generate-javadoc |
63 | 63 | COMMAND javadoc |
64 | - -d "${CMAKE_CURRENT_BINARY_DIR}/jmorfeusz_javadoc" | |
64 | + -d "${TARGET_DIR}/javadoc" | |
65 | 65 | -sourcepath "${CMAKE_CURRENT_BINARY_DIR}" |
66 | 66 | -windowtitle "JMorfeusz - Morfeusz Java binding" |
67 | 67 | -use |
... | ... | @@ -71,7 +71,7 @@ add_custom_target(generate-javadoc |
71 | 71 | DEPENDS jmorfeusz) |
72 | 72 | |
73 | 73 | add_custom_target(package-javadoc |
74 | - COMMAND mkdir -p "${TARGET_DIR}" && ${CMAKE_COMMAND} -E tar "cfvz" "${TARGET_DIR}/jmorfeusz_javadoc.tgz" "${CMAKE_CURRENT_BINARY_DIR}/jmorfeusz_javadoc" | |
74 | + COMMAND mkdir -p "${TARGET_DIR}" && ${CMAKE_COMMAND} -E tar "cfvz" "${TARGET_DIR}/javadoc.tgz" "${TARGET_DIR}/javadoc" | |
75 | 75 | DEPENDS generate-javadoc) |
76 | 76 | |
77 | 77 | if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
... | ... |
morfeusz/wrappers/morfeusz_python.i
... | ... | @@ -55,25 +55,13 @@ |
55 | 55 | } |
56 | 56 | }; |
57 | 57 | |
58 | -%ignore morfeusz::Morfeusz::createInstance(morfeusz::MorfeuszUsage); | |
58 | +//%ignore morfeusz::Morfeusz::createInstance(morfeusz::MorfeuszUsage); | |
59 | 59 | %extend morfeusz::Morfeusz { |
60 | 60 | std::vector<morfeusz::MorphInterpretation> morfeusz::Morfeusz::_generateByTagId(const std::string& lemma, int tagId) const { |
61 | 61 | std::vector<morfeusz::MorphInterpretation> res; |
62 | 62 | $self->generate(lemma, tagId, res); |
63 | 63 | return res; |
64 | 64 | } |
65 | - | |
66 | - static morfeusz::Morfeusz* morfeusz::Morfeusz::createAnalyzerInstance(const std::string& dictName=morfeusz::Morfeusz::getDefaultDictName()) { | |
67 | - return morfeusz::Morfeusz::createInstance(morfeusz::ANALYSE_ONLY); | |
68 | - } | |
69 | - | |
70 | - static morfeusz::Morfeusz* morfeusz::Morfeusz::createGeneratorInstance(const std::string& dictName=morfeusz::Morfeusz::getDefaultDictName()) { | |
71 | - return morfeusz::Morfeusz::createInstance(morfeusz::GENERATE_ONLY); | |
72 | - } | |
73 | - | |
74 | - static morfeusz::Morfeusz* morfeusz::Morfeusz::createInstance(const std::string& dictName=morfeusz::Morfeusz::getDefaultDictName()) { | |
75 | - return morfeusz::Morfeusz::createInstance(morfeusz::BOTH_ANALYSE_AND_GENERATE); | |
76 | - } | |
77 | 65 | }; |
78 | 66 | |
79 | 67 | %feature("shadow") morfeusz::ResultsIterator::next %{ |
... | ... | @@ -88,7 +76,7 @@ def next(self): |
88 | 76 | |
89 | 77 | def analyse_iter(self, text): |
90 | 78 | """ |
91 | - Analyse given text and return an iterator over MorphInterpretation as a result. | |
79 | + Analyse given text and return an iterator over MorphInterpretation objects as a result. | |
92 | 80 | """ |
93 | 81 | return $action(self, text) |
94 | 82 | %} |
... | ... | @@ -103,6 +91,72 @@ def analyse(self, text): |
103 | 91 | return res |
104 | 92 | %} |
105 | 93 | |
94 | +%feature("shadow") morfeusz::Morfeusz::setAggl %{ | |
95 | +def setAggl(self, optionString): | |
96 | + """ | |
97 | + Select agglutination rules option | |
98 | + """ | |
99 | + $action(self, optionString.encode('utf8')) | |
100 | +%} | |
101 | + | |
102 | +%feature("shadow") morfeusz::Morfeusz::setPraet %{ | |
103 | +def setPraet(self, optionString): | |
104 | + """ | |
105 | + Select past tense segmentation | |
106 | + """ | |
107 | + $action(self, optionString.encode('utf8')) | |
108 | +%} | |
109 | + | |
110 | +%feature("shadow") morfeusz::Morfeusz::setCaseHandling %{ | |
111 | +def setCaseHandling(self, option): | |
112 | + """ | |
113 | + Set case handling option (valid options are CONDITIONALLY_CASE_SENSITIVE, STRICTLY_CASE_SENSITIVE, IGNORE_CASE) | |
114 | + """ | |
115 | + $action(self, option) | |
116 | +%} | |
117 | + | |
118 | +%feature("shadow") morfeusz::Morfeusz::setTokenNumbering %{ | |
119 | +def setTokenNumbering(self, option): | |
120 | + """ | |
121 | + Set token numbering option (valid options are SEPARATE_NUMBERING, CONTINUOUS_NUMBERING) | |
122 | + """ | |
123 | + $action(self, option) | |
124 | +%} | |
125 | + | |
126 | +%feature("shadow") morfeusz::Morfeusz::setWhitespaceHandling %{ | |
127 | +def setWhitespaceHandling(self, option): | |
128 | + """ | |
129 | + Set whitespace handling handling option (valid options are SKIP_WHITESPACES, KEEP_WHITESPACES, APPEND_WHITESPACES) | |
130 | + """ | |
131 | + $action(self, option) | |
132 | +%} | |
133 | + | |
134 | +%feature("shadow") morfeusz::Morfeusz::setDictionary %{ | |
135 | +def setDictionary(self, dictName): | |
136 | + """ | |
137 | + Set dictionary to be used by this instance (by name) | |
138 | + """ | |
139 | + $action(self, dictName.encode('utf8')) | |
140 | +%} | |
141 | + | |
142 | +%feature("shadow") morfeusz::Morfeusz::createInstance(morfeusz::MorfeuszUsage) %{ | |
143 | +@staticmethod | |
144 | +def _createInstance(usage): | |
145 | + return $action(usage) | |
146 | +%} | |
147 | + | |
148 | +%feature("shadow") morfeusz::Morfeusz::createInstance(const std::string&, morfeusz::MorfeuszUsage) %{ | |
149 | +@staticmethod | |
150 | +def createInstance(dictName=None, usage=BOTH_ANALYSE_AND_GENERATE): | |
151 | + """ | |
152 | + Creates new instance of Morfeusz class. Usage may be BOTH_ANALYZE_AND_GENERATE (default), ONLY_ANALYSE and ONLY_GENERATE. | |
153 | + """ | |
154 | + if dictName is None: | |
155 | + return Morfeusz._createInstance(usage) | |
156 | + else: | |
157 | + return $action(dictName.encode('utf8'), usage) | |
158 | +%} | |
159 | + | |
106 | 160 | %feature("shadow") morfeusz::Morfeusz::_generateByTagId %{ |
107 | 161 | def _generateByTagId(self, lemma, tagId): |
108 | 162 | res = InterpsList() |
... | ... | @@ -151,6 +205,56 @@ def generate(self, lemma, tagId=None): |
151 | 205 | %} |
152 | 206 | }; |
153 | 207 | |
208 | +%feature("shadow") morfeusz::MorphInterpretation::getTag %{ | |
209 | +def getTag(self, morfeusz): | |
210 | + """ | |
211 | + Returns tag as string. | |
212 | + """ | |
213 | + return $action(self, morfeusz) | |
214 | +%} | |
215 | + | |
216 | +%feature("shadow") morfeusz::MorphInterpretation::getName %{ | |
217 | +def getName(self, morfeusz): | |
218 | + """ | |
219 | + Returns this interpretation named entity as string | |
220 | + """ | |
221 | + return $action(self, morfeusz) | |
222 | +%} | |
223 | + | |
224 | +%feature("shadow") morfeusz::MorphInterpretation::getLabelsAsString %{ | |
225 | +def getLabelsAsUnicode(self, morfeusz): | |
226 | + """ | |
227 | + Returns this interpretation labels as string | |
228 | + """ | |
229 | + return $action(self, morfeusz).decode('utf8') | |
230 | +%} | |
231 | + | |
232 | +%feature("shadow") morfeusz::MorphInterpretation::getLabels %{ | |
233 | +def getLabels(self, morfeusz): | |
234 | + """ | |
235 | + Returns this interpretation labels as a set of strings | |
236 | + """ | |
237 | + return { l.decode('utf8') for l in $action(self, morfeusz) } | |
238 | +%} | |
239 | + | |
240 | +%feature("shadow") morfeusz::MorphInterpretation::createIgn %{ | |
241 | +@staticmethod | |
242 | +def createIgn(startNode, endNode, orth, lemma): | |
243 | + """ | |
244 | + Creates unknown interpretation | |
245 | + """ | |
246 | + return $action(self, startNode, endNode, orth.encode('utf8'), lemma.encode('utf8')) | |
247 | +%} | |
248 | + | |
249 | +%feature("shadow") morfeusz::MorphInterpretation::createWhitespace %{ | |
250 | +@staticmethod | |
251 | +def createWhitespace(startNode, endNode, orth): | |
252 | + """ | |
253 | + Creates whitespace interpretation | |
254 | + """ | |
255 | + return $action(self, startNode, endNode, orth.encode('utf8')) | |
256 | +%} | |
257 | + | |
154 | 258 | %feature("shadow") morfeusz::IdResolver::getTag %{ |
155 | 259 | def getTag(self, tagId): |
156 | 260 | return $action(self, tagId).decode('utf8') |
... | ... |
morfeusz/wrappers/python/test.py
... | ... | @@ -54,6 +54,9 @@ class TestSequenceFunctions(unittest.TestCase): |
54 | 54 | except RuntimeError: |
55 | 55 | pass |
56 | 56 | |
57 | + def testValidCaseHandling(self): | |
58 | + self.morfeusz.setCaseHandling(morfeusz2.IGNORE_CASE) | |
59 | + | |
57 | 60 | def testInvalidCaseHandling(self): |
58 | 61 | try: |
59 | 62 | self.morfeusz.setCaseHandling(0) |
... | ... |