public static Map<String, Set<Integer>> getLinkedPageIdMap(String pathCategorylinks, 
			String pathCategory, Set<Category> categorySet)
					throws FileNotFoundException, IOException {
		// Prepare map with category titles
		Map<String,String> reverseCategoryTitleMap = new HashMap<String,String>();
		for(Category category : categorySet) {
			// TODO: this only works for one level of subcategories
			reverseCategoryTitleMap.put(category.getTitle(),category.getParentCategoryTitle());
		}		

		// Prepare return map
		Map<String, Set<Integer>> returnMap = new HashMap<String, Set<Integer>>();
		
		String marker = "INSERT INTO `categorylinks` VALUES";
		Pattern tuplePattern = Pattern.compile("\\((?<from>\\d+?),\'(?<to>\\S+?)\',.+?,\'(?<type>\\w+?)\'\\)");
		
		// search through Wikipedia file
		try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(pathCategorylinks)))) {
			String line;
			int counter=0;
			while( (line = br.readLine()) != null && reverseCategoryTitleMap.size()>0) { 
    			counter++;
    			if(counter % 10 == 0) {
					System.out.print(".");
				}
				if(line.startsWith(marker)) {	// search for "INSERT INTO `categorylinks` VALUES"
					Matcher matcher = tuplePattern.matcher(line.substring(marker.length()));
	    			while (matcher.find()) {
	    				if(reverseCategoryTitleMap.keySet().contains(matcher.group("to"))) {
	    					// found an entry belonging to a category
    						if(matcher.group("type").compareTo("page")==0) {
    							// found a page belonging to a category
    							String parentCategoryTitle = reverseCategoryTitleMap.get(matcher.group("to"));
    							Set<Integer> idSet = null;
    							if(returnMap.containsKey(parentCategoryTitle)) {
    								idSet = returnMap.get(parentCategoryTitle);
    							} else {
    								idSet = new HashSet<Integer>();
    							}
    							// add id to parent
    							idSet.add(Integer.parseInt(matcher.group("from")));
    							returnMap.put(parentCategoryTitle, idSet);
//    							System.out.println(reverseCategoryTitleMap.get(matcher.group("to")) + " > " + matcher.group("to") + " > " + matcher.group("from"));
		    				}
	    				}
	    		    }
				}
			}
		}
		
		return returnMap;
	}