comparison src/wikigraph/LinkConvertGraph.java @ 21:f9ef906676eb draft

modify LinkToNode.java
author one
date Tue, 28 Aug 2012 14:04:15 +0900
parents 2c3a10047ec6
children fbf0cf550b06
comparison
equal deleted inserted replaced
20:2c3a10047ec6 21:f9ef906676eb
92 92
93 LinkConvertGraph lcg; 93 LinkConvertGraph lcg;
94 94
95 95
96 try { 96 try {
97 97
98 lcg = new LinkConvertGraph(filename); 98 lcg = new LinkConvertGraph(filename);
99 99
100 lcg.parseXml(); 100 lcg.parseXml();
101 // lcg.printHash(); 101 // lcg.printHash();
102 102
103 FileOutputStream fos = new FileOutputStream("./resource/wikilink.log"); 103 FileOutputStream fos = new FileOutputStream("./resource/wikilink.log");
104 lcg.printHash(fos); 104 lcg.printHash(fos);
105 105
106 HashMap<String,HashSet<String>> hash = lcg.getHash(); 106 HashMap<String,HashSet<String>> hash = lcg.getHash();
107 107
108 GraphDatabaseService graphDb = new EmbeddedGraphDatabase("wikiLinkDB_"); 108 GraphDatabaseService graphDb = new EmbeddedGraphDatabase("wikiLinkDB");
109 LinkToNode ltn = new LinkToNode(graphDb); 109 LinkToNode ltn = new LinkToNode(graphDb);
110 110
111 Transaction tx = graphDb. beginTx(); 111 Transaction tx = graphDb. beginTx();
112
113 Node delNode = graphDb.getNodeById(0);
114 delNode.delete();
112 115
113 for (Map.Entry<String,HashSet<String>> map : hash.entrySet()) { 116 for (Map.Entry<String,HashSet<String>> map : hash.entrySet()) {
114 String pageTitle = map.getKey(); 117 String pageTitle = map.getKey();
115 118
116 Node pageNode; 119 Node pageNode;
122 125
123 for (String linkPageTitle : map.getValue()) { 126 for (String linkPageTitle : map.getValue()) {
124 Node linkNode; 127 Node linkNode;
125 if ( ltn.getId(linkPageTitle) == null) { 128 if ( ltn.getId(linkPageTitle) == null) {
126 linkNode = ltn.createNodeWithPageTitle(linkPageTitle); 129 linkNode = ltn.createNodeWithPageTitle(linkPageTitle);
130 ltn.setPageRank(linkNode, 0);
127 } else { 131 } else {
128 linkNode = ltn.getNode(linkPageTitle); 132 linkNode = ltn.getNode(linkPageTitle);
129 } 133 }
130 ltn.setHasLink(pageNode, linkNode); 134 ltn.setHasLink(pageNode, linkNode);
131 135