Skip to content

Commit

Permalink
remove all_words, all_strings lists from QueryGoal
Browse files Browse the repository at this point in the history
- only used for text highlighting in parser text (ViewFile.html) which can be done with include_strings only
  • Loading branch information
reger committed Sep 2, 2013
1 parent 169ef89 commit 392174d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion htroot/yacysearchitem.java
Expand Up @@ -218,7 +218,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
prop.putHTML("content_publisher", result.publisher());
prop.putHTML("content_creator", result.creator());// author
prop.putHTML("content_subject", result.subject());
final List<String> query = theSearch.query.getQueryGoal().getAllStrings();
final List<String> query = theSearch.query.getQueryGoal().getIncludeStrings();
final StringBuilder s = new StringBuilder(query.size() * 20);
for (final String t: query) {
s.append('+').append(t);
Expand Down
25 changes: 8 additions & 17 deletions source/net/yacy/search/query/QueryGoal.java
Expand Up @@ -50,18 +50,16 @@ public class QueryGoal {

private String query_original;
private HandleSet include_hashes, exclude_hashes;
private final ArrayList<String> include_words, exclude_words, all_words;
private final ArrayList<String> include_strings, exclude_strings, all_strings;
private final ArrayList<String> include_words, exclude_words;
private final ArrayList<String> include_strings, exclude_strings;


public QueryGoal(HandleSet include_hashes, HandleSet exclude_hashes) {
this.query_original = null;
this.include_words = new ArrayList<String>();
this.exclude_words = new ArrayList<String>();
this.all_words = new ArrayList<String>();
this.include_strings = new ArrayList<String>();
this.exclude_strings = new ArrayList<String>();
this.all_strings = new ArrayList<String>();
this.include_hashes = include_hashes;
this.exclude_hashes = exclude_hashes;
}
Expand All @@ -72,10 +70,8 @@ public QueryGoal(String query_original, String query_words) {
this.query_original = query_original;
this.include_words = new ArrayList<String>();
this.exclude_words = new ArrayList<String>();
this.all_words = new ArrayList<String>();
this.include_strings = new ArrayList<String>();
this.exclude_strings = new ArrayList<String>();
this.all_strings = new ArrayList<String>();

// remove funny symbols
query_words = CharacterCoding.html2unicode(AbstractScraper.stripAllTags(query_words.toCharArray())).toLowerCase().trim();
Expand All @@ -87,11 +83,11 @@ public QueryGoal(String query_original, String query_words) {
}

// parse first quoted strings
parseQuery(query_words, this.include_strings, this.exclude_strings, this.all_strings);

parseQuery(query_words, this.include_strings, this.exclude_strings);
// .. end then take these strings apart to generate word lists
for (String s: this.include_strings) parseQuery(s, this.include_words, this.include_words, this.all_words);
for (String s: this.exclude_strings) parseQuery(s, this.exclude_words, this.exclude_words, this.all_words);
for (String s: this.include_strings) parseQuery(s, this.include_words, this.include_words);
for (String s: this.exclude_strings) parseQuery(s, this.exclude_words, this.exclude_words);

WordCache.learn(this.include_strings);
WordCache.learn(this.exclude_strings);
Expand All @@ -112,7 +108,7 @@ public QueryGoal(String query_original, String query_words) {
* sq = '\''
* dq = '"'
*/
private static void parseQuery(String s, ArrayList<String> include_string, ArrayList<String> exclude_string, ArrayList<String> all_string) {
private static void parseQuery(String s, ArrayList<String> include_string, ArrayList<String> exclude_string) {
while (s.length() > 0) {
// parse query
int p = 0;
Expand All @@ -136,7 +132,6 @@ private static void parseQuery(String s, ArrayList<String> include_string, Array
p++; // go behind the stop character (eats up space, sq and dq)
s = p < s.length() ? s.substring(p) : "";
if (string.length() > 0) {
if (!all_string.contains(string)) all_string.add(string);
if (inc) {
if (!include_string.contains(string)) include_string.add(string);
} else {
Expand Down Expand Up @@ -186,11 +181,7 @@ public boolean matches(String text) {
for (String e: this.exclude_strings) if (t.indexOf(e.toLowerCase()) >= 0) return false;
return true;
}

public ArrayList<String> getAllStrings() {
return all_strings;
}


public void filterOut(final SortedSet<String> blueList) {
// filter out words that appear in this set
// this is applied to the queryHashes
Expand Down

0 comments on commit 392174d

Please sign in to comment.