#endif
// This method is exported from nltk_native_library.so
-EXPORT_API void nltk_initialize();
-EXPORT_API void nltk_finalize();
-EXPORT_API PyObject* nltk_getModule(char* m_name);
-EXPORT_API PyObject* nltk_getFunctionHandle(PyObject* m_module , char * f_name);
-EXPORT_API PyObject* nltk_makeArgsFromPyObject(PyObject* pyobj);
-EXPORT_API PyObject* nltk_makeArgsFromString(char* info);
-EXPORT_API PyObject* nltk_callFunctionWithArgs(PyObject* m_func, PyObject* args);
-EXPORT_API int nltk_getSizeFromList(PyObject* list);
-EXPORT_API int nltk_getSizeFromTuple(PyObject* tuple);
-EXPORT_API PyObject* nltk_getElementFromTupleByIndex(PyObject* tuple, int index);
-EXPORT_API PyObject* nltk_getElementFromListByIndex(PyObject* list, int index);
-EXPORT_API char* nltk_getStringFromElement(PyObject* elm);
-EXPORT_API char* nltk_getattrib(int z);
+EXPORT_API void nltk_initialize(void);
+EXPORT_API void nltk_finalize(void);
+EXPORT_API PyObject* nltk_get_module(char* module_name);
+EXPORT_API PyObject* nltk_get_function_handle(PyObject* module , char * func_name);
+EXPORT_API PyObject* nltk_make_args_from_pyobject(PyObject* pyobj);
+EXPORT_API PyObject* nltk_make_args_from_string(char* info);
+EXPORT_API PyObject* nltk_call_function_with_args(PyObject* func, PyObject* args);
+EXPORT_API int nltk_get_size_from_list(PyObject* list);
+EXPORT_API int nltk_get_size_from_tuple(PyObject* tuple);
+EXPORT_API PyObject* nltk_get_element_from_tuple_by_index(PyObject* tuple, int index);
+EXPORT_API PyObject* nltk_get_element_from_list_by_index(PyObject* list, int index);
+EXPORT_API char* nltk_get_string_from_element(PyObject* elm);
+EXPORT_API char* nltk_get_attribute(void);
#ifdef __cplusplus
}
#include "nltk_native_library.h"
// This is an example of an exported method.
-void nltk_initialize()
+void nltk_initialize(void)
{
Py_Initialize();
}
-void nltk_finalize()
+void nltk_finalize(void)
{
Py_Finalize();
}
-PyObject* nltk_getModule(char* m_name)
+PyObject* nltk_get_module(char* module_name)
{
- return PyImport_ImportModuleNoBlock(m_name);
+ return PyImport_ImportModuleNoBlock(module_name);
}
-int nltk_getSizeFromList(PyObject* list)
+int nltk_get_size_from_list(PyObject* list)
{
if PyList_Check(list)
{
}
}
-int nltk_getSizeFromTuple(PyObject* tuple)
+int nltk_get_size_from_tuple(PyObject* tuple)
{
if PyTuple_Check(tuple)
{
}
}
-PyObject* nltk_getElementFromListByIndex(PyObject* list, int index)
+PyObject* nltk_get_element_from_list_by_index(PyObject* list, int index)
{
PyObject* element;
if PyList_Check(list)
return PyString_AsString(elm);
}
-PyObject* nltk_getElementFromTupleByIndex(PyObject* tuple, int index)
+PyObject* nltk_get_element_from_tuple_by_index(PyObject* tuple, int index)
{
PyObject* element;
if PyTuple_Check(tuple)
return element;
}
-char* nltk_getStringFromElement(PyObject* elm)
+char* nltk_get_string_from_element(PyObject* elm)
{
char* ch = (char*) malloc(255);
strcpy(ch, PyString_AsString(elm));
return ch;
}
-PyObject* nltk_getFunctionHandle(PyObject* m_module, char *f_name)
+PyObject* nltk_get_function_handle(PyObject* module, char *func_name)
{
- return PyObject_GetAttrString(m_module, f_name);
+ return PyObject_GetAttrString(module, func_name);
}
-PyObject* nltk_makeArgsFromString(char* info)
+PyObject* nltk_make_args_from_string(char* info)
{
PyObject *pArgs;
//create args tuple struct to fill the arg one by one ,here , only create one string with 1
return pArgs;
}
-PyObject* nltk_makeArgsFromPyObject(PyObject* pyobj)
+PyObject* nltk_make_args_from_pyobject(PyObject* pyobj)
{
PyObject *pArgs;
//create args tuple struct to fill the arg one by one ,here ,only create one python object with 1
return pArgs;
}
-PyObject* nltk_callFunctionWithArgs(PyObject* m_func, PyObject* args)
+PyObject* nltk_call_function_with_args(PyObject* func, PyObject* args)
{
- return PyObject_CallObject(m_func, args);
+ return PyObject_CallObject(func, args);
}
// This is an example of an method to get attribute of module.
-char* nltk_getattrib(int z)
+char* nltk_get_attribute(void)
{
PyObject *pModule, *pFunc;
PyObject *pArgs;
pModule = PyImport_ImportModule("site");
if (pModule != NULL)
{
- //create args tuple struct to fill the arg one by one ,here ,only create one param with 1
- pArgs = PyTuple_New(1);
- //set a string for item 0 of tuple
- PyTuple_SetItem(pArgs, 0, PyString_FromString("Hello World"));
- //call word_tokenize func with args
- pFunc = PyObject_GetAttrString(pModule, "USER_SITE");
- if (pFunc != NULL) {
- strcpy(ch, PyString_AsString(pFunc));
+ //create args tuple struct to fill the arg one by one ,here ,only create one param with 1
+ pArgs = PyTuple_New(1);
+ //set a string for item 0 of tuple
+ PyTuple_SetItem(pArgs, 0, PyString_FromString("Hello World"));
+ //call word_tokenize func with args
+ pFunc = PyObject_GetAttrString(pModule, "USER_SITE");
+ if (pFunc != NULL) {
+ strcpy(ch, PyString_AsString(pFunc));
} else {
- strcpy(ch, "attribute get error\n");
+ strcpy(ch, "attribute get error\n");
}
} else {
strcpy(ch, "nltk module import error\n");