-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatelabelsdataframeflc.py
41 lines (32 loc) · 1.23 KB
/
createlabelsdataframeflc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
This file creates the labels of the dataframe for the FLC task.
"""
import os
import pandas as pd
class CreateLabelsDataframeFLC:
"""
Class to create the labels of the FLC dataframe.
"""
@staticmethod
def load_labels(path: str):
'''
This helper function will create a dataframe with the labels of the dataset.
It will be then called from the createdataframeflc.py.
:type: path: str
:return: Pandas dataframe
'''
data = []
for dirs, subdir, files in os.walk(path):
# Go through the directory with the files
for file in files:
filepath = dirs + '/' + file
with open(filepath, 'r') as single_file:
# loop through all lines using f.readlines() method
for line in single_file.readlines():
line = line.split()
data.append(line)
dataframe = pd.DataFrame(data, columns=['article_id', 'technique',
'start_index', 'end_index'])
# print(df) # Debug
return dataframe
# load_labels = CreateLabelsDataframe.load_labels('./datasets/couplelabelsfordev') # Debug