Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions underthesea/datasets/uit_absa_hotel/uit_absa_hotel.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ def encode(self, labels):
if type(labels) == list:
return [self.encode(label) for label in labels]
label = labels # label is a string
if label not in self.label2index:
index = self.vocab_size
self.label2index[label] = index
self.index2label[index] = label
self.vocab_size += 1
return index
else:
if label in self.label2index:
return self.label2index[label]
index = self.vocab_size
self.label2index[label] = index
self.index2label[index] = label
self.vocab_size += 1
return index
Comment on lines +25 to +31

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function LabelEncoder.encode refactored with the following changes:



class UITABSAHotel:
Expand All @@ -41,7 +40,7 @@ def __init__(self, training="aspect"):
train_file = join(DATASETS_FOLDER, UITABSAHotel.NAME, "Train_Hotel.txt")
dev_file = join(DATASETS_FOLDER, UITABSAHotel.NAME, "Dev_Hotel.txt")
test_file = join(DATASETS_FOLDER, UITABSAHotel.NAME, "Test_Hotel.txt")
print("Currently training: %s (aspect or polarity)" % training)
print(f"Currently training: {training} (aspect or polarity)")
Comment on lines +44 to +43

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UITABSAHotel.__init__ refactored with the following changes:


self.training = training # aspect or polarity
self.label_encoder = LabelEncoder()
Expand Down
15 changes: 7 additions & 8 deletions underthesea/datasets/uit_absa_restaurant/uit_absa_restaurant.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ def encode(self, labels):
if type(labels) == list:
return [self.encode(label) for label in labels]
label = labels # label is a string
if label not in self.label2index:
index = self.vocab_size
self.label2index[label] = index
self.index2label[index] = label
self.vocab_size += 1
return index
else:
if label in self.label2index:
return self.label2index[label]
index = self.vocab_size
self.label2index[label] = index
self.index2label[index] = label
self.vocab_size += 1
return index
Comment on lines +25 to +31

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function LabelEncoder.encode refactored with the following changes:



class UITABSARestaurant:
Expand All @@ -41,7 +40,7 @@ def __init__(self, training="aspect"):
train_file = join(DATASETS_FOLDER, UITABSARestaurant.NAME, "Train.txt")
dev_file = join(DATASETS_FOLDER, UITABSARestaurant.NAME, "Dev.txt")
test_file = join(DATASETS_FOLDER, UITABSARestaurant.NAME, "Test.txt")
print("Currently training: %s (aspect or polarity)" % training)
print(f"Currently training: {training} (aspect or polarity)")
Comment on lines +44 to +43

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UITABSARestaurant.__init__ refactored with the following changes:


self.training = training # aspect or polarity
self.label_encoder = LabelEncoder()
Expand Down