This project contains the source code of GitHub README content classifier from the paper "Categorizing the Content of GitHub README Files" (Gede Artha Azriadi Prana, Christoph Treude, Ferdian Thung, Thushari Atapattu, David Lo), published in 2018 in Empirical Software Engineering. DOI: 10.1007/s10664-018-9660-3
This project is written in Python 3. It also uses SQLite to store intermediary data during processing. By default the database is database/data.db
.
The following sections describe three use cases and the steps to follow for each scenario.
- Set up file paths in
config/config.cfg
. By default, CSV files listing the section titles and their labels are ininput/
.dataset_1.csv
contains the section titles and labels for the development set, whereasdataset_2.csv
contains the section titles and labels for the evaluation set. The README files corresponding to the CSV files are ininput/ReadMes/
directory. - Empty all database tables by running the script
script/loading/empty_all_tables.py
- Run
script/loading/load_section_dataset_25pct.py
to extract and load section overview (title text, labels) and content of development set into database. - Run
script/loading/load_section_dataset_75pct.py
to extract and load section overview (title text, labels) and content of evaluation set into database. - Run the
script/experiment/*
scripts as required. E.g. to run cross-validation on the best-performing SVM version, runscript/experiment/classifier_75pct_tfidf.py
.
Note that 25pct
and 75pct
in script names refer to development and evaluation sets, respectively. Before running an experiment, please ensure that you've loaded the correct set.
- Run
script/classifier/load_combined_set_and_train_model
to extract and load contents and titles listed in combined development and evaluation sets into the database. This script by default readsdataset_combined.csv
for section heading and labels, and the README files ininput/ReadMes/
directory for the section contents. - Download the new README file(s) whose sections are to be labeled into a directory.
- Open configuration file of the classifier (
config/config.cfg
), and edit thetarget_readme_file_dir
variable to point to the location of the README file(s) to be labeled. - Run
script/classifier/load_and_classify_target
to extract contents of the new README files, load the section contents, and perform classification. - By default, the resulting section labels will be saved in
output/output_section_codes.csv
. Classifier will also identify which codes exist for each file, and which codes don't yet exist (i.e. potential for README expansion). This information will be saved inoutput/output_file_codes.csv
Each script used in the previous section automates multiple steps in the workflow to make usage simpler. If you want more detailed breakdown, e.g. to facilitate evaluation of intermediary result after each step in the workflow, please use the following steps.
- Run
script/loading/load_section_dataset_combined.py
. This script extracts and loads section overview (title text, labels) from CSV file containing complete set of section headings and labels. Inconfig/config.cfg
, this CSV file is specified asdataset_combined.csv
by default. The script also loads section content of the associated README files. All these data are subsequently stored in tables with name ending incombined
in the database. - Run
script/classifier/classifier_train_model.py
. This script will train SVM model using the data in*combined
database tables. The resulting model, TFIDF vectorizer, and matrix label binarizer will be saved inmodel/
directory.
- Download the new README file(s) whose sections are to be labeled into a directory.
- Open configuration file of the classifier (
config/config.cfg
), and edit thetarget_readme_file_dir
variable to point to the location of the README file(s) to be labeled. - Run
script/loading/load_target_section_data.py
to load the section heading and content data into database.
- Run
script/classifier/classifier_classify_target.py
. This script will use the saved model, vectorizer, and binarizer to classify target README files in the directory specified intarget_readme_file_dir
variable inconfig/config.cfg
. - By default, the resulting section labels will be saved in
output/output_section_codes.csv
. Classifier will also identify which codes exist for each file, and which codes don't yet exist (i.e. potential for README expansion). This information will be saved inoutput/output_file_codes.csv
All scripts will log output (such as F1 score, execution times) into log/
directory. Preprocessed README files (with numbers, mailto:
links etc. abstracted out) are saved in temp/
directory. Patterns used for heuristics are listed in doc/Patterns.ods
.