Commit 17431be70162bfb3e4157011adb34ef84d4dffa8

Authored by bruno
1 parent 6e20a4d2
Exists in master

retirando namespaces)

Makefile
... ... @@ -73,6 +73,5 @@ test-plugin:
73 73 $(CC) plugin\testPlugin.cpp -EHsc
74 74 $(CLEAN_OBJ)
75 75  
76   -
77 76 #Gera documentação
78 77 doc:
... ...
include/pyClip.h
... ... @@ -3,27 +3,24 @@
3 3  
4 4 #include "Python.h"
5 5  
6   -namespace Clipboard
  6 +class PyClip
7 7 {
8   - class PyClip
9   - {
10   - private:
11   - PyObject * pName;
12   - PyObject * pModule;
13   - PyObject * pDict;
14   - PyObject * pFunc;
15   - PyObject * p_On;
16   - PyObject * p_Off;
17   - PyObject * pArgs;
18   - PyObject * pResult;
19   - public:
20   - PyClip();
21   - ~PyClip();
22   - char* clip();
23   - void bdragOn();
24   - void bdragOff();
25   - };
26   -}
  8 + private:
  9 + PyObject * pName;
  10 + PyObject * pModule;
  11 + PyObject * pDict;
  12 + PyObject * pFunc;
  13 + PyObject * p_On;
  14 + PyObject * p_Off;
  15 + PyObject * pArgs;
  16 + PyObject * pResult;
  17 + public:
  18 + PyClip();
  19 + ~PyClip();
  20 + char* clip();
  21 + void bdragOn();
  22 + void bdragOff();
  23 +};
27 24  
28 25 #endif
29 26  
... ...
include/pyTradutor.h
1 1 //*****************************************************************
2 2 /*
3   - VLibras: Automatic contents translator from Portuguese to LIBRAS
  3 +VLibras: Automatic contents translator from Portuguese to LIBRAS
4 4  
5   - Copyright (c) 2015 Gustavo Sobral, Erickson Silva, Leonardo Araújo
6   - VLibras-Core group at LAViD, Federal University of Paraiba
  5 +Copyright (c) 2015 Gustavo Sobral, Erickson Silva, Leonardo Araújo
  6 +VLibras-Core group at LAViD, Federal University of Paraiba
7 7 */
8 8 //*****************************************************************
9 9  
10 10 /**
11   - * \file pyTradutor.hpp
12   - * \authors Erickson Silva, Gustavo Sobral
13   - * \date Janeiro 2015
14   - */
  11 +* \file pyTradutor.hpp
  12 +* \authors Erickson Silva, Gustavo Sobral
  13 +* \date Janeiro 2015
  14 +*/
15 15 #ifndef _PYTRADUTOR_H
16 16 #define _PYTRADUTOR_H
17 17  
18 18 #include "Python.h"
19 19  
20 20 /** \brief Classe para execução do Tradutor
21   - *
22   - * Essa classe permite a execução e comunição do Tradutor
23   - * (Português -> Glosa) do sistema escrito em Python
24   - * permitindo sua utilização numa aplicação C++.
25   - */
26   - namespace Tradutor
27   - {
28   - class PyTradutor
29   - {
  21 +*
  22 +* Essa classe permite a execução e comunição do Tradutor
  23 +* (Português -> Glosa) do sistema escrito em Python
  24 +* permitindo sua utilização numa aplicação C++.
  25 +*/
  26 +class PyTradutor
  27 +{
30 28 private:
31 29 PyObject * pName;
32 30 PyObject * pModule;
... ... @@ -35,28 +33,27 @@
35 33 PyObject * pArgs;
36 34 PyObject * pResult;
37 35 public:
38   - /** \brief O construtor da classe
39   - *
40   - * O construtor inicia o ambiente Python para execução da tradução do tradutor.
41   - */
42   - PyTradutor();
  36 +/** \brief O construtor da classe
  37 +*
  38 +* O construtor inicia o ambiente Python para execução da tradução do tradutor.
  39 +*/
  40 +PyTradutor();
43 41  
44   - /** \brief O destrutor da classe
45   - *
46   - * O Destrutor finaliza o ambiente Python montado para execução da tradução.
47   - */
48   - ~PyTradutor();
  42 +/** \brief O destrutor da classe
  43 +*
  44 +* O Destrutor finaliza o ambiente Python montado para execução da tradução.
  45 +*/
  46 +~PyTradutor();
49 47  
50   - /** \brief Converte Português para Glosa
51   - *
52   - * Converte a string de entrada em Português para Glosa
53   - * através da execução do Tradutor e retorna esse resultado
54   - *
55   - * \param input Ponteiro para char com o texto de entrada em Portugês
56   - * \return Ponteiro para char com a tradução da entrada em Glosa
57   - */
58   - char * convertStringToGlosa(const char * input);
59   - };
60   -}
  48 +/** \brief Converte Português para Glosa
  49 +*
  50 +* Converte a string de entrada em Português para Glosa
  51 +* através da execução do Tradutor e retorna esse resultado
  52 +*
  53 +* \param input Ponteiro para char com o texto de entrada em Portugês
  54 +* \return Ponteiro para char com a tradução da entrada em Glosa
  55 +*/
  56 +char * convertStringToGlosa(const char * input);
  57 +};
