Background
The FreeLing API defines an interface that does not adhere to standard Java naming conventions. For example:
package freeling;
public class sentence extends ListWord {
public void set_parse_tree(parse_tree arg0) {
The interface is defined using SWIG, which is similar to IDL:
class sentence : public std::list<word> {
public:
sentence(void);
void set_parse_tree(const parse_tree &);
Problem
Academically speaking, how would you map the interface to conventional Java naming standards (e.g., class Sentence and setParseTree( parseTree arg0 ))?
Ideas
- Convert the 650+ line interface file manually (and send a patch to the developers).
- Regex search and replace voodoo (using vi):
:1,$s/_\([a-z]\)/\u\1/g - Create wrapper classes from the 53 auto-generated Java source files.
Thank you!
SWIG provides a
%renamedirective that allows the names to be different in the client and implementation languages.But doing this will nearly double the length of the interface file.Actually, SWIG provides bulk renaming. See the documentation
My recommendation is just to leave it as-is. You’re calling C++ functions, they have C++ names. If anything, this helps you remember that you’re calling out to C++ and need to follow C++ rules for object lifetime management, there’s a slight JNI performance penalty, etc.