Commit ffb4524553e717a7647a9dd8a7bd447bd909e16a
1 parent
e4d907d0
Exists in
master
and in
1 other branch
Corrige paths para funcionar no Windows
Showing
3 changed files
with
25 additions
and
13 deletions
Show diff stats
src/new/AplicaRegras.py
... | ... | @@ -22,7 +22,8 @@ class AplicaRegras(object): |
22 | 22 | it.load(texto) |
23 | 23 | self.__ts = [] |
24 | 24 | self.__verb = False |
25 | - self.__adv = False; | |
25 | + self.__adv = False | |
26 | + self.__plural = False | |
26 | 27 | self.__countVerb = 0 |
27 | 28 | self.__countAdv = 0 |
28 | 29 | while(it.hasNext()): |
... | ... | @@ -32,6 +33,9 @@ class AplicaRegras(object): |
32 | 33 | |
33 | 34 | if self.__dicionarios.hasPalavraIgnorada(tag) == False: # verifica se nao eh artigo/preposicao |
34 | 35 | |
36 | + if tag[-2:] == "-P": | |
37 | + self.__plural = True | |
38 | + | |
35 | 39 | #VERIFICA SE É ADVERBIO E CONTA A QUANTIDADE |
36 | 40 | if tag[:3] == "ADV": |
37 | 41 | if (self.__dicionarios.hasTempoVerbal(token)): |
... | ... | @@ -71,7 +75,9 @@ class AplicaRegras(object): |
71 | 75 | self.__ts = self.verbalAnalysis(self.__ts) |
72 | 76 | |
73 | 77 | #VERIFICA SE É PLURAL |
74 | - return self.hasPlural(self.__ts) | |
78 | + if self.__plural: return self.hasPlural(self.__ts) | |
79 | + | |
80 | + return self.__ts | |
75 | 81 | |
76 | 82 | |
77 | 83 | # converte romano para numero | ... | ... |
src/new/LeitorDicionarios.py
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | #LAViD - Laboratório de Aplicações de Vídeo Digital |
8 | 8 | |
9 | 9 | from os.path import expanduser |
10 | -import csv | |
10 | +import csv, platform | |
11 | 11 | |
12 | 12 | class LeitorDicionarios(object): |
13 | 13 | #_iInstance = None |
... | ... | @@ -30,7 +30,13 @@ class LeitorDicionarios(object): |
30 | 30 | |
31 | 31 | # Define e inicializa os atributos |
32 | 32 | def __init__(self): |
33 | - self.__path = expanduser("~") + "/vlibras-translate/data/" | |
33 | + | |
34 | + so = platform.system() | |
35 | + if so == 'Windows': | |
36 | + self.__path = expanduser("~") + "\\vlibras-translate\data\\" | |
37 | + else: | |
38 | + self.__path = expanduser("~") + "/vlibras-translate/data/" | |
39 | + | |
34 | 40 | self.__dicInf = {} |
35 | 41 | self.__dicSin = {} |
36 | 42 | self.__dicWords = {} | ... | ... |
src/new/alexp.py
... | ... | @@ -27,16 +27,14 @@ |
27 | 27 | |
28 | 28 | """Este módulo contém funções que permitem utilizar o Aelius para etiquetar uma sentença, construindo entradas lexicais com base nas etiquetas atribuídas às palavras da sentença. Essas entradas lexicais são integradas em uma gramática CFG dada, que é transformada em um parser, utilizado para gerar uma árvore de estrutura sintagmática da sentença. |
29 | 29 | """ |
30 | -import re, string,nltk,os | |
30 | +import re, string,nltk,platform | |
31 | +from os.path import expanduser | |
31 | 32 | from Aelius.Extras import carrega |
32 | 33 | from Aelius import AnotaCorpus |
33 | 34 | |
34 | 35 | # definição de algumas variáveis globais para |
35 | 36 | # facilitar utilização das diferentes funções do módulo |
36 | 37 | |
37 | -# sintaxe default em subpasta de nltk_data | |
38 | -DIR="/vlibras-translate/data/cfg.syn.nltk" | |
39 | - | |
40 | 38 | # eventualmente será preciso incluir aqui outros sinais |
41 | 39 | # de pontuação, como o travessão |
42 | 40 | PUNCT=string.punctuation |
... | ... | @@ -86,11 +84,13 @@ def corrigeAnotacao(lista): |
86 | 84 | def encontraArquivo(caminho=DIR): |
87 | 85 | """Encontra arquivo na pasta vlibras-translate. |
88 | 86 | """ |
89 | - home = os.path.expanduser("~") | |
90 | - path = os.path.realpath(home+caminho) | |
91 | - return path | |
87 | + so = platform.system() | |
88 | + if so == 'Windows': | |
89 | + return expanduser("~") + "\\vlibras-translate\data\cfg.syn.nltk" | |
90 | + else: | |
91 | + return expanduser("~") + "/vlibras-translate/data/cfg.syn.nltk" | |
92 | 92 | |
93 | -def extraiSintaxe(caminho=DIR): | |
93 | +def extraiSintaxe(): | |
94 | 94 | """Extrai gramática armazenada em arquivo cujo caminho é definido relativamente ao diretório nltk_data. |
95 | 95 | """ |
96 | 96 | arquivo=encontraArquivo(caminho) |
... | ... | @@ -119,7 +119,7 @@ def constroiAnalisador(s): |
119 | 119 | corrigeAnotacao(SENTENCA_ANOTADA) |
120 | 120 | entradas=geraEntradasLexicais(SENTENCA_ANOTADA) |
121 | 121 | lexico="\n".join(entradas) |
122 | - gramatica="%s\n%s" % (extraiSintaxe(DIR).strip(),lexico) | |
122 | + gramatica="%s\n%s" % (extraiSintaxe().strip(),lexico) | |
123 | 123 | cfg=nltk.CFG.fromstring(gramatica) |
124 | 124 | return nltk.ChartParser(cfg) |
125 | 125 | ... | ... |