|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectMinimumSnippet
public class MinimumSnippet
When you do a web search, the results page shows you a snippet for each result, showing you search terms in context. For purposes of this project, a snippet is a subsequence of a document that contains all the search terms. For this project, you will write code that, given a document (a sequence of words) and set of search terms, find the minimal length subsequence in the document that contains all of the search terms. If there are multiple subsequences that have the same minimal length, you may return any one of them.
| Constructor Summary | |
|---|---|
MinimumSnippet(java.lang.Iterable<java.lang.String> document,
java.util.List<java.lang.String> terms)
Compute minimum snippet. |
|
| Method Summary | |
|---|---|
boolean |
foundAllTerms()
Returns whether or not all terms were found in the document. |
int |
getEndingPos()
Return the ending position of the snippet |
int |
getLength()
Return total number of elements contained in the snippet. |
int |
getPos(int index)
Returns the position of one of the search terms as it appears in the original document |
int |
getStartingPos()
Return the starting position of the snippet |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MinimumSnippet(java.lang.Iterable<java.lang.String> document,
java.util.List<java.lang.String> terms)
document - The Document is an Iterableterms - The terms you need to look for. The terms will be unique
(e.g., no term will be repeated), although you do not need to
check for that. There should always be at least one term and
your code should
throw an IllegalArgumentException if "terms" is
empty.| Method Detail |
|---|
public boolean foundAllTerms()
public int getStartingPos()
public int getEndingPos()
public int getLength()
public int getPos(int index)
index - index of the term in the original list of terms. For example, if index
is 0 then the method will return the position (in the document) of the first search term.
If the index is 1, then the method will return the position (in the document) of the
second search term. Etc.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||