Presentation is loading. Please wait.

Presentation is loading. Please wait.

KWIC example The KWIC [key word in context] system accepts an ordered set of lines; each line is an ordered set of words, and each word is an ordered set.

Similar presentations


Presentation on theme: "KWIC example The KWIC [key word in context] system accepts an ordered set of lines; each line is an ordered set of words, and each word is an ordered set."— Presentation transcript:

1 KWIC example The KWIC [key word in context] system accepts an ordered set of lines; each line is an ordered set of words, and each word is an ordered set of characters. Any line may "circularly shifted" by repeatedly removing the first word and appending it at the end of the line. The KWIC index system outputs a list of all circular shifts of all lines in alphabetical order.

2 KWIC example  Input: strings, each of which consists of several words. Clouds are white. Ottawa is beautiful.  Output: a sorted list of all orderings of each input string. are white Clouds beautiful Ottawa is Clouds are white is beautiful Ottawa Ottawa is beautiful white Clouds are

3 Solution 1: Main Program/Subroutine Master control InputOutput Alphabetize Circ shift CharactersIndexAlphabetized index

4 Solution 1: Main Program/Subroutine  With shared memory  Master control calls Input, which inputs and stores characters CircShift, which reads characters/writes index Alphabetize, which alphabetizes index Output, which prints alphabetized index

5 Solution 1: Main Program/Subroutine  Advantages Efficient representation of data (since they are shared)  Disadvantages Changes to data format affects several modules. Difficulty to implement changes/enhancements in the overall processing algorithm. Don't support reuse.

6 Solution 2: Abstract Data Types Set char Char Word Set char Char Setup Word alph i-th Master control InputOutput Characters Circular shift Alphabetic shift

7 Solution 2: Abstract Data Types  Data is not shared anymore encapsulated in objects  Advantages Changes in algorithms and data representation in individual components don't affect other components. More reuse support.  Drawbacks Changes in functionality can be difficult might involve components modification or addition

8 Solution 3: Implicit Invocation InsertDeletei-th Master control InputOutput Lines Shifted lines Alphabetize Circ shift InsertDeletei-th

9 Solution 3: Implicit Invocation Calls to circular shift and alphabetizer are implicit, and are the result of inserting lines. Data accessed abstractly Advantages Supports functional enhancements. Changes to data don't affect computation. Supports reuse. Drawbacks Difficult to control processing order. Tend to use more space than other solutions.

10 Solution 4: Pipes and Filters Circular ShiftAlphabetizer input linesshifted linesshifted/sorted lines

11 Solution 4: Pipes and Filters  Advantages Maintains intuitive flow of processing. Supports reuse. Supports addition of functionality. Supports modifications.  Drawbacks Virtualy impossible to support an interactive system. Inefficient use of space - each filter must copy all data to its output.

12 Comparison Change in algorithm Change in data representation Change in function Performance Reuse SharedAbstractImplicitPipe and datadata typeinvocationfilter --++ -+-- --++ ++-- -+-+


Download ppt "KWIC example The KWIC [key word in context] system accepts an ordered set of lines; each line is an ordered set of words, and each word is an ordered set."

Similar presentations


Ads by Google