12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #coding:utf8
- import psycopg2
- import codecs
- import re
- def havelook():
- conn = psycopg2.connect(dbname="BiddingKM_test_10000",user="postgres",password="postgres",host="192.168.2.101")
-
- cursor = conn.cursor()
-
- sql = " select A.entity_text,A.begin_index,A.end_index,B.tokens from entity_mention A,sentences B where A.entity_type='money' and A.doc_id=B.doc_id and A.sentence_index=B.sentence_index "
-
- cursor.execute(sql)
-
- rows = cursor.fetchmany(1000)
-
- MAX_NUM = 7
- with codecs.open("look.txt", "w", encoding="utf8") as f:
- while(rows):
- for row in rows:
- entity_text = row[0]
- begin_index = row[1]
- end_index = row[2]
- tokens = row[3]
- if begin_index>MAX_NUM:
- begin = begin_index-MAX_NUM
- else:
- begin = 0
- if end_index+MAX_NUM<len(tokens):
- end = end_index+MAX_NUM+1
- else:
- end = -1
- f.write("".join(tokens[begin:begin_index]))
- f.write("\t")
- f.write(entity_text)
- f.write("\t")
- f.write("".join(tokens[begin_index:end_index+1]))
- f.write("\t")
- f.write("".join(tokens[end_index+1:end]))
- f.write("\n")
- rows = cursor.fetchmany(1000)
- f.flush()
- f.close()
- conn.close()
-
- def moneySupervice():
- text = "地址:全椒县襄河镇港口路96号,投标报价:"
- pattern_tenderee = re.compile("报价上限|限价|造价|控制总?价|预算|概算|(?:造?价|投资|规模)预?估?算|预?估算?(?:造?价|投资|规模)|(?:总|项目|计划)(?:[估预概]算|投资)|(?:投资|采购)(?:单价|总)?(?:额|金额)+")
- pattern_wintenderer = re.compile("(?:中标|成交)(?:价|金额)|报价")
- if re.search(pattern_tenderee,text) is not None:
- print(0)
- elif re.search(pattern_wintenderer,text) is not None:
- print(1)
- else:
- print(2)
-
- if __name__=="__main__":
- moneySupervice()
|