From f90140d78e74665dda2017e1fd3c3306a1dd06ac Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 19 Sep 2024 09:05:19 +0200 Subject: [PATCH] Creado funciones para AllenBradley --- .../x1_importar_to_master.cpython-310.pyc | Bin 2182 -> 2297 bytes ...x2_master_export2translate.cpython-310.pyc | Bin 1263 -> 1359 bytes .../x3_llm_auto_translate.cpython-310.pyc | Bin 9788 -> 9897 bytes ...grate_translates_to_master.cpython-310.pyc | Bin 2231 -> 2329 bytes ...omplete_empty_cells_master.cpython-310.pyc | Bin 1940 -> 2029 bytes .../x6_update_from_master.cpython-310.pyc | Bin 2179 -> 2266 bytes .../funciones_base.cpython-310.pyc | Bin 5450 -> 8156 bytes funciones_comunes/funciones_base.py | 181 ++++++++++++++++-- menu_pasos_traduccion.py | 155 +++++++++++++++ pasos_traduccion.py | 111 ----------- x1_importar_to_master.py | 40 ++-- x2_master_export2translate.py | 14 +- x3_llm_auto_translate.py | 17 +- x4_integrate_translates_to_master.py | 14 +- x5_complete_empty_cells_master.py | 10 +- x6_update_from_master.py | 8 +- 16 files changed, 381 insertions(+), 169 deletions(-) create mode 100644 menu_pasos_traduccion.py delete mode 100644 pasos_traduccion.py diff --git a/__pycache__/x1_importar_to_master.cpython-310.pyc b/__pycache__/x1_importar_to_master.cpython-310.pyc index 19013668777e9d3e14fc9513846fe3897fa4f1f5..f03955ed4fc63f6bf569f46f365c8d92628483e4 100644 GIT binary patch delta 1320 zcmYjR-D?~-5Z6fBU3qWs?6c!IZqg6P(^BHP4YV&w(>9^>)0DU+)VM6mY0tj%-QHO% z8`o&Lz=itq;D@k}C2&XopF-)|zVx|;(#KM0n~v6TT!Cgsqmkw}zZva!&A*zBLA~x1 z96$g0Tl@X_Cyi?$pS->?T9^J-AZuIo#7}}T0Fkg+%`o`Yx^IL~*0Q9Rv~<+&;D=f3 z^C9r-;k=78(_Q_t7n+;+VmFLUorNmT|>3zhHjD&Hi~y(@46_3?hFUf7oXiN zFSiD=vonZVgW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zLf$B;xMy5L`@sRIdy-g6kc3;CB<04*ngK&7fscA_Z}LqULz*QaKz*x?$eme+oV#+>M>0z7O`ZA^knUr z0>Pqvea7$!yd|>!C*q$22!pn=M24UQF5T>Zc6Ze+Hwrk!R}^#y(LtPacA_}ZYNQ(I zQ_XDC8UG^5Hcjf9q-C6%bii37>e>q5Pxg(&rBIpalUt z3+g94+C}*`?0dAd-9|}PagvbYJCqc=glwn<{DhE;2{Lb=iItGGf4`XhTUqH}J{%;6 zg=1$d!-gsop#G!P*X&gCGA9Skf~o!CLsSy`3vj3a2LfcQ^ z5|Lg&hdQ4{;>t!zzooUz^6knn+KD@z?-HG46W4b}a(@utw117n@+61=0X~YL;*_`{ IDjuf)3??h~0RR91 diff --git a/__pycache__/x2_master_export2translate.cpython-310.pyc b/__pycache__/x2_master_export2translate.cpython-310.pyc index 625636c2986018ee027ddee9cd84dd1c5064b6d1..bbcd4cf5fb4cec82fb9cccfdf0f7f4bbd712bf0c 100644 GIT binary patch delta 722 zcmYL{&ubGw6vyYy%x)%|q)n@>q|$ow5UfHK@e+zsJw)mcsHYGZmdvOdy1Qj|+e6tU zU`~QU%N|Q0`2+l01dlm;^5Rj@i*GizK6ta=`Ocd+pBeUN^{dy28x4)80mL1T7|iJH;lf^pms*S;LjazHKpL zo1e zip2f`b?~4LOSB2*rd<>g0fI=%c_j&SsH5c633z(9`=;>t{bqCS9{G{-6H~=%;}rXR z`=O;Pd9GSSeyF8fz^xBr6}*e(AU-?}BOlxABsG3<#T@6Gq#%=_LqGe2s-tKQ7>Y6Ojb{(9QK^!DJ@ z<%6R|N0(Q%oB+{v-B4l)OE~eg(B2Y&C>Rv(SAV+Bz7OkqtS5S8 z^!P0XOUAIG3CSUDSf-E|3CVz1zACwDN)ZL+oTMzF2_07yZId=hFuTHCf^{e=(7mD) z1!>i_E0)ug+uFE}9bEDE6bOzfCHw>VNUw+a|vEt)uIUFkjPJ%4sQFcr)SVLo5C ziZ>sHvq*+2oJ|AMa%VxB8}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JAt(CM%ZMw}U;dH@1Q^{|toPYwJIRf6E zWZIT^QR3@KUY3#;_~uBB7=BPJM~A#i?!CRljDQgoP6&c4P1@8@!EL`n^m$wAmeM-q ziV+fubQ(sjhJag9pLA$}n6Q{GiT}?N_lFkCdjdphg2imKVFzQm~B= zdM`d0F!q5TLq~+)3UC)hj>s|VP)bCw&$W@m#G^vxZis-h?ZD)}HDV$JF>s~`MB2=V zi?E1*-->oHWt7JsGrOdO?bidb7Piw1alC!UN-uyPV#o*jQW=N`jigW^*`^poH&RVi z#2~>{U~Pvn0#PdtBl7J#h=uxRP9hQqbnkUaj5H<9+mM1J4~>v@azOPYhEDP@q~P&AqL9YWv14y9mA=^(Rx&k_vPO7Z+SfDaI?WRo{T;h{-Y(I!q>DS`Q^GOV zhw1HKyT3bhhirdkHz_H65N#vudIK2kA_WnV;W$g4;v@UA^>-0BqZe?aLiE0@`58n( zO(WdavM>rBiHl}LjG;7!VxGoHWgyd2d(F4fiI!|!!LDZ%RP0GccIMbAE8*F`rF6u{ zdYn&k=cOFb?S=DVB!_6p4x#1GtI@J_30!gmjXg(8{t~nl2GDYXXbFfMBoNMHkVT}7 znX{wa0uKj}!SvZ7WDs5)h<7zGF15Mb7*cgL(gh^smxIH-iNnnq zc`PIkImqL@3Q&M7EHdxFLO1o10w4G9NOSbSKN z4smoyNgNK1^pByD{&=>v(wCwyi|AwePngO%`fQjSu#dMbQCKTlCHpSREz8F{%qR(E zt%B>T#3%M~U1RKq$bISZDS2-EY-=MU7 zvQ;>wbl02>#!fP&ENum-^FP%QrctUN;+9`wc=aC_67tyV{}vLQ8jLf;0r*F-Mscl& z1mli=U?~HVCRn-CP=o^UHmX8fUaf6t`YTeiFRLWQFH29Uf!(M>dVXKHG(oSR)1z) tuWo8+O($~EBPq{IFUrQ&j;8BR%-M+v`kr}r;?01E256Kq?4a}C{{c%d@?Zb} diff --git a/__pycache__/x4_integrate_translates_to_master.cpython-310.pyc b/__pycache__/x4_integrate_translates_to_master.cpython-310.pyc index 6bd011cb485c170a382c8e32921a12e400c68415..5f079772fe61801313eaa8182a5d264309f735e3 100644 GIT binary patch delta 880 zcmZ`$zi-n}5Ps*MFaDLZl%hR#3p?t-&dxs&iHVKBpb`uBT&1vZ)}6mQfA{&`y{}UrryH^BS_JL;#jl-H zhmfB#`PXzz9-*h7-Z!>3Hkh^TGJD(ORpty}yT)tD13txT1BigRn8R>-M1b&X$nXY$ zoEdI&mwS8$SsD-q&C-{vU%suwvDBYf4FS$T*3r|)KuAV9FjNGLAayd8p&Is+CJ}0` z3-y#R3q3!l9RNmLOxfv)=6{+V5@8KJW(XTkX$k`)6;+HC;bFASDkI#*+dG-jsp3z8+3yq} zxFbiv`Ig!OyEdj-xF7qQFV@e`wIw)i;8xojhKW%G270;fO#}=CL2>0w%{8W8VO=Ql zA`T(Bkts}@T!O3#JRPpnz||vPXhIjJPzUAKbnx1L2P0VJO4osw~NH3^51~bC{H;1c+Qfg+B(=RHP>> zsGvXutQXM;K7Lz+fXyu^WsCIm9+|?(PYr>6s3z+~QOy*6M+7~f+ANrX%u3nBRH)W= z!2lUgt%*G)+EIMMr{oTKBsZvbwWmB~cOAj1q)N1}d}aU5yY4ng_EBL~i8A(jX0ne1 z^A@v;b+>UfA#9RCa~mKbtT3Q;k~#8AUU*6F+^PCiUzC gUxG{7SAOAq4P~5gIKF(~lsmk}Jq~5$xCGd*-{7&ND*ylh diff --git a/__pycache__/x5_complete_empty_cells_master.cpython-310.pyc b/__pycache__/x5_complete_empty_cells_master.cpython-310.pyc index 8346263e129170359c69826cbf3158a95be64af7..8dbe4936b399f0aaf790a2415bde6b2fb8b3c570 100644 GIT binary patch delta 537 zcmY*WziZn-7`;zA{je%wGCm^dHdDp;Jo(9lJSqt_tpVeD8Sgdms1UF3Wf2X6QH;67}uR&%wNi z(055zOB3Wsbo}LGvps!F&7MsQJ%_>P(hUN{%505VGnhfI!YT~TsvjUaWDjU@24cFN zJM5*yWp3{1{O7Qk%^b1q&M+Vf-DP{u51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%%&BRphTdY9?P$iX&%PL98esW6Ehz7J_yGIY6(a7x` zECAb}OKb#X1U=h}H4U-|HsLZdye^G|;x?(%{NSd|Bs9j3urvY^lEo2n2s%OmVG*Ir z_jQzz6>JM(7eFMGN(C>MN~K4L9X^?xI5Xhk;CfI>4cBbjv`k=~x6O^*+*wsgDhU|y W;!(r%8X-X#_@?3Rh!9Qk|M?GM#c{*{ diff --git a/funciones_comunes/funciones_base.py b/funciones_comunes/funciones_base.py index d5cc6fa..a902628 100644 --- a/funciones_comunes/funciones_base.py +++ b/funciones_comunes/funciones_base.py @@ -86,12 +86,7 @@ def es_columna_tipo_xxYY(columna): return bool(re.match(r"^[a-z]{2}-[A-Z]{2}$", columna)) -# -# Transforma: "A271/47/6 Air - M - Necessaria Manutenzione Filtro" -> -# "A[[digits]]/[[digits]]/[[digits]] Air - M - Necessaria Manutenzione Filtro" -# -# Este procesamiento se aplica a las celdas clave -def compactar_celda_clave(celda_original): +def compactar_celda_clave_siemens(celda_original): if pd.isnull(celda_original): return celda_original @@ -104,12 +99,57 @@ def compactar_celda_clave(celda_original): return re.sub(r"<(.*?)>|\d+", reemplazar, str(celda_original)) +def compactar_celda_traducida(tipo_PLC, celda_traducida): + if tipo_PLC == "siemens" : + return compactar_celda_traducida_siemens(celda_traducida) + else : + return compactar_celda_traducida_ab(celda_traducida) + +def obtener_digitos_celda_original(tipo_PLC, celda_original): + if tipo_PLC == "siemens" : + return obtener_digitos_celda_original_siemens(celda_original) + else : + return obtener_digitos_celda_original_ab(celda_original) + +def decompactar_celda_traducida(tipo_PLC, celda_original, celda_traducida): + if tipo_PLC == "siemens" : + decompactar_celda_traducida_siemens(celda_original, celda_traducida) + else : + decompactar_celda_traducida_ab(celda_original, celda_traducida) + +def verificar_celda_traducida(tipo_PLC, celda_clave, celda_traducida): + if tipo_PLC == "siemens" : + verificar_celda_traducida_siemens(celda_clave, celda_traducida) + else : + verificar_celda_traducida_ab(celda_clave, celda_traducida) + + +# SIEMENS +# +# Transforma: "A271/47/6 Air - M - Necessaria Manutenzione Filtro" -> +# "A[[digits]]/[[digits]]/[[digits]] Air - M - Necessaria Manutenzione Filtro" +# +# Este procesamiento se aplica a las celdas clave +def compactar_celda_clave_siemens(celda_original): + if pd.isnull(celda_original): + return celda_original + + def reemplazar(match): + if match.group(1): # Si hay contenido dentro de <> + return f"<{match.group(1)}>" + return "[[digits]]" + + # Reemplaza dígitos fuera de <> con [[digits]], y preserva el contenido dentro de <> + return re.sub(r"<(.*?)>|\d+", reemplazar, str(celda_original)) + + +# SIEMENS # # Transforma: "A[[digits]]/[[digits]]/[[digits]] Air - M - Necessaria Manutenzione Filtro" -> # "A<>/<>/<> Air - M<#>" /> - Necessaria Manutenzione Filtro" # # Este procesamiento se aplica a las celdas traducidas -def compactar_celda_traducida(celda_traducida): +def compactar_celda_traducida_siemens(celda_traducida): if pd.isnull(celda_traducida): return celda_traducida celda_traducida = compactar_celda_clave(celda_traducida) @@ -122,10 +162,10 @@ def compactar_celda_traducida(celda_traducida): # Reemplaza <...> con <#> y [[digits]] con <> return re.sub(r"<(.*?)>|\[\[digits\]\]", reemplazar, str(celda_traducida)) - +# SIEMENS # de "A271/47/6 Air - M - Necessaria Manutenzione Filtro" -> [271,47,6] # Obtener la secuencias de dígitos por [[digits]] -def obtener_digitos_celda_original(celda_original): +def obtener_digitos_celda_original_siemens(celda_original): if pd.isnull(celda_original): return [] @@ -137,13 +177,13 @@ def obtener_digitos_celda_original(celda_original): return digitos - +# SIEMENS # Original Traducida # Transforma: "A271/47/6 Air - M - Necessaria Manutenzione Filtro" , "A<>/<>/<> Air - M<#> - Filter Maintenance Required" -> # "A271/47/6 Air - M - Necessaria Manutenzione Filtro" # # Este procesamiento se aplica a las celdas traducidas para regresar al valor original -def decompactar_celda_traducida(celda_original, celda_traducida): +def decompactar_celda_traducida_siemens(celda_original, celda_traducida): digitos = obtener_digitos_celda_original(celda_original) celda_destino = celda_traducida @@ -161,7 +201,10 @@ def decompactar_celda_traducida(celda_original, celda_traducida): return celda_destino -def verificar_celda_traducida(celda_clave, celda_traducida): +# +# SIEMENS +# +def verificar_celda_traducida_siemens(celda_clave, celda_traducida): # Contar los placeholders de dígitos digitos_clave = celda_clave.count("[[digits]]") digitos_traducida = celda_traducida.count("<>") @@ -179,7 +222,103 @@ def verificar_celda_traducida(celda_clave, celda_traducida): text_error += f" - Tags en clave: {tags_clave}, Tags en traducida: {tags_traducida}" return False, text_error +# ALLEN BRADLEY +# Transforma: "A271/47/6 Air - M/*field ref="0" */ - Necessaria Manutenzione Filtro" -> +# "A[[digits]]/[[digits]]/[[digits]] Air - M/*field ref="[[digits]]" */ - Necessaria Manutenzione Filtro" +# +# Este procesamiento se aplica a las celdas clave +def compactar_celda_clave_ab(celda_original): + if pd.isnull(celda_original): + return celda_original + + def reemplazar(match): + if match.group(1): # Si hay contenido dentro de /*...*/ + return f"/*{match.group(1)}*/" + return "[[digits]]" + + # Reemplaza dígitos fuera de /*...*/ con [[digits]], y preserva el contenido dentro de /*...*/ + return re.sub(r"/\*(.*?)\*/|\d+", reemplazar, str(celda_original)) + + +# ALLEN BRADLEY +# Transforma: "A[[digits]]/[[digits]]/[[digits]] Air - M/*field ref="[[digits]]" */ - Necessaria Manutenzione Filtro" -> +# "A<>/<>/<> Air - M/*#*/ - Necessaria Manutenzione Filtro" +# +# Este procesamiento se aplica a las celdas traducidas +def compactar_celda_traducida_ab(celda_traducida): + if pd.isnull(celda_traducida): + return celda_traducida + celda_traducida = compactar_celda_clave_ab(celda_traducida) + + def reemplazar(match): + if match.group(1): # Si hay contenido dentro de /*...*/ + return "/*#*/" + return "<>" + + # Reemplaza /*...*/ con /*#*/ y [[digits]] con <> + return re.sub(r"/\*(.*?)\*/|\[\[digits\]\]", reemplazar, str(celda_traducida)) + + +# ALLEN BRADLEY +# De "A271/47/6 Air - M/*field ref="0" */ - Necessaria Manutenzione Filtro" -> [271,47,6] +# Obtener las secuencias de dígitos para [[digits]] +def obtener_digitos_celda_original_ab(celda_original): + if pd.isnull(celda_original): + return [] + + # Reemplazamos temporalmente el contenido de los comentarios con un marcador + texto_sin_tags = re.sub(r'/\*[^*]*\*/', '<>', str(celda_original)) + + # Ahora buscamos los dígitos + digitos = re.findall(r'\d+', texto_sin_tags) + + return digitos + + +# ALLEN BRADLEY +# Transformación para regresar al valor original +def decompactar_celda_traducida_ab(celda_original, celda_traducida): + digitos = obtener_digitos_celda_original_ab(celda_original) + celda_destino = celda_traducida + + # Reemplaza <> con dígitos + for d in digitos: + celda_destino = celda_destino.replace("<>", d, 1) + + # Reemplaza /*#*/ con el contenido original dentro de /*...*/ + original_tags = re.findall(r"/\*.*?\*/", celda_original) + translated_tags = re.findall(r"/\*#\*/", celda_destino) + + for orig, trans in zip(original_tags, translated_tags): + celda_destino = celda_destino.replace(trans, orig, 1) + + return celda_destino + + +# +# ALLEN BRADLEY +# +def verificar_celda_traducida_ab(celda_clave, celda_traducida): + # Contar los placeholders de dígitos + digitos_clave = celda_clave.count("[[digits]]") + digitos_traducida = celda_traducida.count("<>") + + # Contar los placeholders de comentarios + tags_clave = sum(1 for tag in re.findall(r"/\*.*?\*/", celda_clave) if tag != "[[digits]]") + tags_traducida = celda_traducida.count("/*#*/") + + # Verificar si las cantidades coinciden + if digitos_clave == digitos_traducida and tags_clave == tags_traducida: + return True, "" + else: + text_error = f"Error de verificación:" + f" - Celda clave: {celda_clave}" + f" - Celda traducida: {celda_traducida}" + text_error += f" - Dígitos en clave: {digitos_clave}, Dígitos en traducida: {digitos_traducida}" + text_error += f" - Comentarios en clave: {tags_clave}, Comentarios en traducida: {tags_traducida}" + return False, text_error + + if __name__ == "__main__": + # SIEMENS celda_original = 'A271/47/6 Air - M - Necessaria Manutenzione Filtro' celda_original = 'DB/DB/DB' celda_original = 'Text' @@ -195,4 +334,20 @@ if __name__ == "__main__": print("Celda : " + decompactar_celda_traducida(celda_original, celda_tradc)) print("Celda Original : " + celda_original) - print(verificar_celda_traducida(celda_clave=celda_clave, celda_traducida= celda_tradc)) \ No newline at end of file + print(verificar_celda_traducida(celda_clave=celda_clave, celda_traducida= celda_tradc)) + + # ALLEN BRADLEY + celda_original = 'Z2-A5-128: Drive Unload Channel Overload /*N:3 {[PLC_Connection]Buttons[#1].Program_Nr} NOFILL DP:0*/ - /*S:0 {[PLC_Connection]Buttons[#1].Program_Description}*/' + # Simulando una celda traducida después del procesamiento + celda_traducida = 'Z[[digits]]-A[[digits]]-[[digits]]: Drive Unload Channel Overload /*#*/ - /*#*/' + + celda_clave = compactar_celda_clave_ab(celda_original) + celda_tradc = compactar_celda_traducida_ab(celda_traducida) + + print() + print("Celda Original : " + celda_original) + print("Celda Clave : " + celda_clave) + print("Celda Traducida Compactada : " + celda_tradc) + print("Dígitos : " + ','.join(obtener_digitos_celda_original_ab(celda_original))) + print("Celda Reconstituida : " + decompactar_celda_traducida_ab(celda_original, celda_tradc)) + print("Verificación : ", verificar_celda_traducida_ab(celda_clave=celda_clave, celda_traducida=celda_tradc)) diff --git a/menu_pasos_traduccion.py b/menu_pasos_traduccion.py new file mode 100644 index 0000000..e992d2e --- /dev/null +++ b/menu_pasos_traduccion.py @@ -0,0 +1,155 @@ +import tkinter as tk +from tkinter import ttk +from tkinter import messagebox +import funciones_comunes as fc +import x1_importar_to_master +import x2_master_export2translate +import x3_llm_auto_translate +import x4_integrate_translates_to_master +import x5_complete_empty_cells_master +import x6_update_from_master + +# Crear la ventana principal +ventana = tk.Tk() +ventana.title("Ayuda para traducir textos de TIA Portal y Allen Bradley") +ventana.geometry("600x550") # Aumentamos el tamaño para acomodar los nuevos widgets + +# Opciones para tipo_PLC +opciones_tipo_PLC = ['siemens', 'allenbradley'] + +# Variables para almacenar las selecciones del usuario +tipo_PLC_var = tk.StringVar() +idioma_maestra_var = tk.StringVar() +idioma_var = tk.StringVar() +idioma_var2 = tk.StringVar() + +# Crear listas de idiomas con sus códigos +idiomas_lista = sorted([(nombre, codigo) for _, (nombre, codigo) in fc.IDIOMAS.items()]) + +# Crear un combobox para seleccionar el tipo de PLC +label_tipo_PLC = tk.Label(ventana, text="Selecciona el tipo de PLC:") +combo_tipo_PLC = ttk.Combobox(ventana, textvariable=tipo_PLC_var, state="readonly") +combo_tipo_PLC["values"] = opciones_tipo_PLC +combo_tipo_PLC.current(0) # Selecciona 'siemens' por defecto + +# Crear combobox para seleccionar el Idioma Columna Maestra +label_maestra = tk.Label(ventana, text="Idioma Columna Maestra:") +combo_maestra = ttk.Combobox(ventana, textvariable=idioma_maestra_var, state="readonly") +combo_maestra["values"] = [nombre for nombre, _ in idiomas_lista] +combo_maestra.current(0) # Selecciona el primer idioma por defecto + +# Crear comboboxes para seleccionar los idiomas +label_idioma1 = tk.Label(ventana, text="Selecciona el idioma principal:") +combo = ttk.Combobox(ventana, textvariable=idioma_var, state="readonly") +combo["values"] = [nombre for nombre, _ in idiomas_lista] +combo.current(1) # Selecciona el segundo idioma por defecto + +label_idioma2 = tk.Label(ventana, text="Selecciona el segundo idioma:") +combo2 = ttk.Combobox(ventana, textvariable=idioma_var2, state="readonly") +combo2["values"] = [nombre for nombre, _ in idiomas_lista] +combo2.current(2) # Selecciona el tercer idioma por defecto + +# Ubicar los widgets en la ventana +label_tipo_PLC.pack(pady=5) +combo_tipo_PLC.pack(pady=5) +label_maestra.pack(pady=5) +combo_maestra.pack(pady=5) +label_idioma1.pack(pady=5) +combo.pack(pady=5) +label_idioma2.pack(pady=5) +combo2.pack(pady=5) + +# Función para obtener el código del idioma seleccionado a partir del índice +def obtener_codigo_idioma(indice): + return idiomas_lista[indice][1] + +# Funciones que se llamarán cuando se presionen los botones +def accion_boton1(): + tipo_PLC = tipo_PLC_var.get() + indice_maestra = combo_maestra.current() + codigo_columna_maestra = obtener_codigo_idioma(indice_maestra) + print("Ejecutando x1_importar_to_master.py") + x1_importar_to_master.run(tipo_PLC, codigo_columna_maestra) + +def accion_boton2(): + tipo_PLC = tipo_PLC_var.get() + indice_maestra = combo_maestra.current() + codigo_columna_maestra = obtener_codigo_idioma(indice_maestra) + print("Ejecutando x2_master_export2translate.py") + x2_master_export2translate.run(tipo_PLC, codigo_columna_maestra) + +def accion_boton3(): + tipo_PLC = tipo_PLC_var.get() + indice_maestra = combo_maestra.current() + codigo_columna_maestra = obtener_codigo_idioma(indice_maestra) + traducir_todo = messagebox.askyesno("Traducir todo", "¿Desea traducir todas las celdas?") + print("Ejecutando x3_llm_auto_translate.py") + x3_llm_auto_translate.run(tipo_PLC, codigo_columna_maestra, traducir_todo) + +def accion_boton4(): + tipo_PLC = tipo_PLC_var.get() + indice_maestra = combo_maestra.current() + codigo_columna_maestra = obtener_codigo_idioma(indice_maestra) + print("Ejecutando x4_integrate_translates_to_master.py") + x4_integrate_translates_to_master.run(tipo_PLC, codigo_columna_maestra) + +def accion_boton5(): + tipo_PLC = tipo_PLC_var.get() + indice_maestra = combo_maestra.current() + codigo_columna_maestra = obtener_codigo_idioma(indice_maestra) + indice_idioma1 = combo.current() + codigo_columna_secundaria = obtener_codigo_idioma(indice_idioma1) + print("Ejecutando x5_complete_empty_cells_master.py") + x5_complete_empty_cells_master.run(tipo_PLC, codigo_columna_maestra, codigo_columna_secundaria) + +def accion_boton6(): + tipo_PLC = tipo_PLC_var.get() + indice_maestra = combo_maestra.current() + codigo_columna_maestra = obtener_codigo_idioma(indice_maestra) + print("Ejecutando x6_update_from_master.py") + x6_update_from_master.run(tipo_PLC, codigo_columna_maestra) + +# Crear los botones con el mismo ancho +button_width = 70 +paso1 = tk.Button(ventana, text="1 - Importar al Master", command=accion_boton1, width=button_width) +paso2 = tk.Button( + ventana, + text="2 - Exportar idioma a '2_master_export2translate.xlsx'", + command=accion_boton2, + width=button_width +) +paso3 = tk.Button( + ventana, + text="3 - Traducir y generar '3_master_export2translate_translated.xlsx'", + command=accion_boton3, + width=button_width +) +paso4 = tk.Button( + ventana, + text="4 - Integrar las traducciones al '1_hmi_master_translates'", + command=accion_boton4, + width=button_width +) +paso5 = tk.Button( + ventana, + text="5 - Completar celdas vacías usando el segundo idioma", + command=accion_boton5, + width=button_width +) +paso6 = tk.Button( + ventana, + text="6 - Exportar desde '1_hmi_master_translates' al PLC", + command=accion_boton6, + width=button_width +) + +# Ubicar los botones en la ventana +paso1.pack(pady=5) +paso2.pack(pady=5) +paso3.pack(pady=5) +paso4.pack(pady=5) +paso5.pack(pady=5) +paso6.pack(pady=5) + +# Iniciar el bucle principal de la interfaz +ventana.mainloop() diff --git a/pasos_traduccion.py b/pasos_traduccion.py deleted file mode 100644 index 33ffa7c..0000000 --- a/pasos_traduccion.py +++ /dev/null @@ -1,111 +0,0 @@ -import tkinter as tk -from tkinter import ttk -from tkinter import messagebox -import funciones_comunes as fc -import x1_importar_to_master -import x2_master_export2translate -import x3_llm_auto_translate -import x4_integrate_translates_to_master -import x5_complete_empty_cells_master -import x6_update_from_master - -# Crear la ventana principal -ventana = tk.Tk() -ventana.title("Ayuda para traducir textos de TIA Portal") -ventana.geometry("600x400") - - -# Funciones que se llamarán cuando se presionen los botones -def accion_boton1(): - print("Ejecutando x1_importar_to_master.py") - x1_importar_to_master.run() - -def accion_boton2(): - indice_seleccionado = combo.current() - x2_master_export2translate.run(indice_seleccionado) - -def accion_boton3(): - indice_seleccionado = combo.current() - traducir_todo = messagebox.askyesno("Traducir todo", "¿Desea traducir todas las celdas (s/n)? ") - - x3_llm_auto_translate.run(indice_seleccionado, traducir_todo) - -def accion_boton4(): - indice_seleccionado = combo.current() - x4_integrate_translates_to_master.run(indice_seleccionado, 0.5) - -def accion_boton5(): - indice_seleccionado = combo.current() - indice_seleccionado2 = combo2.current() - x5_complete_empty_cells_master.run(indice_seleccionado, indice_seleccionado2) - -def accion_boton6(): - indice_seleccionado = combo.current() - x6_update_from_master.run(indice_seleccionado) - - -# Crear los botones con el mismo ancho -button_width = 70 -paso1 = tk.Button(ventana, text="1 - Importar al Master", command=accion_boton1, width=button_width) -paso2 = tk.Button( - ventana, - text="2 - Exportar Idioma a 2_master_export2translate.xlsx.", - command=accion_boton2, - width=button_width -) -paso3 = tk.Button( - ventana, - text="3 - Traducir y generar 3_master_export2translate_translated.xlsx.", - command=accion_boton3, - width=button_width -) -paso4 = tk.Button( - ventana, - text="4- Integrar las traducciones al 1_hmi_master_translates.", - command=accion_boton4, - width=button_width -) -paso5 = tk.Button( - ventana, - text="5 - Completar en 1_hmi_master_translates el idioma seleccionado usando el segundo idioma.", - command=accion_boton5, - width=button_width -) -paso6 = tk.Button( - ventana, - text="6 - Exportar usando un archivo exporta desde Tia Portal usando 1_hmi_master_translates.", - command=accion_boton6, - width=button_width -) - -# Crear una variable para almacenar el idioma seleccionado -idioma_var = tk.StringVar() -idioma_var2 = tk.StringVar() -# Crear un combobox (OptionMenu) para seleccionar el idioma -combo = ttk.Combobox(ventana, textvariable=idioma_var, state="readonly") -combo2 = ttk.Combobox(ventana, textvariable=idioma_var2, state="readonly") -label1 = tk.Label(ventana, text="Idioma de Traduccion:") -label2 = tk.Label(ventana, text="Selecciona segundo idioma:") - -# Rellenar el combobox con los nombres de los idiomas -combo["values"] = [nombre for _, (nombre, _) in fc.IDIOMAS.items()] -combo2["values"] = [nombre for _, (nombre, _) in fc.IDIOMAS.items()] - -# Ubicar el combobox en la ventana -label1.pack(pady=1) -combo.pack(pady=1) -label2.pack(pady=1) -combo2.pack(pady=1) -paso1.pack(pady=(30,2)) -paso2.pack(pady=2) -paso3.pack(pady=2) -paso4.pack(pady=2) -paso5.pack(pady=2) -paso6.pack(pady=2) - -# Seleccionar el primer elemento por defecto -combo.current(4) -combo2.current(1) - -# Iniciar el bucle principal de la interfaz -ventana.mainloop() diff --git a/x1_importar_to_master.py b/x1_importar_to_master.py index 3fbc046..eb527bc 100644 --- a/x1_importar_to_master.py +++ b/x1_importar_to_master.py @@ -4,43 +4,43 @@ import re from manejoArchivos import select_file import funciones_comunes as fc -def preprocesar_importacion(df_importacion): +def preprocesar_importacion(tipo_PLC, codigo_columna_maestra, df_importacion): # Iterar sobre las filas del DataFrame de importación for index, fila in df_importacion.iterrows(): - clave_original = str(fila["it-IT"]) - clave_sustituida = fc.compactar_celda_clave(clave_original) + clave_original = str(fila[codigo_columna_maestra]) + clave_sustituida = fc.compactar_celda_clave(tipo_PLC, clave_original) # Sustituir en las demás columnas del tipo "xx-YY" for columna in df_importacion.columns: - if columna != "it-IT" and fc.es_columna_tipo_xxYY(columna): + if columna != codigo_columna_maestra and fc.es_columna_tipo_xxYY(columna): df_importacion.at[index, columna] = ( - fc.compactar_celda_traducida(fila[columna]) + fc.compactar_celda_traducida(tipo_PLC, fila[columna]) ) # Guardar la clave sustituida - df_importacion.at[index, "it-IT"] = clave_sustituida + df_importacion.at[index, codigo_columna_maestra] = clave_sustituida return df_importacion -def importar(archivo_maestro, archivo_importacion): +def importar(tipo_PLC, codigo_columna_maestra, archivo_maestro, archivo_importacion): if not os.path.exists(archivo_maestro): - # Crear un DataFrame maestro vacío con la columna "it-IT" - df_maestro = pd.DataFrame(columns=["it-IT"]) + # Crear un DataFrame maestro vacío con la columna codigo_columna_maestra + df_maestro = pd.DataFrame(columns=[codigo_columna_maestra]) else: df_maestro = pd.read_excel(archivo_maestro) df_importacion = pd.read_excel(archivo_importacion) # Preprocesar el archivo de importación - df_importacion = preprocesar_importacion(df_importacion) + df_importacion = preprocesar_importacion(tipo_PLC, codigo_columna_maestra, df_importacion) # Obtener las claves existentes en el archivo maestro - claves_maestro = set(df_maestro["it-IT"].dropna().astype(str)) + claves_maestro = set(df_maestro[codigo_columna_maestra].dropna().astype(str)) # Filtrar filas del archivo de importación que no están en el archivo maestro nuevas_filas = df_importacion[ - df_importacion["it-IT"].apply( + df_importacion[codigo_columna_maestra].apply( lambda x: len(str(x)) > 5 and str(x) not in claves_maestro ) ] @@ -63,14 +63,14 @@ def importar(archivo_maestro, archivo_importacion): # Iterar sobre las nuevas filas para agregarlas y actualizar las claves for _, fila in nuevas_filas.iterrows(): - clave = str(fila["it-IT"]) + clave = str(fila[codigo_columna_maestra]) if clave not in claves_maestro: claves_maestro.add(clave) - # Solo agregar las columnas del tipo "xx-YY" y "it-IT" + # Solo agregar las columnas del tipo "xx-YY" y codigo_columna_maestra fila_filtrada = { col: fila[col] for col in fila.index - if col == "it-IT" or fc.es_columna_tipo_xxYY(col) + if col == codigo_columna_maestra or fc.es_columna_tipo_xxYY(col) } filas_a_agregar.append(fila_filtrada) @@ -84,13 +84,15 @@ def importar(archivo_maestro, archivo_importacion): print(f"Se han agregado {len(filas_a_agregar)} nuevas filas al archivo maestro.") -def run() : +def run(tipo_PLC, codigo_columna_maestra) : # Cargar el archivo maestro y el archivo de importación - archivo_maestro = ".\\data\\1_hmi_master_translates.xlsx" + archivo_maestro = f".\\data\\1_hmi_master_translates_{tipo_PLC}.xlsx" archivo_importacion = select_file("xlsx") if archivo_importacion: - importar(archivo_maestro, archivo_importacion) + importar(tipo_PLC, codigo_columna_maestra, archivo_maestro, archivo_importacion) if __name__ == "__main__": - run() + tipo_PLC = "siemens" + codigo_columna_maestra = "it-IT" + run(tipo_PLC) diff --git a/x2_master_export2translate.py b/x2_master_export2translate.py index ef10300..4e2e254 100644 --- a/x2_master_export2translate.py +++ b/x2_master_export2translate.py @@ -3,7 +3,7 @@ import os from manejoArchivos import select_file import funciones_comunes as fc -def exportar_para_traduccion(archivo_maestro, target_lang_code): +def exportar_para_traduccion(tipo_PLC, archivo_maestro, target_lang_code): if not os.path.exists(archivo_maestro): print("El archivo maestro no existe.") return @@ -18,20 +18,22 @@ def exportar_para_traduccion(archivo_maestro, target_lang_code): df_export[target_lang_code] = df_maestro[target_lang_code] # Guardar el archivo exportado - ruta_export = os.path.join(os.path.dirname(archivo_maestro), '2_master_export2translate.xlsx') + ruta_export = os.path.join(os.path.dirname(archivo_maestro), f'2_master_export2translate_{tipo_PLC}.xlsx') fc.save_dataframe_with_retries(df_export,output_path=ruta_export) print(f"Archivo exportado para traducción: {ruta_export}") -def run(seleccion_idioma): - archivo_maestro = ".\\data\\1_hmi_master_translates.xlsx" +def run(tipo_PLC, seleccion_idioma): + archivo_maestro = f".\\data\\1_hmi_master_translates_{tipo_PLC}.xlsx" if seleccion_idioma not in fc.IDIOMAS: print("Selección inválida.") else: _, target_lang_code = fc.IDIOMAS[seleccion_idioma] - exportar_para_traduccion(archivo_maestro, target_lang_code) + exportar_para_traduccion(tipo_PLC, archivo_maestro, target_lang_code) if __name__ == "__main__": + tipo_PLC = "siemens" + codigo_columna_maestra = "it-IT" fc.mostrar_idiomas() seleccion_idioma = int(input("Introduce el número del idioma de destino: ")) - run(seleccion_idioma) \ No newline at end of file + run(tipo_PLC, seleccion_idioma) \ No newline at end of file diff --git a/x3_llm_auto_translate.py b/x3_llm_auto_translate.py index c1f5970..17f5893 100644 --- a/x3_llm_auto_translate.py +++ b/x3_llm_auto_translate.py @@ -204,9 +204,9 @@ def calcular_afinidad(texto1, texto2): return score -def main(file_path, target_lang_code, target_lang, traducir_todo, batch_size=10): +def main(tipo_PLC, codigo_columna_maestra, file_path, target_lang_code, target_lang, traducir_todo, batch_size=10): df = pd.read_excel(file_path) - source_col = "it-IT" + source_col = codigo_columna_maestra source_translated_col = target_lang_code target_col = f"{target_lang_code} Translated" check_translate_col = f"{target_lang_code} CheckTranslate" @@ -357,26 +357,29 @@ def main(file_path, target_lang_code, target_lang, traducir_todo, batch_size=10) df.at[index, affinity_col] = affinities[celda_clave] output_path = os.path.join( - os.path.dirname(file_path), "3_master_export2translate_translated.xlsx" + os.path.dirname(file_path), f"3_master_export2translate_translated_{tipo_PLC}.xlsx" ) fc.save_dataframe_with_retries(df, output_path=output_path) logger.info(f"Archivo traducido guardado en: {output_path}") print(f"Archivo traducido guardado en: {output_path}") -def run(seleccion_idioma, traducir_todo): +def run(tipo_PLC, codigo_columna_maestra, seleccion_idioma, traducir_todo): batch_size = 20 - translate_file = ".\\data\\2_master_export2translate.xlsx" + translate_file = f".\\data\\2_master_export2translate_{tipo_PLC}.xlsx" if seleccion_idioma not in fc.IDIOMAS: print("Selección inválida.") else: target_lang, target_lang_code = fc.IDIOMAS[seleccion_idioma] - main(translate_file, target_lang_code, target_lang, traducir_todo, batch_size) + main(tipo_PLC, codigo_columna_maestra, translate_file, target_lang_code, target_lang, traducir_todo, batch_size) if __name__ == "__main__": + tipo_PLC = "siemens" + codigo_columna_maestra = "it-IT" fc.mostrar_idiomas() seleccion_idioma = int(input("Introduce el número del idioma de destino: ")) traducir_todo = ( input("¿Desea traducir todas las celdas (s/n)? ").strip().lower() == "s" ) - run(seleccion_idioma, traducir_todo) + tipo_PLC = "siemens" + run(tipo_PLC, codigo_columna_maestra, seleccion_idioma, traducir_todo) diff --git a/x4_integrate_translates_to_master.py b/x4_integrate_translates_to_master.py index 3d7bf42..f15eceb 100644 --- a/x4_integrate_translates_to_master.py +++ b/x4_integrate_translates_to_master.py @@ -14,7 +14,7 @@ def revertir_transformaciones(texto, digitos, secciones): texto = texto.replace('<#>', f'<{seccion}>', 1) return texto -def importar_traduccion(archivo_maestro, archivo_traduccion, target_lang_code, nivel_afinidad_minimo): +def importar_traduccion(tipo_PLC, archivo_maestro, archivo_traduccion, target_lang_code, nivel_afinidad_minimo): if not os.path.exists(archivo_maestro): print("El archivo maestro no existe.") return @@ -46,21 +46,23 @@ def importar_traduccion(archivo_maestro, archivo_traduccion, target_lang_code, n fc.save_dataframe_with_retries(df_maestro,output_path=archivo_maestro) print(f"Traducciones importadas y archivo maestro actualizado: {archivo_maestro}.") -def run(seleccion_idioma , nivel_afinidad_minimo): - archivo_maestro = ".\\data\\1_hmi_master_translates.xlsx" - archivo_traduccion = ".\\data\\3_master_export2translate_translated.xlsx" +def run(tipo_PLC, codigo_columna_maestra, seleccion_idioma , nivel_afinidad_minimo): + archivo_maestro = f".\\data\\1_hmi_master_translates_{tipo_PLC}.xlsx" + archivo_traduccion = f".\\data\\3_master_export2translate_translated_{tipo_PLC}.xlsx" if seleccion_idioma not in fc.IDIOMAS: print("Selección inválida.") else: target_lang, target_lang_code = fc.IDIOMAS[seleccion_idioma] - importar_traduccion(archivo_maestro, archivo_traduccion, target_lang_code, nivel_afinidad_minimo ) + importar_traduccion(tipo_PLC, archivo_maestro, archivo_traduccion, target_lang_code, nivel_afinidad_minimo ) if __name__ == "__main__": + tipo_PLC = "siemens" + codigo_columna_maestra = "it-IT" nivel_afinidad_minimo = input("Introduce el nivel minimo de afinidad para importar (presiona Enter para usar el valor por defecto 0.5): ") nivel_afinidad_minimo = float(nivel_afinidad_minimo) if nivel_afinidad_minimo else 0.5 fc.mostrar_idiomas() seleccion_idioma = int(input("Introduce el número del idioma de destino: ")) - run(seleccion_idioma, nivel_afinidad_minimo) + run(tipo_PLC, codigo_columna_maestra, seleccion_idioma, nivel_afinidad_minimo) diff --git a/x5_complete_empty_cells_master.py b/x5_complete_empty_cells_master.py index 9412a59..023998b 100644 --- a/x5_complete_empty_cells_master.py +++ b/x5_complete_empty_cells_master.py @@ -46,8 +46,8 @@ def complete_emptys(archivo_maestro, target_lang_code, second_lang_code): f"Traducciones importadas y archivo maestro actualizado: {archivo_maestro}." ) -def run(seleccion_idioma, seleccion_idioma_secundario): - archivo_maestro = ".\\data\\1_hmi_master_translates.xlsx" +def run(tipo_PLC, codigo_columna_maestra, seleccion_idioma, seleccion_idioma_secundario): + archivo_maestro = f".\\data\\1_hmi_master_translates_{tipo_PLC}.xlsx" if seleccion_idioma not in fc.IDIOMAS: print("Selección inválida.") @@ -59,9 +59,11 @@ def run(seleccion_idioma, seleccion_idioma_secundario): _, target_lang_code = fc.IDIOMAS[seleccion_idioma] _, second_lang_code = fc.IDIOMAS[seleccion_idioma_secundario] - complete_emptys(archivo_maestro, target_lang_code, second_lang_code) + complete_emptys(tipo_PLC, archivo_maestro, target_lang_code, second_lang_code) if __name__ == "__main__": + tipo_PLC = "siemens" + codigo_columna_maestra = "it-IT" fc.mostrar_idiomas() seleccion_idioma = int(input("Introduce el número del idioma de destino: ")) if seleccion_idioma not in fc.IDIOMAS: @@ -75,5 +77,5 @@ if __name__ == "__main__": if seleccion_idioma_secundario not in fc.IDIOMAS: print("Selección inválida.") exit - run(seleccion_idioma, seleccion_idioma_secundario) + run(tipo_PLC, codigo_columna_maestra, seleccion_idioma, seleccion_idioma_secundario) diff --git a/x6_update_from_master.py b/x6_update_from_master.py index 81403e4..db01ceb 100644 --- a/x6_update_from_master.py +++ b/x6_update_from_master.py @@ -68,8 +68,8 @@ def update_from_master(archivo_maestro, archivo_to_update, target_lang_code): ) logger.info(" .... ") -def run(seleccion_idioma) : - archivo_maestro = ".\\data\\1_hmi_master_translates.xlsx" +def run(tipo_PLC, codigo_columna_maestra, seleccion_idioma) : + archivo_maestro = f".\\data\\1_hmi_master_translates_{tipo_PLC}.xlsx" archivo_to_update = select_file("xlsx") if archivo_to_update: if seleccion_idioma not in fc.IDIOMAS: @@ -79,6 +79,8 @@ def run(seleccion_idioma) : update_from_master(archivo_maestro, archivo_to_update, target_lang_code) if __name__ == "__main__": + tipo_PLC = "siemens" + codigo_columna_maestra = "it-IT" fc.mostrar_idiomas() seleccion_idioma = int(input("Introduce el número del idioma de destino: ")) - run() \ No newline at end of file + run(tipo_PLC, codigo_columna_maestra) \ No newline at end of file