From a8fbc0f80b42e928fa09b206b7aa499753aaa49e Mon Sep 17 00:00:00 2001 From: liangym <34430015+lym0302@users.noreply.github.com> Date: Tue, 15 Feb 2022 10:21:30 +0800 Subject: [PATCH] Delete ssstr.py --- speechserving/tests/tts/ssstr.py | 62 -------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 speechserving/tests/tts/ssstr.py diff --git a/speechserving/tests/tts/ssstr.py b/speechserving/tests/tts/ssstr.py deleted file mode 100644 index 0a84e354..00000000 --- a/speechserving/tests/tts/ssstr.py +++ /dev/null @@ -1,62 +0,0 @@ -#coding=utf-8 -import time - -def find_index(find_str: str, key: str) -> list: - """find duicheng str based on a special middle index - - Args: - find_str (str): orignal str - index (int): middle index - - Returns: - str: dst str - """ - index_list = [] - count = find_str.count(key) - if count == 0: - return index_list - index = 0 - for i in range(count - 1): - index = find_str.find(key, index + 1) - index_list.append(index) - - index_list.sort(reverse=True) - return index_list - -def find_max(input_str: str) -> str: - max_str = "" - if len(input_str) == 1: - return input_str - for i in range(len(input_str)): - temp_str = "" - find_str = input_str[i:] - if(len(find_str) < len(max_str)): - return max_str - key = input_str[i] - index_list = find_index(find_str, key) - if index_list != []: - for index in index_list: - left_index = 1 - right_index = index - 1 - if right_index == 0 or left_index == right_index: # aa or aba - temp_str = find_str[:index+1] - - else: #example: index % 2 == 0: abcba, index % 2 == 1: abccba - while((index % 2 == 0 and left_index != right_index) or (index % 2 == 1 and left_index != right_index - 1)): - if find_str[left_index] == find_str[right_index]: - left_index += 1 - right_index -= 1 - continue - else: - break - if((index % 2 == 0 and left_index == right_index) or (index % 2 == 1 and left_index == right_index - 1 and find_str[left_index] == find_str[right_index])): - temp_str = find_str[:index+1] - - if len(temp_str) > len(max_str): - max_str = temp_str - return max_str - -start_time = time.time() -str = "abcdabaaaaacaaaa" -print(find_max(str)) -print(time.time() - start_time)