Skip to content

Commit

Permalink
Merge pull request #15 from PumucklRandom/develop
Browse files Browse the repository at this point in the history
strip space around words
  • Loading branch information
PumucklRandom authored Oct 4, 2024
2 parents 3734f57 + 4a636a2 commit f432302
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontend/pages/decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ def _preload_table(self) -> None:

def _update_words(self) -> None:
try:
if self.state.title: self.filename = self.state.title
self.state.source_words, self.state.target_words = self.ui_grid.get_values()
self.state.source_words = list(map(str.strip, self.state.source_words))
self.state.target_words = list(map(str.strip, self.state.target_words))
except Exception:
logger.error(f'Error in "_update_words" with exception:\n{traceback.format_exc()}')
ui.notify(self.ui_language.GENERAL.Error.internal, type = 'negative', position = 'top')
Expand Down Expand Up @@ -122,6 +123,7 @@ def _refresh_replace(self) -> None:

def _split_text(self) -> None:
try:
self.filename = self.state.title
_hash = hash(self.state.source_text)
if self.state.s_hash == _hash:
return
Expand Down Expand Up @@ -229,6 +231,7 @@ def _upload_handler(self, event: events.UploadEventArguments) -> None:
data = event.content.read().decode('utf-8')
self.state.source_words, self.state.target_words, self.state.sentences = self.decoder.import_(data = data)
self.state.title = pathlib.Path(event.name).stem
self.filename = self.state.title
self.state.source_text = ' '.join(self.state.source_words)
self.state.s_hash = hash(self.state.source_text)
self.state.d_hash = hash(
Expand Down

0 comments on commit f432302

Please sign in to comment.