26 lines
727 B
Python
26 lines
727 B
Python
|
|
import pandas as pd
|
||
|
|
|
||
|
|
class RDF_completation_task_dataset():
|
||
|
|
"""
|
||
|
|
Write the CSV for the fourth task, which is "Predicting subsequent triples based on a given context".
|
||
|
|
Each RDF is saved as str
|
||
|
|
CSV Composition: ["MovieID","RDF"]
|
||
|
|
"""
|
||
|
|
def __init__(self, output_path:str):
|
||
|
|
|
||
|
|
|
||
|
|
self.output = open(output_path, "w")
|
||
|
|
# then the first row as header
|
||
|
|
header = ["MovieID","RDF"]
|
||
|
|
self.output.write(",".join(header) + "\n")
|
||
|
|
|
||
|
|
def close(self):
|
||
|
|
self.output.close()
|
||
|
|
|
||
|
|
def write(self, RDF: pd.DataFrame):
|
||
|
|
"""
|
||
|
|
Args:
|
||
|
|
RDF (pd.DataFrame): ["MovieID","RDF"]
|
||
|
|
"""
|
||
|
|
|
||
|
|
RDF.to_csv(self.output, index=False, header=False)
|