Department is responsible for the industrial domain knowledge map construction, for industrialization and information fusion, sounds good tall and difficult, anyway, I can not understand so deep, fortunately, the department manager led.
Want to do professional domain knowledge map First of all have to have the domain knowledge, where does this knowledge come from? The main source is definitely crawling from the internet!
Climb down a lot of knowledge directly piled up in that certainly not, but also to establish a relationship, one of the important is the text classification! So how do you classify it?
Let's talk about it later ... Because whatever you do, start by taking out the data you want in the database.
#Coding=utf-8Importsysreload (SYS) sys.setdefaultencoding ('Utf-8') fromPymongoImportmongoclient#establishing a MongoDB database connectionClient = Mongoclient ('IP', 27017)#user authenticationdb =client. Library name Db.authenticate ("Account Number","Password")#The collection used to connect, which is what we usually call a tablecollection=db. Table name#Then you can use collection to do some of the database tables.With open ('file name. txt','WB') as F:
#接下来可实现提取想要的字段内的数据 forIteminchCollection.find ({}, {"Summary": 1,"Manual": 1,"Claim": 1,"_id": 0}):ifItem.has_key ('Summary') anditem['Summary']: f.write (item['Summary']) ifItem.has_key ('Manual') anditem['Manual']: f.write (item['Manual']) ifItem.has_key ('Claim') anditem['Claim']: f.write (item['Claim']) F.write ('\ n')
Python joins MongoDB to extract data from some fields and write to TXT file