mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
move path to local_config.py, add levenshtein_test.py
This commit is contained in:
@@ -20,8 +20,8 @@ delay = 0.100 # seconds
|
||||
basedir = '.'
|
||||
if 2 == len(sys.argv): basedir = sys.argv[1]
|
||||
|
||||
event_files_dir = os.path.join(basedir, 'event_files')
|
||||
fifo_path = os.path.join(basedir, 'cmdfifo')
|
||||
event_files_dir = os.path.join(basedir, conf('path_event_files'))
|
||||
fifo_path = os.path.join(basedir, conf('path_cmdfifo'))
|
||||
|
||||
def debug_enabled():
|
||||
# return True
|
||||
|
||||
38
levenshtein_test.py
Executable file
38
levenshtein_test.py
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
from common import levenshtein
|
||||
|
||||
(a, b) = ('foo barbaz', 'foobar baz')
|
||||
(a, b) = ('sitting', 'kitten')
|
||||
(a, b) = ('Monte Kali (Heringen)', 'http://de.wikipedia.org/wiki/Monte_Kali_%28Heringen%29')
|
||||
|
||||
(matrix, ret) = levenshtein(a, b, return_table=True)
|
||||
|
||||
sep = ' '*0
|
||||
out = ''
|
||||
for B in b:
|
||||
out += sep + '%2s' % B
|
||||
print(sep + ' '*4 + out)
|
||||
|
||||
for i in range(len(matrix)):
|
||||
if 0 == i:
|
||||
out = ' '
|
||||
else:
|
||||
out = '%2s' % a[i-1]
|
||||
|
||||
for j in range(len(matrix[i])):
|
||||
if 0 == i or 0 == j:
|
||||
col = '30;42'
|
||||
elif i == j:
|
||||
col = '41'
|
||||
else:
|
||||
col = 0
|
||||
|
||||
if 0 != col:
|
||||
out += sep + '\x1b[%sm%2d\x1b[m' %(col, matrix[i][j])
|
||||
else:
|
||||
out += sep + '%2d' % matrix[i][j]
|
||||
|
||||
print(out)
|
||||
|
||||
print(ret)
|
||||
@@ -22,6 +22,8 @@ config['hist_max_time'] = 10 * 60
|
||||
config['uptime'] = -time.time()
|
||||
config['request_counter'] = 0
|
||||
|
||||
config['path_event_files'] = 'event_files'
|
||||
config['path_cmdfifo'] = 'cmdfifo'
|
||||
config['persistent_storage'] = 'urlbot.persistent'
|
||||
|
||||
# the "dice" feature will use more efficient random data (0) for given users
|
||||
|
||||
Reference in New Issue
Block a user