ruanchaves commited on
Commit
f1abc1a
1 Parent(s): da6c6fa

Update loyola.py

Browse files
Files changed (1) hide show
  1. loyola.py +15 -0
loyola.py CHANGED
@@ -26,6 +26,7 @@ i.e. the task of adding spaces between the words on a identifier.
26
  """
27
  _URL = "https://raw.githubusercontent.com/ruanchaves/hashformers/master/datasets/loyola-udelaware-identifier-splitting-oracle.txt"
28
 
 
29
  class Loyola(datasets.GeneratorBasedBuilder):
30
 
31
  VERSION = datasets.Version("1.0.0")
@@ -71,10 +72,24 @@ class Loyola(datasets.GeneratorBasedBuilder):
71
  break
72
  except StopIteration:
73
  break
 
74
  output = haystack
 
 
 
 
 
 
 
 
 
 
 
 
75
  while pos:
76
  next_pos = pos.popleft()
77
  output = output[:next_pos] + " " + output[next_pos:]
 
78
  return output
79
 
80
  with open(filepath, 'r') as f:
 
26
  """
27
  _URL = "https://raw.githubusercontent.com/ruanchaves/hashformers/master/datasets/loyola-udelaware-identifier-splitting-oracle.txt"
28
 
29
+
30
  class Loyola(datasets.GeneratorBasedBuilder):
31
 
32
  VERSION = datasets.Version("1.0.0")
 
72
  break
73
  except StopIteration:
74
  break
75
+
76
  output = haystack
77
+
78
+ while pos:
79
+ next_pos = pos.popleft()
80
+ output = output[:next_pos] + " " + output[next_pos:]
81
+
82
+ pos = deque()
83
+ previous = output[0]
84
+ for index, char in enumerate(output[1:]):
85
+ if (not previous.isalnum() and not previous.isspace()) and char.isalnum():
86
+ pos.appendleft(index + 1)
87
+ previous = char
88
+
89
  while pos:
90
  next_pos = pos.popleft()
91
  output = output[:next_pos] + " " + output[next_pos:]
92
+
93
  return output
94
 
95
  with open(filepath, 'r') as f: