How to use language articles right? (German, French, Spanish)

I tried it with a few APIs but sadly it gave me everything back but not the article or the gender of the noun.

So I solved it by calling Wiktionary without an API, for example https://de.wiktionary.org/wiki/Apfel and searched on the whole site for “Genus”. Genus is kind of the gender of the noun. So I cut out the first letter after “Genus:” and got the gender of the noun. With the gender of the noun I could build the article I needed. It is a really inefficient way but it works.

I uploaded the function on GitHub

You can just copy it can use it if you need.

I imported the function in my actions and added this code:

        noun=str(tracker.get_slot('noun')).title()
        gender=german_gender_wiki.search(noun)
        
        if(gender=="N"or gender=="M"):
            articel="dein "
            #SlotSet("articel", "dein")
        elif(gender=="F"):
            articel="deine "
            #SlotSet("articel","deine")
        else:
            articel="deine "#I gave the error case the acticle of the plural because this function dont recognice plural
        
        answer="Hier " + articel+ noun
        dispatcher.utter_message(answer)

This solution is ok. Could be definitely better but it works.

I tried it in German and it worked. I tested it with some French words, I think it also worked there but I can’t really tell because my French is not that good.

So if some of you try it out in other languages please let me know if it worked out.

Another way would be to write all words you need in an extra file or a list, but with the articles they have. The reason why I didn’t do it is that you always need to update the list/file when you add new words to your nlu.md so you need to do everything twice.