mitar avatar mitar committed 10369e6

New version of `setup.py`.

Comments (0)

Files changed (66)

-include *.py addon.xml *.txt
-recursive-include source *
-recursive-include doc *.*
-recursive-include widgets *.*
-
+recursive-include _text *.png
+recursive-include scripts *
+include COPYING
+include LICENSE
+include *.py *.txt *.rst
 #!/usr/bin/env python
-"""\
-Text Mining Add-On for Orange
-
-Orange Text Mining is an addon for the Orange data
-mining software package.
-"""
-DOCLINES = __doc__.split("\n")
 
 try:
-    from setuptools import setup
-    have_setuptools = True
+    import distribute_setup
+    distribute_setup.use_setuptools()
 except ImportError:
-    from distutils.core import setup
-    have_setuptools = False
-    
-from distutils.core import Extension
-import distutils.ccompiler
-import os, sys, glob
+    # For documentation we load setup.py to get version
+    # so it does not matter if importing fails
+    pass
 
+import os, sys
 
-CLASSIFIERS = """\
-Development Status :: 4 - Beta
-Programming Language :: Python
-License :: OSI Approved :: GNU General Public License (GPL)
-Operating System :: POSIX
-Operating System :: Microsoft :: Windows
-Topic :: Scientific/Engineering :: Information Analysis
-Intended Audience :: Education
-Intended Audience :: Science/Research
-"""
+from setuptools import setup, find_packages
 
-KEYWORDS = """\
-data mining 
-machine learning,
-artificial intelligence
-text mining
-"""                      
+# Has to be last import as it seems something is changing it somewhere
+from distutils.extension import Extension
 
-NAME                = "Orange-Text-Mining"
-DESCRIPTION         = DOCLINES[0]
-LONG_DESCRIPTION    = "\n".join(DOCLINES[2:])
-URL                 = "https://bitbucket.org/biolab/orange-addon-text"
-DOWNLOAD_URL        = "https://bitbucket.org/biolab/orange-addon-text/downloads"
-LICENSE             = "GNU General Public License (GPL)"
-CLASSIFIERS         = filter(None, CLASSIFIERS.split("\n"))
-AUTHOR              = "Bojana Dalbelo Basic, Sasa Petrovic, Frane Saric, Mladen Kolar, Annie Morin, Jean-Hugues Chauchat"
-KEYWORDS            = filter(None, KEYWORDS.split('\n'))
+NAME = 'Orange-Text'
+DOCUMENTATION_NAME = 'Orange Text Mining'
 
-MAYOR = 1
-MINOR = 1
-MICRO = 0
-ISRELEASED = False
+VERSION = '1.2'
 
-VERSION = "%i.%ia.%i" % (MAYOR, MINOR, MICRO)
+DESCRIPTION = 'Orange Text Mining add-on for Orange data mining software package.'
+LONG_DESCRIPTION = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
+AUTHOR = 'Bioinformatics Laboratory, FRI UL'
+AUTHOR_EMAIL = 'contact@orange.biolab.si'
+URL = 'http://orange.biolab.si/addons/'
+DOWNLOAD_URL = 'https://bitbucket.org/biolab/orange-text/downloads'
+LICENSE = 'GPLv3'
 
-extra_compile_args=[
-        '-fno-strict-aliasing',
-        '-Wall',
-        '-Wno-sign-compare',
-        '-Woverloaded-virtual'
-        ]
+KEYWORDS = (
+    'data mining',
+    'machine learning',
+    'artificial intelligence',
+    'text mining',
+    'orange',
+    'orange add-on',
+)
 
-if sys.platform == "win32":
-    # For mingw compiler
-    extra_link_args=["-static-libgcc", "-static-libstdc++"] 
-else:
-    extra_link_args = []
-    
-# list all documentation files that need to be included
-docFiles = []
-for (dirp, dirns, n) in os.walk('doc'):
-	nr = [n1.replace('\\', '/') for n1 in n]
-	dirn = dirp.replace('\\', '/')[4:]
-	if len(dirn):
-		dirn = dirn + '/'
-	docFiles.extend( [dirn + n1r for n1r in nr if '.svn' not in dirp + '/' + n1r] )
+CLASSIFIERS = (
+    'Development Status :: 4 - Beta',
+    'Environment :: X11 Applications :: Qt',
+    'Environment :: Console',
+    'Environment :: Plugins',
+    'Programming Language :: Python',
+    'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
+    'Operating System :: OS Independent',
+    'Topic :: Scientific/Engineering :: Artificial Intelligence',
+    'Topic :: Scientific/Engineering :: Visualization',
+    'Topic :: Software Development :: Libraries :: Python Modules',
+    'Intended Audience :: Education',
+    'Intended Audience :: Science/Research',
+    'Intended Audience :: Developers',
+)
 
