Exemple #1
0
def saveLightsideTrainingAnswers(essays, fname, scoreType="domain1_score"):
    with open(DATA_PATH + fname, "w") as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(["label", "text"])
        for ess_id in sorted(essays):
            ess = essays[ess_id]
            writer.writerow([ess.getScore(scoreType), ess.getText()])
    def addTrainingScore(self, essay, scoreName='domain1_score'):
        if essay.essay_id not in self.trainingAnswerMap:
            raise LookupError("Essay hasn't been added to training answers yet.")
            return

        data = { "training_answer": lsrh.getTrainingAnswerURL(self.trainingAnswerMap[essay.essay_id]),
                 "label": str(essay.getScore(scoreName)) }
        r = self.session.post(lsrh.getHumanScoreURL(), data=json.dumps(data), headers=self.headers)
        self.trainingScoresMap[essay.essay_id] = lsrh.getIdFromResponse(r)
Exemple #3
0
def saveEssaysAsCsv(essays, fname="training.csv"):
    """ takes in essays, a dict from ids to Essay objects, and an output filename; writes those essays to a file """
    with open(DATA_PATH + fname, "w") as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(header)
        for ess_id in sorted(essays):
            ess = essays[ess_id]
            writer.writerow(
                [ess.essay_id, ess.prompt_id, ess.getText()] + [ess.getScore(header[i]) for i in range(3, len(header))]
            )