def test_analyze(): main.get_coins_bittrex() # Negative sentiment text = "do not buy dogecoin, it is bad" to_buy = main.analyze(text) assert len(to_buy) == 0 # Positive sentiment text = "please buy dogecoin" to_buy = main.analyze(text) assert len(to_buy) == 1
def interface(analyze=True, convert=True, prompt=False, benchmark=False): import main if benchmark: # @Benchmark Mode main.benchmark() elif prompt: # @Prompt Mode mode = click.prompt('Choose mode (analysis, conversion)', type=str) if mode == 'analysis': source = click.prompt('Enter source audio path 🎧 ', type=str) target = click.prompt('Enter target audio path 🔊 ', type=str) main.analyze(source, target) elif mode == 'conversion': matrices = click.prompt('Enter matrices path 🔢 ', type=str) original = click.prompt('Enter audio path 🎧 ', type=str) main.convert(matrices, original) else: click.secho('Error: Invalid Mode ✘', fg='red') else: # @Default Mode if len(analyze) == 2: main.analyze(analyze[0], analyze[1]) elif len(convert) == 2: main.convert(convert[0], convert[1])
#!/usr/bin/env python3 from main import analyze from os import listdir from os.path import isfile, join import sys imagesPath = '' imagePath = '' for i in range(len(sys.argv)): if sys.argv[i] == '--images-path': i += 1 imagesPath = sys.argv[i] if sys.argv[i] == '--image-path': i += 1 imagePath = sys.argv[i] if imagesPath == '' and imagePath == '': print('Error: no images path specified') exit() if imagesPath != '': filesList = [[join(imagesPath, f), f] for f in listdir(imagesPath) if (isfile(join(imagesPath, f)) and f.endswith('.jpg'))] for file in filesList: analyze(file) else: analyze([imagePath, imagePath])
def tweet_callback(text, user, link): to_buy = main.analyze(text) assert len(to_buy) > 0 bot.notify_tweet(text, user, link, to_buy)
def api_call(file) -> Analysis: # revai.get_transcript("test.m4a") analysis = analyze(file, phrase) return analysis
def test_sample(self): expected = [(('a', 'k', 'u'), 2), (('a', 'k', 'l'), 1), (('a', 'l', 'u'), 1), (('k', 'l', 'u'), 1), (('a', 'k', 'n'), 1), (('a', 'n', 'u'), 1), (('k', 'n', 'u'), 1)] self.assertEqual(analyze('input/sample.txt'), expected)
def test_char_length2(self): expected = [] self.assertEqual(analyze('input/sample.txt', char_length=5), expected)
def test_char_length(self): expected = [(('a', 'k', 'l', 'u'), 1), (('a', 'k', 'n', 'u'), 1)] self.assertEqual(analyze('input/sample.txt', char_length=4), expected)
def test_top_n(self): expected = [(('a', 'k', 'u'), 2), (('a', 'k', 'l'), 1)] self.assertEqual(analyze('input/sample.txt', top_n=2), expected)