-
Notifications
You must be signed in to change notification settings - Fork 0
/
Wiki.py
49 lines (41 loc) · 1.53 KB
/
Wiki.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import wikipedia
# Mapping from monument names to Wikipedia page titles
monument_to_wiki_id = {
"Ajantha Caves": "Ajantha Caves",
"alai_darwaza": "Alai Darwaza",
"alai_minar": "Qutub Minar",
"basilica_of_bom_jesus": "Basilica of Bom Jesus",
"Charar-E-Sharif": "Charar-e-Sharief shrine",
"charminar": "Charminar",
"Chhota Imambara": "Chota Imambara",
"Ellora Caves": "Ellora Caves",
"Fatehpur Sikri": "Jama Mosque",
"Gateway of India": "Gateway of India",
"golden temple": "Golden Temple",
"Hawa mahal": "Hawa Mahal",
"Hymayun_s Tomb": "Humayun's Tomb",
"India_gate": "All India War Memorial",
"iron_pillar": "Iron Pillar",
"jamali_kamali_tomb": "Jamali Kamali Mosque and Tomb",
"Khajuraho": "Lakshmana Temple, Khajuraho",
"lotus_temple": "LotusTemple",
"mysore_palace": "Amba Vilas Palace",
"qutub_minar": "Qutub Minar",
"Sun Temple Konark": "Konark Sun Temple",
"tajmahal": "TajMahal",
"tanjavur temple": "Brihadisvara Temple",
"victoria memorial": "Victoria Memorial, Kolkata",
}
def summarize(monument, lines=5):
"""
Fetches and returns a summary of the given monument from Wikipedia.
Parameters:
monument (str): The name of the monument to summarize.
Returns:
str: A summary of the given monument.
"""
# Using a dictionary to get wikipedia ID of the monument
monument_id = monument_to_wiki_id[monument]
# Using summary function of wikipedia
summary = wikipedia.summary(monument_id, sentences=lines)
return summary