export_articles_processed.py 875 B

1234567891011121314151617181920212223242526
  1. #coding:utf8
  2. import psycopg2
  3. import codecs
  4. conn = psycopg2.connect(dbname="BiddingKM_test_10000",user="postgres",password="postgres",host="192.168.2.101")
  5. cursor = conn.cursor()
  6. exporttable = " is_firsttenderer "
  7. cursor.execute(" select A1.id,A1.content,B1.content from articles A1,articles_processed B1 where A1.id=B1.id and A1.id in(select distinct B.doc_id from "+exporttable+" A,entity_mention B,dd_graph_variables_holdout D where A.id=D.variable_id and A.entity_id=B.entity_id) ")
  8. all_doc_id = cursor.fetchall()
  9. for doc_id in all_doc_id:
  10. with codecs.open("export_article/"+str(doc_id[0])+"_a.html","w",encoding="utf8") as f:
  11. f.write(doc_id[1])
  12. f.flush()
  13. f.close()
  14. with codecs.open("export_article/"+str(doc_id[0])+"_b.html","w",encoding="utf8") as f:
  15. f.write(doc_id[2])
  16. f.flush()
  17. f.close()