public void matchFound(Scanner s, TreeNode match_item) { // add the match item to our matches list this.matches.AddLast(match_item); TreeFlag f = match_item.getFlags(); this.totalBadness += f.getBadness(); this.totalGoodness += f.getGoodness(); this.totalPostbad += f.getPostbadness(); // if the match is marked bad, add the category to our bad category list if (f.getBadness() > 0) { this.badCategories.AddLast(f.getCategory()); } // if the match is marked good, add the category to our good category list if (f.getGoodness() > 0) { this.goodCategories.AddLast(f.getCategory()); } // if the match is marked postbad, add the category to our postbad category list if (f.getPostbadness() > 0) { this.postbadCategories.AddLast(f.getCategory()); } }
public int quantifyResultsForUrl(String url, KernelResults hostname_results, KernelResults url_results) { int result = 0; bool is_good = false; bool is_bad = false; bool is_unknown = true; // if the hostname is known bad then we are bad if (hostname_results.getTotalBadness() > 0) { is_bad = true; is_good = false; is_unknown = false; } // if the hostname is known good then we are good if (hostname_results.getTotalGoodness() > 0) { is_good = true; is_bad = false; is_unknown = false; } // if the hostname or the full url is known postbad then we are bad if (hostname_results.getTotalPostbad() > 0 || url_results.getTotalPostbad() > 0) { is_bad = true; is_good = false; is_unknown = false; } // if the site is not yet known then check the rest of the url if (is_unknown) { // if the rest of the url is known bad then we are bad if (url_results.getTotalBadness() > 0) { is_bad = true; is_good = false; is_unknown = false; } // if the rest of the url is known postbad then we are bad if (url_results.getTotalPostbad() > 0) { is_bad = true; is_good = false; is_unknown = false; } if (url_results.getTotalGoodness() > 0) { foreach (TreeNode i in url_results.getMatches()) { TreeFlag f = i.getFlags(); if (f.getGoodness() > 0) { String extracted = i.extractWord(); if (url == extracted || url == "http://" + extracted || url == "http://www." + extracted) { is_bad = false; is_good = true; is_unknown = false; break; } } } } } if (is_bad) { result = -1; } if (is_good) { result = 1; } return(result); }