From d145ecee5514e9da7261f3fbc73c5b100a2c58ec Mon Sep 17 00:00:00 2001 From: Askill Date: Fri, 24 Apr 2020 22:00:15 +0200 Subject: [PATCH] started adapting search for new db modell --- __pycache__/migrate.cpython-37.pyc | Bin 2092 -> 2393 bytes __pycache__/run.cpython-37.pyc | Bin 377 -> 377 bytes __pycache__/search.cpython-37.pyc | Bin 2788 -> 3166 bytes application/__pycache__/db2.cpython-37.pyc | Bin 2863 -> 2920 bytes .../__pycache__/endpoints.cpython-37.pyc | Bin 1419 -> 1416 bytes application/db2.py | 21 +++--- application/endpoints.py | 4 +- migration/migrate.py => migrate.py | 51 ++++++++++++- migration/db.py | 56 -------------- migration/db2.py | 70 ------------------ search.py | 15 ++++ 11 files changed, 75 insertions(+), 142 deletions(-) rename migration/migrate.py => migrate.py (55%) delete mode 100644 migration/db.py delete mode 100644 migration/db2.py diff --git a/__pycache__/migrate.cpython-37.pyc b/__pycache__/migrate.cpython-37.pyc index 220a3a2ce88905faaaa75ce78d6e2f3d884dbcb4..14d4ebb44213e1057fb2f1cf91e0be2033354f55 100644 GIT binary patch literal 2393 zcmZ9O&u<$=6vt;~e|YUUiJPRqL$MGlwWtENAXHGH2m%7BDyXTHVg(|{vvt>Aubr7S zO`>&$2yjE{p{Jf4aYEv6=pQoThJ=(mrydaBH|r#*Yt5UV@6GJa=e_4oW@k$bPhsu1 z@BSz=_7`ItH9gLxBi)}^)0dv~Q5R%E z2B-sBlqJ+f$v0SS<``Dl-5NJVoeqYN2TJNTr!hSKw0w$MKZDr+vBSnZWhtKs$&dIU zAB#++*z}Np#l|9ax~}BX`IV2Iz1yiX@iKPA*V(r#V>fd%(ew4K)X&^QF5Mne_jYe( z&ZLmJM||vMd=g~d5$A08)+WO$SeIT;s2^xX`ZSZ_$lU&<-$7e4yh7ow@jIdFw~_^wf~?tTN4zMfp2Z=dta} z8|@FbhHB6a+o|6Ae4upu(J1L?9rmN7rMCJ}N43&$Ww;Mh(A>lpMd;~k5R41%@;P3{ z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diff --git a/__pycache__/run.cpython-37.pyc b/__pycache__/run.cpython-37.pyc index 2856dab875f5a0c32e24d0064a4594092b00c660..54e754a334e90da278aea45d1319829560e4f6b5 100644 GIT binary patch delta 20 acmey#^plC(iIKs1PzK=y84v}rnS;G*`{`MjqHqeb)9TWdwPoOtZwLOvTfbeGi2vPD%V1Yw; z5gO2tOMo3>L*N*F*4fx3n|?tMi${=&$8ak0*I@2g>>9h3UGo$kTN%%*N5-BcPo0V_ zarcc!W@aCmyUv$z1bbDyr^!BJdg8_06!Rp_o5B!1vA=#t>^JXFlsYoDkxN0Fz^@fj z-$%)QjlmShLKL-lxPy_7qhXd77Diz_j*uHfk70_T!N3am7Ebe=d&e1u7Q-yV0z>;b z%+ai;2#%JL3 zDqj}z>RJJZ6Q}*_^pZHu!qH&7-pg(C;VVy9qtB%PPAtdEL~lO%&V+@Dvz?tN`!EW( z;xN0O|6*N&jr>pR+Xow*#!5$+MH<)GF~=AWGZLlLqg3W?;_)4Zb%H=1PF7ji?O9UM%+NJV&C}_GBFv|k z?w((R{k^%_T@y5+i9&2~3#}2euFdUZ&f!iTbGeIlDE7KVUc{IwtXCTM1rs*fVc`fD z?TGM15$&k(#W312F(O9Mj*BrdE=rvOFNrcQi^4-KsQjc>0wdcyteXL3(Ahk&U;;|q zhv30$D%!W;}*~iUK{;7p`WoeI#+B^V?aDqa}PdlGF{gXqRD4-Ls!C`py94g!*VNUCFxyd7e1^xY-z^Gf13HDR1|#8g=G2 zCn+#RFil_)oI{|&#EbF*y&sFtkWWL-5(`%#iaz0N;PpRSZGcl%;14p-^SgvM6Grdj?V8qC9coH>j!&(Z$^KwYgB diff --git a/application/__pycache__/db2.cpython-37.pyc b/application/__pycache__/db2.cpython-37.pyc index 4e39f1a468a6853906b68ec3574b9824e161c40d..50b6ea5b880beb1549e08c06829c40a6f7c83c5e 100644 GIT binary patch delta 1223 zcmah|K~ED=5Z?E?-R{2KZC9d=h+x%FT##xJK@%||0b*i$frIuSBJTkWxR|%)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bukbu&rugd3xM-!bv)FePgS|;!;jv-ld ztZD^}WMNFpPG{IgD!AtsoTF%)WI(N{FqP!zlD5^$k#|WC%Xa#e|moIkLjr( zXpdtvh3K6XP3BZ+(MU8S=?9Y%(S6;{A*%DD>Q*J9P@gF*io7 z>w4+O;Xm8W?6eMLUDFLwV;y}}eB8W2&+0nh3PI*>#cA4qk>uwD+tPS$Mqs)q6xcH* S-S$_?f=40>A}8`9M~L4=UC+({ diff --git a/application/__pycache__/endpoints.cpython-37.pyc b/application/__pycache__/endpoints.cpython-37.pyc index 40d531f9ad4fdce3a7d5ef11ad86af1f453acb34..deb421eb04de60646be58966c5aa30af680506a5 100644 GIT binary patch delta 151 zcmeC??%?Ki;^pOH0D|xKi{k<}@|H4*-eM^(NzK({y2YetP{aw8TFFo(uz5BU6C($E zacW{wa)#05CCruF0zj!EFd;ZugC$o~1I|a5S;b<)s4)3HON@#%NS+r&$btwCtjgnA FbpQem9lHPk delta 154 zcmeC+?&juo;^pOH00QYP3*$mI@|H45MsXCEq~?a_7o})2-D1)+DB=W4uVg6V-#nd( ziIJTxEfFYRJb58=B{x4%rU*<3Ojc#d6;+4xk!6;%m@vvuzQYouA_bD?1rahJf&;7a H7*-tsPIw+N diff --git a/application/db2.py b/application/db2.py index dacee76..52db64e 100644 --- a/application/db2.py +++ b/application/db2.py @@ -10,7 +10,7 @@ import time engine = db.create_engine('mysql+mysqldb://root@server/fs2?charset=utf8mb4', echo=False, encoding="utf8", pool_size=1000, max_overflow=0) Base = declarative_base() -Session = sessionmaker(bind=engine) +Session = sessionmaker(bind=engine, autoflush=False) # https://docs.sqlalchemy.org/en/13/orm/basic_relationships.html#association-object @@ -20,7 +20,7 @@ class Recipe(Base): name = Column('name', Text) instructions = Column('instructions', Text) url = Column('url', Text) - img = Column('img', LargeBinary) + img = Column('img', LargeBinary(length=(2**32)-1)) imgURL = Column('imgURL', Text) ingredient = relationship("RecIngred", back_populates="recipe") @@ -30,25 +30,26 @@ class RecIngred(Base): ingredient_amount = Column('ingredient_amount', Text) ingredient_amount_mu = Column('ingredient_amount_mu', Text) # measurement unit - recipe_id = Column(Integer, ForeignKey('recipe.recipe_id'), primary_key=True) - ingredient_name = Column(String(50), ForeignKey('ingredient.name'), primary_key=True) - recipe = relationship("Recipe", back_populates="ingredient") ingredient = relationship("Ingredient", back_populates="recipe") + recipe_id = Column(Integer, ForeignKey('recipe.recipe_id'), primary_key=True) + ingredient_name = Column(String(200), ForeignKey('ingredient.name'), primary_key=True) + + class Ingredient(Base): __tablename__ = "ingredient" - name = Column('name', String(50), primary_key=True) + name = Column('name', String(200), primary_key=True) recipe = relationship("RecIngred", back_populates="ingredient") trunks = relationship("IngredTrunk", back_populates="ingredient") class IngredTrunk(Base): __tablename__ = 'ingredtrunk' - ingredient_name = Column(String(50), ForeignKey('ingredient.name'), primary_key=True) - trunk_name = Column(String(50), ForeignKey('ingredient.name'), primary_key=True) + ingredient_name = Column(String(200), ForeignKey('ingredient.name'), primary_key=True) + trunk_name = Column(String(50), ForeignKey('trunk.name'), primary_key=True) - ingredient = relationship("Ingredient", back_populates="trunk") - trunk = relationship("Trunk", back_populates="ingredient") + ingredient = relationship("Ingredient", back_populates="trunks") + trunk = relationship("Trunk", back_populates="ingredients") class Trunk(Base): __tablename__ = "trunk" diff --git a/application/endpoints.py b/application/endpoints.py index c994f78..6b72728 100644 --- a/application/endpoints.py +++ b/application/endpoints.py @@ -20,10 +20,10 @@ class RecipeList(Resource): args = parser.parse_args() ingreds = args["ingred"] - ingreds = [migrate.stemWord(ingred)[0] for ingred in ingreds + search.defaultArr] + ingreds = [migrate.stem(ingred)[0] for ingred in ingreds + search.defaultArr] start = time.time() - indx = search.fastes(ingreds) + indx = search.search2(ingreds) end = time.time() print("get recipes",end - start, "\n") diff --git a/migration/migrate.py b/migrate.py similarity index 55% rename from migration/migrate.py rename to migrate.py index bd1fc80..5e56bf9 100644 --- a/migration/migrate.py +++ b/migrate.py @@ -3,8 +3,8 @@ import cv2 import base64 import nltk as nltk from nltk.corpus import stopwords -import db as db1 -import db2 as db2 +#import db as db1 +#import db2 as db2 def stemWord(word): try: @@ -25,7 +25,7 @@ def stemWord(word): #migrate('./data/recs.json') -def migrateDb1ToDb2(): +def migrateRecsDb1ToDb2(): session1 = db1.Session() session2 = db2.Session() @@ -57,4 +57,47 @@ def migrateDb1ToDb2(): count+=1 print(count/length) -migrateDb1ToDb2() \ No newline at end of file +def TrunkDb2(): + session2 = db2.Session() + + count = 0 + length = session2.query(db2.Ingredient).count() + for i2 in session2.query(db2.Ingredient).all(): + try: + for trunk1 in stem(i2.name): + + ri2 = db2.IngredTrunk() + trunk = session2.query(db2.Trunk).filter(db2.Trunk.name == trunk1).first() + if trunk is None: + trunk = db2.Trunk(name=trunk1) + + if session2.query(db2.IngredTrunk).filter(db2.IngredTrunk.ingredient_name == i2.name, db2.IngredTrunk.trunk_name == trunk1).first() is None: + ri2.trunk = trunk + i2.trunks.append(ri2) + + session2.commit() + + except Exception as e: + print(e) + session2 = db2.Session() + + count+=1 + print(count/length) + + +def stem(l1): + '''Tokenize and stem word, result is 1d list''' + snowball = nltk.SnowballStemmer(language='german') + stopset = set(stopwords.words('german')) + stopset |= set("(),") + l2 = [] + + for token in nltk.word_tokenize(l1): + token = snowball.stem(token) + if token in stopset or not token.isalpha() or len(token) < 2: + continue + l2.append(token) + + return l2 +#migrateDb1ToDb2() +#TrunkDb2() \ No newline at end of file diff --git a/migration/db.py b/migration/db.py deleted file mode 100644 index 032d5c6..0000000 --- a/migration/db.py +++ /dev/null @@ -1,56 +0,0 @@ -import sqlalchemy as db -from sqlalchemy import Column, String, Integer, Numeric, Table, DateTime, ARRAY, ForeignKey, create_engine, LargeBinary, Enum, Text -from sqlalchemy.orm import sessionmaker, relationship, column_property -from datetime import datetime -from sqlalchemy.ext.declarative import declarative_base -import enum -from flask import Flask -import time - -engine = db.create_engine('mysql+mysqldb://root@server/fs?charset=utf8mb4', echo=False, encoding="utf8", pool_size=1000, max_overflow=0) - -Base = declarative_base() -Session = sessionmaker(bind=engine) - -# https://docs.sqlalchemy.org/en/13/orm/basic_relationships.html#association-object - - -class Recipe(Base): - __tablename__ = "recipe" - recipe_id = Column('recipe_id', Integer, primary_key=True, autoincrement=True) - name = Column('name', Text) - instructions = Column('instructions', Text) - url = Column('url', Text) - img = Column('img', LargeBinary(length=(2**32)-1)) - ingredient = relationship("Ingredient", backref="recipe") - trunk = relationship("Trunk", backref="recipe") - - -class Ingredient(Base): - __tablename__ = "ingredient" - ingredient_id = Column('ingredient_id', Integer, primary_key=True, autoincrement=True) - name = Column('name', Text) - ingredient_amount = Column('ingredient_amount', Text) - ingredient_amount_mu = Column('ingredient_amount_mu', Text) # measurement unit - - recipe_id = Column(Integer, ForeignKey('recipe.recipe_id')) - - -class Trunk(Base): - __tablename__ = "trunk" - trunk_id = Column('trunk_id', Integer, primary_key=True, autoincrement=True) - name = Column('name', Text) - - recipe_id = Column(Integer, ForeignKey('recipe.recipe_id')) - -def initDB(counter): - try: - Base.metadata.create_all(engine) - except Exception as e: - print(e) - counter += 1 - if counter < 13: - time.sleep(5) - initDB(counter) - -initDB(0) \ No newline at end of file diff --git a/migration/db2.py b/migration/db2.py deleted file mode 100644 index 52db64e..0000000 --- a/migration/db2.py +++ /dev/null @@ -1,70 +0,0 @@ -import sqlalchemy as db -from sqlalchemy import Column, String, Integer, Numeric, Table, DateTime, ARRAY, ForeignKey, create_engine, LargeBinary, Enum, Text -from sqlalchemy.orm import sessionmaker, relationship, column_property -from datetime import datetime -from sqlalchemy.ext.declarative import declarative_base -import enum -from flask import Flask -import time - -engine = db.create_engine('mysql+mysqldb://root@server/fs2?charset=utf8mb4', echo=False, encoding="utf8", pool_size=1000, max_overflow=0) - -Base = declarative_base() -Session = sessionmaker(bind=engine, autoflush=False) - -# https://docs.sqlalchemy.org/en/13/orm/basic_relationships.html#association-object - -class Recipe(Base): - __tablename__ = "recipe" - recipe_id = Column('recipe_id', Integer, primary_key=True, autoincrement=True) - name = Column('name', Text) - instructions = Column('instructions', Text) - url = Column('url', Text) - img = Column('img', LargeBinary(length=(2**32)-1)) - imgURL = Column('imgURL', Text) - ingredient = relationship("RecIngred", back_populates="recipe") - -class RecIngred(Base): - - __tablename__ = 'recingred' - ingredient_amount = Column('ingredient_amount', Text) - ingredient_amount_mu = Column('ingredient_amount_mu', Text) # measurement unit - - recipe = relationship("Recipe", back_populates="ingredient") - ingredient = relationship("Ingredient", back_populates="recipe") - - recipe_id = Column(Integer, ForeignKey('recipe.recipe_id'), primary_key=True) - ingredient_name = Column(String(200), ForeignKey('ingredient.name'), primary_key=True) - - -class Ingredient(Base): - __tablename__ = "ingredient" - name = Column('name', String(200), primary_key=True) - recipe = relationship("RecIngred", back_populates="ingredient") - trunks = relationship("IngredTrunk", back_populates="ingredient") - -class IngredTrunk(Base): - __tablename__ = 'ingredtrunk' - ingredient_name = Column(String(200), ForeignKey('ingredient.name'), primary_key=True) - trunk_name = Column(String(50), ForeignKey('trunk.name'), primary_key=True) - - ingredient = relationship("Ingredient", back_populates="trunks") - trunk = relationship("Trunk", back_populates="ingredients") - -class Trunk(Base): - __tablename__ = "trunk" - name = Column('name', String(50), primary_key=True) - ingredients = relationship("IngredTrunk", back_populates="trunk") - - -def initDB(counter=0): - try: - Base.metadata.create_all(engine) - except Exception as e: - print(e) - counter += 1 - if counter < 13: - time.sleep(5) - initDB(counter) - -initDB() \ No newline at end of file diff --git a/search.py b/search.py index 1fa2c96..dcc4f2c 100644 --- a/search.py +++ b/search.py @@ -1,5 +1,6 @@ from application.db import Session, Recipe, Ingredient, Trunk +import application.db2 as db from flask import g import nltk as nltk from nltk.corpus import stopwords @@ -21,6 +22,20 @@ def fastes(inputArr): indx[str(recipe_id[0])] += 1 return(indx) +def search2(inputArr): + indx = {} + dbSession = db.Session() + for inpu in inputArr: + ids = [] + for recipe in dbSession.query(db.Trunk.ingredients.recipe).filter(db.Trunk.name == inpu).all(): + + if str(recipe.recipe_id) not in indx: + indx[str(recipe.recipe_id)] = 0 + + indx[str(recipe.recipe_id)] += 1 + return(indx) + + def stemInput(inputArr): inputArr2 = []