@Override public void startElement( String nameSpaceURI, String localName, String rawName, Attributes attrs) throws SAXException { if (idToFileMatches.isEmpty()) return; if (rawName == null) { rawName = localName; } String elt_name = rawName; if (elt_name.equals("files")) { String fileCount = attrs.getValue("", "totalFileCount"); if (fileCount != null) totalFileCount = Integer.parseInt(fileCount); Logger.minor(this, "totalfilecount = " + totalFileCount); } if (elt_name.equals("file")) { try { String id = attrs.getValue("id"); ArrayList<FileMatch> matches = idToFileMatches.get(id); if (matches != null) { for (FileMatch match : matches) { String key = attrs.getValue("key"); int l = attrs.getLength(); String title = null; int wordCount = -1; if (l >= 3) { try { title = attrs.getValue("title"); } catch (Exception e) { Logger.error(this, "Index Format not compatible " + e.toString(), e); } try { String wordCountString = attrs.getValue("wordCount"); if (wordCountString != null) { wordCount = Integer.parseInt(attrs.getValue("wordCount")); } } catch (Exception e) { // Logger.minor(this, "No wordcount found " + e.toString(), e); } } for (FindRequest req : match.word.searches) { Set<TermPageEntry> result = req.getUnfinishedResult(); float relevance = 0; if (logDEBUG) Logger.debug( this, "termcount " + (match.termpositions == null ? 0 : match.termpositions.size()) + " filewordcount = " + wordCount); if (match.termpositions != null && match.termpositions.size() > 0 && wordCount > 0) { relevance = (float) (match.termpositions.size() / (float) wordCount); if (totalFileCount > 0 && match.word.inWordFileCount > 0) relevance *= Math.log((float) totalFileCount / (float) match.word.inWordFileCount); if (logDEBUG) Logger.debug( this, "Set relevance of " + title + " to " + relevance + " - " + key); } TermPageEntry pageEntry = new TermPageEntry( req.getSubject(), relevance, new FreenetURI(key), title, match.termpositions); result.add(pageEntry); // Logger.minor(this, "added "+inFileURI+ " to "+ match); } } } } catch (Exception e) { Logger.error( this, "File id and key could not be retrieved. May be due to format clash", e); } } }