From: judy <jh...@ri...> - 2011-09-29 13:04:25
|
Thanks again, Carlos. I'm new to python, it's good to know the rest of my questions aren't SPARQLWrapper-specific. Sent from my iPad On Sep 29, 2011, at 3:19 AM, Carlos Tejo <car...@fu...> wrote: > Dear Judy, > >> Thank you very much for your reply! I was able to copy your example and >> get a good result. > > Great! > >> Just one more question to extend the result set, if >> you don't mind. I have multiple >> OPTIONAL entities to select (about 10) and would like to know if it's >> possible to OR them: >> >> for result in results["results"]["bindings"]: >> if result.has_key("party"): >> print "* " + result["person"]["value"] + " ** " + >> result["party"]["value"] >> >> (OR) >> >> if result.has_key("party"): >> print "* " + result["person"]["value"] + " ** " + >> result["party"]["value"] >> >> else: >> print result["person"]["value"] >> >> and also -- is it possible to organize results to print them using %s >> while still using your if-then method? Here's how do it now: >> >> for result in results["results"]["bindings"]: >> project = result["project"]["value"].encode('utf-8') >> filename = result["filename"]["value"].encode('utf-8') >> url = result["url"]["value"].encode('utf-8') >> url = result["url"]["value"].encode('utf-8') >> keywords = result["keywords"]["value"].encode('utf-8') >> >> print "<p class=\"results\"><span>Project</span>: %s</p><p >> class=\"indent\"><span>Filename</span>: %s</p><p >> class=\"indent\"><span>URL</span>:<a href=\"%s\">%s</a></p><p >> class=\"indent\"><span>Keywords</span>: %s</p>" % \ >> (project,filename,url,url,keywords) > > That question is regarding how python works. I think that this > question would be answer better in other forums [1]. > >> Thank you for your SPARQLWrapper effort. > > Thank you for use it :) > > Cheers, > > Carlos Tejo > > [1] http://stackoverflow.com/questions/tagged/python > > -- > Carlos Tejo Alonso > CTIC-Centro Tecnológico > Parque Científico y Tecnológico de Gijón > c/ Ada Byron, 39 Edificio Centros Tecnológicos > 33203 Gijón - Asturias - Spain > Tel.: +34 984 29 12 12 > Fax: +34 984 39 06 12 > E-mail: car...@fu... > http://www.fundacionctic.org > Privacy Policy: http://www.fundacionctic.org/privacidad > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > _______________________________________________ > sparql-wrapper-devel mailing list > spa...@li... > https://lists.sourceforge.net/lists/listinfo/sparql-wrapper-devel |