23
23
24
24
25
25
def get_wiki_langs ():
26
- """Provides the list of language to find Creative Commons usage data on.
26
+ """
27
+ Provides the list of language to find Creative Commons usage data on.
27
28
28
29
The codes represent the language codes defined by ISO 639-1 and ISO 639-3,
29
30
and the decision of which language code to use is usually determined by the
30
31
IETF language tag policy.
31
32
(https://en.wikipedia.org/wiki/List_of_Wikipedias#Wikipedia_edition_codes)
32
33
33
34
Returns:
34
- pd.DataFrame: A Dataframe containing information of each Wikipedia
35
- language and its respective encoding on web address.
35
+ - pd.DataFrame: A Dataframe containing information of each Wikipedia
36
+ language and its respective encoding on web address.
36
37
"""
37
38
return pd .read_csv (f"{ CWD } /language-codes_csv.csv" )
38
39
39
40
40
41
def get_request_url (lang = "en" ):
41
- """Provides the API Endpoint URL for specified parameter combinations.
42
+ """
43
+ Provides the API Endpoint URL for specified parameter combinations.
42
44
43
45
Args:
44
- lang:
45
- A string representing the language that the search results are
46
- presented in. Alternatively, the default value is by Wikipedia
47
- customs "en".
46
+ - lang: A string representing the language that the search results are
47
+ presented in. Alternatively, the default value is by Wikipedia customs "en"
48
48
49
49
Returns:
50
- string: A string representing the API Endpoint URL for the query
51
- specified by this function's parameters.
50
+ - string: A string representing the API Endpoint URL for the query
51
+ specified by this function's parameters.
52
52
"""
53
53
base_url = (
54
54
r"wikipedia.org/w/api.php?action=query&meta=siteinfo&siprop=statistics"
@@ -59,17 +59,16 @@ def get_request_url(lang="en"):
59
59
60
60
61
61
def get_response_elems (language = "en" ):
62
- """Provides the metadata for query of specified parameters
62
+ """
63
+ Provides the metadata for query of specified parameters
63
64
64
65
Args:
65
- language:
66
- A string representing the language that the search results are
67
- presented in. Alternatively, the default value is by Wikipedia
68
- customs "en".
66
+ - language: A string representing the language that the search results are
67
+ presented in. Alternatively, the default value is by Wikipedia customs "en"
69
68
70
69
Returns:
71
- dict: A dictionary mapping metadata to its value provided from the API
72
- query of specified parameters.
70
+ - dict: A dictionary mapping metadata to its value provided from the API
71
+ query of specified parameters.
73
72
"""
74
73
search_data = None
75
74
try :
@@ -114,10 +113,8 @@ def record_lang_data(lang="en"):
114
113
"""Writes the row for LICENSE_TYPE to file to contain Google Query data.
115
114
116
115
Args:
117
- lang:
118
- A string representing the language that the search results are
119
- presented in. Alternatively, the default value is by Wikipedia
120
- customs "en".
116
+ - lang: A string representing the language that the search results are
117
+ presented in. Alternatively, the default value is by Wikipedia customs "en"
121
118
"""
122
119
response = get_response_elems (lang )
123
120
if response != {}:
@@ -141,8 +138,8 @@ def get_current_data():
141
138
Wikipedia texts are licensed under CC-BY-SA 3.0
142
139
143
140
Returns:
144
- pd.DataFrame: A DataFrame recording the number of CC-licensed documents
145
- per search query of assumption.
141
+ - pd.DataFrame: A DataFrame recording the number of CC-licensed documents
142
+ per search query of assumption.
146
143
"""
147
144
return pd .read_csv (DATA_WRITE_FILE ).set_index ("language" )
148
145
0 commit comments