Ejemplo n.º 1
0
def judge_level_usable():
    data_frame = pjd.get_case_level_data_frame()
    judge_to_case_dict = pjd.create_dict_of_judges_cases(data_frame)
    case_to_path_dict, case_set = pjd.get_relative_path_of_cases()
    if demo_local:
        outDir = '../Aggregate'
    outDirectory = outDir + "/JudgeLevelUsable"
    util.createDirectory(outDirectory)
    err_count = 0
    for judge, case_list in judge_to_case_dict.items():
        current_judge_score = np.zeros(40)
        case_count = 0
        for case_id in case_list:
            if case_id in case_set:
                err_count += 1
            else:
                pass
            if case_id in case_to_path_dict:
                case_count += 1
                path = case_to_path_dict[case_id]
                current_score = pkl.load(open(path, 'rb'))
                current_judge_score += current_score
        if not case_count == 0:
            score = current_judge_score / case_count
            file = judge + '.p'
            util.writeToPickle(score, outDirectory, '', file)
    if err_count == 0:
        print("No change needed")
    else:
        print("Change case to path method")
Ejemplo n.º 2
0
def circuityear_level():
    circuityear_case_dict = util.getDataFromPickle('circuit_year_level', '../')
    case_to_path_dict, case_set = pjd.get_relative_path_of_cases()
    if demo_local:
        outDir = '../Aggregate'
    outDirectory = outDir + "/CircuitYearLevel"
    util.createDirectory(outDirectory)
    err_count = 0
    for circuityear, case_list in circuityear_case_dict.items():
        circuit = circuityear[0]
        year = circuityear[1]
        if year > 1963:
            current_circuityear_score = np.zeros(40)
            case_count = 0
            for case_id in case_list:
                if case_id in case_set:
                    err_count += 1
                else:
                    pass
                if case_id in case_to_path_dict:
                    case_count += 1
                    path = case_to_path_dict[case_id]
                    current_score = pkl.load(open(path, 'rb'))
                    current_circuityear_score += current_score
            if not case_count == 0:
                score = current_circuityear_score / case_count
                file = '{0}_{1}.p'.format(circuit, year)
                util.writeToPickle(score, outDirectory, '', file)
    if err_count == 0:
        print("No change needed")
    else:
        print("Change case to path method")
    '''
Ejemplo n.º 3
0
def case_level():
    sentiment_dir = '/home/' + username + '/VADER_DATA_STORE/'
    similarity_dir = '/home/' + username + '/SIMILARITY_DATA_STORE/'
    if (demo_local):
        sentiment_dir = '../VADER_DATA_STORE'
        similarity_dir = '../SIMILARITY_DATA_STORE'
        outDir = '../Aggregate'
    list_similarity_dir = util.getDirectoryList(similarity_dir)
    outDirectory = outDir + '/CaseLevel'
    for directory in list_similarity_dir:
        if not directory.endswith('zip'):
            util.createDirectory(outDirectory)
            util.createDirectory(outDirectory + "/" + directory)
            files = util.getFilesListFromDir(directory, False)
            for file in files:
                sentiment_list = util.getDataFromPickle(
                    file, sentiment_dir + "/" + directory + '/')
                similarity_list = util.getDataFromPickle(
                    file, similarity_dir + "/" + directory + '/')
                for similarity in similarity_list:
                    similarity[:] = [
                        util.normalize_similarity(score)
                        for score in similarity
                    ]
                if len(similarity_list) == len(sentiment_list):
                    ss = np.dot(sentiment_list, similarity_list)
                    if len(sentiment_list) == 0:
                        util.writeToPickle(0, outDirectory, directory, file)
                    else:
                        util.writeToPickle(ss / len(sentiment_list),
                                           outDirectory, directory, file)
Ejemplo n.º 4
0
def check_case_exist():
    data_frame = pjd.get_case_level_data_frame()
    judge_to_case_dict = pjd.create_dict_of_judges_cases(data_frame)
    case_to_path_dict = pjd.get_relative_path_of_cases()
    if demo_local:
        outDir = '../Aggregate'
    outDirectory = outDir + "/JudgeLevelErrors"
    util.createDirectory(outDirectory)
    for judge, case_list in judge_to_case_dict.items():
        case_count = 0
        for case_id in case_list:
            if case_id in case_to_path_dict:
                case_count += 1
        if not case_count == len(case_list):
            file = judge + ".p"
            util.writeToPickle([len(case_list), case_count], outDirectory, '',
                               file)
Ejemplo n.º 5
0
def main():
    if (not demo):
        root_Directory = 'data/clean_Mar_20'
        if (demo_local):
            global outDir
            outDir = "SNLP_sentiment"
            root_Directory = '../../Data/clean_Mar_20'
        list_of_dirs = util.getDirectoryList(root_Directory)
        for directory in list_of_dirs:
            if not directory.endswith('zip'):
                year = int(directory)
                if year >= 1964:
                    print(directory)
                    util.createDirectory(outDir)
                    util.createDirectory(outDir + "/" + directory)

                    files = util.getFilesListFromDir(directory)
                    for file_name in files:
                        para_list = util.getParaListFromFile(
                            file_name, directory)
                        avgParaSentimentList, paraSentimentList = getParaSentimentList(
                            para_list)
                        util.writeToPickle(paraSentimentList,
                                           outDir,
                                           directory,
                                           file_name,
                                           avg=False)
                        util.writeToPickle(avgParaSentimentList,
                                           outDir,
                                           directory,
                                           file_name,
                                           avg=True)
    else:
        para_list = [
            "DRUMMOND, C. J. The schooner American was at Oswego in the fall of 1872, and took in a cargo of coal for Chicago, leaving Oswego on the tenth of November. A general bill of lading was given, and a high price charged for the transportation of the coal from Oswego to Chicago, being $2.75 per ton. The schooner met with adverse winds and did not arrive at Port Huron until November 29th. The weather, according to the testimony of the witnesses, was very inclement that fall, and the captain concluded that the safest course was to strip the vessel and lay up at Port Huron. The schooner accordingly remained there with her cargo during the winter, and the coal was not delivered in Chicago or received by the consignees until May 8, 1873, when the spring freight was paid by the consignees on the coal, being much less than that charged in the bill of lading. After the coal had been thus delivered by the schooner to the consignees, a libel was filed claiming the amount of freight stated in the bill of lading, the consignees having refused to pay any more than the spring price of freight. The case went to proof before the district court, where the libel was dismissed; but a cross-libel having been filed claiming that the captain of the American was negligent in wintering at Port Hur on, and that the vessel should have come on in the fall of 1872, the district court gave a decree on the cross-libel for damages against the libelants in consequence of the supposed negligence of the captain. From t hese decrees the libelants have appealed to this court, and the question is whether the decrees of the district court are right.",
            "Several cities, New York City in particular for this paper, have a 311 24-hour hot line and online service, which allows anyone, residents and tourists, to report a non-emergency problem. Reported 311 problems are passed along to government services, who address and solve the problem. The records of 311 calls are publicly open and updated daily.",
            "Analysis of 311 calls can clearly be of great use for a wide variety of purposes, ranging from a rich understanding of the status of a city to the effectiveness of the government services in addressing such calls. Ideally, the analysis can also support a prediction of future 311 calls, which would enable the assignment of service resources by the city government.",
            "We have been extensively analyzing 311 calls in NYC. In this paper, we profile the data set and highlight a few interesting facts. We provide statistics along complaint types, geolocation, and temporal patterns and show the diversity of the big 311 data along those dimensions. We then discuss the prediction problem of number of calls, where we experiment with different sets of semantic features. We show that the prediction error for different complaint types can significantly vary if some features are not considered."
        ]
        avgParaSentimentList, paraSentimentList = getParaSentimentList(
            para_list)
        print(avgParaSentimentList)
        print(paraSentimentList)
Ejemplo n.º 6
0
def judge_level():
    data_frame = pjd.get_case_level_data_frame()
    judge_to_case_dict = pjd.create_dict_of_judges_cases(data_frame)
    case_to_path_dict = pjd.get_relative_path_of_cases()
    if demo_local:
        outDir = '../Aggregate'
    outDirectory = outDir + "/JudgeLevel"
    util.createDirectory(outDirectory)
    for judge, case_list in judge_to_case_dict.items():
        current_judge_score = np.zeros(40)
        for case_id in case_list:
            if case_id in case_to_path_dict:
                path = case_to_path_dict[case_id]
                current_score = pkl.load(open(path, 'rb'))
                current_judge_score += current_score
        if len(case_list) == 0:
            score = np.zeros(40)
        else:
            score = current_judge_score / len(case_list)
        file = judge + '.p'
        util.writeToPickle(score, outDirectory, '', file)