flpelerin commited on
Commit
11565c4
·
1 Parent(s): 783b8e4

Update file tokenizer.py

Browse files
Files changed (1) hide show
  1. tokenizer.py +6 -14
tokenizer.py CHANGED
@@ -147,26 +147,18 @@ class Tokenizer:
147
 
148
 
149
  def c_compile(self):
150
- import os
151
- import subprocess
152
-
153
- # Get the current working directory
154
- cwd = os.getcwd()
155
 
156
  # Construct the path to the c_tokenizer directory
157
- c_tokenizer_dir = os.path.join(cwd, 'c_tokenizer')
158
-
159
- # Change to the c_tokenizer directory
160
- os.chdir(c_tokenizer_dir)
161
 
162
- # Invoke Make
163
- subprocess.run(['make'])
164
-
165
- # Change back to the original directory
166
- os.chdir(cwd)
167
 
168
 
169
  def c_encode(self, text): #TODO: Implement
 
170
  self.c_compile()
171
 
172
  return [1, 2, 3, 4]
 
147
 
148
 
149
  def c_compile(self):
150
+ # Get the path of the current Python script
151
+ script_dir = os.path.dirname(__file__)
 
 
 
152
 
153
  # Construct the path to the c_tokenizer directory
154
+ c_tokenizer_dir = os.path.join(script_dir, 'c_tokenizer')
 
 
 
155
 
156
+ # Invoke Make on the c_tokenizer directory
157
+ subprocess.run(['make'], cwd=c_tokenizer_dir)
 
 
 
158
 
159
 
160
  def c_encode(self, text): #TODO: Implement
161
+
162
  self.c_compile()
163
 
164
  return [1, 2, 3, 4]