def getBlog(self, filter = None): parsedFilter = SearchFilter() parsedFilter.decode(filter) conn = MySQLdb.connect (host = "localhost", user = "******", passwd = "helloall", db = "fydp_db") cursor = conn.cursor () select = "SELECT feedurl FROM fydp_db.feeditem " + parsedFilter.toSQL() print "select received: %s" % select cursor.execute (select) row = cursor.fetchone() cursor.close () conn.close () return row
def getBlog(self, filter=None): parsedFilter = SearchFilter() parsedFilter.decode(filter) conn = MySQLdb.connect(host="localhost", user="******", passwd="helloall", db="fydp_db") cursor = conn.cursor() select = "SELECT feedurl FROM fydp_db.feeditem " + parsedFilter.toSQL() print "select received: %s" % select cursor.execute(select) row = cursor.fetchone() cursor.close() conn.close() return row
def getBlog(self, filter): conn = solr.SolrConnection('http://localhost:8983/solr') print filter parsedFilter = SearchFilter() parsedFilter.decode(filter) print parsedFilter.toSolr() response = conn.query(**(parsedFilter.toSolr())) conn.close() return [hit['link'] for hit in response.results]
def getBlogPost(self, filter = None): conn = MySQLdb.connect (host = "localhost", user = self.username, passwd = self.password, db = "fydp_db") parsedFilter = SearchFilter() parsedFilter.decode(filter) cursor = conn.cursor () # Write to log! select = "SELECT title FROM fydp_db.feeditem " + parsedFilter.toSQL() print 'select recieved: %s' % select cursor.execute (select) #TODO make this read the limit and send that many, #TODO call an outside function and return the proper results depending # on the link row = cursor.fetchone() cursor.close () conn.close () return row
def getBlogPost(self, filter=None): conn = MySQLdb.connect(host="localhost", user=self.username, passwd=self.password, db="fydp_db") parsedFilter = SearchFilter() parsedFilter.decode(filter) cursor = conn.cursor() # Write to log! select = "SELECT title FROM fydp_db.feeditem " + parsedFilter.toSQL() print 'select recieved: %s' % select cursor.execute(select) #TODO make this read the limit and send that many, #TODO call an outside function and return the proper results depending # on the link row = cursor.fetchone() cursor.close() conn.close() return row
def getBlogPost(self, filter): conn = solr.SolrConnection('http://localhost:8983/solr') print filter parsedFilter = SearchFilter() parsedFilter.decode(filter) params = parsedFilter.toSolr() params['q'] = params['q'] + " sentiment:[0.75 TO 1.0]" good_response = conn.query(**(params)) params = parsedFilter.toSolr() params['q'] = params['q'] + " sentiment:[0.0 TO 0.25]" bad_response = conn.query(**(params)) conn.close() goodText = "" badText = "" results = good_response.results + bad_response.results for hit in results: if hit['sentiment'] == True: goodText += hit['content'] elif hit['sentiment'] == False: badText += hit['content'] q, p = ngrams.main(goodText, badText, ngrams.getWordsForDisplay) return (q, p, [(hit['title'], hit['content'], hit['sentiment']) for hit in results if hit['content']])
def build_filter(f): filters = SearchFilters() for i in f: filters.add_and_filter(SearchFilter(i["col"], i["op"], i["value"])) return filters