Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposing changes to alex.utils & cleaning up. #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import sys
import re
from add_cities_to_stops import load_list, get_city_for_stop
from alex.utils.various import remove_dups_stable
from alex.utils.various import list_remove_duplicates_keep_ordering
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather keep the old name – I think it describes the function sufficiently and the new one makes lines too long ;-).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that I had to study the code of the method to understand what is it doing - it was not apparent to me on the first sight it is working on a list. So how about list_remove_dups_stable ?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I've just realized that I wrote this function... maybe that's why it seemed so clear to me 😄 . So I'm probably not the right one to judge... remove_list_dups_stable would sound slightly better to me, but i'm OK with both.

from alex.components.nlg.tools.cs import word_for_number
if __name__ == '__main__':
import autopath
Expand Down Expand Up @@ -463,7 +463,7 @@ def expand_abbrevs(stop_name):
try:
# replacement variants
if type(repls) == list:
variants = list(remove_dups_stable([regex.sub(repl, var)
variants = list(list_remove_duplicates_keep_ordering([regex.sub(repl, var)
for repl in repls for var in variants]))
# just a single replacement
else:
Expand Down
8 changes: 4 additions & 4 deletions alex/applications/PublicTransportInfoCS/data/expand_stops.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from ufal.morphodita import Tagger, Forms, TaggedLemmas, TokenRanges, Morpho, TaggedLemmasForms

from alex.utils.config import online_update
from alex.utils.various import remove_dups_stable
from alex.utils.various import list_remove_duplicates_keep_ordering
from getopt import getopt


Expand Down Expand Up @@ -131,7 +131,7 @@ def load_file(self, fname):
if line.startswith('#'): # skip comments
continue
stop, variants = self.parse_line(line)
self.stops[stop] = list(remove_dups_stable(variants + self.stops[stop]))
self.stops[stop] = list(list_remove_duplicates_keep_ordering(variants + self.stops[stop]))

def expand_file(self, fname):
"""Load a list of stops from a file and expand it."""
Expand All @@ -156,9 +156,9 @@ def expand_file(self, fname):
prev_tag = word[2]
# use all possible combinations if there are more variants for this case
inflected = map(self.__postprocess_func,
remove_dups_stable([' '.join(var)
list_remove_duplicates_keep_ordering([' '.join(var)
for var in itertools.product(*forms)]))
self.stops[stop] = list(remove_dups_stable(self.stops[stop] + inflected))
self.stops[stop] = list(list_remove_duplicates_keep_ordering(self.stops[stop] + inflected))
ctr += 1
if ctr % 1000 == 0:
print >> sys.stderr, '.',
Expand Down
1 change: 0 additions & 1 deletion alex/applications/PublicTransportInfoCS/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from alex.components.slu.base import SLUPreprocessing
from alex.components.asr.utterance import Utterance
from alex.utils.czech_stemmer import cz_stem
from alex.components.nlg.template import TemplateNLGPreprocessing
from alex.components.nlg.tools.cs import word_for_number
import re
Expand Down
3 changes: 0 additions & 3 deletions alex/tests/test_tts_flite_en.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,3 @@

print 'saving the TTS audio in ./tmp/flite_tts.wav'
audio.save_wav(cfg, './tmp/flite_tts.wav', wav)

print 'playing audio'
audio.play(cfg, wav)
3 changes: 0 additions & 3 deletions alex/tests/test_tts_google_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,3 @@

print 'saving the TTS audio in ./tmp/google_tts.wav'
audio.save_wav(cfg, './tmp/google_tts.wav', wav)

print 'playing audio'
audio.play(cfg, wav)
3 changes: 0 additions & 3 deletions alex/tests/test_tts_google_en.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,3 @@

print 'saving the TTS audio in ./tmp/google_tts.wav'
audio.save_wav(cfg, './tmp/google_tts.wav', wav)

print 'playing audio'
audio.play(cfg, wav)
23 changes: 0 additions & 23 deletions alex/utils/audio_play.py

This file was deleted.

3 changes: 3 additions & 0 deletions alex/utils/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from heapq import nsmallest
from operator import itemgetter

# TODO: Move this to config. This is evil.
Copy link
Member

Choose a reason for hiding this comment

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

I agree.

persistent_cache_directory = '~/.alex_persistent_cache'


Expand Down Expand Up @@ -229,6 +230,8 @@ def wrapper(*args, **kwds):

return decorator


# TODO: Fix.
persistent_cache_directory = os.path.expanduser(persistent_cache_directory)
if not os.path.exists(persistent_cache_directory):
os.makedirs(persistent_cache_directory)
Expand Down
44 changes: 0 additions & 44 deletions alex/utils/caminfodb.py

This file was deleted.

1 change: 1 addition & 0 deletions alex/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

config = None

# TODO: Move this to config.
Copy link
Member

Choose a reason for hiding this comment

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

I agree.

online_update_server = "https://vystadial.ms.mff.cuni.cz/download/alex/"


Expand Down
48 changes: 0 additions & 48 deletions alex/utils/cuda.py

This file was deleted.

173 changes: 0 additions & 173 deletions alex/utils/czech_stemmer.py

This file was deleted.

Loading