revuloj / revo-fonto

Artikolfonto kaj bildoj - do la enhavo de Reta Vortaro
GNU General Public License v2.0
17 stars 0 forks source link

Revo en ChatGPT #61

Open stefangrotz opened 10 months ago

stefangrotz commented 10 months ago

Mi sukcesis uzi revo.xdxf en ChatGPT uzante "ChatGPT Code interpreter": chatGPT-revo

I used this prompt with a minified version of an example python code and some information about the data structure:

 # reta vortaro - revo.xdxf
When asked about the reta vortaro, revo or generally about complex multi-lingual dictionary questions, you can search revo.xdxf using python. The Esperanto words can be found in the <ar> elements, examples in <ex> and translations to other languages in <dtrn>. For non-Esperanto word searches always search in dtrn and return the corresponding Esperanto word and example if not specified differently. Here is an example of the data structure of translations: <dtrn> /de/ Beispiel, Muster, Vorbild</dtrn> There can be additional elements inside of the elements described above. Write robust code that can handle messy XML.

Here is an example of such a search for an Esperanto word:

import xml.etree.ElementTree as D
def A(file_path,word):
    C='def';E=D.parse(file_path);F=E.getroot()
    for A in F.findall('.//ar'):
        B=A.find('k')
        if B is not None and B.text.strip()==word:G=A.find(C).text if A.find(C)is not None else'No definition found';H=[A.text for A in A.findall('.//def/ex')]or['No examples found'];I=[A.text for A in A.findall('dtrn')]or['No translations found'];return{'word':word,'definition':G,'examples':H,'translations':I}
B='revo.xdxf'
C=A(B,'krokodili')
print(C)

Eble estonte mi uzos tion en la projekto "EsperantoGPT" https://github.com/parolteknologio/EsperantoGPT

Kion vi pensas pri tio?

wdiestel commented 10 months ago

Jes, efektive tre interesa. Ankaŭ kiel ĝi klarigas ĉion aldone en la angla. Verŝajne, se vi volas serioze uzi tion, vi ankaŭ devos atentigi ĝin, ke kelkaj artikoloj havas ingigitan strukturon (subsencoj...)

( Ĉu vi povus ankaŭ ĝentile demandi, ĉu la roboto inklinus forigi kelkajn cimojn el mia listo de ne jam solvitaj ;-)