add local es
This commit is contained in:
parent
a0f6e6534a
commit
434a9e51f3
5 changed files with 78 additions and 13 deletions
BIN
histogram.png
BIN
histogram.png
Binary file not shown.
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 106 KiB |
Binary file not shown.
|
|
@ -48,7 +48,9 @@ class DataFrame:
|
|||
def create(self):
|
||||
self.df_eng = pd.DataFrame(columns=['name','category'])
|
||||
self.df_de = pd.DataFrame(columns=['name','category'])
|
||||
resp=self.es.getFeatures()
|
||||
resp=self.es.search("retromotion-indexer_development_products",{"_source":["descriptions","descriptionsSource","nameSource","shortDescriptionSource","categoriesSource"],
|
||||
'size' : 65000,
|
||||
"query": {"match_all": {}}})
|
||||
|
||||
for hit in resp['hits']['hits']:
|
||||
list_row_en = dict (name=None,category=None)
|
||||
|
|
@ -80,6 +82,22 @@ class DataFrame:
|
|||
self.clean()
|
||||
return [self.df_eng,self.df_de]
|
||||
|
||||
def getNormal(self):
|
||||
self.df_eng = pd.DataFrame(columns=['name','category'])
|
||||
resp=self.es.search("english-taxonomy-normal",{"_source":["name","category"],
|
||||
'size' : 5000,
|
||||
"query": {"match_all": {}}})
|
||||
for hit in resp['hits']['hits']:
|
||||
list_row_en = dict (name=None,category=None)
|
||||
list_row_en["name"]=hit['_source']['name']
|
||||
list_row_en["category"]=hit['_source']['category']
|
||||
|
||||
new_row = pd.Series(list_row_en)
|
||||
self.df_eng=pd.concat([self.df_eng, new_row.to_frame().T], ignore_index=True)
|
||||
|
||||
|
||||
|
||||
return self.df_eng
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,20 @@ class ElasticSearchDb:
|
|||
|
||||
def __init__(self,url):
|
||||
self.url=url
|
||||
self.client = Elasticsearch(url)
|
||||
self.es = Elasticsearch(url)
|
||||
|
||||
def getFeatures(self):
|
||||
resp = self.client.search(index="retromotion-indexer_development_products",
|
||||
body={"_source":["descriptions","descriptionsSource","nameSource","shortDescriptionSource","categoriesSource"],
|
||||
'size' : 65000,
|
||||
"query": {"match_all": {}}})
|
||||
def search(self,_index,doc):
|
||||
resp = self.es.search(index=_index,
|
||||
body=doc)
|
||||
return resp
|
||||
|
||||
def ingest(self,_index,doc,type):
|
||||
self.es.index(
|
||||
index=_index,
|
||||
body=doc,
|
||||
doc_type=type
|
||||
)
|
||||
|
||||
def create(self,_index,request_body):
|
||||
|
||||
self.es.indices.create(index=_index, body=request_body)
|
||||
|
|
|
|||
|
|
@ -8,12 +8,50 @@ from NN import RNN
|
|||
from evaluate import Evaluate
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
es =ElasticSearchDb("http://172.17.212.35:9200")
|
||||
# es =ElasticSearchDb("http://172.17.212.35:9200")
|
||||
es_local =ElasticSearchDb("http://192.168.0.30:9200")
|
||||
|
||||
|
||||
df=DataFrame(es_local)
|
||||
|
||||
df.getNormal()
|
||||
|
||||
df_en = df.getNormal()
|
||||
|
||||
# [df_en, df_de]=df.create()
|
||||
|
||||
# docDict = df_en.to_dict(orient='records')
|
||||
|
||||
# request_body = {
|
||||
# "settings": {
|
||||
# "number_of_shards": 5,
|
||||
# "number_of_replicas": 1
|
||||
# },
|
||||
# 'mappings': {
|
||||
# "product_taxonomy": {
|
||||
|
||||
# 'properties': {
|
||||
# 'name': {'type': 'text'},
|
||||
# 'category': {'type': 'text'},
|
||||
# }
|
||||
# }
|
||||
|
||||
# }
|
||||
# }
|
||||
|
||||
# es_local.create('english-taxonomy-normal',request_body)
|
||||
|
||||
|
||||
# for val in docDict:
|
||||
# print (val)
|
||||
# es_local.ingest('english-taxonomy-normal',val,'product_taxonomy')
|
||||
|
||||
|
||||
|
||||
|
||||
df=DataFrame(es)
|
||||
|
||||
[df_en, df_de]=df.create()
|
||||
|
||||
# vectorizer = Vectorize(1,1)
|
||||
# vectorizer.setTfidFitTransform(df_en["name"])
|
||||
|
|
@ -42,7 +80,7 @@ def main():
|
|||
# rnn=torch.load('ngram-rnn-classification.pt')
|
||||
|
||||
train = Train(df_en)
|
||||
train.run(200000)
|
||||
train.run(90000)
|
||||
train.predict('vaico centering bush propshaft',2)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue