diff --git a/histogram.png b/histogram.png index 4b02f7d..a8ef6e1 100644 Binary files a/histogram.png and b/histogram.png differ diff --git a/ngram-rnn-classification.pt b/ngram-rnn-classification.pt index 633b533..7787cb8 100644 Binary files a/ngram-rnn-classification.pt and b/ngram-rnn-classification.pt differ diff --git a/rm_clasificationmodel/DataFrameClass.py b/rm_clasificationmodel/DataFrameClass.py index efc40b0..50a5569 100644 --- a/rm_clasificationmodel/DataFrameClass.py +++ b/rm_clasificationmodel/DataFrameClass.py @@ -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,7 +82,23 @@ 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 + diff --git a/rm_clasificationmodel/ElasticSearchClass.py b/rm_clasificationmodel/ElasticSearchClass.py index 2369e1c..3879baf 100644 --- a/rm_clasificationmodel/ElasticSearchClass.py +++ b/rm_clasificationmodel/ElasticSearchClass.py @@ -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": {}}}) - return resp \ No newline at end of file + 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) diff --git a/rm_clasificationmodel/main.py b/rm_clasificationmodel/main.py index de94522..584b0d4 100644 --- a/rm_clasificationmodel/main.py +++ b/rm_clasificationmodel/main.py @@ -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) + df=DataFrame(es_local) - [df_en, df_de]=df.create() + 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') + + + + + # 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)