-modules = [
-        Extension(
-                '_orngTextWrapper',
-                sources=[
-                                'source/orngTextWrapper/Wrapper_wrap.cxx',
-                                'source/orngTextWrapper/Wrapper.cpp',
-                                'source/tmt/common/Common.cpp',
-                                'source/tmt/common/Files.cpp',
-                                'source/tmt/lemmatization/FSADictionary.cpp',
-                                'source/tmt/lemmatization/FSALemmatization.cpp',
-                                'source/tmt/lemmatization/Lemmatization.cpp',
-                                'source/tmt/lemmatization/PorterStemmer.cpp',
-                                'source/tmt/strings/StringUtils.cpp',
-                                'source/tmt/strings/UTF8Tokenizer.cpp',
-                                'source/lemmagen/RdrLemmatizer.cpp'
-                ],
-                extra_compile_args=extra_compile_args,
-                include_dirs=['.', 'source'],
-                define_macros=[('TMTNOZLIB','1'), ('NDEBUG', '1')],
-                language='c++',
-                extra_link_args=extra_link_args
-        )
+PACKAGES = find_packages(
+    exclude = ('*.tests', '*.tests.*', 'tests.*', 'tests'),
+)
+
+PACKAGE_DATA = {
+}
+
+SETUP_REQUIRES = (
+    'setuptools',
+)
+
+INSTALL_REQUIRES = (
+    'Orange',
+    'setuptools',
+),
+
+EXTRAS_REQUIRE = {
+    'GUI': (
+        # Dependencies which are problematic to install automatically
+        #'PyQt', # No setup.py
+    ),
+}
+
+DEPENDENCY_LINKS = (
+)
+
+ENTRY_POINTS = {
+    'orange.addons': (
+        'text = _text',
+    ),
+    'orange.widgets': (
+        'Text Mining = _text.widgets',
+    ),
+}
+
+extra_compile_args = [
+    '-fno-strict-aliasing',
+    '-Wall',
+    '-Wno-sign-compare',
+    '-Woverloaded-virtual',
 ]
 
-DEST_DIR="Orange/add-ons/Text"
+extra_link_args = [
+]
 
-if os.path.exists("VERSION.txt"):
-    VERSION = open("VERSION.txt", "rb").read()
+if sys.platform == 'win32':
+    # For MinGW compiler
+    extra_link_args += [
+        '-static-libgcc',
+        '-static-libstdc++',
+    ]
+    
+EXT_MODULES = [
+    Extension(
+        '_text._orngTextWrapper',
+        sources = [
+            'src/orngTextWrapper/Wrapper_wrap.cxx',
+            'src/orngTextWrapper/Wrapper.cpp',
+            'src/tmt/common/Common.cpp',
+            'src/tmt/common/Files.cpp',
+            'src/tmt/lemmatization/FSADictionary.cpp',
+            'src/tmt/lemmatization/FSALemmatization.cpp',
+            'src/tmt/lemmatization/Lemmatization.cpp',
+            'src/tmt/lemmatization/PorterStemmer.cpp',
+            'src/tmt/strings/StringUtils.cpp',
+            'src/tmt/strings/UTF8Tokenizer.cpp',
+            'src/lemmagen/RdrLemmatizer.cpp',
+        ],
+        language = 'c++',
+        extra_compile_args = extra_compile_args,
+        extra_link_args = extra_link_args,
+        include_dirs = [
+            os.path.abspath(os.path.join(os.path.dirname(__file__), 'src')),
+        ],
+        define_macros = [
+            ('TMTNOZLIB', '1'),
+            ('NDEBUG', '1'),
+        ],
+    ),
+]
 
-if have_setuptools:
-    setuptool_args = {"install_requires": ["Orange"],
-                      "zip_safe": False,
-                     }
-else:
-    setuptool_args = {}
-    
-    
-PACKAGES = [ 'widgets', 'widgets.prototypes', 'doc', '' ]
-
-PACKAGE_DATA = {'doc': docFiles, 
-                'widgets': ['icons/*.png'],
-                '': ['addon.xml']
-                }
-
-if __name__ == "__main__":
-        setup(name = NAME,
-              version = VERSION,
-              description = DESCRIPTION,
-              long_description = LONG_DESCRIPTION,
-              author = AUTHOR,
-              url = URL,
-              download_url = DOWNLOAD_URL,
-              license = LICENSE,
-              package_dir = {"": "."},
-              packages = PACKAGES,
-              package_data = PACKAGE_DATA,
-              py_modules = [ 'orngText', 'orngTextWrapper', 'textConfiguration'],
-              extra_path = ("orange-text", DEST_DIR),
-              ext_modules = modules,
-              **setuptool_args)
-
+if __name__ == '__main__':
+    setup(
+        name = NAME,
+        version = VERSION,
+        description = DESCRIPTION,
+        long_description = LONG_DESCRIPTION,
+        author = AUTHOR,
+        author_email = AUTHOR_EMAIL,
+        url = URL,
+        download_url = DOWNLOAD_URL,
+        license = LICENSE,
+        keywords = KEYWORDS,
+        classifiers = CLASSIFIERS,
+        packages = PACKAGES,
+        package_data = PACKAGE_DATA,
+        setup_requires = SETUP_REQUIRES,
+        install_requires = INSTALL_REQUIRES,
+        extras_require = EXTRAS_REQUIRE,
+        dependency_links = DEPENDENCY_LINKS,
+        entry_points = ENTRY_POINTS,
+        include_package_data = True,
+        zip_safe = False,
+        ext_modules = EXT_MODULES,
+    )

source/Makefile

-PYTHONINCLUDE = $(shell python -c "import sys; print sys.prefix+'/include/python'+sys.version[:3]")
-PYTHONLIB = $(shell python -c "import sys; print sys.prefix+'/lib/python'+sys.version[:3]")
-PYTHONSITEPKGS = $(PYTHONLIB)/site-packages
-OS = $(shell uname)
-
-COMPILER = g++
-CCOMPILER = gcc
-LINKER = g++
-
-ifeq ($(OS), Darwin)
-  COMPILEOPTIONS = -fPIC -fpermissive -fno-common -w -O3 -I$(PYTHONINCLUDE)
-  LINKOPTIONS = -dynamiclib -headerpad_max_install_names -undefined dynamic_lookup -lstdc++ $(LDFLAGS)
-else
-  COMPILEOPTIONS = -fPIC -fpermissive -w -O3 -I$(PYTHONINCLUDE)
-  LINKOPTIONS = -shared -lstdc++ $(LDFLAGS)
-endif
-
-all: modules
-
-Makefile.depends: ../setup.py
-	python -c "import sys; sys.path=['..']+sys.path; import setup; setup.writeMakeFileDepends();"
-
-include Makefile.depends
-
-%.o: %.cxx
-	$(COMPILER) $(COMPILEOPTIONS) $(CXXFLAGS) $(COMPILEOPTIONSMODULES) -c $< -o $@
-
-%.cxx: %.i
-	swig -python $<
-
-%.o: %.cpp
-	$(COMPILER) $(COMPILEOPTIONS) $(CXXFLAGS) $(COMPILEOPTIONSMODULES) -c $< -o $@
-
-%.o: %.c
-	$(CCOMPILER) $(COMPILEOPTIONS) $(CFLAGS) $(COMPILEOPTIONSMODULES) -c $< -o $@
-
-clean:
-	rm -f *.o ../*.so
-	rm -f ./*/*.o ./*/*/*.o
-	rm Makefile.depends
-
-.PHONY: all clean

source/lemmagen/RdrLemmatizer.cpp

-/******************************************************************************
-This file is part of the lemmagen library. It gives support for lemmatization.
-Copyright (C) 2006-2007 Matjaz Jursic <matjaz@gmail.com>
-
-The lemmagen library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-******************************************************************************/
-#include "RdrLemmatizer.h"
-#include <cstdio>
-#include <cstring>
-#include <stdexcept>
-//-------------------------------------------------------------------------------------------
-//helper macros for nicer code and faster execution
-#if AddrLen == 3
-	#define GETDWORD(type, wVar, wAddr) \
-				type wVar = *((dword*) &abData[wAddr]) & 0x00FFFFF
-#else
-	#define GETDWORD(type, wVar, wAddr) \
-				type wVar = *((dword *) &abData[wAddr]) 
-#endif
-
-#define GETBYTEMOVE(type, bByte, iSize) \
-			type bByte = abData[iAddr]; \
-			iAddr += iSize
-
-#define GETDWORDMOVE(type, wVar, iSize) \
-			GETDWORD(type, wVar, iAddr);  \
-			iAddr += iSize
-
-#define GETSTRINGMOVE(type, acString, iSize) \
-			type acString = new char[iSize+1]; \
-			strncpy(acString, (char*) &abData[iAddr], iSize); \
-			acString[iSize] = NULL; \
-			iAddr += iSize
-
-//-------------------------------------------------------------------------------------------
-//constructor
-RdrLemmatizer::RdrLemmatizer() {
-	this->abData = (byte*) abDataStatic;
-	this->iDataLen = iDataLenStatic;
-}
-
-//-------------------------------------------------------------------------------------------
-//destructor
-RdrLemmatizer::~RdrLemmatizer() {
-	if (this->abData != (byte*) abDataStatic)
-		delete[] abData;
-}
-
-//-------------------------------------------------------------------------------------------
-//lematizes word according to this data
-char *RdrLemmatizer::Lemmatize(const char *acWord, char *acOutBuffer) const{
-	byte bWordLen = strlen(acWord);
-
-	dword iAddr = DataStart;
-	dword iParentAddr = DataStart;
-	dword iTmpAddr;
-	char bLookChar = bWordLen;
-	byte bType = abData[iAddr];
-
-	while(true) {
-		iTmpAddr = iAddr+FlagLen+AddrLen;
-				
-		//check if additional characters match
-		if ((bType & BitAddChar) == BitAddChar) {
-			byte bNewSufxLen = abData[iTmpAddr];
-			iTmpAddr += LenSpecLen;
-
-			bLookChar -= bNewSufxLen;
-
-			//test additional chars if ok
-			if (bLookChar>=0)
-				do bNewSufxLen--;
-				while (bNewSufxLen!=255 && abData[iTmpAddr+bNewSufxLen] == (byte) acWord[bLookChar+bNewSufxLen]);
-
-			//wrong node, take parents rule
-			if (bNewSufxLen!=255) {	iAddr = iParentAddr; break; } 
-
-			//right node, but we are at the end (there will be no new loop) finish by returning this rule
-			if ((bType & ~BitEntireWr) == TypeLeafAC) break;
-
-			//right node and we need to go on with subnodes (it si probably type TypeIntrAC )
-			//set iTmpAddr to start of hashtable
-			iTmpAddr += abData[iTmpAddr-LenSpecLen];
-		} 
-
-		//move lookup char back
-		bLookChar--;
-		//check if we are still inside the word (bLookChar==0 when at the begining of word)
-		if (bLookChar<0) {
-			//this means that we are just one character in front of the word so we must look for entireword entries
-			if((bType & BitInternal) == BitInternal) {
-				//go to the hashtable position 0(NULL) and look idf address is not NULL
-				iTmpAddr += ModLen;
-				byte bChar = abData[iTmpAddr];
-				GETDWORD(,iTmpAddr,iTmpAddr+CharLen);
-				if (bChar == NULL && iTmpAddr!=NULL) {
-					//we have a candidate for entireword, redirect addresses
-					iParentAddr = iAddr;
-					iAddr = iTmpAddr;
-					bType = abData[iAddr];
-					//increase lookchar (because we actualy eat one character)
-					bLookChar++;
-				}
-			}
-			break;
-		}
-		
-		//find best node in hash table
-		if((bType & BitInternal) == BitInternal) {
-			byte bMod = abData[iTmpAddr];
-			byte bChar = acWord[bLookChar];
-
-			iTmpAddr += ModLen + (bChar%bMod)*(AddrLen+CharLen); 
-
-			iTmpAddr = abData[iTmpAddr] == bChar ? iTmpAddr + CharLen : iAddr + FlagLen;
-
-			iParentAddr = iAddr;
-			GETDWORD(,iAddr, iTmpAddr);
-			bType = abData[iAddr];
-
-			if ((bType & ~BitEntireWr) == TypeRule) break;
-		}
-	}
-	//if this is entire-word node, and we are not at the begining of word it's wrong node - take parents
-	if((bType & BitEntireWr) == BitEntireWr && bLookChar!=0) {
-		iAddr = iParentAddr;
-		bType = abData[iAddr];
-	}
-
-	//search ended before we came to te node of type rule but current node is OK so find it's rule node
-	if((bType & ~BitEntireWr) != TypeRule)  GETDWORD( ,iAddr, iAddr+FlagLen);
-	
-	//we have (100%) node of type rule for lemmatization - now it's straight forward to lemmatize
-	//read out rule
-	iTmpAddr = iAddr + FlagLen;
-	byte iFromLen = abData[iTmpAddr];
-	iTmpAddr += LenSpecLen;
-	byte iToLen = abData[iTmpAddr];
-	iTmpAddr += LenSpecLen;
-
-	//prepare output buffer
-	byte iStemLen = bWordLen - iFromLen;
-	char *acReturn = acOutBuffer == NULL ? new char[iStemLen + iToLen + 1] : acOutBuffer;
-	
-	//do actual lematirazion using given rule
-	memcpy(acReturn, acWord, iStemLen);
-	memcpy(&acReturn[iStemLen], &abData[iTmpAddr], iToLen);
-	acReturn[iStemLen + iToLen] = NULL;
-	
-	return acReturn;
-}
-
-
-/*  OLD VERSION
-char *RdrLemmatizer::Lemmatize(const char *acWord, char *acOutBuffer) const{
-	byte bWordLen = strlen(acWord);
-
-	dword iAddr = DataStart;
-	dword iParentAddr = DataStart;
-	dword iTmpAddr;
-	char bLookChar = bWordLen;
-	byte bType = abData[iAddr];
-
-	while(true) {
-		iTmpAddr = iAddr+FlagLen+AddrLen;
-				
-		//check if additional characters match
-		if ((bType & BitAddChar) == BitAddChar) {
-			byte bNewSufxLen = abData[iTmpAddr];
-			iTmpAddr += LenSpecLen;
-
-			bLookChar -= bNewSufxLen;
-
-			//test additional chars if ok
-			if (bLookChar>=0)
-				do bNewSufxLen--;
-				while (bNewSufxLen!=255 && abData[iTmpAddr+bNewSufxLen] == (byte) acWord[bLookChar+bNewSufxLen]);
-
-			//wrong node, take parents rule
-			if (bNewSufxLen!=255) {	iAddr = iParentAddr; break; } 
-
-			//right node, but we are at the end (there will be no new loop) finish by returning this rule
-			if (bType == TypeLeafAC) break;
-
-			//right node and we need to go on with subnodes
-			iTmpAddr += abData[iTmpAddr-LenSpecLen];
-		} 
-
-		//move lookup char back
-		bLookChar--;
-		if (bLookChar<0) break;
-		
-		//find best node in hash table
-		if((bType & BitInternal) == BitInternal) {
-			byte bMod = abData[iTmpAddr];
-			byte bChar = acWord[bLookChar];
-
-			iTmpAddr += ModLen + (bChar%bMod)*(AddrLen+CharLen); 
-
-			iTmpAddr = abData[iTmpAddr] == bChar ? iTmpAddr + CharLen : iAddr + FlagLen;
-
-			iParentAddr = iAddr;
-			GETDWORD(,iAddr, iTmpAddr);
-			bType = abData[iAddr];
-
-			if (bType == TypeRule) break;
-		}
-	}
-	//search ended because we came to the begining of word
-	if(bType!=TypeRule)  GETDWORD( ,iAddr, iAddr+FlagLen);
-	
-	iTmpAddr = iAddr + FlagLen;
-	byte iFromLen = abData[iTmpAddr];
-	iTmpAddr += LenSpecLen;
-	byte iToLen = abData[iTmpAddr];
-	iTmpAddr += LenSpecLen;
-
-	//lematizes a word using given rule
-	byte iStemLen = bWordLen - iFromLen;
-	char *acReturn = acOutBuffer == NULL ? new char[iStemLen + iToLen + 1] : acOutBuffer;
-	
-	memcpy(acReturn, acWord, iStemLen);
-	memcpy(&acReturn[iStemLen], &abData[iTmpAddr], iToLen);
-	acReturn[iStemLen + iToLen] = NULL;
-	
-	return acReturn;
-} */
-
-
-//-------------------------------------------------------------------------------------------
-//loads all data needed from binary file
-void RdrLemmatizer::LoadBinary(istream &is) {
-	iDataLen =0;
-	is.read((char*) &iDataLen, 4);
-	abData = new byte[iDataLen];
-	is.read((char*) abData, iDataLen);
-}
-//-------------------------------------------------------------------------------------------
-//loads all data needed from binary file
-void RdrLemmatizer::LoadBinary(const char *acFileName) {
-	FILE *fp = fopen(acFileName, "rb");
-	if (!fp)
-		throw runtime_error("Can't open lemmatization dictionary.");
-	fread(&iDataLen, sizeof(int), 1, fp);
-	abData = new byte[iDataLen];
-	fread(abData, 1, iDataLen, fp);
-	fclose(fp);
-/*	// commented out because file streams sometimes won't work from python extension.
-
-	ifstream ifs(acFileName, ios_base::in | ios_base::binary);
-	if (!ifs)
-		throw runtime_error("Can't open file...");
-	LoadBinary(ifs);
-	ifs.close();
-*/
-}

source/lemmagen/RdrLemmatizer.h

-/******************************************************************************
-This file is part of the lemmagen library. It gives support for lemmatization.
-Copyright (C) 2006-2007 Matjaz Jursic <matjaz@gmail.com>
-
-The lemmagen library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-******************************************************************************/
-#pragma once
-
-#define AllInOneFile
-
-//-------------------------------------------------------------------------------------------
-//includes
-#include <iostream>
-#include <fstream>
-#include <iomanip>
-#include <sstream>
-
-#ifndef AllInOneFile
-	#include "RdrLemmData.h"
-#endif
-
-//-------------------------------------------------------------------------------------------
-//if data is not loaded from separate file define empty structure
-#ifndef RrdLemmData
-	#define RrdLemmData
-	#define DATA_LEN 8
-	#define DATA_TBL {0x0000000000000000}
-#endif
-
-//-------------------------------------------------------------------------------------------
-//typedefs
-typedef unsigned char byte;
-typedef unsigned short word;
-typedef unsigned int dword;
-typedef unsigned long long qword;
-
-//-------------------------------------------------------------------------------------------
-//const variables that algorithm depends on
-#define AddrLen 4
-#define FlagLen 1
-#define ModLen 1
-#define LenSpecLen 1
-#define CharLen 1
-#define DataStart 0
-
-#define RoundDataLen 8
-
-#define BitDefault	0x00
-#define BitAddChar	0x01
-#define BitInternal	0x02
-#define BitEntireWr	0x04
-
-
-#define TypeRule	(BitDefault)
-#define TypeRuleEw		(BitDefault | BitEntireWr)
-#define TypeLeafAC	(BitDefault | BitAddChar)
-#define TypeLeafACEw	(BitDefault | BitAddChar | BitEntireWr)
-#define TypeIntr	(BitDefault | BitInternal)
-#define TypeIntrAC	(BitDefault | BitAddChar | BitInternal)
-
-//-------------------------------------------------------------------------------------------
-//main data structure and it's length 
-static dword iDataLenStatic = DATA_LEN;
-static qword abDataStatic[] = DATA_TBL;
-
-//-------------------------------------------------------------------------------------------
-using namespace std;
-
-class RdrLemmatizer{
-private:
-	byte *abData;
-	int iDataLen;
-
-public:
-	RdrLemmatizer();
-	~RdrLemmatizer();
-
-	char *Lemmatize(const char *acWord, char *acOutBuffer = NULL) const;
-
-	void LoadBinary(const char *acFileName);
-	void LoadBinary(istream &is);
-
-};
-

source/orngTextWrapper/Wrapper.cpp

-#include "orngTextWrapper/Wrapper.h"
-#include "tmt/common/Common.h"
-#include "tmt/lemmatization/FSALemmatization.h"
-#include "tmt/lemmatization/PorterStemmer.h"
-#include "tmt/strings/StringUtils.h"
-#include "tmt/strings/UTF8Tokenizer.h"
-
-#include <algorithm>
-
-static void InitTMTOrange()
-{
-	TMT::InitTMT();
-}
-
-baseLemmatizer::~baseLemmatizer()
-{
-}
-
-std::string baseLemmatizer::lemmatizeText(const char *s) const
-{
-	InitTMTOrange();
-	TMT::UTF8Tokenizer tokenizer(s, false);
-	std::string result;
-	for (TMT::UTF8Tokenizer::iterator i = tokenizer.begin(); i != tokenizer.end(); ++i)
-		if (i->isWord())
-			result += getLemma(i->getString().c_str());
-		else
-			result.append(i->start, i->end);
-	return result;
-}
-
-lemmatizer::lemmatizer(const char *path) : lem(0)
-{
-	InitTMTOrange();
-	lem = new TMT::FSALemmatization(path);
-}
-
-lemmatizer::~lemmatizer()
-{
-	delete lem;
-}
-
-enum WordCase
-{
-	Lowercase,
-	Uppercase,
-	Titlecase,
-	Mixedcase
-};
-
-static void MatchCase(WordCase wc, std::string *trg)
-{
-	if (wc == Lowercase || trg->empty())
-		return;
-	if (wc == Titlecase)
-	{
-		int split = TMT::UTF8CharSize(trg->c_str());
-		std::string tmp;
-		TMT::UTF8Uppercase(trg->substr(0, split), &tmp);
-		*trg = tmp + trg->substr(split);
-	}
-	else
-	{
-		std::string tmp;
-		TMT::UTF8Uppercase(*trg, &tmp);
-		*trg = tmp;
-	}
-}
-
-std::string lemmatizer::getLemma(const char *s) const
-{
-	InitTMTOrange();
-	std::string lowercased;
-	TMT::UTF8Lowercase(s, &lowercased);
-	std::vector<std::string> result = lem->getLemmas(lowercased);
-	if (result.empty())
-		return s;
-
-	WordCase targetCase = Lowercase;
-
-	if (s != lowercased)
-	{
-		int nUCased = 0;
-		const char *ps = s;
-		const char *pl = lowercased.c_str();
-		for (int i = 0, j = 0; j < lowercased.size();)
-		{
-			if (TMT::UTF8GetUCS(ps + i) != TMT::UTF8GetUCS(pl + j))
-				++nUCased;
-
-			i += TMT::UTF8CharSize(ps + i);
-			j += TMT::UTF8CharSize(pl + j);
-		}
-
-		if (nUCased > 0)
-			targetCase = Uppercase;
-		if (nUCased == 1 && TMT::UTF8GetUCS(ps) != TMT::UTF8GetUCS(pl))
-			targetCase = Titlecase;
-	}
-
-	MatchCase(targetCase, &result[0]);
-
-	return result[0];
-}
-
-std::string porter::getLemma(const char *s) const
-{
-	InitTMTOrange();
-	return TMT::PorterStemmer().stem(s);
-}
-
-std::vector<std::string> tokenizeNonWords(const char *text)
-{
-	InitTMTOrange();
-	std::vector<std::string> result;
-	TMT::UTF8Tokenizer tokenizer(text);
-	for (TMT::UTF8Tokenizer::iterator i = tokenizer.begin(); i != tokenizer.end(); ++i)
-		if (i->isWord() && !i->hasDigits())
-			result.push_back(i->getString());
-	return result;
-}
-
-std::string removeWords(const char *text, const std::vector<std::string> &words)
-{
-	InitTMTOrange();
-	std::vector<std::string> sortedWords(words.size());
-	for (int i = 0; i < words.size(); ++i)
-		sortedWords[i] = words[i];
-	sort(sortedWords.begin(), sortedWords.end());
-
-	InitTMTOrange();
-	TMT::UTF8Tokenizer tokenizer(text);
-	bool lastWasWhiteSpace;
-	std::string result, lastToken, curToken;
-	for (TMT::UTF8Tokenizer::iterator i = tokenizer.begin(); i != tokenizer.end(); ++i)
-	{
-		if (lastToken.empty())
-			lastWasWhiteSpace = false;
-
-		curToken = i->getString();
-
-		if (i->isWord())
-		{
-			if (binary_search(sortedWords.begin(), sortedWords.end(), curToken))
-				curToken.clear();
-			else
-				result += lastToken;
-		}
-		else
-			result += lastToken;
-
-		curToken.swap(lastToken);
-		lastWasWhiteSpace = i->isWhitespace();
-	}
-	result += lastToken;
-
-	return result;
-}
-
-#include "lemmagen/RdrLemmatizer.h"
-
-lemmagen::lemmagen(const char *path) : lem(0)
-{
-	InitTMTOrange();
-	lem = new RdrLemmatizer();
-	lem->LoadBinary(path);
-}
-
-lemmagen::~lemmagen()
-{
-	delete lem;
-}
-
-std::string lemmagen::getLemma(const char *s) const
-{
-	InitTMTOrange();
-	char *str = lem->Lemmatize(s);
-	std::string rez = str;
-	delete[] str;
-	return rez;
-}

source/orngTextWrapper/Wrapper.h

-#ifndef ORNGTEXTWRAPPER_H__
-#define ORNGTEXTWRAPPER_H__
-
-#include <string>
-#include <vector>
-
-namespace TMT
-{
-	class Lemmatization;
-};
-class RdrLemmatizer;
-
-class baseLemmatizer
-{
-public:
-	virtual ~baseLemmatizer();
-
-	virtual std::string getLemma(const char *s) const = 0;
-	std::string lemmatizeText(const char *s) const;
-protected:
-};
-
-class lemmatizer : public baseLemmatizer
-{
-public:
-	explicit lemmatizer(const char *path);
-	~lemmatizer();
-
-	std::string getLemma(const char *s) const;
-private:
-	TMT::Lemmatization *lem;
-};
-
-class lemmagen : public baseLemmatizer
-{
-public:
-	explicit lemmagen(const char *path);
-	~lemmagen();
-
-	std::string getLemma(const char *s) const;
-private:
-	RdrLemmatizer *lem;
-};
-
-class porter : public baseLemmatizer
-{
-public:
-	std::string getLemma(const char *s) const;
-};
-
-std::vector<std::string> tokenizeNonWords(const char *text);
-std::string removeWords(const char *text, const std::vector<std::string> &words);
-
-#endif

source/orngTextWrapper/Wrapper.i

-%module(docstring="Interface to orange text functions.") orngTextWrapper
-%include "std_string.i"
-%include "std_vector.i"
-%{
-#include "orngTextWrapper/Wrapper.h"
-%}
-%include "exception.i"
-
-%template(VectorStr) std::vector<std::string>;
-
-%exception {
-  try {
-    $action
-  } catch (const std::exception &e) {
-    SWIG_exception(SWIG_RuntimeError, e.what());
-  }
-}
-
-namespace TMT
-{
-	class Lemmatization;
-};
-class RdrLemmatizer;
-
-class baseLemmatizer
-{
-public:
-	virtual ~baseLemmatizer();
-
-	virtual std::string getLemma(const char *s) const = 0;
-	std::string lemmatizeText(const char *s) const;
-protected:
-};
-
-class lemmatizer : public baseLemmatizer
-{
-public:
-	explicit lemmatizer(const char *path);
-	~lemmatizer();
-
-	std::string getLemma(const char *s) const;
-private:
-	TMT::Lemmatization *lem;
-};
-
-class lemmagen : public baseLemmatizer
-{
-public:
-	explicit lemmagen(const char *path);
-	~lemmagen();
-
-	std::string getLemma(const char *s) const;
-private:
-	RdrLemmatizer *lem;
-};
-
-class porter : public baseLemmatizer
-{
-public:
-	std::string getLemma(const char *s) const;
-};
-
-std::vector<std::string> tokenizeNonWords(const char *text);
-std::string removeWords(const char *text, const std::vector<std::string> &words);

source/orngTextWrapper/Wrapper_wrap.cxx

-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.31
- * 
- * This file is not intended to be easily readable and contains a number of 
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG 
- * interface file instead. 
- * ----------------------------------------------------------------------------- */
-
-#define SWIGPYTHON
-#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
-
-#ifdef __cplusplus
-template<class T> class SwigValueWrapper {
-    T *tt;
-public:
-    SwigValueWrapper() : tt(0) { }
-    SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { }
-    SwigValueWrapper(const T& t) : tt(new T(t)) { }
-    ~SwigValueWrapper() { delete tt; } 
-    SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; }
-    operator T&() const { return *tt; }
-    T *operator&() { return tt; }
-private:
-    SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
-};
-#endif
-
-/* -----------------------------------------------------------------------------
- *  This section contains generic SWIG labels for method/variable
- *  declarations/attributes, and other compiler dependent labels.
- * ----------------------------------------------------------------------------- */
-
-/* template workaround for compilers that cannot correctly implement the C++ standard */
-#ifndef SWIGTEMPLATEDISAMBIGUATOR
-# if defined(__SUNPRO_CC)
-#   if (__SUNPRO_CC <= 0x560)
-#     define SWIGTEMPLATEDISAMBIGUATOR template
-#   else
-#     define SWIGTEMPLATEDISAMBIGUATOR 
-#   endif
-# else
-#   define SWIGTEMPLATEDISAMBIGUATOR 
-# endif
-#endif
-
-/* inline attribute */
-#ifndef SWIGINLINE
-# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
-#   define SWIGINLINE inline
-# else
-#   define SWIGINLINE
-# endif
-#endif
-
-/* attribute recognised by some compilers to avoid 'unused' warnings */
-#ifndef SWIGUNUSED
-# if defined(__GNUC__)
-#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-#     define SWIGUNUSED __attribute__ ((__unused__)) 
-#   else
-#     define SWIGUNUSED
-#   endif
-# elif defined(__ICC)
-#   define SWIGUNUSED __attribute__ ((__unused__)) 
-# else
-#   define SWIGUNUSED 
-# endif
-#endif
-
-#ifndef SWIGUNUSEDPARM
-# ifdef __cplusplus
-#   define SWIGUNUSEDPARM(p)
-# else
-#   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
-# endif
-#endif
-
-/* internal SWIG method */
-#ifndef SWIGINTERN
-# define SWIGINTERN static SWIGUNUSED
-#endif
-
-/* internal inline SWIG method */
-#ifndef SWIGINTERNINLINE
-# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
-#endif
-
-/* exporting methods */
-#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
-#  ifndef GCC_HASCLASSVISIBILITY
-#    define GCC_HASCLASSVISIBILITY
-#  endif
-#endif
-
-#ifndef SWIGEXPORT
-# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-#   if defined(STATIC_LINKED)
-#     define SWIGEXPORT
-#   else
-#     define SWIGEXPORT __declspec(dllexport)
-#   endif
-# else
-#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
-#     define SWIGEXPORT __attribute__ ((visibility("default")))
-#   else
-#     define SWIGEXPORT
-#   endif
-# endif
-#endif
-
-/* calling conventions for Windows */
-#ifndef SWIGSTDCALL
-# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-#   define SWIGSTDCALL __stdcall
-# else
-#   define SWIGSTDCALL
-# endif 
-#endif
-
-/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
-#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
-# define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-
-/* Python.h has to appear first */
-#include <Python.h>
-
-/* -----------------------------------------------------------------------------
- * swigrun.swg
- *
- * This file contains generic CAPI SWIG runtime support for pointer
- * type checking.
- * ----------------------------------------------------------------------------- */
-
-/* This should only be incremented when either the layout of swig_type_info changes,
-   or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
-
-/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
-#ifdef SWIG_TYPE_TABLE
-# define SWIG_QUOTE_STRING(x) #x
-# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
-# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
-#else
-# define SWIG_TYPE_TABLE_NAME
-#endif
-
-/*
-  You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
-  creating a static or dynamic library from the swig runtime code.
-  In 99.9% of the cases, swig just needs to declare them as 'static'.
-  
-  But only do this if is strictly necessary, ie, if you have problems
-  with your compiler or so.
-*/
-
-#ifndef SWIGRUNTIME
-# define SWIGRUNTIME SWIGINTERN
-#endif
-
-#ifndef SWIGRUNTIMEINLINE
-# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
-#endif
-
-/*  Generic buffer size */
-#ifndef SWIG_BUFFER_SIZE
-# define SWIG_BUFFER_SIZE 1024
-#endif
-
-/* Flags for pointer conversions */
-#define SWIG_POINTER_DISOWN        0x1
-
-/* Flags for new pointer objects */
-#define SWIG_POINTER_OWN           0x1
-
-
-/* 
-   Flags/methods for returning states.
-   
-   The swig conversion methods, as ConvertPtr, return and integer 
-   that tells if the conversion was successful or not. And if not,
-   an error code can be returned (see swigerrors.swg for the codes).
-   
-   Use the following macros/flags to set or process the returning
-   states.
-   
-   In old swig versions, you usually write code as:
-
-     if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
-       // success code
-     } else {
-       //fail code
-     }
-
-   Now you can be more explicit as:
-
-    int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
-    if (SWIG_IsOK(res)) {
-      // success code
-    } else {
-      // fail code
-    }
-
-   that seems to be the same, but now you can also do
-
-    Type *ptr;
-    int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
-    if (SWIG_IsOK(res)) {
-      // success code
-      if (SWIG_IsNewObj(res) {
-        ...
-	delete *ptr;
-      } else {
-        ...
-      }
-    } else {
-      // fail code
-    }
-    
-   I.e., now SWIG_ConvertPtr can return new objects and you can
-   identify the case and take care of the deallocation. Of course that
-   requires also to SWIG_ConvertPtr to return new result values, as
-
-      int SWIG_ConvertPtr(obj, ptr,...) {         
-        if (<obj is ok>) {			       
-          if (<need new object>) {		       
-            *ptr = <ptr to new allocated object>; 
-            return SWIG_NEWOBJ;		       
-          } else {				       
-            *ptr = <ptr to old object>;	       
-            return SWIG_OLDOBJ;		       
-          } 				       
-        } else {				       
-          return SWIG_BADOBJ;		       
-        }					       
-      }
-
-   Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
-   more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
-   swig errors code.
-
-   Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
-   allows to return the 'cast rank', for example, if you have this
-
-       int food(double)
-       int fooi(int);
-
-   and you call
- 
-      food(1)   // cast rank '1'  (1 -> 1.0)
-      fooi(1)   // cast rank '0'
-
-   just use the SWIG_AddCast()/SWIG_CheckState()
-
-
- */
-#define SWIG_OK                    (0) 
-#define SWIG_ERROR                 (-1)
-#define SWIG_IsOK(r)               (r >= 0)
-#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)  
-
-/* The CastRankLimit says how many bits are used for the cast rank */
-#define SWIG_CASTRANKLIMIT         (1 << 8)
-/* The NewMask denotes the object was created (using new/malloc) */
-#define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
-/* The TmpMask is for in/out typemaps that use temporal objects */
-#define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
-/* Simple returning values */
-#define SWIG_BADOBJ                (SWIG_ERROR)
-#define SWIG_OLDOBJ                (SWIG_OK)
-#define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
-#define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
-/* Check, add and del mask methods */
-#define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
-#define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
-#define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
-#define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
-#define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
-#define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
-
-
-/* Cast-Rank Mode */
-#if defined(SWIG_CASTRANK_MODE)
-#  ifndef SWIG_TypeRank
-#    define SWIG_TypeRank             unsigned long
-#  endif
-#  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
-#    define SWIG_MAXCASTRANK          (2)
-#  endif
-#  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
-#  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
-SWIGINTERNINLINE int SWIG_AddCast(int r) { 
-  return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
-}
-SWIGINTERNINLINE int SWIG_CheckState(int r) { 
-  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 
-}
-#else /* no cast-rank mode */
-#  define SWIG_AddCast
-#  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
-#endif
-
-
-
-
-#include <string.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void *(*swig_converter_func)(void *);
-typedef struct swig_type_info *(*swig_dycast_func)(void **);
-
-/* Structure to store inforomation on one type */
-typedef struct swig_type_info {
-  const char             *name;			/* mangled name of this type */
-  const char             *str;			/* human readable name of this type */
-  swig_dycast_func        dcast;		/* dynamic cast function down a hierarchy */
-  struct swig_cast_info  *cast;			/* linked list of types that can cast into this type */
-  void                   *clientdata;		/* language specific type data */
-  int                    owndata;		/* flag if the structure owns the clientdata */
-} swig_type_info;
-
-/* Structure to store a type and conversion function used for casting */
-typedef struct swig_cast_info {
-  swig_type_info         *type;			/* pointer to type that is equivalent to this type */
-  swig_converter_func     converter;		/* function to cast the void pointers */
-  struct swig_cast_info  *next;			/* pointer to next cast in linked list */
-  struct swig_cast_info  *prev;			/* pointer to the previous cast */
-} swig_cast_info;
-
-/* Structure used to store module information
- * Each module generates one structure like this, and the runtime collects
- * all of these structures and stores them in a circularly linked list.*/
-typedef struct swig_module_info {
-  swig_type_info         **types;		/* Array of pointers to swig_type_info structures that are in this module */
-  size_t                 size;		        /* Number of types in this module */
-  struct swig_module_info *next;		/* Pointer to next element in circularly linked list */
-  swig_type_info         **type_initial;	/* Array of initially generated type structures */
-  swig_cast_info         **cast_initial;	/* Array of initially generated casting structures */
-  void                    *clientdata;		/* Language specific module data */
-} swig_module_info;
-
-/* 
-  Compare two type names skipping the space characters, therefore
-  "char*" == "char *" and "Class<int>" == "Class<int >", etc.
-
-  Return 0 when the two name types are equivalent, as in
-  strncmp, but skipping ' '.
-*/
-SWIGRUNTIME int
-SWIG_TypeNameComp(const char *f1, const char *l1,
-		  const char *f2, const char *l2) {
-  for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
-    while ((*f1 == ' ') && (f1 != l1)) ++f1;
-    while ((*f2 == ' ') && (f2 != l2)) ++f2;
-    if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
-  }
-  return (l1 - f1) - (l2 - f2);
-}
-
-/*
-  Check type equivalence in a name list like <name1>|<name2>|...
-  Return 0 if not equal, 1 if equal
-*/
-SWIGRUNTIME int
-SWIG_TypeEquiv(const char *nb, const char *tb) {
-  int equiv = 0;
-  const char* te = tb + strlen(tb);
-  const char* ne = nb;
-  while (!equiv && *ne) {
-    for (nb = ne; *ne; ++ne) {
-      if (*ne == '|') break;
-    }
-    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
-    if (*ne) ++ne;
-  }
-  return equiv;
-}
-
-/*
-  Check type equivalence in a name list like <name1>|<name2>|...
-  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
-*/
-SWIGRUNTIME int
-SWIG_TypeCompare(const char *nb, const char *tb) {
-  int equiv = 0;
-  const char* te = tb + strlen(tb);
-  const char* ne = nb;
-  while (!equiv && *ne) {
-    for (nb = ne; *ne; ++ne) {
-      if (*ne == '|') break;
-    }
-    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
-    if (*ne) ++ne;
-  }
-  return equiv;
-}
-
-
-/* think of this as a c++ template<> or a scheme macro */
-#define SWIG_TypeCheck_Template(comparison, ty)         \
-  if (ty) {                                             \
-    swig_cast_info *iter = ty->cast;                    \
-    while (iter) {                                      \
-      if (comparison) {                                 \
-        if (iter == ty->cast) return iter;              \
-        /* Move iter to the top of the linked list */   \
-        iter->prev->next = iter->next;                  \
-        if (iter->next)                                 \
-          iter->next->prev = iter->prev;                \
-        iter->next = ty->cast;                          \
-        iter->prev = 0;                                 \
-        if (ty->cast) ty->cast->prev = iter;            \
-        ty->cast = iter;                                \
-        return iter;                                    \
-      }                                                 \
-      iter = iter->next;                                \
-    }                                                   \
-  }                                                     \
-  return 0
-
-/*
-  Check the typename
-*/
-SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheck(const char *c, swig_type_info *ty) {
-  SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
-}
-
-/* Same as previous function, except strcmp is replaced with a pointer comparison */
-SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
-  SWIG_TypeCheck_Template(iter->type == from, into);
-}
-
-/*
-  Cast a pointer up an inheritance hierarchy
-*/
-SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
-  return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
-}
-
-/* 
-   Dynamic pointer casting. Down an inheritance hierarchy
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
-  swig_type_info *lastty = ty;
-  if (!ty || !ty->dcast) return ty;
-  while (ty && (ty->dcast)) {
-    ty = (*ty->dcast)(ptr);
-    if (ty) lastty = ty;
-  }
-  return lastty;
-}
-
-/*
-  Return the name associated with this type
-*/
-SWIGRUNTIMEINLINE const char *
-SWIG_TypeName(const swig_type_info *ty) {
-  return ty->name;
-}
-
-/*
-  Return the pretty name associated with this type,
-  that is an unmangled type name in a form presentable to the user.
-*/
-SWIGRUNTIME const char *
-SWIG_TypePrettyName(const swig_type_info *type) {
-  /* The "str" field contains the equivalent pretty names of the
-     type, separated by vertical-bar characters.  We choose
-     to print the last name, as it is often (?) the most
-     specific. */
-  if (!type) return NULL;
-  if (type->str != NULL) {
-    const char *last_name = type->str;
-    const char *s;
-    for (s = type->str; *s; s++)
-      if (*s == '|') last_name = s+1;
-    return last_name;
-  }
-  else
-    return type->name;
-}
-
-/* 
-   Set the clientdata field for a type
-*/
-SWIGRUNTIME void
-SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
-  swig_cast_info *cast = ti->cast;
-  /* if (ti->clientdata == clientdata) return; */
-  ti->clientdata = clientdata;
-  
-  while (cast) {
-    if (!cast->converter) {
-      swig_type_info *tc = cast->type;
-      if (!tc->clientdata) {
-	SWIG_TypeClientData(tc, clientdata);
-      }
-    }    
-    cast = cast->next;
-  }
-}
-SWIGRUNTIME void
-SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
-  SWIG_TypeClientData(ti, clientdata);
-  ti->owndata = 1;
-}
-  
-/*
-  Search for a swig_type_info structure only by mangled name
-  Search is a O(log #types)
-  
-  We start searching at module start, and finish searching when start == end.  
-  Note: if start == end at the beginning of the function, we go all the way around
-  the circular list.
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_MangledTypeQueryModule(swig_module_info *start, 
-                            swig_module_info *end, 
-		            const char *name) {
-  swig_module_info *iter = start;
-  do {
-    if (iter->size) {
-      register size_t l = 0;
-      register size_t r = iter->size - 1;
-      do {
-	/* since l+r >= 0, we can (>> 1) instead (/ 2) */
-	register size_t i = (l + r) >> 1; 
-	const char *iname = iter->types[i]->name;
-	if (iname) {
-	  register int compare = strcmp(name, iname);
-	  if (compare == 0) {	    
-	    return iter->types[i];
-	  } else if (compare < 0) {
-	    if (i) {
-	      r = i - 1;
-	    } else {
-	      break;
-	    }
-	  } else if (compare > 0) {
-	    l = i + 1;
-	  }
-	} else {
-	  break; /* should never happen */
-	}
-      } while (l <= r);
-    }
-    iter = iter->next;
-  } while (iter != end);
-  return 0;
-}
-
-/*
-  Search for a swig_type_info structure for either a mangled name or a human readable name.
-  It first searches the mangled names of the types, which is a O(log #types)
-  If a type is not found it then searches the human readable names, which is O(#types).
-  
-  We start searching at module start, and finish searching when start == end.  
-  Note: if start == end at the beginning of the function, we go all the way around
-  the circular list.
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_TypeQueryModule(swig_module_info *start, 
-                     swig_module_info *end, 
-		     const char *name) {
-  /* STEP 1: Search the name field using binary search */
-  swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
-  if (ret) {
-    return ret;
-  } else {
-    /* STEP 2: If the type hasn't been found, do a complete search
-       of the str field (the human readable name) */
-    swig_module_info *iter = start;
-    do {
-      register size_t i = 0;
-      for (; i < iter->size; ++i) {
-	if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
-	  return iter->types[i];
-      }
-      iter = iter->next;
-    } while (iter != end);
-  }
-  
-  /* neither found a match */
-  return 0;
-}
-
-/* 
-   Pack binary data into a string
-*/
-SWIGRUNTIME char *
-SWIG_PackData(char *c, void *ptr, size_t sz) {
-  static const char hex[17] = "0123456789abcdef";
-  register const unsigned char *u = (unsigned char *) ptr;
-  register const unsigned char *eu =  u + sz;
-  for (; u != eu; ++u) {
-    register unsigned char uu = *u;
-    *(c++) = hex[(uu & 0xf0) >> 4];
-    *(c++) = hex[uu & 0xf];
-  }
-  return c;
-}
-
-/* 
-   Unpack binary data from a string
-*/
-SWIGRUNTIME const char *
-SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
-  register unsigned char *u = (unsigned char *) ptr;
-  register const unsigned char *eu = u + sz;
-  for (; u != eu; ++u) {
-    register char d = *(c++);
-    register unsigned char uu;
-    if ((d >= '0') && (d <= '9'))
-      uu = ((d - '0') << 4);
-    else if ((d >= 'a') && (d <= 'f'))
-      uu = ((d - ('a'-10)) << 4);
-    else 
-      return (char *) 0;
-    d = *(c++);
-    if ((d >= '0') && (d <= '9'))
-      uu |= (d - '0');
-    else if ((d >= 'a') && (d <= 'f'))
-      uu |= (d - ('a'-10));
-    else 
-      return (char *) 0;
-    *u = uu;
-  }
-  return c;
-}
-
-/* 
-   Pack 'void *' into a string buffer.
-*/
-SWIGRUNTIME char *
-SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
-  char *r = buff;
-  if ((2*sizeof(void *) + 2) > bsz) return 0;
-  *(r++) = '_';
-  r = SWIG_PackData(r,&ptr,sizeof(void *));
-  if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
-  strcpy(r,name);
-  return buff;
-}
-
-SWIGRUNTIME const char *
-SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
-  if (*c != '_') {
-    if (strcmp(c,"NULL") == 0) {
-      *ptr = (void *) 0;
-      return name;
-    } else {
-      return 0;
-    }
-  }
-  return SWIG_UnpackData(++c,ptr,sizeof(void *));
-}
-
-SWIGRUNTIME char *
-SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
-  char *r = buff;
-  size_t lname = (name ? strlen(name) : 0);
-  if ((2*sz + 2 + lname) > bsz) return 0;
-  *(r++) = '_';
-  r = SWIG_PackData(r,ptr,sz);
-  if (lname) {
-    strncpy(r,name,lname+1);
-  } else {
-    *r = 0;
-  }
-  return buff;
-}
-
-SWIGRUNTIME const char *
-SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
-  if (*c != '_') {
-    if (strcmp(c,"NULL") == 0) {
-      memset(ptr,0,sz);
-      return name;
-    } else {
-      return 0;
-    }
-  }
-  return SWIG_UnpackData(++c,ptr,sz);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-/*  Errors in SWIG */
-#define  SWIG_UnknownError    	   -1 
-#define  SWIG_IOError        	   -2 
-#define  SWIG_RuntimeError   	   -3 
-#define  SWIG_IndexError     	   -4 
-#define  SWIG_TypeError      	   -5 
-#define  SWIG_DivisionByZero 	   -6 
-#define  SWIG_OverflowError  	   -7 
-#define  SWIG_SyntaxError    	   -8 
-#define  SWIG_ValueError     	   -9 
-#define  SWIG_SystemError    	   -10
-#define  SWIG_AttributeError 	   -11
-#define  SWIG_MemoryError    	   -12 
-#define  SWIG_NullReferenceError   -13
-
-
-
-
-/* Add PyOS_snprintf for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
-#  define PyOS_snprintf _snprintf
-# else
-#  define PyOS_snprintf snprintf
-# endif
-#endif
-
-/* A crude PyString_FromFormat implementation for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-
-#ifndef SWIG_PYBUFFER_SIZE
-# define SWIG_PYBUFFER_SIZE 1024
-#endif
-
-static PyObject *
-PyString_FromFormat(const char *fmt, ...) {
-  va_list ap;
-  char buf[SWIG_PYBUFFER_SIZE * 2];
-  int res;
-  va_start(ap, fmt);
-  res = vsnprintf(buf, sizeof(buf), fmt, ap);
-  va_end(ap);
-  return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
-}
-#endif
-
-/* Add PyObject_Del for old Pythons */
-#if PY_VERSION_HEX < 0x01060000
-# define PyObject_Del(op) PyMem_DEL((op))
-#endif
-#ifndef PyObject_DEL
-# define PyObject_DEL PyObject_Del
-#endif
-
-/* A crude PyExc_StopIteration exception for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-# ifndef PyExc_StopIteration
-#  define PyExc_StopIteration PyExc_RuntimeError
-# endif
-# ifndef PyObject_GenericGetAttr
-#  define PyObject_GenericGetAttr 0
-# endif
-#endif
-/* Py_NotImplemented is defined in 2.1 and up. */
-#if PY_VERSION_HEX < 0x02010000
-# ifndef Py_NotImplemented
-#  define Py_NotImplemented PyExc_RuntimeError
-# endif
-#endif
-
-
-/* A crude PyString_AsStringAndSize implementation for old Pythons */
-#if PY_VERSION_HEX < 0x02010000
-# ifndef PyString_AsStringAndSize
-#  define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
-# endif
-#endif
-
-/* PySequence_Size for old Pythons */
-#if PY_VERSION_HEX < 0x02000000
-# ifndef PySequence_Size
-#  define PySequence_Size PySequence_Length
-# endif
-#endif
-
-
-/* PyBool_FromLong for old Pythons */
-#if PY_VERSION_HEX < 0x02030000
-static
-PyObject *PyBool_FromLong(long ok)
-{
-  PyObject *result = ok ? Py_True : Py_False;
-  Py_INCREF(result);
-  return result;
-}
-#endif
-
-/* Py_ssize_t for old Pythons */
-/* This code is as recommended by: */
-/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
-#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
-typedef int Py_ssize_t;
-# define PY_SSIZE_T_MAX INT_MAX
-# define PY_SSIZE_T_MIN INT_MIN
-#endif
-
-/* -----------------------------------------------------------------------------
- * error manipulation
- * ----------------------------------------------------------------------------- */
-
-SWIGRUNTIME PyObject*
-SWIG_Python_ErrorType(int code) {
-  PyObject* type = 0;
-  switch(code) {
-  case SWIG_MemoryError:
-    type = PyExc_MemoryError;
-    break;
-  case SWIG_IOError:
-    type = PyExc_IOError;
-    break;
-  case SWIG_RuntimeError:
-    type = PyExc_RuntimeError;
-    break;
-  case SWIG_IndexError:
-    type = PyExc_IndexError;
-    break;
-  case SWIG_TypeError:
-    type = PyExc_TypeError;
-    break;
-  case SWIG_DivisionByZero:
-    type = PyExc_ZeroDivisionError;
-    break;
-  case SWIG_OverflowError:
-    type = PyExc_OverflowError;
-    break;
-  case SWIG_SyntaxError:
-    type = PyExc_SyntaxError;
-    break;
-  case SWIG_ValueError:
-    type = PyExc_ValueError;
-    break;
-  case SWIG_SystemError:
-    type = PyExc_SystemError;
-    break;
-  case SWIG_AttributeError:
-    type = PyExc_AttributeError;
-    break;
-  default:
-    type = PyExc_RuntimeError;
-  }
-  return type;
-}
-
-
-SWIGRUNTIME void
-SWIG_Python_AddErrorMsg(const char* mesg)
-{
-  PyObject *type = 0;
-  PyObject *value = 0;
-  PyObject *traceback = 0;
-
-  if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
-  if (value) {
-    PyObject *old_str = PyObject_Str(value);
-    PyErr_Clear();
-    Py_XINCREF(type);
-    PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
-    Py_DECREF(old_str);
-    Py_DECREF(value);
-  } else {
-    PyErr_Format(PyExc_RuntimeError, mesg);
-  }
-}
-
-
-
-#if defined(SWIG_PYTHON_NO_THREADS)
-#  if defined(SWIG_PYTHON_THREADS)
-#    undef SWIG_PYTHON_THREADS
-#  endif
-#endif
-#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
-#  if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
-#    if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
-#      define SWIG_PYTHON_USE_GIL
-#    endif
-#  endif
-#  if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
-#    ifndef SWIG_PYTHON_INITIALIZE_THREADS
-#     define SWIG_PYTHON_INITIALIZE_THREADS  PyEval_InitThreads() 
-#    endif
-#    ifdef __cplusplus /* C++ code */
-       class SWIG_Python_Thread_Block {
-         bool status;
-         PyGILState_STATE state;
-       public:
-         void end() { if (status) { PyGILState_Release(state); status = false;} }
-         SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
-         ~SWIG_Python_Thread_Block() { end(); }
-       };
-       class SWIG_Python_Thread_Allow {
-         bool status;
-         PyThreadState *save;
-       public:
-         void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
-         SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
-         ~SWIG_Python_Thread_Allow() { end(); }
-       };
-#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK   SWIG_Python_Thread_Block _swig_thread_block
-#      define SWIG_PYTHON_THREAD_END_BLOCK     _swig_thread_block.end()
-#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW   SWIG_Python_Thread_Allow _swig_thread_allow
-#      define SWIG_PYTHON_THREAD_END_ALLOW     _swig_thread_allow.end()
-#    else /* C code */
-#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK   PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
-#      define SWIG_PYTHON_THREAD_END_BLOCK     PyGILState_Release(_swig_thread_block)
-#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW   PyThreadState *_swig_thread_allow = PyEval_SaveThread()
-#      define SWIG_PYTHON_THREAD_END_ALLOW     PyEval_RestoreThread(_swig_thread_allow)
-#    endif
-#  else /* Old thread way, not implemented, user must provide it */
-#    if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
-#      define SWIG_PYTHON_INITIALIZE_THREADS
-#    endif
-#    if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
-#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK
-#    endif
-#    if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
-#      define SWIG_PYTHON_THREAD_END_BLOCK
-#    endif
-#    if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
-#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW
-#    endif
-#    if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
-#      define SWIG_PYTHON_THREAD_END_ALLOW
-#    endif
-#  endif
-#else /* No thread support */
-#  define SWIG_PYTHON_INITIALIZE_THREADS
-#  define SWIG_PYTHON_THREAD_BEGIN_BLOCK
-#  define SWIG_PYTHON_THREAD_END_BLOCK
-#  define SWIG_PYTHON_THREAD_BEGIN_ALLOW
-#  define SWIG_PYTHON_THREAD_END_ALLOW
-#endif
-
-/* -----------------------------------------------------------------------------
- * Python API portion that goes into the runtime
- * ----------------------------------------------------------------------------- */
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* cc-mode */
-#endif
-#endif
-
-/* -----------------------------------------------------------------------------
- * Constant declarations
- * ----------------------------------------------------------------------------- */
-
-/* Constant Types */
-#define SWIG_PY_POINTER 4
-#define SWIG_PY_BINARY  5
-
-/* Constant information structure */
-typedef struct swig_const_info {
-  int type;
-  char *name;
-  long lvalue;
-  double dvalue;
-  void   *pvalue;
-  swig_type_info **ptype;
-} swig_const_info;
-
-#ifdef __cplusplus
-#if 0
-{ /* cc-mode */
-#endif
-}
-#endif
-
-
-/* -----------------------------------------------------------------------------
- * See the LICENSE file for information on copyright, usage and redistribution
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
- *
- * pyrun.swg
- *
- * This file contains the runtime support for Python modules
- * and includes code for managing global variables and pointer
- * type checking.
- *
- * ----------------------------------------------------------------------------- */
-
-/* Common SWIG API */
-
-/* for raw pointers */
-#define SWIG_Python_ConvertPtr(obj, pptr, type, flags)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
-#define SWIG_ConvertPtr(obj, pptr, type, flags)         SWIG_Python_ConvertPtr(obj, pptr, type, flags)
-#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
-#define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(ptr, type, flags)
-#define SWIG_CheckImplicit(ty)                          SWIG_Python_CheckImplicit(ty) 
-#define SWIG_AcquirePtr(ptr, src)                       SWIG_Python_AcquirePtr(ptr, src)
-#define swig_owntype                                    int
-
-/* for raw packed data */
-#define SWIG_ConvertPacked(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
-#define SWIG_NewPackedObj(ptr, sz, type)                SWIG_Python_NewPackedObj(ptr, sz, type)
-
-/* for class or struct pointers */
-#define SWIG_ConvertInstance(obj, pptr, type, flags)    SWIG_ConvertPtr(obj, pptr, type, flags)
-#define SWIG_NewInstanceObj(ptr, type, flags)           SWIG_NewPointerObj(ptr, type, flags)
-
-/* for C or C++ function pointers */
-#define SWIG_ConvertFunctionPtr(obj, pptr, type)        SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
-#define SWIG_NewFunctionPtrObj(ptr, type)               SWIG_Python_NewPointerObj(ptr, type, 0)
-
-/* for C++ member pointers, ie, member methods */
-#define SWIG_ConvertMember(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
-#define SWIG_NewMemberObj(ptr, sz, type)                SWIG_Python_NewPackedObj(ptr, sz, type)
-
-
-/* Runtime API */
-
-#define SWIG_GetModule(clientdata)                      SWIG_Python_GetModule()
-#define SWIG_SetModule(clientdata, pointer)             SWIG_Python_SetModule(pointer)
-#define SWIG_NewClientData(obj)                         PySwigClientData_New(obj)
-
-#define SWIG_SetErrorObj                                SWIG_Python_SetErrorObj                            
-#define SWIG_SetErrorMsg                        	SWIG_Python_SetErrorMsg				   
-#define SWIG_ErrorType(code)                    	SWIG_Python_ErrorType(code)                        
-#define SWIG_Error(code, msg)            		SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 
-#define SWIG_fail                        		goto fail					   
-
-
-/* Runtime API implementation */
-
-/* Error manipulation */
-
-SWIGINTERN void 
-SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
-  SWIG_PYTHON_THREAD_BEGIN_BLOCK; 
-  PyErr_SetObject(errtype, obj);
-  Py_DECREF(obj);
-  SWIG_PYTHON_THREAD_END_BLOCK;
-}
-
-SWIGINTERN void 
-SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
-  SWIG_PYTHON_THREAD_BEGIN_BLOCK;
-  PyErr_SetString(errtype, (char *) msg);
-  SWIG_PYTHON_THREAD_END_BLOCK;
-}
-
-#define SWIG_Python_Raise(obj, type, desc)  SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
-
-/* Set a constant value */
-
-SWIGINTERN void
-SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {   
-  PyDict_SetItemString(d, (char*) name, obj);
-  Py_DECREF(obj);                            
-}
-
-/* Append a value to the result obj */
-
-SWIGINTERN PyObject*
-SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
-#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
-  if (!result) {
-    result = obj;
-  } else if (result == Py_None) {
-    Py_DECREF(result);
-    result = obj;
-  } else {
-    if (!PyList_Check(result)) {
-      PyObject *o2 = result;
-      result = PyList_New(1);
-      PyList_SetItem(result, 0, o2);
-    }
-    PyList_Append(result,obj);
-    Py_DECREF(obj);
-  }
-  return result;
-#else
-  PyObject*   o2;
-  PyObject*   o3;
-  if (!result) {
-    result = obj;
-  } else if (result == Py_None) {
-    Py_DECREF(result);
-    result = obj;
-  } else {
-    if (!PyTuple_Check(result)) {
-      o2 = result;
-      result = PyTuple_New(1);
-      PyTuple_SET_ITEM(result, 0, o2);
-    }
-    o3 = PyTuple_New(1);
-    PyTuple_SET_ITEM(o3, 0, obj);
-    o2 = result;
-    result = PySequence_Concat(o2, o3);