duabymoon / model /model2.py
JibexBanks's picture
Added more data to the model
97d4912
from sentence_transformers import SentenceTransformer
import numpy as np
import faiss
import json
# dua_data = {
# "A Perfect and Comprehensive Prayer": 1,
# "Prayer for Affirmation of Faith and Attainment of Piety": 2,
# "Prayer for Affirmation of Faith and its Acceptance": 3,
# "Hadrat Ibrahim (A.S)'s (Abraham) Prayer to Offer Everything to his Lord": 4,
# "Prayer for Attaining the Good in this World and Hereafter": 5,
# "Prayer of Beneficence in this world and in the world Hereafter": 6,
# "Prayer Against the Evil Insinuations of Satan": 7,
# "Prayer for Being Steadfast in Guidance": 8,
# "Prayer for Steadfastness and Victory over the Disbelievers": 9,
# "Prayers for Escaping Divine Chastisement, for His Forgiveness, Righteous End, Fulfilment of God’s": 10,
# "Comprehensive Prayer for Forgiveness of Sins, for Mercy and for Victory over the Enemy": 11,
# "Prayer for Steadfastness and Good End": 13,
# "Prayer for Forgiveness and for Escaping Wrath of God": 14,
# "Prayer for Forgiveness of Sins and Transgressions and Prayer for Steadfastness": 15,
# "Prayer for Mercy and Forgiveness": 28,
# "Prayer of Forgiveness in Asking Questions in Ignorance": 17,
# "Prayer for Deliverance from Misfortune": 18,
# "Prayer for Attaining Strength whilst Confronting Evil": 19,
# "Prayer for Recovery from Disease": 20,
# "Prayer for Seeking God's Protection, Forgiveness and Mercy": 21,
# "Confessing Unintentional Transgression and Seeking Forgiveness": 22,
# "Prayers for Forgiveness and Mercy": 23,
# "Prayer for Mercy": 24,
# "Prayer for Seeking Forgiveness for People gone Astray": 25,
# "Prayer for Safety from Divine Wrath": 26,
# "Prayer for Attaining Forgiveness and Removal of Rancour": 27,
# "Humble Prayers of Throne-Bearing Angels for the Believers": 29,
# "Prayer of a Patient Believing Wife for Deliverance from a Cruel Husband": 30,
# "Prayer for Safety from Transgression on Seeing the End of the Transgressors": 31,
# "Prayer for Safety from Tyrannical People": 32,
# "Prayer for Migration and Escaping Cruel People": 33,
# "Prayer for Safety from Being Unjust in Times of Strength": 34,
# "Prayer for Increase of Knowledge": 35,
# "Prayer for Open-Heartedness, Ease of Affairs and Effectiveness of Speech": 36,
# "Prayer for Spiritual Progress and Forgiveness": 37,
# "Prayer for the Righteous End and Death in the State of being a Muslim": 38,
# "Humble Prayer for Receiving Goodness": 39,
# "Prayer for Sustenance and Peace": 40,
# "Prayer for Spiritual and Worldly Advancement of Children": 41,
# "Prayer of the Apostles of Jesus Christas": 43,
# "Prayer for Strength, Superiority, Increase of Sustenance and Deliverance from Debt": 44,
# "Prayer for Just Decision and Victory": 45,
# "Cry for Help on being Overwhelmed": 46,
# "Prayer for Arbitration": 47,
# "Prayer regarding Disbelievers and Atheists": 48,
# "Prayer for Forgiveness for Parents, Believers and for One's Ownself": 49,
# "Prayer for the Guidance of Mankind": 50,
# "Prayer for Victory over Enemies": 51,
# "Prayer for Victory over Mischief Makers": 52,
# "Prayer for Escaping the Evil Influences of Wicked People": 53,
# "Requesting Divine Signs against Disobedient People": 54,
# "Thanksgiving by Hadrat Musa (A.S) (Moses) and a Prayer for Release from Cruel People": 55,
# "Prayer for Just Decisions": 56,
# "Prayer for God’s Mercy and Ease in Affairs": 57,
# "Prayer for Virtuous Children": 58,
# "Prayer for Obedient and Worshipping Children": 59,
# "Prayer for Steadfastness in Worship for Oneself, One's Children and Forgiveness for Parents and Believers": 60,
# "Prayer for the Ability to Decide, Virtue, One's Good Repute and for Paradise": 61,
# "Prayer for Extraordinary Strength and Sovereignty": 62,
# "Prayer of Thanks for Righteous Actions and Pious Children": 63,
# "Prayer of Thanks and for Piety": 64,
# "Prayer for Chaste Progeny": 65,
# "Prayer for Children in Old Age": 66,
# "Prayer for Riddance of Loneliness and for Children to be Good Heirs": 67,
# "Prayer for a Righteous Wife, for Children and Setting a Good Example for them": 68,
# "Prayer for Remembering Parent's Kindness and a Prayer of Mercy for them": 69,
# "Prayer on Boarding a Boat": 70,
# "Another Prayer on Boarding a Boat": 71,
# "Prayer of Riding a Mount": 72,
# "Believing in God's Absolute Power and Belief in His Promises": 73,
# "Prayer for a Good Beginning and End and Special Victory": 74,
# "Prayer for Appreciation of Deeds": 75,
# "Prayer of Peace for Godly People": 76,
# "Prayer of Inclination towards God and Declaration of Total Belief": 77,
# "Prayer for God’s Protection": 78,
# "Prayer for God's Arbitration": 79,
# "On the Rejection by People, and a Prayer for Victory": 80,
# "Declaration of Belief in God’s Promises upon Hearing His Verses": 81,
# "Prayer Recited at Dawn and Dusk for Recompense of Failings": 82,
# "Prayer at Times of Adversity": 83,
# "Prayer for Dedicating Children and Making Vows": 84,
# "Prayer of God’s Holy Servants in the Face of Ridicule by Non-believers": 85,
# "Prayers for Deliverance from Grief and Sorrow": 86,
# "Prayers for Seeking Allah’s Shelter and Safety from every type of Evil": 87,
# "Surah Ikhlas": 88,
# "Surah Al-Falaq": 89,
# "Surah An-Nas": 90,
# "A Beautiful Prayer for Acceptance of Prayers": 91,
# "This prayer is attributed in the Holy Qur’an to that group of sincere and pious people especially from Christianity who recognized and accepted truth and prayed.": 2,
# "When the apostles of Hadrat ‘Isa (A.S) (Jesus) saw rejection from every quarter they raised this proclamation in his support, believed in him and prayed in these words:": 3,
# "The righteous people have been advised in the Holy": 4,
# "Hadrat Anas bin Malik (R.A) was asked to recite a prayer": 5,
# "Hadrat Musa (A.S) (Moses) prayed for his people in these": 6,
# "‘Amr bin Sa‘id (R.A) relates that the Holy Prophet (S.A.W) taught his Companions some prayers to recite when retiring for the night. This prayer is one of them.": 7,
# "Hadrat Umm-e-Salamah (R.A) relates the Holy Prophet (S.A.W)": 8,
# "From the Holy Qur’an we learn that when Hadrat": 9,
# "revealed the Holy Prophet (S.A.W) started salat and he was crying. Hadrat Bilal (R.A) asked him the reason for his weeping. He replied that these verses had been revealed to him and added that whosoever recites these verses and does not ponder over them was very unfortunate. The traditions also tell us that the Holy Prophet (S.A.W) used to recite these verses daily and at night time and told his followers that whosoever recites these verses of Al-e-Imran at night will have the rewards equal to worshipping all the night.": 10,
# "This prayer comprises of the last two verses of Surah Al-Baqarah. Hadrat Abu Mas‘ud (R.A) relates that the Holy Prophet (S.A.W) said reciting these two verses before retiring at night is more than enough. Moreover they are from among the treasure of Heavens which has not been given to any Prophet before the Holy Prophet (S.A.W) . Regarding these two verses the Holy Prophet (S.A.W) emphasised that we must remember them and make our family remember them because these are based jointly on the salat, Qur’an and supplication. (Only the supplication part of these verses is being printed here).": 11,
# "When in the court of the Pharaoh the designs of the magicians were frustrated and Pharaoh threatened them with revenge, supplicating God, they replied:": 13,
# "This prayer is for seeking forgiveness from Allah. The Holy Prophet (S.A.W) said that when God intends to punish a people, He looks at the ones who offer Tahajjud prayers and ones who seek pardon from Him and because of them He postpones the punishment.": 14,
# "Allah praises those Godly people who believe in His Prophets and joining the Prophets do not hesitate in confronting the enemies. The Holy Qur'an mentions their prayers as a result of which, God will grant them rewards in this world and in the hereafter": 15,
# "When Hadrat Adam (A.S) (Adam) by mistake ate from the forbidden tree, God taught him some prayers and as a result turned to him with compassion.": 16,
# "When the son of Nuh (A.S) (Noah) was drowning in the flood, Nuh (A.S) (Noah) supplicated God for the safety of his son. God reprimanded him that as a result of his son’s misdeeds, the son was not amongst his people. Then Nuh (A.S) (Noah) implored God with the following humble prayer and became the recipient of God's mercy and blessings.": 17,
# "Hadrat Sa‘d bin Abi Waqqas (R.A) relates that the Holy Prophet (S.A.W) said that whosoever recites this prayer, which Hadrat Yunus (A.S) (Jonnah) offered in the belly of the whale, his prayer will be accepted. It is in the traditions that there is a promise of َكذالك ننجي المؤمنين (TThus do We deliver those who believe). Whosoever confesses his transgression will have his prayers accepted.": 18,
# "When the wife of ‘Aziz of Egypt conspired with her friends to incline Hadrat Yusuf (A.S) (Joseph) towards evil he offered this humble prayer, acceptance of which is mentioned in the Holy Qur’an. God saved Hadrat Yusuf (A.S) (Joseph) from the evil designs of the women.": 19,
# "Hadrat Ayyub (A.S) (Job) prayed for recovery from his grave illness. With the following words he begged mercy. This prayer was accepted and he was miraculously cured.": 20,
# "On receiving Divine sign Hadrat Musa (A.S) (Moses) went to Mount Tur with seventy followers. An earthquake occurred and Hadrat Musa (A.S) (Moses) thought that this was a punishment for his people for associating partners with Allah.": 21,
# "While trying to stop a fight a person was accidentally killed by Hadrat Musa’s (A.S) (Moses) blow. He prayed in the following words and God forgave him.": 22,
# "During the absence of Hadrat Musa (A.S) (Moses) the Israelites took a calf as their god. On his return he was very angry with his brother, his deputy and successor and reprimanded his people. His people prayed in repentance. This prayer can also be called ‘prayer of repentance’ by the followers of Hadrat Musa (A.S) (Moses).": 23,
# "On the same occasion Musa (A.S) (Moses) prayed for forgiveness for his brother and himself.": 24,
# "Hadrat Abu Dharr (R.A) relates that the Holy Prophet (S.A.W) stayed up all night reciting this prayer. I enquired, 'O Messenger of Allah, You know the whole of the Holy Qur’an by heart, why did you keep repeating one verse?' He replied, ‘I was praying for my followers.’ I asked him about the reply he received from God. He said, ‘If I tell you of it, most people will forsake prayer.’ This is the same prayer that Hadrat ‘Isa (A.S) (Jesus) recited for his followers.": 25,
# "Enumerating the attributes of the servants of the Gracious Lord, Allah says that these servants are the ones who pass the hours of the night prostrating and standing before their Lord and seek safety from Divine wrath.": 26,
# "A companion of the Holy Prophet (S.A.W) offered prayers with him. The Holy Prophet (S.A.W) said that this person is heaven-bound. Hadrat ‘Abdullah bin ‘Umarra was curious about what deed on the part of that person had deserved God's Beneficence and so he went and stayed overnight with him and was shown great hospitality. Ibne ‘Umarra said, \"I offered 'Tahajjud' prayers while this person slept. I observed an obligatory fast the next day while he did not. I questioned him about his actions which entitled him to be heaven-bound. He answered: ‘As the Holy Prophet (S.A.W) has told you about it you better enquire from him.\" Ibne ‘Umarra went to the Holy Prophet (S.A.W) and asked him. The Holy Prophet (S.A.W) told him to go back and ask him about it with his permission. This companion of the Holy Prophet (S.A.W) said, “Firstly, I do not value worldly things. If I get them it is fine and if I do not get them it does not matter to me. Secondly, I do not have jealousy or bear rancour against anyone.”Hadrat Ibne ‘Umar (R.A) admitted that most surely God had given him superiority over others. This is a prayer Allah has taught to believers.": 27,
# "Hadrat Abu-Bakr (R.A) requested the Holy Prophet (S.A.W) for a prayer to recite during salat. The prayer which was taught to him contains special supplications for mercy and forgiveness.": 28,
# "The Companions of the Holy Prophet (S.A.W) were gathered together and were talking about God's Greatness when the Holy Prophet (S.A.W) came and said, \"I also will tell you something about God's Greatness.\" Then he mentioned the throne-bearing angels of God who are His magnificent creation. Yahya bin Mu‘adh ar-Razira used to say that if one heavenly angel prays for the forgiveness of the believers, there is hope for God's pardon of sins, let alone the whole host of angels praying collectively.": 29,
# "Pharaoh used to treat his wife cruelly because she changed her religion. His wife prayed for escaping his bad treatment. It is related that her prayer was accepted and her heavenly abode was shown to her in this very world.": 30,
# "Having seen heaven, Ashab-e-A‘raf (perfect believers) will spontaneously start to recite this verse on seeing the people of Fire.": 31,
# "Hadrat Musa (A.S) (Moses) advised a small company of believing young men from among his people.’ You have believed in Allah, so put your trust in Him.’ These young men prayed in response.": 32,
# "Hadrat ‘Abdullah bin ‘Abbas (R.A) (whose mother, Umm-e-Fadl, believed in Islam in the early period) used to relate that, when the Holy Prophet (S.A.W) migrated from Makkah, he and his mother were amongst the weak women and children who were mentioned in the Holy Qur’an. That they used to pray for the success of the migration. God delivered these oppressed people at the time of the conquest of Makkah.": 33,
# "The Holy Prophet (S.A.W) instructed his followers to treat the vanquished people with kindness.": 34,
# "The Holy Prophet (S.A.W) was taught the following prayer so that his decisions be Divinely guided.": 35,
# "When Hadrat Musaa (Moses) was instructed to deliver God's message to the Pharaoh's court, he prayed in these words. Hadrat Asma’ binte ‘Umaisra relates \"I heard the Holy Prophet (S.A.W) offering this prayer at the foot of Mount Thabir. He was praying to his God and saying, “O my Lord, I pray to You in the same words as my brother Musa (A.S) (Moses).\"": 36,
# "God advises believers to repent sincerely. God will forgive their sins and place them in the heavens of His pleasure. There will be light in front of these believers and light behind them and they will pray.": 37,
# "When God granted Hadrat Yusuf (A.S) (Joseph) sovereignty after the ordeal of imprisonment, his brothers came to his court and brought their father with them. Hadrat Yusuf (A.S) (Joseph) thanked God and prayed.": 38,
# "Hadrat Anas bin Malikra relates that the Holy Prophet (S.A.W) said Hadrat Musa (A.S) (Moses) was so hungry, he became desperate even for a piece of a date. God not only provided food and shelter for him in a foreign land but also arranged a home and a wife for him.": 39,
# "All the prayers that the Hadrat Ibrahim (A.S) (Abraham) recited when he was building the Ka‘bah were accepted. These prayers were for Makkah to be a peaceful town, its inhabitants to receive sustenance and his progeny to be saved from idolatry and associating partners with God.": 40,
# "The prayer Hadrat Ibrahim (A.S) (Abraham) offered for the spiritual and worldly advancement of his progeny": 41,
# "Hadrat ‘Isa (A.S) (Jesus) prayed on the insistence of his apostles for sustenance from Heaven. God replied,‘Surely I will send it down to you, but whosoever of you disbelieves afterwards, I will surely punish them wherewith I will not punish any other of the people’.": 43,
# "The Holy Prophet (S.A.W) advised Hadrat Mu‘adh (R.A) to recite these two verses for deliverance from debt. He said that if a believer in distress recites these verses, God would rid him of the burden of debt and misery. Muqatil (R.A) bin Hayyan said that the Holy Prophet (S.A.W) was taught this prayer for victory over Persia and Rome": 44,
# "Hadrat ‘Abdullah bin ‘Abbas (R.A) relates that Hadrat Shu‘aib (A.S) (Jethro) despaired of his people's non-belief. He prayed to God for arbitration. As a result of this prayer his people were completely destroyed by an earthquake.": 45,
# "When the denial of Hadrat Nuh’s (A.S) (Noah) people reached an extreme, they called him a liar and a madman. In vexation, Hadrat Nuh (A.S) (Noah) prayed to God.": 46,
# "Hadrat Nuh (A.S) (Noah) was distressed by his people. He prayed to God for a decisive sign. He prayed for his safety and the safety of his followers. God accepted his prayer and saved him and his followers in an Ark and destroyed the disbelievers.": 47,
# "Hadrat Nuh (A.S) (Noah) ultimately prayed against his people when God revealed to him, ‘None of your people will believe except those who have already believed’.": 48,
# "After praying for Divine decree against non-believers, Hadrat Nuh (A.S) (Noah) prayed for the believers.": 49,
# "At the time of building the Ka‘bah, the House of God, Hadrat Ibrahim (A.S) (Abraham) offered a grand prayer for the guidance of mankind. A prayer about which the Holy Prophetsa said that he was the product of his father Ibrahim’s (A.S) (Abraham) prayer.": 50,
# "God says about this prayer of Hadrat Musa (A.S) (Moses) that he was informed of the acceptance of his supplication. He was advised to be steadfast and not follow the ignorant people.": 51,
# "Hadrat Lut (A.S) (Lot) advised his people to refrain from lewd actions. They replied that if he was a true Prophet he should call down punishment on them": 52,
# "In response to Hadrat Lut’s (A.S) (Lot) advice, his people threatened him with expulsion from the country. He prayed and God accepted his prayer. God saved Hadrat Lut (A.S) (Lot) and his family (except his wife) and his people were annihilated.": 53,
# "Hadrat Musa (A.S) (Moses) informed his followers of the victory over the Promised Land and asked them to enter it. They refused. On this, Musa (A.S) (Moses) prayed and as aresult the land was denied to the followers of Musa (A.S) (Moses) for forty years.": 54,
# "Hadrat Musa (A.S) (Moses) killed a person unintentionally. He prayed for forgiveness and God informed him of the acceptance of his prayer. Hadrat Musa (A.S) (Moses) was grateful and offered this prayer in response.": 55,
# "Hadrat Qatadah (R.A) relates that whenever the Holy Prophet (S.A.W) faced a battle, he offered in particular this prayer.": 56,
# "While mentioning Ashab-e-Kahf, God says that they were few young men who hid themselves in caves for safeguarding their belief in the unity of God.": 57,
# "Hadrat Ibrahim (A.S) (Abraham) prayed for virtuous children who could continue his mission.God gave him glad tidings of a forebearing son": 58,
# "Hadrat Ibrahim (A.S) (Abraham) offered this prayer while re-building the Ka‘bah with Hadrat Isma‘il (A.S) (Ishmael).": 59,
# "Hadrat Ibne Juraij (R.A) used to say that the followers of Hadrat Ibrahim (A.S) (Abraham) were always steadfast in worshipping God. ‘Allamah Sha‘bi (R.A) said that the prayer which Hadrat Nuh (A.S) (Noah) and Hadrat Ibrahim (A.S) (Abraham) offered for the forgiveness of believing men and believing women, gave me so much pleasure that even the wealth of the whole world would not have been equal to it.": 60,
# "The Holy Prophet (S.A.W) said that if after performing ablution, a person who offers this prayer of Hadrat Ibrahim in the name of Allah, God bestows heavenly food and drink on him. His illness becomes an atonement of his sins. His life is the life of an obedient one and his death is that of the martyr, even though his sins are as numerous as the foam of the seas. The ability to decide and piety are bestowed on him. His good name lives in the world.": 61,
# "This prayer of Hadrat Sulaiman (A.S) (Solomon) was accepted and the big rebellious people became obedient to him. Hadrat Salmah bin Al-Akwa‘ (R.A) said that whenever the Holy Prophet (S.A.W) prayed, he mentioned God's attribute ‘Wahhab’. For example he would say, 'شبكات رتي الأعلى الوقاب' Holy is my Lord the most High, the 'Bestower'. ": 62,
# "It is mentioned in the traditions that the first person to offer this prayer was Hadrat Abu-Bakr (R.A). His prayer was accepted and as a result his parents, brother and all his children accepted Islam.": 63,
# "When the army of Hadrat Sulaiman (A.S) (Solomon) passed by the valley of Namlah, its inhabitants were afraid and hid themselves in their houses. On seeing this Hadrat Sulaiman (A.S) (Solomon) prayed spontaneously.": 64,
# "On seeing out of season fruits near Hadrat Maryam (A.S) (Mary), Hadrat Zakariyyah (A.S) (Zachariah) her guardian asked her where they had come from? She answered spontaneously, ‘It is from Allah’. On hearing this Hadrat Zakariyyah (A.S) (Zachariah) prayed fervently and the glad tidings of acceptance were given to him while he was still praying. Hadrat Yahya (A.S) (John) was granted to him": 65,
# "The beautiful style that Hadrat Zakariyyah (A.S) (Zachariah) adopted for this prayer was bound to be accepted.": 66,
# "God says that when Hadrat Zakariyyah (A.S) (Zachariah) prayed, “We accepted his prayers”. His wife recovered and Yahya (A.S) (John) was bestowed upon him.": 67,
# "Whilst mentioning the characteristics of the servants of God, the Holy Prophet (S.A.W) told us that they used to say the following prayers:": 68,
# "The Holy Prophet (S.A.W) was taught this prayer for his parents and the parents of his followers. Holy Prophet (S.A.W) used to say that the son could never repay his parents' favours unless he frees his enslaved father.": 69,
# "At the time of the flood, Hadrat Nuh (A.S) (Noah) prayed according to God’s instructions and his Ark anchored at Mount Judi. The Holy Prophet (S.A.W) used to say that this prayer would safeguard his followers boat from sinking.": 70,
# "God instructed Hadrat Nuh (A.S) (Noah) to say:": 71,
# "The Holy Prophet (S.A.W) used to say these words three times سُبْحَانَ الله اَلْحَمْدُ لِلَّهِ اللَّهُ أَكْبَرِ and offer this prayer o on riding a mount:": 72,
# "The Holy Prophet (S.A.W) said that a lost or missing thing can be found by reciting these verses of the Holy Qur'an": 73,
# "Hadrat ‘Abdullah bin ‘Abbas (R.A) relates that these verses were revealed near the time of migration. For a good beginning and end this prayer is tried and tested.": 74,
# "The Holy Prophet (S.A.W) said that whosoever will recite this prayer after salat or on leaving a meeting; God will weigh his actions with good measure and grant extra favours.": 75,
# "The Holy Prophet (S.A.W) was taught this prayer of peace for the holy people": 76,
# "When Hadrat Musa (A.S) (Moses) could not bear the manifestation of God and he became unconscious. On recovering he offered this supplication.": 77,
# "When Hadrat Ibrahim (A.S) (Abraham) was thrown into the fire, he offered this prayer.": 78,
# "Sa‘id bin Hasanah (R.A) relates that he knew of a verse, which when recited, a supplicant would receive whatever he begged The Holy Prophet (S.A.W) used to begin his Tahajjud with it and added words of, اللَّهُمَّ رَبَّ جِبْرِيلَ وَمِيكَائِيلَ وَإِسْرَا فِيلَ \"Allah the Lord of Jibrā'īl l (Gabriel), Mīkā'īl (Michael) and Isrāfīl (Israfel).\"": 79,
# "God delivered Hadrat Nuh (A.S)'s (Noah) Ark from the flood.": 80,
# "The learned believers prostrated themselves on hearing the revealed verses.": 81,
# "Hadrat ‘Abdullah bin ‘Abbas (R.A) relates that the Holy Prophet (S.A.W) said: “If a person recites these verses at dawn he would recompensate his day's failings in advance and if he recites them at dusk, his sins during the night will be atoned”.": 82,
# "When the believers who are patient face a calamity or receive a shock they pray in the following manner. God bestows His blessings and mercy on them. These are the rightly guided people. Hadrat Husain bin ‘Ali (R.A) relates that if a believer recites “Inna lillahi wa inna ilaihi Raji‘un” God grants him reward equal to his adversity. Lost things are found by the blessings of this prayer.": 83,
# "Hadrat Maryam (A.S)’s (Mary) mother offered this prayer before giving birth to her child. This prayer was accepted and she was granted a daughter like Hadrat Maryam (A.S) (Mary).": 84,
# "On the Day of Judgement, when the non-believers and those who reject God's words will confess to their sins, God will tell them to go away and not talk to Him. ‘You are the ones who ridiculed my servants who prayed and I have rewarded them in ample measure.’": 85,
# "Hadrat Abū Darda (R.A) relates that whosoever repeats this prayer seven times at dawn and dusk, God will deliver him from grief and sorrows of this world and the world hereafter.": 86,
# "Hadrat 'Abdullah (R.A) relates that the Holy Prophet (S.A.W) said, 'Repeat the last three Surahs of the Holy Qur'an. There is nothing like these for bestowal of refuge.' Hadrat Aishah (R.A) relates that whenever the Holy Prophet (S.A.W) fell ill, he would recite the last two Surahs of the Holy Qur'an and blow on himself. When his last illness became severe, she recited these last three Surahs, blew on her hands and rubbed on his body.": 87,
# "nan": 90,
# "At the time of building the Ka‘bah Hadrat Ibrahim (A.S) (Abraham) finished his prayers with this supplication.": 91
# }
global dua_data
with open("json/data_keys.json",'rb') as fl:
dua_data = json.load(fl)
keys = [i for i in dua_data.keys()]
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2",cache_folder="./all-MiniLM-L6-v2")
embeddings = model.encode(keys)
dimension = embeddings.shape[1]
embeddings = embeddings / np.linalg.norm(embeddings, axis=1, keepdims=True)
Index = faiss.IndexFlatIP(dimension)
Index.add(embeddings) # type: ignore
faiss.write_index(Index,"./model/dua_model.faiss")
"""
USAGE
def search(question,top_k=1):
question_embeddings = model.encode([question])
question_embeddings = question_embeddings / np.linalg.norm(question_embeddings,axis=1,keepdims=True)
distances,indices = Index.search(np.array(question_embeddings),top_k)
results = [(keys[i], distances[0][pos]) for pos,i in enumerate(indices[0])]
return results
question = input("Question: ")
print(search(question))
"""