#!/usr/bin/python

# Run this script generated by the entrancer project which create a corpora of
# all words found in the java file.
#

import json
from collections import defaultdict
import os

BASE_DIR = "/Users/gdevanla/Dropbox/private/se_research/myprojects/fetch/experiments/iTrust/data"


def gen_source_method_corpora(input_fname, destination_dir):
    with open(input_fname) as f:
        for line in f:
            data = line.split()
            fname = data[0].rsplit(".")[0].split("/")[-1]
            with open(os.path.join(destination_dir, fname), "w") as fw:
                fw.write(" ".join(data[1:]))

if __name__ == '__main__':
    gen_source_method_corpora(os.path.join(BASE_DIR, "data/source_methods.csv"),
                              os.path.join(BASE_DIR, "corpora/source"))
