/var/log/messages

Aug 6, 2018 - 1 minute read - Comments - recommendation

Context Aware Recommendation (2)

昨日エントリの件、レコメンドなクエリを投げても 0 件とのことで色々確認してみるにデータ投入クエリがエンバグしまくってることが分かった次第。

修正版を以下に引用しておきます。

CREATE CONSTRAINT ON ( rest:Restaurant ) ASSERT rest.pid IS UNIQUE;
CREATE CONSTRAINT ON ( company:Company ) ASSERT company.name IS UNIQUE;
CREATE CONSTRAINT ON ( usr:User ) ASSERT usr.UserID IS UNIQUE;

//Import users.............

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM
"file:///Users_50.csv"
AS line
WITH line

MERGE (company:Company {name: "Ameyasoft"})
MERGE (usr:User {uid: line.UserID})
CREATE (company)-[:USER_PROFILE]->(usr)

CREATE (prsnl:Personal {name: "Personal"})
CREATE (usr)-[:PERSONAL]->(prsnl)

CREATE (intrst:Interest {attr9: line.Interest})
CREATE (prsnl)-[:INTEREST]->(intrst)

CREATE (prsnlt:Persnlty {attr10: line.Personality})
CREATE (prsnl)-[:USER_PROFILE]->(prsnlt)

CREATE (trnsp:Transp {attr5: line.Transport})
CREATE (prsnl)-[:TRANSPORT]->(trnsp)

CREATE (marrd:Married {attr6: line.Marital_Status})
CREATE (prsnl)-[:MARITAL_STATUS]->(marrd)


CREATE (brthyr:Byear {attr8: line.Birth_Year})
CREATE (prsnl)-[:BIRTH_YEAR]->(brthyr)


CREATE (relgn:Religion {attr11: line.Religion})
CREATE (prsnl)-[:RELIGION]->(relgn)


CREATE (habit:Habit {name: "Habits"})
CREATE (usr)-[:HABITS]->(habit)

CREATE (smkr:Smoker {attr1: line.Smoker})
CREATE (habit)-[:SMOKER]->(smkr)

CREATE (drnk:Drink {attr2: line.Drink_Level})
CREATE (habit)-[:DRINK_LEVEL]->(drnk)

CREATE (dress:Dress {attr3: line.Dress_Pref})
CREATE (habit)-[:DRESS]->(dress)

CREATE (hijos:Hijos {attr7: line.Hijos})
CREATE (habit)-[:HIJOS]->(hijos)

CREATE (ambnc:Ambnce {attr4: line.Ambience})
CREATE (habit)-[:AMBIENCE]->(ambnc)

CREATE (actv:Activity {attr12: line.Activity})
CREATE (habit)-[:USER_PROFILE]->(actv)

CREATE (budgt:Budget {attr13: line.Budget})
CREATE (habit)-[:BUDGET]->(budgt)

CREATE (m:Cuisine {name: line.UserID})
CREATE (usr)-[:CUISINE]->(m)

;

//Import user choices of cuisines.......

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM
"file:///UCuisine.csv"
AS line
WITH line

CREATE (f:Food {name: line.Cuisine})
WITH line, f

MATCH (n:User {uid:line.UserID})-[:CUISINE]->(m:Cuisine {name: line.UserID})
//MERGE (n)-[:CUISINE]->(m)-[:LIKES]->(f)
CREATE (m)-[:LIKES]->(f)
;

//Import restaurants.............

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM
"file:///Restaurants.csv"
AS line
WITH line

MERGE (company:Company {name: "Ameyasoft"})
MERGE (rest:Restaurant {pid: toInt(line.PlaceID), name: line.Name})
CREATE (company)-[:RESTAURANT]->(rest)

//CREATE (addr:Addrs {street: line.Address, city: line.City, state: line.State, zip: line.Zip, country: line.Country})
CREATE (addr:Addrs {street: line.Address, city: line.City, state: line.State, country: line.Country})
CREATE (rest)-[:ADDRESS]->(addr)

CREATE (featrs:Features {alcohol: line.Alcohol, smoking: line.Smoking_Area, dress: line.Dress_Code, price: line.Price, ambience: line.Ambience})
CREATE (rest)-[:FEATURES]->(featrs)

;

//Import restaurant cuisines.......

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM
"file:///RestCuisine.csv"
AS line
WITH line

MATCH (n:Restaurant {pid: toInt(line.PlaceID)})
MERGE (n)-[:REST_CUISINE]->(cuse:Cusine {name: line.Cuisine});

context aware recommendation Context Aware Recommendation (3)

comments powered by Disqus