Carlos-Francisco Méndez-Cruz

Conditional Random Fields

......@@ -256,14 +256,14 @@ if __name__ == "__main__":
print("*********************************")
name = options.trainingFile.replace('.txt', '.fStopWords_' + str(options.excludeStopWords) + '.fSymbols_' + str(
options.excludeSymbols) + '.txt')
with open(os.path.join(options.outputPath, "reports", "y_pred_" + name), "w") as oFile:
with open(os.path.join(options.outputPath, "reports-l", "y_pred_" + name), "w") as oFile:
for y in y_pred:
oFile.write(str(y) + '\n')
print("*********************************")
name = options.trainingFile.replace('.txt', '.fStopWords_' + str(options.excludeStopWords) + '.fSymbols_' + str(
options.excludeSymbols) + '.txt')
with open(os.path.join(options.outputPath, "reports", "y_test_" + name), "w") as oFile:
with open(os.path.join(options.outputPath, "reports-l", "y_test_" + name), "w") as oFile:
for y in y_test:
oFile.write(str(y) + '\n')
......@@ -272,7 +272,7 @@ if __name__ == "__main__":
# labels = list(crf.classes_)
# labels.remove('O')
with open(os.path.join(options.outputPath, "reports", "report_" + nameReport), mode="a") as oFile:
with open(os.path.join(options.outputPath, "reports-l", "report_" + nameReport), mode="a") as oFile:
oFile.write('\n********** EVALUATION **********\n')
oFile.write("Flat F1: " + str(metrics.flat_f1_score(y_test, y_pred, average='weighted', labels=labels)))
oFile.write('\n')
......