I believe practising, repeating the word and gradually associating it with its gender is the best way. Generally, we associate words with their gender as we grow up and learn how to speak (I'm a native Portuguese speaker)... it becomes natural, with time.
maybe the un belong to the book? In spanish book is masculine so being a romance language as well, Perhaps that is the case with French... If the un was before girl it might be wrong bc a girl is feminine so then it would be une... I am guessing