Commit 9a42d9209cc7d23ef1b2441ceeda3313e332a207

Authored by Michał Lenart
1 parent d2e7800b

- praca nad upiększeniem wrappera javowego

git-svn-id: svn://svn.nlp.ipipan.waw.pl/morfeusz/morfeusz@240 ff4e3ee1-f430-4e82-ade0-24591c43f1fd
morfeusz/wrappers/morfeusz.i
... ... @@ -23,6 +23,7 @@ using namespace morfeusz;
23 23 %include "std_string.i"
24 24 %include "std_except.i"
25 25 %include "exception.i"
  26 +%include "typemaps.i"
26 27  
27 28 %exception {
28 29 try{
... ... @@ -43,6 +44,7 @@ using namespace morfeusz;
43 44 %include "morfeusz_java.i"
44 45 #endif
45 46  
  47 +
46 48 namespace morfeusz {
47 49 %ignore MorphInterpretation::MorphInterpretation(
48 50 int startNode,
... ... @@ -57,22 +59,28 @@ namespace morfeusz {
57 59 %ignore MorphInterpretation::createIgn(int startNode, int endNode, const std::string& orth, const Tagset<std::string>& tagset);
58 60 %ignore MorphInterpretation::createWhitespace(int startNode, int endNode, const std::string& orth, const Tagset<std::string>& tagset);
59 61 %ignore Morfeusz::analyze(const char*) const;
  62 +
  63 + %newobject Morfeusz::createInstance();
  64 + %newobject Morfeusz::analyze(const std::string&) const;
60 65 }
61 66  
  67 +%template(InterpsList) std::vector<morfeusz::MorphInterpretation>;
  68 +%template(StringsList) std::vector<string>;
  69 +
62 70 // instantiate vector of interpretations
63 71 namespace std {
64 72 // dirty hack so it will compile without no-arg constructor for MorphInterpretation
65 73 %ignore vector<morfeusz::MorphInterpretation>::vector(size_type);
66 74 %ignore vector<morfeusz::MorphInterpretation>::resize;
67 75  
68   - %template(InterpsList) vector<morfeusz::MorphInterpretation>;
69   - %template(StringsList) vector<string>;
  76 +
  77 + //%template(InterpsList) vector<morfeusz::MorphInterpretation>;
  78 + //%template(StringsList) vector<string>;
  79 +
  80 +
70 81 }
71 82  
72   -//%include "../Morfeusz.hpp"
73 83 %include "../morfeusz2.h"
74   -//%include "../const.hpp"
75   -//%include "../exceptions.hpp"
76 84  
77 85  
78 86 #ifdef SWIGPYTHON
... ...
morfeusz/wrappers/morfeusz_java.i
... ... @@ -33,4 +33,21 @@ import java.io.IOException;
33 33 static {
34 34 System.loadLibrary("jmorfeusz");
35 35 }
36   -%}
37 36 \ No newline at end of file
  37 +%}
  38 +
  39 +%typemap(javabase) std::vector<morfeusz::MorphInterpretation> "java.util.AbstractList<MorphInterpretation>"
  40 +%typemap(javabase) std::vector<morfeusz::String> "java.util.AbstractList<String>"
  41 +
  42 +%typemap(javabody) morfeusz::Morfeusz %{
  43 + public List<MorphInterpretation> analyzeAsList(String text) {
  44 + InterpsList res = new InterpsList();
  45 + analyze(text, res);
  46 + return res;
  47 + }
  48 +%}
  49 +
  50 +%extend std::vector {
  51 + T& std::vector::get(int idx) const {
  52 + return at(idx);
  53 + }
  54 +}
38 55 \ No newline at end of file
... ...