61 58  
62 59 #endif
63 60 \ No newline at end of file
... ...
plugin/corePlugin.h
... ... @@ -7,8 +7,6 @@
7 7 #include <string.h>
8 8  
9 9 using namespace std;
10   -using namespace Tradutor;
11   -using namespace Clipboard;
12 10  
13 11 extern "C"
14 12 {
... ... @@ -19,12 +17,12 @@ extern &quot;C&quot;
19 17 PyClip clipboard;
20 18  
21 19 //Inicializa Objetos
22   - EXPORT_API int coreInitize(void);
  20 + EXPORT_API int coreInitize(void);
23 21  
24   - //Faz tradução de Português para glosa
25   - EXPORT_API char* coreExecute(void);
  22 + //Faz tradução de Português para glosa
  23 + EXPORT_API char* coreExecute(void);
26 24  
27   - //Libera Objetos utilizados
  25 + //Libera Objetos utilizados
28 26 EXPORT_API int coreFinalize(void);
29 27 }
30 28  
... ...
src/pyClip.cpp
1 1 #include "pyClip.h"
2 2  
3   -namespace Clipboard
  3 +PyClip::PyClip()
4 4 {
5   - PyClip::PyClip()
6   - {
7   - // Initialize the Python interpreter
8   - Py_Initialize();
9   -
10   - // Type conversion between C++ string to Py string
11   - pName = PyString_FromString("Clipboard");
12   - assert(pName!=NULL);
13   - // Loads the script name saved in 'pName'
14   - pModule = PyImport_Import(pName);
15   - //PyErr_Print();
16   - assert(pModule!=NULL);
17   - // Returns the dictionary object that implements the namespace pModule
18   - pDict = PyModule_GetDict(pModule);
19   - //PyErr_Print();
20   - assert(pDict!=NULL);
21   - // Return the object from dictionary pDict which has a key 'iniciar'
22   - pFunc = PyDict_GetItemString(pDict, "clip");
23   - p_On = PyDict_GetItemString(pDict, "bdragOn");
24   - p_Off = PyDict_GetItemString(pDict, "bdragOff");
25   - //PyErr_Print();
26   - assert(pFunc!=NULL);
27   - }
28   -
29   - PyClip::~PyClip()
30   - {
31   - Py_Finalize();
32   - }
33   -
34   - char * PyClip::clip()
35   - {
36   - // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs'
37   - pResult = PyObject_CallObject(pFunc,pArgs);
38   - assert(pResult!=NULL);
39   -
40   - return PyString_AsString(pResult);
41   - }
42   -
43   - void PyClip::bdragOn()
44   - {
45   - // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs'
46   - PyObject_CallObject(p_On,pArgs);
47   -
48   - }
49   -
50   - void PyClip::bdragOff()
51   - {
52   - // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs'
53   - PyObject_CallObject(p_Off,pArgs);
54   - }
55   -
56   -}
57 5 \ No newline at end of file
  6 + // Initialize the Python interpreter
  7 + Py_Initialize();
  8 +
  9 + // Type conversion between C++ string to Py string
  10 + pName = PyString_FromString("Clipboard");
  11 + assert(pName!=NULL);
  12 +
  13 + // Loads the script name saved in 'pName'
  14 + pModule = PyImport_Import(pName);
  15 +
  16 + //PyErr_Print();
  17 + assert(pModule!=NULL);
  18 +
  19 + // Returns the dictionary object that implements the namespace pModule
  20 + pDict = PyModule_GetDict(pModule);
  21 +
  22 + //PyErr_Print();
  23 + assert(pDict!=NULL);
  24 +
  25 + // Return the object from dictionary pDict which has a key 'iniciar'
  26 + pFunc = PyDict_GetItemString(pDict, "clip");
  27 + p_On = PyDict_GetItemString(pDict, "bdragOn");
  28 + p_Off = PyDict_GetItemString(pDict, "bdragOff");
  29 +
  30 + //PyErr_Print();
  31 + assert(pFunc!=NULL);
  32 +}
  33 +
  34 +PyClip::~PyClip()
  35 +{
  36 + Py_Finalize();
  37 +}
  38 +
  39 +char * PyClip::clip()
  40 +{
  41 + // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs'
  42 + pResult = PyObject_CallObject(pFunc,pArgs);
  43 + assert(pResult!=NULL);
  44 +
  45 + return PyString_AsString(pResult);
  46 +}
  47 +
  48 +void PyClip::bdragOn()
  49 +{
  50 + // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs'
  51 + PyObject_CallObject(p_On,pArgs);
  52 +
  53 +}
  54 +
  55 +void PyClip::bdragOff()
  56 +{
  57 + // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs'
  58 + PyObject_CallObject(p_Off,pArgs);
  59 +}
  60 +
