def repeat(second=1.0): global current, is_seoul_bus, route_name, routeID response = parse(is_seoul_bus, get_response(is_seoul_bus, routeID)) if current == {}: compare(route_name, response, current) current = response else: compare(route_name, response, current) current = response #print('Repeating...') threading.Timer(second, repeat, [second]).start()
def get_url_info(saved_id): conn = MySQLdb.connect(host=mysql_info['host'], user=mysql_info['user'], passwd=mysql_info['passwd'], db=mysql_info['db'], port=int(mysql_info['port']), charset='utf8') cur = conn.cursor() if str(saved_id) != '': sql1 = 'SELECT count(1) FROM `t_zzyq_news` where id>%s order by id asc' % saved_id sql2 = 'SELECT id,content,url,title FROM `t_zzyq_news` where id>%s order by id asc' % saved_id else: sql1 = 'SELECT count(1) FROM `t_zzyq_news` where id order by id asc' sql2 = 'SELECT id,content,url,title FROM `t_zzyq_news` where id order by id asc' cur.execute(sql1) count = cur.fetchone() print(count[0]) cur.execute(sql2) result = cur.fetchall() conn.cursor().close() conn.close() for i in range(0, count[0]): id = result[i][0] content = result[i][1] url = result[i][2] title = result[i][3] # save_url(url) split_to_word(content, id, db_word_path) html_content = '' n = 0 while html_content == '': html_content = get_clean_content(url) if html_content == '': time.sleep(2) print('%s的html_content为空,稍后重试' % str(id)) n += 1 if n == 3: break split_to_word(html_content, id, html_word_path) first_path = db_word_path + '\\' + str(id) + '.txt' second_path = html_word_path + '\\' + str(id) + '.txt' compare(id, title, first_path, second_path) path = dirs + '\\id.txt' a = open(path, 'w') a.truncate() a.write(str(id)) a.close()
def detect(a): #a = "Counter-Strike is a first-person shooter in which players join either the terrorist team, the counter-terrorist team, or become spectators. Each team attempts to complete their mission objective and/or eliminate the opposing team. Each round starts with the two teams spawning simultaneously.A player can choose to play as one of eight different default character models (four for each side, although Counter-Strike: Condition Zero added two extra models, bringing the total to ten). Players are generally given a few seconds before the round begins (known as freeze time) to prepare and buy equipment, during which they cannot attack or move (one notable exception is that a player may receive damage during freeze time. This happens when a map is changed to spawn players at a certain height above the ground, thus causing fall damage to the player" #comp = "Counter-Strike is a first-person shooter in which players join either the terrorist team, the counter-terrorist team, or become spectators. Each team attempts to complete their mission objective and/or eliminate the opposing team. Each round starts with the two teams spawning simultaneously.A player can choose to play as one of eight different default character models (four for each side, although Counter-Strike: Condition Zero added two extra models, bringing the total to ten). Players are generally given a few seconds before the round begins (known as freeze time) to prepare and buy equipment, during which they cannot attack or move (one notable exception is that a player may receive damage during freeze time. This happens when a map is changed to spawn players at a certain height above the ground, thus causing fall damage to the player." a = remove_punctuation(a) comp = a a = chunks(a, 250) #comp = remove_punctuation(comp) comp = remv_extra(comp) #print a #print comp #print len(comp) sites, site_list = begin(a) lev_list = [] i = 0 #print len(sites) #print len(site_list) for item in site_list: item = remove_punctuation(item) item = remv_extra(item) #print item lev = compare(item, comp) lev_list.append(lev) #print sites[i] #print lev_list[i] print sites[i], lev_list[i] i = i + 1 return sites, lev_list
def detect(a): #a = "Counter-Strike is a first-person shooter in which players join either the terrorist team, the counter-terrorist team, or become spectators. Each team attempts to complete their mission objective and/or eliminate the opposing team. Each round starts with the two teams spawning simultaneously.A player can choose to play as one of eight different default character models (four for each side, although Counter-Strike: Condition Zero added two extra models, bringing the total to ten). Players are generally given a few seconds before the round begins (known as freeze time) to prepare and buy equipment, during which they cannot attack or move (one notable exception is that a player may receive damage during freeze time. This happens when a map is changed to spawn players at a certain height above the ground, thus causing fall damage to the player" #comp = "Counter-Strike is a first-person shooter in which players join either the terrorist team, the counter-terrorist team, or become spectators. Each team attempts to complete their mission objective and/or eliminate the opposing team. Each round starts with the two teams spawning simultaneously.A player can choose to play as one of eight different default character models (four for each side, although Counter-Strike: Condition Zero added two extra models, bringing the total to ten). Players are generally given a few seconds before the round begins (known as freeze time) to prepare and buy equipment, during which they cannot attack or move (one notable exception is that a player may receive damage during freeze time. This happens when a map is changed to spawn players at a certain height above the ground, thus causing fall damage to the player." a = remove_punctuation(a) comp = a a = chunks(a,250) #comp = remove_punctuation(comp) comp= remv_extra(comp) #print a #print comp #print len(comp) sites,site_list = begin(a) lev_list = [] i=0 #print len(sites) #print len(site_list) for item in site_list: item = remove_punctuation(item) item = remv_extra(item) #print item lev = compare(item, comp) lev_list.append(lev) #print sites[i] #print lev_list[i] print sites[i], lev_list[i] i = i+1 return sites,lev_list
def compute(self): for itr in range(len(self.clusters)-self.target_size): score = compare(self.clusters) self.clusters[score[0]].add(self.clusters.pop(score[1])) self.text.insert('1.0', " classified {0} time(s) now there are {1} clusters\n".format(itr+1,len(self.clusters))) self.root.update() self.text.insert('1.0', " classification finished\n")
def histComic(comicURL): webObject = fetchWeb(comicURL,False) cache = Cache() cacheObject = cache.fetchCache(comicURL,None) if not compare(webObject, cacheObject): cache.storeCache(webObject) Scheduler.histComicNotification += 1 notification("Hist: " + comicURL) return None
def resolve(theorem, outer, clause, loc): if loc == 1: opp = 2 else: opp = 1 for i in clause[loc]: find = i[:i.find('(')] for j in theorem[outer][opp]: new = j[:j.find('(')] curr = theorem[outer][opp].index(j) if find == new: compare(clause, theorem[outer]) subst = unify(parse_term(i), parse_term(j), {}) if subst is not None: found = substitute(theorem, outer, subst, i, clause, loc, opp, curr) return found return False
def newComic(comicURLs): lastChange = None for url in comicURLs: cache = Cache() webObject = fetchWeb(url,False) cacheObject = cache.fetchCache(url,None) if not compare(webObject, cacheObject): cache.storeCache(webObject) lastChange = url if lastChange: Scheduler.newComicNotification += 1 notification("New: " + lastChange) return None
def main(): best=10000000 bestmatch = "" sample, sampleDuration = loadmusic(argv[1]) '''plt.title("Sample Peaks") plt.plot(*zip(*sample)) plt.show()''' d = {} for m in music.find(): # for each music in the collection k, s = compare(sample, m["peaks"]); # gets the correspondency value l = [abs(i-j) for i,j in s.items()] std = numpy.std(l) # calculates standard deviation between differences of time instants print m["music"], k, numpy.std(l) d[std] = s if std < best: best = std bestmatch = m["music"] c = correlation(d[min(d)], False) #print "correlation: ", c print bestmatch srtfile = "/home/michel/data/db/" + bestmatch.split('.')[0] + ".srt" readlyrics(srtfile, argv[2]) bmatch = music.find_one({"music": bestmatch}) maxpeak = max([i for i,j in bmatch["peaks"] ]) print "maxpeak: ", maxpeak duration = bmatch["duration"] * 1000 print "duration: ", duration x = (c * duration) / maxpeak + sampleDuration print x '''
def _compare(name,segs,refs): compare(refs,ic100_ref,name,segs)
_compare('mean_t',mean_t,refs) _compare('rc_t',rc_t,refs) #_compare('watershed:direct',water_direct,refs) #_compare('watershed:gradient',water_gradient,refs) #_compare('watershed:direct_rc',water_direct_rc,refs) #_compare('watershed:gradient_rc',water_gradient_rc,refs) _compare('watershed:direct_mean',water_direct_mean,refs) _compare('watershed:gradient_mean',water_gradient_mean,refs) #_compare('watershed:direct_raw',water_direct_raw,refs) #_compare('watershed:gradient_raw',water_gradient_raw,refs) #_compare('watershed:direct:full',water_direct,refs_full) #_compare('watershed:gradient:full',water_gradient,refs_full) #_compare('watershed:direct_raw:full',water_direct_raw,refs_full) #_compare('watershed:gradient_raw:full',water_gradient_raw,refs_full) #_compare('active_masks',active_masks,refs) _compare('active_masks:filtered',active_masks_filtered,refs) #_compare('active_masks2',active_masks2,refs) #_compare('roysam',roysams,refs) _compare('roysam_mean',roysams_mean,refs) #_compare('roysams_mean_filter',roysams_mean_filtered,refs) _compare('roysams_mean_filter_no_AS',roysams_mean_filtered[5:],refs[5:]) aabid_refs = ic100_ref[:5] + gnf_ref[:5] aabids = [Task(load_aabid,'ic100',i) for i in xrange(5)] +\ [Task(load_aabid,'gnf',i) for i in xrange(5)] compare(aabid_refs,ic100_ref[:5],'AS',aabids) # vim: set ts=4 sts=4 sw=4 expandtab smartindent:
import matplotlib import numpy as np import matplotlib.pyplot as plt from base import * from compare import * infile = open("C:\Users\wearable\Trevor.txt", "r") #infile2 = open("C:\Users\wearable\IT.txt", "r") oxy = [] oxy_1 = [] test1 = base(infile) test1.clear() oxy = test1.start() oxy_1 = test1.filter(0.15, 150.0, 1000.0, 0.0) test2 = compare(oxy, oxy_1, 14) test2.xavier() test2.clear() plt.plot(oxy, 'r') plt.plot(oxy_1, 'b') plt.show()
import matplotlib import numpy as np import matplotlib.pyplot as plt from base import * from compare import * infile = open("C:\Users\wearable\it2.txt", "r") #infile2 = open("C:\Users\wearable\IT.txt", "r") oxy = [] oxy_1 = [] test1 = base(infile) test1.clear() oxy = test1.start() oxy_1 = test1.filter(0.15, 150.0, 1000.0, 0.0) test2 = compare(oxy, oxy_1, 14) test2.xavier() test2.clear() plt.plot(oxy, 'r') plt.plot(oxy_1, 'b') plt.show()
# -*- coding: utf-8 -*- """ Created on Wed Feb 11 19:06:27 2015 @author: user """ from BCD_GEM import * from compare import * from generate_gaussians import * N = 10000 P = 20 K = 5 X, Y, phi1, rho1, pi1 = generate_gaussian_mix(N, P, K) phi2, rho2, pi2 = BCD_GEM(X, Y, K, myLambda) print phi2 print rho2 print pi2 compare(phi1, phi2, pi1, pi2, rho1, rho2)
def test_compare_short(): nose.tools.assert_equal([8, 12], compare(triangle[1],triangle[2])) nose.tools.assert_equal([6], compare(triangle[0],triangle[1]))
import PIL from PIL import Image import barcodeReader import read_text import compare img = Image.open("IMG_9000.JPG") bgr = (8, 70, 208) barcode_values = barcodeReader(img, bgr) print(barcode_values) text_values = read_text(path, full_text) print(text_values) validation = compare(text_values, barcode_values)
#_compare('otsu',otsu,refs) #_compare('mean_t',mean_t,refs) #_compare('rc_t',rc_t,refs) #_compare('watershed:direct',water_direct,refs) #_compare('watershed:gradient',water_gradient,refs) #_compare('watershed:direct_rc',water_direct_rc,refs) #_compare('watershed:gradient_rc',water_gradient_rc,refs) #_compare('watershed:direct_mean',water_direct_mean,refs) #_compare('watershed:gradient_mean',water_gradient_mean,refs) #_compare('watershed:direct_raw',water_direct_raw,refs) #_compare('watershed:gradient_raw',water_gradient_raw,refs) #_compare('watershed:direct:full',water_direct,refs_full) #_compare('watershed:gradient:full',water_gradient,refs_full) #_compare('watershed:direct_raw:full',water_direct_raw,refs_full) #_compare('watershed:gradient_raw:full',water_gradient_raw,refs_full) #_compare('active_masks',active_masks,refs) #_compare('active_masks:filtered',active_masks_filtered,refs) #_compare('active_masks2',active_masks2,refs) #_compare('roysam',roysams,refs) #_compare('roysam_mean',roysams_mean,refs) #_compare('roysams_mean_filter',roysams_mean_filtered,refs) #_compare('roysams_mean_filter_no_AS',roysams_mean_filtered[5:],refs[5:]) aabid_refs = ic100_ref[:5] + gnf_ref[:5] aabids = [Task(load_aabid,'ic100',i) for i in xrange(5)] +\ [Task(load_aabid,'gnf',i) for i in xrange(5)] compare(aabid_refs,ic100_ref[:5],'AS',aabids)
from PIL import Image (from *) import compare im = Image.open("chemin de l'image") # isolation des couches de couleur de l'image im1 = im.split()[0] # couche rouge im2 = im.split()[1] # couche verte im3 = im.split()[2] # couche bleu im4 = im.convert("L") # conversion RGBA -> niveaux de gris compare(im1, im2, im3, im4)
from compare import * my_language = language("patterns/patterns_en.txt", "entities/entities_en.txt") print( compare(input("> "), [["Hello", "Hi", "Hey"], "bot"], entities=my_language.entities))