nanom commited on
Commit
539e962
Β·
1 Parent(s): e0efd7f

Delete errorManager class commited by mistake

Browse files
Files changed (1) hide show
  1. modules/module_BiasExplorer.py +22 -24
modules/module_BiasExplorer.py CHANGED
@@ -12,8 +12,7 @@ __all__ = ['WordBiasExplorer', 'WEBiasExplorer2Spaces', 'WEBiasExplorer4Spaces']
12
  class WordBiasExplorer:
13
  def __init__(
14
  self,
15
- embedding, # Embedding class instance
16
- errorManager # ErrorManager class instance
17
  ) -> None:
18
 
19
  self.embedding = embedding
@@ -21,7 +20,6 @@ class WordBiasExplorer:
21
  self.positive_end = None
22
  self.negative_end = None
23
  self.DIRECTION_METHODS = ['single', 'sum', 'pca']
24
- self.errorManager = errorManager
25
 
26
  def __copy__(
27
  self
@@ -247,12 +245,12 @@ class WordBiasExplorer:
247
  out_msj = ""
248
 
249
  if not word:
250
- out_msj = ['EMBEDDING_NO_WORD_PROVIDED']
251
  else:
252
  if word not in self.embedding:
253
- out_msj = ['EMBEDDING_WORD_OOV', word]
254
 
255
- return self.errorManager.process(out_msj)
256
 
257
  def check_oov(
258
  self,
@@ -269,11 +267,10 @@ class WordBiasExplorer:
269
  class WEBiasExplorer2Spaces(WordBiasExplorer):
270
  def __init__(
271
  self,
272
- embedding, # Embedding class instance
273
- errorManager # ErrorManager class instance
274
  ) -> None:
275
 
276
- super().__init__(embedding, errorManager)
277
 
278
  def calculate_bias(
279
  self,
@@ -372,7 +369,9 @@ class WEBiasExplorer2Spaces(WordBiasExplorer):
372
  most_extream_projection + axis_projection_step,
373
  axis_projection_step))
374
 
375
-
 
 
376
  xlabel = axes_labels_format(
377
  left=self.negative_end,
378
  right=self.positive_end,
@@ -389,11 +388,10 @@ class WEBiasExplorer2Spaces(WordBiasExplorer):
389
  class WEBiasExplorer4Spaces(WordBiasExplorer):
390
  def __init__(
391
  self,
392
- embedding, # Embedding Class instance
393
- errorManager # ErrorManager class instance
394
  ) -> None:
395
 
396
- super().__init__(embedding, errorManager)
397
 
398
  def calculate_bias(
399
  self,
@@ -504,15 +502,9 @@ class WEBiasExplorer4Spaces(WordBiasExplorer):
504
  projections_df['projection']
505
  .abs()
506
  .max(),
507
- decimals=1
508
- )
509
-
510
- sns.scatterplot(x='projection_x',
511
- y='projection_y',
512
- data=projections_df,
513
- # color=list(projections_df['color'].to_list()), # No se distinguen los colores
514
- color='blue'
515
- )
516
 
517
  plt.xticks(np.arange(-most_extream_projection,
518
  most_extream_projection + axis_projection_step,
@@ -520,8 +512,14 @@ class WEBiasExplorer4Spaces(WordBiasExplorer):
520
  for _, row in (projections_df.iterrows()):
521
  ax.annotate(
522
  row['word'], (row['projection_x'], row['projection_y']))
 
 
 
 
523
 
524
-
 
 
525
  x_label = axes_labels_format(
526
  left=name_left,
527
  right=name_right,
@@ -549,4 +547,4 @@ class WEBiasExplorer4Spaces(WordBiasExplorer):
549
  ax.set_xticks([])
550
  ax.set_yticks([])
551
 
552
- return ax
 
12
  class WordBiasExplorer:
13
  def __init__(
14
  self,
15
+ embedding # Embedding Class instance
 
16
  ) -> None:
17
 
18
  self.embedding = embedding
 
20
  self.positive_end = None
21
  self.negative_end = None
22
  self.DIRECTION_METHODS = ['single', 'sum', 'pca']
 
23
 
24
  def __copy__(
25
  self
 
245
  out_msj = ""
246
 
247
  if not word:
248
+ out_msj = "Error: First you most enter a word!"
249
  else:
250
  if word not in self.embedding:
251
+ out_msj = f"Error: The word '<b>{word}</b>' is not in the vocabulary!"
252
 
253
+ return out_msj
254
 
255
  def check_oov(
256
  self,
 
267
  class WEBiasExplorer2Spaces(WordBiasExplorer):
268
  def __init__(
269
  self,
270
+ embedding # Embedding class instance
 
271
  ) -> None:
272
 
273
+ super().__init__(embedding)
274
 
275
  def calculate_bias(
276
  self,
 
369
  most_extream_projection + axis_projection_step,
370
  axis_projection_step))
371
 
372
+ # xlabel = ('← {} {} {} β†’'.format(self.negative_end,
373
+ # ' ' * 20,
374
+ # self.positive_end))
375
  xlabel = axes_labels_format(
376
  left=self.negative_end,
377
  right=self.positive_end,
 
388
  class WEBiasExplorer4Spaces(WordBiasExplorer):
389
  def __init__(
390
  self,
391
+ embedding # Embedding Class instance
 
392
  ) -> None:
393
 
394
+ super().__init__(embedding)
395
 
396
  def calculate_bias(
397
  self,
 
502
  projections_df['projection']
503
  .abs()
504
  .max(),
505
+ decimals=1)
506
+ sns.scatterplot(x='projection_x', y='projection_y', data=projections_df,
507
+ palette=projections_df['color'])
 
 
 
 
 
 
508
 
509
  plt.xticks(np.arange(-most_extream_projection,
510
  most_extream_projection + axis_projection_step,
 
512
  for _, row in (projections_df.iterrows()):
513
  ax.annotate(
514
  row['word'], (row['projection_x'], row['projection_y']))
515
+
516
+ # x_label = '← {} {} {} β†’'.format(name_left,
517
+ # ' ' * 20,
518
+ # name_right)
519
 
520
+ # y_label = '← {} {} {} β†’'.format(name_top,
521
+ # ' ' * 20,
522
+ # name_bottom)
523
  x_label = axes_labels_format(
524
  left=name_left,
525
  right=name_right,
 
547
  ax.set_xticks([])
548
  ax.set_yticks([])
549
 
550
+ return ax