... ...
src/pyTradutor.cpp
1 1 //*****************************************************************
2 2 /*
3   - VLibras: Automatic contents translator from Portuguese to LIBRAS
  3 +VLibras: Automatic contents translator from Portuguese to LIBRAS
4 4  
5   - Copyright (c) 2015 Gustavo Sobral, Erickson Silva, Leonardo Araújo
6   - VLibras-Core group at LAViD, Federal University of Paraiba
  5 +Copyright (c) 2015 Gustavo Sobral, Erickson Silva, Leonardo Araújo
  6 +VLibras-Core group at LAViD, Federal University of Paraiba
7 7 */
8 8 //*****************************************************************
9 9  
10 10 /**
11   - * \file pyTradutor.cpp
12   - * \authors Erickson Silva, Gustavo Sobral
13   - * \date Janeiro 2015
14   - */
  11 +* \file pyTradutor.cpp
  12 +* \authors Erickson Silva, Gustavo Sobral
  13 +* \date Janeiro 2015
  14 +*/
15 15  
16 16 #include "pyTradutor.h"
17 17  
18   -namespace Tradutor
  18 +PyTradutor::PyTradutor()
19 19 {
20   - PyTradutor::PyTradutor()
21   - {
22   - // Initialize the Python interpreter
23   - Py_Initialize();
24   -
25   - // Type conversion between C++ string to Py string
26   - pName = PyString_FromString("PortGlosa");
27   - assert(pName!=NULL);
28   - // Loads the script name saved in 'pName'
29   - pModule = PyImport_Import(pName);
30   - //PyErr_Print();
31   - assert(pModule!=NULL);
32   - // Returns the dictionary object that implements the namespace pModule
33   - pDict = PyModule_GetDict(pModule);
34   - //PyErr_Print();
35   - assert(pDict!=NULL);
36   - // Return the object from dictionary pDict which has a key 'iniciar'
37   - pFunc = PyDict_GetItemString(pDict, "traduzir");
38   - //PyErr_Print();
39   - assert(pFunc!=NULL);
40   - }
41   -
42   - PyTradutor::~PyTradutor()
43   - {
44   - // Free the allocated memory and finalize the Python interpreter
45   - Py_Finalize();
46   - }
47   -
48   - char * PyTradutor::convertStringToGlosa(const char * input)
49   - {
50   - // Generates a new Tuple object with size '1' and value 'input' (converted)
51   - pArgs = PyTuple_Pack(1, PyString_FromString(input));
52   - PyErr_Print();
53   - assert(pArgs!=NULL);
54   - // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs'
55   - pResult = PyObject_CallObject(pFunc, pArgs);
56   - PyErr_Print();
57   - assert(pResult!=NULL);
58   - // Converts the string Python type to C++
59   - return PyString_AsString(pResult);
60   - //return "Ambulancia";
61   - }
  20 + // Initialize the Python interpreter
  21 + Py_Initialize();
  22 +
  23 + // Type conversion between C++ string to Py string
  24 + pName = PyString_FromString("PortGlosa");
  25 + assert(pName!=NULL);
  26 +
  27 + // Loads the script name saved in 'pName'
  28 + pModule = PyImport_Import(pName);
  29 +
  30 + //PyErr_Print();
  31 + assert(pModule!=NULL);
  32 +
  33 + // Returns the dictionary object that implements the namespace pModule
  34 + pDict = PyModule_GetDict(pModule);
  35 +
  36 + //PyErr_Print();
  37 + assert(pDict!=NULL);
  38 +
  39 + // Return the object from dictionary pDict which has a key 'iniciar'
  40 + pFunc = PyDict_GetItemString(pDict, "traduzir");
  41 +
  42 + //PyErr_Print();
  43 + assert(pFunc!=NULL);
62 44 }
  45 +
  46 +PyTradutor::~PyTradutor()
  47 +{
  48 + // Free the allocated memory and finalize the Python interpreter
  49 + Py_Finalize();
  50 +}
  51 +
  52 +char * PyTradutor::convertStringToGlosa(const char * input)
  53 +{
  54 + // Generates a new Tuple object with size '1' and value 'input' (converted)
  55 + pArgs = PyTuple_Pack(1, PyString_FromString(input));
  56 + PyErr_Print();
  57 + assert(pArgs!=NULL);
  58 +
  59 + // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs'
  60 + pResult = PyObject_CallObject(pFunc, pArgs);
  61 + PyErr_Print();
  62 + assert(pResult!=NULL);
  63 +
  64 + // Converts the string Python type to C++
  65 + return PyString_AsString(pResult);
  66 +
  67 +}
  68 +
