Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parametrize code variables in bot.py to match each wikipedia configuration file #46

Merged
merged 8 commits into from
Oct 17, 2023
Merged

Parametrize code variables in bot.py to match each wikipedia configuration file #46

merged 8 commits into from
Oct 17, 2023

Conversation

Bhbee
Copy link
Contributor

@Bhbee Bhbee commented Oct 9, 2023

This PR fixes #11. Previously bot.py worked only with the Spanish Wikipedia.
But after parameterizing, it currently can work with several Wikipedias present in the newly created "wikipedia_config.json" file which is generated by the newly created "serialize_data.py" script.
The serialize_data.py can be edited to add the required information of other Wikipedias that are not available in the file.
For example, to add Ghana Wikipedia, add to the dictionary the correct keys and values for Ghana Wikipedia config:

wikipedia_config = {
"es": {
"file_to_be_analysed": "query.csv",
"language": "es"
},
"it": {.....},
"ak": {
"file_to_be_analysed": "ghana.csv",
"language": "ak"
}
}

To generate the result of the analysis:(results.txt) file, you can run the bot.py script like this:
python bot.py en
or
python3 bot.py en

where en is the initial for the English Wikipedia. This can be changed to the initial of any desired Wikipedia.
for example
python bot.py es

Created a "default.csv" file to test the English Wikipedia configuration. Hence the new "results.txt file"

This PR also takes into consideration the comment of @wikicurricula-uy on PR #17 which was closed about the separation of solutions.

Copy link
Owner

@wikicurricula-uy wikicurricula-uy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, @Bhbee! I don't understand why is it necesary to create a serialize_data.py file.
Can't you just create wikipedia_config.json and (maybe) a language_template_config.json?

In an ideal scenario, adding support for a new language should only require us to edit a .json. It should not require us to edit a script.

data-gathering/serialize_data.py Outdated Show resolved Hide resolved
data-gathering/serialize_data.py Outdated Show resolved Hide resolved
data-gathering/bot.py Show resolved Hide resolved
data-gathering/bot.py Show resolved Hide resolved
data-gathering/bot.py Outdated Show resolved Hide resolved
data-gathering/bot.py Show resolved Hide resolved
data-gathering/bot.py Show resolved Hide resolved

article2 = article2[:article2.find("]]")]
if "#RINVIA" in wikitext:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is #RINVIA an equivalent to #REDIRECT? Does it work for all languages?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it doesnt work for all languages. I'll add checking for "REDIRECT" too

data-gathering/bot.py Outdated Show resolved Hide resolved
wikicurricula-uy and others added 2 commits October 17, 2023 10:26
remove accidental message
@wikicurricula-uy wikicurricula-uy merged commit fad92e5 into wikicurricula-uy:main Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parametrize code variables in bot.py to match each Wikipedia's configuration file.
2 participants