razanalsulami commited on
Commit
1901b68
1 Parent(s): 568277b

Create app

Browse files
Files changed (1) hide show
  1. app +27 -0
app ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Sample context and question
2
+ context = """Saudi Arabia, officially known as the Kingdom of Saudi Arabia, is the largest country in the Middle East.
3
+ It is bordered by Jordan, Iraq, Kuwait, Bahrain, Qatar, the United Arab Emirates, Oman, and Yemen.
4
+ The capital city is Riyadh. Saudi Arabia is known for its vast deserts, including the Rub’ al Khali, also
5
+ known as the Empty Quarter, which is the largest continuous sand desert in the world. The country is also famous
6
+ for being the birthplace of Islam and home to its two holiest cities, Mecca and Medina. Saudi Arabia's economy is
7
+ heavily dependent on oil, making it one of the world’s leading oil producers and exporters. The official language
8
+ is Arabic, and the currency is the Saudi riyal."""
9
+
10
+ question = "What is the capital of Saudi Arabia?"
11
+
12
+ # Function to extract the answer from the context
13
+ def find_answer(context, question):
14
+ if "capital" in question.lower():
15
+ # Searching for the word "capital" in the context
16
+ sentences = context.split(".")
17
+ for sentence in sentences:
18
+ if "capital" in sentence.lower():
19
+ # Assuming the answer follows after the word "capital"
20
+ words = sentence.split()
21
+ if "capital" in words:
22
+ index = words.index("capital")
23
+ # Return the next word which should be the capital city
24
+ return words[index + 3] # The word after 'capital city is'
25
+
26
+ answer = find_answer(context, question)
27
+ print(f"Answer: {answer}")