Your Name 3 年之前
父節點
當前提交
214afb0a05
共有 1 個文件被更改,包括 9 次插入4 次删除
  1. 9 4
      choozmo/igool/igtree.py

+ 9 - 4
choozmo/igool/igtree.py

@@ -41,15 +41,20 @@ import pickle
 #kw='電視牆'
 #kw='系統櫃'
 #kw='收納'
-kw='巧克力'
+#kw='軟糖'
+kw='手工餅乾'
 
 #kw='廣告投放策略'
 
+#s={'suggests':[]}
 s = suggests.suggests.get_suggests(kw, source='google')
-G = nx.Graph()
-#G = pickle.load( open( "gs2.p", "rb" ) )
+#G = nx.Graph()
+G = pickle.load( open( "gs2.p", "rb" ) )
 
 
+#G.remove_node('巧克力囊腫')
+#G.remove_node('巧克力雲莊')
+
 for sg in s['suggests']:
     G.add_edge(kw,sg,weight=1)
 
@@ -59,7 +64,7 @@ for sg in s['suggests']:
     for elmt in s2['suggests']:
         G.add_edge(sg,elmt,weight=1)
 
-
+G.remove_nodes_from(list(nx.isolates(G)))
 G.remove_edges_from( list(nx.selfloop_edges(G)))
 
 pickle.dump( G, open( "gs2.p", "wb" ) )