... ...
src/testLibras.cpp
... ... @@ -3,27 +3,25 @@
3 3 #include "pyTradutor.h"
4 4  
5 5 using namespace std;
6   -using namespace Tradutor;
7   -using namespace Clipboard;
8 6  
9 7 int main(int argc, char *argv[])
10 8 {
11   - //Usado para traduzir português para glosa
12   - PyTradutor *tradutor = new PyTradutor();
  9 + //Usado para traduzir português para glosa
  10 + PyTradutor *tradutor = new PyTradutor();
13 11  
14   - //Usado para copiar texto da área de transferência
15   - PyClip *clipboard = new PyClip();
  12 + //Usado para copiar texto da área de transferência
  13 + PyClip *clipboard = new PyClip();
16 14  
17   - //Copia área de transferência para input
18   - char *input = clipboard->clip();
  15 + //Copia área de transferência para input
  16 + char *input = clipboard->clip();
19 17  
20   - //Traduz de português para glosa
21   - char* glosa = tradutor->convertStringToGlosa(input);
  18 + //Traduz de português para glosa
  19 + char* glosa = tradutor->convertStringToGlosa(input);
22 20  
23   - cout << glosa <<endl;
  21 + cout << glosa <<endl;
24 22  
25   - delete clipboard;
26   - delete tradutor;
  23 + delete clipboard;
  24 + delete tradutor;
27 25  
28   - return 0;
  26 + return 0;
29 27 }
30 28 \ No newline at end of file
... ...
translate.log 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +2015-04-02 15:58:44,479 - ERROR:
  2 +
  3 +Traceback (most recent call last):
  4 + File "C:\vlibras-libs\vlibras-translate\src\TraduzSentencas.py", line 26, in iniciar_traducao
  5 + analise_sintatica = alexp.run(sentenca)
  6 + File "C:\vlibras-libs\vlibras-translate\src\alexp.py", line 138, in run
  7 + tree=analisaSentenca(tokens)
  8 + File "C:\vlibras-libs\vlibras-translate\src\alexp.py", line 111, in analisaSentenca
  9 + trees=parser.parse_one(codificada)
  10 + File "C:\Python27\Lib\site-packages\nltk\parse\api.py", line 66, in parse_one
  11 + return next(self.parse(sent, *args, **kwargs), None)
  12 + File "C:\Python27\Lib\site-packages\nltk\parse\chart.py", line 1350, in parse
  13 + chart = self.chart_parse(tokens)
  14 + File "C:\Python27\Lib\site-packages\nltk\parse\chart.py", line 1309, in chart_parse
  15 + self._grammar.check_coverage(tokens)
  16 + File "C:\Python27\Lib\site-packages\nltk\grammar.py", line 631, in check_coverage
  17 + "input words: %r." % missing)
  18 +ValueError: Grammar does not cover some of the input words: u"'TEXTO', 'CERTO'".
  19 +
  20 +
  21 +
  22 +##############################################
  23 +
  24 +
... ...