Upload 5 files
Browse files- Unicorn_logo.png +0 -0
- app.py +86 -0
- qna.csv +401 -0
- requirements.txt +0 -0
- train.py +55 -0
Unicorn_logo.png
ADDED
![]() |
app.py
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
4 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
# Load Q&A data
|
8 |
+
def load_data():
|
9 |
+
return pd.read_csv('qna.csv', encoding='latin1', delimiter=';')
|
10 |
+
|
11 |
+
def get_most_similar_question(new_sentence, vectorizer, tfidf_matrix, questions, answers):
|
12 |
+
new_tfidf = vectorizer.transform([new_sentence])
|
13 |
+
|
14 |
+
similarities = cosine_similarity(new_tfidf, tfidf_matrix)
|
15 |
+
|
16 |
+
most_similar_index = np.argmax(similarities)
|
17 |
+
|
18 |
+
similarity_percentage = similarities[0, most_similar_index] * 100
|
19 |
+
|
20 |
+
return answers[most_similar_index], similarity_percentage
|
21 |
+
|
22 |
+
def answer_the_question(new_sentence, vectorizer, tfidf_matrix, questions, answers):
|
23 |
+
most_similar_answer, similarity_percentage = get_most_similar_question(new_sentence, vectorizer, tfidf_matrix, questions, answers)
|
24 |
+
if similarity_percentage > 70:
|
25 |
+
return most_similar_answer
|
26 |
+
else:
|
27 |
+
return 'Sorry, I am not aware of this information :('
|
28 |
+
|
29 |
+
def main():
|
30 |
+
|
31 |
+
st.markdown(
|
32 |
+
"<h1 style='text-align: center; color: #269A96;'>Unicorn</h1>",
|
33 |
+
unsafe_allow_html=True
|
34 |
+
)
|
35 |
+
|
36 |
+
# Load Q&A data
|
37 |
+
data = load_data()
|
38 |
+
questions = data['question'].tolist()
|
39 |
+
answers = data['answer'].tolist()
|
40 |
+
|
41 |
+
# Create TF-IDF vectorizer
|
42 |
+
vectorizer = TfidfVectorizer()
|
43 |
+
tfidf_matrix = vectorizer.fit_transform(questions)
|
44 |
+
|
45 |
+
# Get user input
|
46 |
+
user_question = st.text_input("Ask me a question:", key="user_question")
|
47 |
+
|
48 |
+
# Apply CSS to style the text input field
|
49 |
+
st.markdown(
|
50 |
+
"""
|
51 |
+
<style>
|
52 |
+
.st-cc {
|
53 |
+
background-color: #269A96 !important;
|
54 |
+
color: #FFFFFF !important;
|
55 |
+
}
|
56 |
+
.st-bk {
|
57 |
+
color: #FFFFFF !important;
|
58 |
+
}
|
59 |
+
</style>
|
60 |
+
""",
|
61 |
+
unsafe_allow_html=True
|
62 |
+
)
|
63 |
+
|
64 |
+
# Process the question when submitted
|
65 |
+
if st.button("Submit", key="submit_button", help="Submit your question"):
|
66 |
+
if user_question:
|
67 |
+
response = answer_the_question(user_question, vectorizer, tfidf_matrix, questions, answers)
|
68 |
+
st.write(response)
|
69 |
+
else:
|
70 |
+
st.warning("Please ask a question.")
|
71 |
+
|
72 |
+
# Apply CSS to style the button
|
73 |
+
st.markdown(
|
74 |
+
"""
|
75 |
+
<style>
|
76 |
+
.css-1bkz6v6 {
|
77 |
+
background-color: #a5eae9;
|
78 |
+
color: #FFFFFF;
|
79 |
+
}
|
80 |
+
</style>
|
81 |
+
""",
|
82 |
+
unsafe_allow_html=True
|
83 |
+
)
|
84 |
+
|
85 |
+
if __name__ == "__main__":
|
86 |
+
main()
|
qna.csv
ADDED
@@ -0,0 +1,401 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
question;answer;;
|
2 |
+
who is pm of India;Modi;;
|
3 |
+
Who is Indian prime minister;Modi;;
|
4 |
+
who is the leader of BJP;Modi;;
|
5 |
+
Who is Indian pm;Modi;;
|
6 |
+
who created you;I was made by Mr. Ninad Mandavkar. He is a Masters Graduate from TU Ilmenau. He is ML enthusiast and his current interests lies in NLP, Deep Learning & Computer Vision;;
|
7 |
+
who developed you;I was made by Mr. Ninad Mandavkar. He is a Masters Graduate from TU Ilmenau. He is ML enthusiast and his current interests lies in NLP, Deep Learning & Computer Vision;;
|
8 |
+
who discovred you;I was made by Mr. Ninad Mandavkar. He is a Masters Graduate from TU Ilmenau. He is ML enthusiast and his current interests lies in NLP, Deep Learning & Computer Vision;;
|
9 |
+
who made you;I was made by Mr. Ninad Mandavkar. He is a Masters Graduate from TU Ilmenau. He is ML enthusiast and his current interests lies in NLP, Deep Learning & Computer Vision;;
|
10 |
+
Who is harry potter?;Harry Potter is a fictional character written by J.K. Rowling and he is the lead hero of a 7 parter series by the same name 'Harry Potter'.;;
|
11 |
+
Who is JK rowling;J. K. Rowling is a British author who created the series 'Harry Potter'. Rowling was born 31 July 1965 at Chipping Sodbury Cottage Hospital in Chipping Sodbury, Yate, Gloucesterhire England. She grew up in Tutshill, Gloucestershire, and went to school at Wyedean Comprehensive. She earned a degree in French and Classics at the University of Exeter. ;;
|
12 |
+
Capital of Afghanistan;Kabul;;
|
13 |
+
Capital of Albania;Tirana;;
|
14 |
+
Capital of Algeria;Algiers;;
|
15 |
+
Capital of Andorra;Andorra la Vella;;
|
16 |
+
Capital of Angola;Luanda;;
|
17 |
+
Capital of Antigua and Barbuda;St. John's;;
|
18 |
+
Capital of Argentina;Buenos Aires;;
|
19 |
+
Capital of Armenia;<;;
|
20 |
+
Capital of Australia;Canberra;;
|
21 |
+
Capital of Austria;Vienna;;
|
22 |
+
Capital of Azerbaijan;Baku;;
|
23 |
+
Capital of The Bahamas;Nassau;;
|
24 |
+
Capital of Bahrain;Manama;;
|
25 |
+
Capital of Bangladesh;Dhaka;;
|
26 |
+
Capital of Barbados;Bridgetown;;
|
27 |
+
Capital of Belarus;Minsk;;
|
28 |
+
Capital of Belgium;Brussels;;
|
29 |
+
Capital of Belize;Belmopan;;
|
30 |
+
Capital of Benin;Porto-Novo;;
|
31 |
+
Capital of Bhutan;Thimphu;;
|
32 |
+
Capital of Bolivia;Sucre;;
|
33 |
+
Capital of Bosnia and Herzegovina;Sarajevo;;
|
34 |
+
Capital of Botswana;Gaborone;;
|
35 |
+
Capital of Brazil;Bras�lia;;
|
36 |
+
Capital of Brunei;Bandar Seri Begawan;;
|
37 |
+
Capital of Bulgaria;Sofia;;
|
38 |
+
Capital of Burkina Faso;Ouagadougou;;
|
39 |
+
Capital of Burundi;Gitega;;
|
40 |
+
Capital of Cabo Verde;Praia;;
|
41 |
+
Capital of Cambodia;Phnom Penh;;
|
42 |
+
Capital of Cameroon;Yaound�;;
|
43 |
+
Capital of Canada;Ottawa;;
|
44 |
+
Capital of Central African Republic;Bangui;;
|
45 |
+
Capital of Chad;N'Djamena;;
|
46 |
+
Capital of Chile;Santiago;;
|
47 |
+
Capital of China;Beijing;;
|
48 |
+
Capital of Colombia;Bogot�;;
|
49 |
+
Capital of Comoros;Moroni;;
|
50 |
+
Capital of Congo;Brazzaville;;
|
51 |
+
Capital of Costa Rica;San Jos�;;
|
52 |
+
Capital of Croatia;Zagreb;;
|
53 |
+
Capital of Cuba;Havana;;
|
54 |
+
Capital of Cyprus;Nicosia;;
|
55 |
+
Capital of Czech Republic;Prague;;
|
56 |
+
Capital of Democratic Republic of the Congo;Kinshasa;;
|
57 |
+
Capital of Denmark;Copenhagen;;
|
58 |
+
Capital of Djibouti;Djibouti (city);;
|
59 |
+
Capital of Dominica;Roseau;;
|
60 |
+
Capital of Dominican Republic;Santo Domingo;;
|
61 |
+
Capital of East Timor;Dili;;
|
62 |
+
Capital of Ecuador;Quito;;
|
63 |
+
Capital of Egypt;Cairo;;
|
64 |
+
Capital of El Salvador;San Salvador;;
|
65 |
+
Capital of Equatorial Guinea;Malabo;;
|
66 |
+
Capital of Eritrea;Asmara;;
|
67 |
+
Capital of Estonia;Tallinn;;
|
68 |
+
Capital of Eswatini;Mbabane (executive); Lobamba (legislative);
|
69 |
+
Capital of Ethiopia;Addis Ababa;;
|
70 |
+
Capital of Fiji;Suva;;
|
71 |
+
Capital of Finland;Helsinki;;
|
72 |
+
Capital of France;Paris;;
|
73 |
+
Capital of Gabon;Libreville;;
|
74 |
+
Capital of The Gambia;Banjul;;
|
75 |
+
Capital of Georgia;Tbilisi;;
|
76 |
+
Capital of Germany;Berlin;;
|
77 |
+
Capital of Ghana;Accra;;
|
78 |
+
Capital of Greece;Athens;;
|
79 |
+
Capital of Grenada;St. George's;;
|
80 |
+
Capital of Guatemala;Guatemala City;;
|
81 |
+
Capital of Guinea;Conakry;;
|
82 |
+
Capital of Guinea-Bissau;Bissau;;
|
83 |
+
Capital of Guyana;Georgetown;;
|
84 |
+
Capital of Haiti;Port-au-Prince;;
|
85 |
+
Capital of Honduras;Tegucigalpa;;
|
86 |
+
Capital of Hungary;Budapest;;
|
87 |
+
Capital of Iceland;Reykjav�k;;
|
88 |
+
Capital of India;New Delhi;;
|
89 |
+
Capital of Indonesia;Jakarta;;
|
90 |
+
Capital of Iran;Tehran;;
|
91 |
+
Capital of Iraq;Baghdad;;
|
92 |
+
Capital of Ireland;Dublin;;
|
93 |
+
Capital of Israel;Jerusalem;;
|
94 |
+
Capital of Italy;Rome;;
|
95 |
+
Capital of Ivory Coast;Yamoussoukro (political capital); Abidjan (economic capital);
|
96 |
+
Capital of Jamaica;Kingston;;
|
97 |
+
Capital of Japan;Tokyo;;
|
98 |
+
Capital of Jordan;Amman;;
|
99 |
+
Capital of Kazakhstan;Nur-Sultan (formerly Astana);;
|
100 |
+
Capital of Kenya;Nairobi;;
|
101 |
+
Capital of Kiribati;South Tarawa;;
|
102 |
+
Capital of Kosovo;Pristina;;
|
103 |
+
Capital of Kuwait;Kuwait City;;
|
104 |
+
Capital of Kyrgyzstan;Bishkek;;
|
105 |
+
Capital of Laos;Vientiane;;
|
106 |
+
Capital of Latvia;Riga;;
|
107 |
+
Capital of Lebanon;Beirut;;
|
108 |
+
Capital of Lesotho;Maseru;;
|
109 |
+
Capital of Liberia;Monrovia;;
|
110 |
+
Capital of Libya;Tripoli;;
|
111 |
+
Capital of Liechtenstein;Vaduz;;
|
112 |
+
Capital of Lithuania;Vilnius;;
|
113 |
+
Capital of Luxembourg;Luxembourg City;;
|
114 |
+
Capital of Madagascar;Antananarivo;;
|
115 |
+
Capital of Malawi;Lilongwe;;
|
116 |
+
Capital of Malaysia;Kuala Lumpur;;
|
117 |
+
Capital of Maldives;Mal�;;
|
118 |
+
Capital of Mali;Bamako;;
|
119 |
+
Capital of Malta;Valletta;;
|
120 |
+
Capital of Marshall Islands;Majuro;;
|
121 |
+
Capital of Mauritania;Nouakchott;;
|
122 |
+
Capital of Mauritius;Port Louis;;
|
123 |
+
Capital of Mexico;Mexico City;;
|
124 |
+
Capital of Federated States of Micronesia;Palikir;;
|
125 |
+
Capital of Moldova;Chi?in?u;;
|
126 |
+
Capital of Monaco;Monaco;;
|
127 |
+
Capital of Mongolia;Ulaanbaatar;;
|
128 |
+
Capital of Montenegro;Podgorica;;
|
129 |
+
Capital of Morocco;Rabat;;
|
130 |
+
Capital of Mozambique;Maputo;;
|
131 |
+
Capital of Myanmar;Naypyidaw;;
|
132 |
+
Capital of Namibia;Windhoek;;
|
133 |
+
Capital of Nauru;Yaren (de facto);;
|
134 |
+
Capital of Nepal;Kathmandu;;
|
135 |
+
Capital of Netherlands;Amsterdam (official); The Hague (seat of government);
|
136 |
+
Capital of New Zealand;Wellington;;
|
137 |
+
Capital of Nicaragua;Managua;;
|
138 |
+
Capital of Niger;Niamey;;
|
139 |
+
Capital of Nigeria;Abuja;;
|
140 |
+
Capital of North Korea;Pyongyang;;
|
141 |
+
Capital of North Macedonia;Skopje;;
|
142 |
+
Capital of Norway;Oslo;;
|
143 |
+
Capital of Oman;Muscat;;
|
144 |
+
Capital of Pakistan;Islamabad;;
|
145 |
+
Capital of Palau;Ngerulmud;;
|
146 |
+
Capital of Panama;Panama City;;
|
147 |
+
Capital of Papua New Guinea;Port Moresby;;
|
148 |
+
Capital of Paraguay;Asunci�n;;
|
149 |
+
Capital of Peru;Lima;;
|
150 |
+
Capital of Philippines;Manila;;
|
151 |
+
Capital of Poland;Warsaw;;
|
152 |
+
Capital of Portugal;Lisbon;;
|
153 |
+
Capital of Qatar;Doha;;
|
154 |
+
Capital of Romania;Bucharest;;
|
155 |
+
Capital of Russia;Moscow;;
|
156 |
+
Capital of Rwanda;Kigali;;
|
157 |
+
Capital of Saint Kitts and Nevis;Basseterre;;
|
158 |
+
Capital of Saint Lucia;Castries;;
|
159 |
+
Capital of Saint Vincent and the Grenadines;Kingstown;;
|
160 |
+
Capital of Samoa;Apia;;
|
161 |
+
Capital of San Marino;San Marino;;
|
162 |
+
Capital of Sao Tome and Principe;S�o Tom�;;
|
163 |
+
Capital of Saudi Arabia;Riyadh;;
|
164 |
+
Capital of Senegal;Dakar;;
|
165 |
+
Capital of Serbia;Belgrade;;
|
166 |
+
Capital of Seychelles;Victoria;;
|
167 |
+
Capital of Sierra Leone;Freetown;;
|
168 |
+
Capital of Singapore;Singapore;;
|
169 |
+
Capital of Slovakia;Bratislava;;
|
170 |
+
Capital of Slovenia;Ljubljana;;
|
171 |
+
Capital of Solomon Islands;Honiara;;
|
172 |
+
Capital of Somalia;Mogadishu;;
|
173 |
+
Capital of South Africa;Pretoria (executive); Bloemfontein (judicial); Cape Town (legislative)
|
174 |
+
Capital of South Korea;Seoul;;
|
175 |
+
Capital of South Sudan;Juba;;
|
176 |
+
Capital of Spain;Madrid;;
|
177 |
+
Capital of Sri Lanka;Sri Jayawardenepura Kotte (official); Colombo (commercial);
|
178 |
+
Capital of Sudan;Khartoum;;
|
179 |
+
Capital of Sweden;Stockholm;;
|
180 |
+
Capital of Switzerland;Bern;;
|
181 |
+
Capital of Syria;Damascus;;
|
182 |
+
Capital of Taiwan;Taipei;;
|
183 |
+
Capital of Tajikistan;Dushanbe;;
|
184 |
+
Capital of Tanzania;Dodoma (official); Dar es Salaam (administrative);
|
185 |
+
Capital of Thailand;Bangkok;;
|
186 |
+
Capital of Togo;Lom�;;
|
187 |
+
Capital of Tonga;Nuku?alofa;;
|
188 |
+
Capital of Trinidad and Tobago;Port of Spain;;
|
189 |
+
Capital of Tunisia;Tunis;;
|
190 |
+
Capital of Turkey;Ankara;;
|
191 |
+
Capital of Turkmenistan;Ashgabat;;
|
192 |
+
Capital of Tuvalu;Funafuti;;
|
193 |
+
Capital of Uganda;Kampala;;
|
194 |
+
Capital of Ukraine;Kyiv;;
|
195 |
+
Capital of United Arab Emirates;Abu Dhabi;;
|
196 |
+
Capital of United Kingdom;London;;
|
197 |
+
Capital of United States;Washington; D.C.;
|
198 |
+
Capital of Uruguay;Montevideo;;
|
199 |
+
Capital of Uzbekistan;Tashkent;;
|
200 |
+
Capital of Vanuatu;Port Vila;;
|
201 |
+
Capital of Vatican City;Vatican City;;
|
202 |
+
Capital of Venezuela;Caracas;;
|
203 |
+
Capital of Vietnam;Hanoi;;
|
204 |
+
Capital of Yemen;Sana'a (de jure); Aden (temporary); Sana'a (Houthi-led Yemen)
|
205 |
+
Capital of Zambia;Lusaka;;
|
206 |
+
Capital of Zimbabwe;Harare;;
|
207 |
+
President of Afghanistan;Ashraf Ghani;;
|
208 |
+
President of Albania;Ilir Meta;;
|
209 |
+
President of Algeria;Abdelmadjid Tebboune;;
|
210 |
+
President of Andorra;Xavier Espot Zamora;;
|
211 |
+
President of Angola;Jo�o Louren�o;;
|
212 |
+
President of Antigua and Barbuda;Rodney Williams;;
|
213 |
+
President of Argentina;Alberto Fern�ndez;;
|
214 |
+
President of Armenia;Armen Sarkissian;;
|
215 |
+
President of Australia;Scott Morrison;;
|
216 |
+
President of Austria;Alexander Van der Bellen;;
|
217 |
+
President of Azerbaijan;Ilham Aliyev;;
|
218 |
+
President of The Bahamas;Hubert Minnis;;
|
219 |
+
President of Bahrain;Hamad bin Isa Al Khalifa;;
|
220 |
+
President of Bangladesh;Abdul Hamid;;
|
221 |
+
President of Barbados;Sandra Mason;;
|
222 |
+
President of Belarus;Alexander Lukashenko;;
|
223 |
+
President of Belgium;King Philippe;;
|
224 |
+
President of Belize;Johnny Brice�o;;
|
225 |
+
President of Benin;Patrice Talon;;
|
226 |
+
President of Bhutan;Jigme Khesar Namgyel Wangchuck;;
|
227 |
+
President of Bolivia;Luis Arce;;
|
228 |
+
President of Bosnia and Herzegovina;�efik D�aferovi? (Chairman of the Presidency);;
|
229 |
+
President of Botswana;Mokgweetsi Masisi;;
|
230 |
+
President of Brazil;Jair Bolsonaro;;
|
231 |
+
President of Brunei;Hassanal Bolkiah;;
|
232 |
+
President of Bulgaria;Rumen Radev;;
|
233 |
+
President of Burkina Faso;Roch Marc Christian Kabor�;;
|
234 |
+
President of Burundi;�variste Ndayishimiye;;
|
235 |
+
President of Cabo Verde;Jorge Carlos Fonseca;;
|
236 |
+
President of Cambodia;King Norodom Sihamoni;;
|
237 |
+
President of Cameroon;Paul Biya;;
|
238 |
+
President of Canada;Justin Trudeau;;
|
239 |
+
President of Central African Republic;Faustin-Archange Touad�ra;;
|
240 |
+
President of Chad;Idriss D�by;;
|
241 |
+
President of Chile;Sebasti�n Pi�era;;
|
242 |
+
President of China;Xi Jinping;;
|
243 |
+
President of Colombia;Iv�n Duque M�rquez;;
|
244 |
+
President of Comoros;Azali Assoumani;;
|
245 |
+
President of Congo;Denis Sassou Nguesso;;
|
246 |
+
President of Costa Rica;Carlos Alvarado Quesada;;
|
247 |
+
President of Croatia;Zoran Milanovi?;;
|
248 |
+
President of Cuba;Miguel D�az-Canel;;
|
249 |
+
President of Cyprus;Nicos Anastasiades;;
|
250 |
+
President of Czech Republic;Milo� Zeman;;
|
251 |
+
President of Democratic Republic of the Congo;F�lix Tshisekedi;;
|
252 |
+
President of Denmark;Queen Margrethe II;;
|
253 |
+
President of Djibouti;Ismail Omar Guelleh;;
|
254 |
+
President of Dominica;Charles Savarin;;
|
255 |
+
President of Dominican Republic;Luis Abinader;;
|
256 |
+
President of East Timor;Francisco Guterres;;
|
257 |
+
President of Ecuador;Len�n Moreno;;
|
258 |
+
President of Egypt;Abdel Fattah el-Sisi;;
|
259 |
+
President of El Salvador;Nayib Bukele;;
|
260 |
+
President of Equatorial Guinea;Teodoro Obiang Nguema Mbasogo;;
|
261 |
+
President of Eritrea;Isaias Afwerki;;
|
262 |
+
President of Estonia;Kersti Kaljulaid;;
|
263 |
+
President of Eswatini;King Mswati III;;
|
264 |
+
President of Ethiopia;Sahle-Work Zewde;;
|
265 |
+
President of Fiji;Jioji Konrote;;
|
266 |
+
President of Finland;Sauli Niinist�;;
|
267 |
+
President of France;Emmanuel Macron;;
|
268 |
+
President of Gabon;Ali Bongo Ondimba;;
|
269 |
+
President of The Gambia;Adama Barrow;;
|
270 |
+
President of Georgia;Salome Zourabichvili;;
|
271 |
+
President of Germany;Frank-Walter Steinmeier;;
|
272 |
+
President of Ghana;Nana Akufo-Addo;;
|
273 |
+
President of Greece;Katerina Sakellaropoulou;;
|
274 |
+
President of Grenada;Angus Mitchell;;
|
275 |
+
President of Guatemala;Alejandro Giammattei;;
|
276 |
+
President of Guinea;Alpha Cond�;;
|
277 |
+
President of Guinea-Bissau;Umaro Sissoco Embal�;;
|
278 |
+
President of Guyana;Irfaan Ali;;
|
279 |
+
President of Haiti;Jovenel Mo�se;;
|
280 |
+
President of Honduras;Juan Orlando Hern�ndez;;
|
281 |
+
President of Hungary;J�nos �der;;
|
282 |
+
President of Iceland;Gu�ni Th. J�hannesson;;
|
283 |
+
President of India;Droupadi Murmu;;
|
284 |
+
President of Indonesia;Joko Widodo;;
|
285 |
+
President of Iran;Ebrahim Raisi;;
|
286 |
+
President of Iraq;Barham Salih;;
|
287 |
+
President of Ireland;Michael D. Higgins;;
|
288 |
+
President of Israel;Reuven Rivlin;;
|
289 |
+
President of Italy;Sergio Mattarella;;
|
290 |
+
President of Ivory Coast;Alassane Ouattara;;
|
291 |
+
President of Jamaica;Andrew Holness;;
|
292 |
+
President of Japan;Naruhito;;
|
293 |
+
President of Jordan;Abdullah II;;
|
294 |
+
President of Kazakhstan;Kassym-Jomart Tokayev;;
|
295 |
+
President of Kenya;Uhuru Kenyatta;;
|
296 |
+
President of Kiribati;Taneti Mamau;;
|
297 |
+
President of Kosovo;Vjosa Osmani;;
|
298 |
+
President of Kuwait;Sabah Al-Ahmad Al-Jaber Al-Sabah;;
|
299 |
+
President of Kyrgyzstan;Sadyr Japarov;;
|
300 |
+
President of Laos;Bounnhang Vorachith;;
|
301 |
+
President of Latvia;Egils Levits;;
|
302 |
+
President of Lebanon;Michel Aoun;;
|
303 |
+
President of Lesotho;Letsie III;;
|
304 |
+
President of Liberia;George Weah;;
|
305 |
+
President of Libya;Mohamed al-Menfi;;
|
306 |
+
President of Liechtenstein;Adrian Hasler;;
|
307 |
+
President of Lithuania;Gitanas Nauseda;;
|
308 |
+
President of Luxembourg;Henri;;
|
309 |
+
President of Madagascar;Andry Rajoelina;;
|
310 |
+
President of Malawi;Lazarus Chakwera;;
|
311 |
+
President of Malaysia;Sultan Abdullah of Pahang;;
|
312 |
+
President of Maldives;Ibrahim Mohamed Solih;;
|
313 |
+
President of Mali;Assimi Go�ta;;
|
314 |
+
President of Malta;George Vella;;
|
315 |
+
President of Marshall Islands;David Kabua;;
|
316 |
+
President of Mauritania;Mohamed Ould Ghazouani;;
|
317 |
+
President of Mauritius;Prithvirajsing Roopun;;
|
318 |
+
President of Mexico;Andr�s Manuel L�pez Obrador;;
|
319 |
+
President of Federated States of Micronesia;David W. Panuelo;;
|
320 |
+
President of Moldova;Maia Sandu;;
|
321 |
+
President of Monaco;Prince Albert II;;
|
322 |
+
President of Mongolia;Khaltmaagiin Battulga;;
|
323 |
+
President of Montenegro;Milo ?ukanovi?;;
|
324 |
+
President of Morocco;Mohammed VI;;
|
325 |
+
President of Mozambique;Filipe Nyusi;;
|
326 |
+
President of Myanmar;Myint Swe;;
|
327 |
+
President of Namibia;Hage Geingob;;
|
328 |
+
President of Nauru;Lionel Aingimea;;
|
329 |
+
President of Nepal;Bidhya Devi Bhandari;;
|
330 |
+
President of Netherlands;King Willem-Alexander;;
|
331 |
+
President of New Zealand;Jacinda Ardern;;
|
332 |
+
President of Nicaragua;Daniel Ortega;;
|
333 |
+
President of Niger;Mohamed Bazoum;;
|
334 |
+
President of Nigeria;Muhammadu Buhari;;
|
335 |
+
President of North Korea;Kim Jong-un;;
|
336 |
+
President of North Macedonia;Stevo Pendarovski;;
|
337 |
+
President of Norway;Harald V;;
|
338 |
+
President of Oman;Haitham bin Tariq Al Said;;
|
339 |
+
President of Pakistan;Arif Alvi;;
|
340 |
+
President of Palau;Surangel Whipps Jr.;;
|
341 |
+
President of Panama;Laurentino Cortizo;;
|
342 |
+
President of Papua New Guinea;James Marape;;
|
343 |
+
President of Paraguay;Mario Abdo Ben�tez;;
|
344 |
+
President of Peru;Pedro Castillo;;
|
345 |
+
President of Philippines;Rodrigo Duterte;;
|
346 |
+
President of Poland;Andrzej Duda;;
|
347 |
+
President of Portugal;Marcelo Rebelo de Sousa;;
|
348 |
+
President of Qatar;Tamim bin Hamad Al Thani;;
|
349 |
+
President of Romania;Klaus Iohannis;;
|
350 |
+
President of Russia;Vladimir Putin;;
|
351 |
+
President of Rwanda;Paul Kagame;;
|
352 |
+
President of Saint Kitts and Nevis;Timothy Harris;;
|
353 |
+
President of Saint Lucia;Allen Chastanet;;
|
354 |
+
President of Saint Vincent and the Grenadines;Ralph Gonsalves;;
|
355 |
+
President of Samoa;Tuimalealiifano Vaaleto'a Sualauvi II;;
|
356 |
+
President of San Marino;Gian Carlo Venturini;;
|
357 |
+
President of Sao Tome and Principe;Evaristo Carvalho;;
|
358 |
+
President of Saudi Arabia;Salman bin Abdulaziz Al Saud;;
|
359 |
+
President of Senegal;Macky Sall;;
|
360 |
+
President of Serbia;Aleksandar Vu?i?;;
|
361 |
+
President of Seychelles;Wavel Ramkalawan;;
|
362 |
+
President of Sierra Leone;Julius Maada Bio;;
|
363 |
+
President of Singapore;Halimah Yacob;;
|
364 |
+
President of Slovakia;Zuzana ?aputov�;;
|
365 |
+
President of Slovenia;Borut Pahor;;
|
366 |
+
President of Solomon Islands;David Kabua;;
|
367 |
+
President of Somalia;Mohamed Abdullahi Mohamed;;
|
368 |
+
President of South Africa;Cyril Ramaphosa;;
|
369 |
+
President of South Korea;Moon Jae-in;;
|
370 |
+
President of South Sudan;Salva Kiir Mayardit;;
|
371 |
+
President of Spain;Pedro S�nchez;;
|
372 |
+
President of Sri Lanka;Gotabaya Rajapaksa;;
|
373 |
+
President of Sudan;Abdel Fattah al-Burhan;;
|
374 |
+
President of Sweden;Carl XVI Gustaf;;
|
375 |
+
President of Switzerland;Guy Parmelin;;
|
376 |
+
President of Syria;Bashar al-Assad;;
|
377 |
+
President of Taiwan;Tsai Ing-wen;;
|
378 |
+
President of Tajikistan;Emomali Rahmon;;
|
379 |
+
President of Tanzania;Samia Suluhu;;
|
380 |
+
President of Thailand;Maha Vajiralongkorn;;
|
381 |
+
President of Togo;Faure Gnassingb�;;
|
382 |
+
President of Tonga;King Tupou VI;;
|
383 |
+
President of Trinidad and Tobago;Paula-Mae Weekes;;
|
384 |
+
President of Tunisia;Kais Saied;;
|
385 |
+
President of Turkey;Recep Tayyip Erdo?an;;
|
386 |
+
President of Turkmenistan;Gurbanguly Berdimuhamedow;;
|
387 |
+
President of Tuvalu;Taneti Mamau;;
|
388 |
+
President of Uganda;Yoweri Museveni;;
|
389 |
+
President of Ukraine;Volodymyr Zelensky;;
|
390 |
+
President of United Arab Emirates;Khalifa bin Zayed Al Nahyan;;
|
391 |
+
President of United Kingdom;Queen Elizabeth II;;
|
392 |
+
President of United States;Joe Biden;;
|
393 |
+
President of Uruguay;Luis Lacalle Pou;;
|
394 |
+
President of Uzbekistan;Shavkat Mirziyoyev;;
|
395 |
+
President of Vanuatu;Tallis Obed Moses;;
|
396 |
+
President of Vatican City;Pope Francis;;
|
397 |
+
President of Venezuela;Nicol�s Maduro;;
|
398 |
+
President of Vietnam;Nguy?n Ph� Tr?ng;;
|
399 |
+
President of Yemen;Abdrabbuh Mansur Hadi;;
|
400 |
+
President of Zambia;Edgar Lungu;;
|
401 |
+
President of Zimbabwe;Emmerson Mnangagwa;;
|
requirements.txt
ADDED
Binary file (4.81 kB). View file
|
|
train.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
4 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
# Load Q&A data
|
8 |
+
@st.cache
|
9 |
+
def load_data():
|
10 |
+
return pd.read_csv('qna.csv', encoding='utf-8', delimiter=';')
|
11 |
+
|
12 |
+
def get_most_similar_question(new_sentence, vectorizer, tfidf_matrix, questions, answers):
|
13 |
+
new_tfidf = vectorizer.transform([new_sentence])
|
14 |
+
|
15 |
+
similarities = cosine_similarity(new_tfidf, tfidf_matrix)
|
16 |
+
|
17 |
+
most_similar_index = np.argmax(similarities)
|
18 |
+
|
19 |
+
similarity_percentage = similarities[0, most_similar_index] * 100
|
20 |
+
|
21 |
+
return answers[most_similar_index], similarity_percentage
|
22 |
+
|
23 |
+
def answer_the_question(new_sentence, vectorizer, tfidf_matrix, questions, answers):
|
24 |
+
most_similar_answer, similarity_percentage = get_most_similar_question(new_sentence, vectorizer, tfidf_matrix, questions, answers)
|
25 |
+
if similarity_percentage > 70:
|
26 |
+
return most_similar_answer
|
27 |
+
else:
|
28 |
+
return 'Sorry, I am not aware of this information :('
|
29 |
+
|
30 |
+
def main():
|
31 |
+
st.title("Q&A Chatbot")
|
32 |
+
|
33 |
+
# Load Q&A data
|
34 |
+
data = load_data()
|
35 |
+
questions = data['question'].tolist()
|
36 |
+
answers = data['answer'].tolist()
|
37 |
+
|
38 |
+
# Create TF-IDF vectorizer
|
39 |
+
vectorizer = TfidfVectorizer()
|
40 |
+
tfidf_matrix = vectorizer.fit_transform(questions)
|
41 |
+
|
42 |
+
# Get user input
|
43 |
+
user_question = st.text_input("Ask me a question:")
|
44 |
+
|
45 |
+
# Process the question when submitted
|
46 |
+
if st.button("Submit"):
|
47 |
+
if user_question:
|
48 |
+
response = answer_the_question(user_question, vectorizer, tfidf_matrix, questions, answers)
|
49 |
+
st.write("Answer:")
|
50 |
+
st.write(response)
|
51 |
+
else:
|
52 |
+
st.warning("Please ask a question.")
|
53 |
+
|
54 |
+
if __name__ == "__main__":
|
55 |
+
main()
|