SearchOperations
Class Query

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by java.util.TreeSet
              extended by TextDatabase.KeywordTreeSet
                  extended by SearchOperations.Query
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.Set, java.util.SortedSet

public class Query
extends KeywordTreeSet

Implementation of the user's query

See Also:
Serialized Form

Field Summary
static char[] activeOperators
          Holds the operators the query can identify
 
Fields inherited from class TextDatabase.KeywordTreeSet
_mostPopularKeyword
 
Constructor Summary
Query(java.lang.String Text)
          Initializes the query from a raw text expression
 
Method Summary
 boolean evaluate(boolean[] BooleanWeights)
          Evaluates the query by using the boolean weights provided by the document 1.
 java.lang.String getExpression()
          Gets the raw expression
 double getTermWeight(java.lang.String KeywordName, double inverseFrequency)
          Gets the weight of term for the specifed query QueryTermWeight = (0.5 + (0.5*term's normalized frequency(query))) * term's inverse document frequency
 void setExpression(java.lang.String Text)
          Set's the query expression
 
Methods inherited from class TextDatabase.KeywordTreeSet
addKeyword, contains, getKeyword, getMostPopularKeywordFrequency, getNormalizedFrequency, getNormalizedFrequency
 
Methods inherited from class java.util.TreeSet
add, addAll, clear, clone, comparator, contains, first, headSet, isEmpty, iterator, last, remove, size, subSet, tailSet
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Field Detail

activeOperators

public static final char[] activeOperators
Holds the operators the query can identify

Constructor Detail

Query

public Query(java.lang.String Text)
Initializes the query from a raw text expression

Method Detail

setExpression

public void setExpression(java.lang.String Text)
Set's the query expression


getExpression

public java.lang.String getExpression()
Gets the raw expression


evaluate

public boolean evaluate(boolean[] BooleanWeights)
Evaluates the query by using the boolean weights provided by the document 1. For every document we get a boolean weight claiming wheter or not it contains a keyword. 2. In the raw expression we replace each keyword for the proper weight 3. The expression is evaluated by identifying each operator and replacing it and it's operands with the result of the evaluation. First we calculate the and operators and than the or operators. 4. In the end the length of the expression should be one. That one character holds the result of the expression.


getTermWeight

public double getTermWeight(java.lang.String KeywordName,
                            double inverseFrequency)
Gets the weight of term for the specifed query QueryTermWeight = (0.5 + (0.5*term's normalized frequency(query))) * term's inverse document frequency