Implementation

 

Observation

From the chapters of book cis350, we see that every chapter HTML file has 2 logical part, the index part and the text part.

Implementation

From the previous design idea and the above observation, I determine the implementing logical to be:

Part I: Index analysis and tag_adding

From the leading No., we can extract structure of the sections and subsection. With these section structure information, we can get the logical level information, then translate the sections and subsections to corresponding level MWAC objects and insert the corresponding tags.
The difficulty of this part is how to recognize the beginning and endian of the index part.
 

Part II: Text analysis and tag_adding

When I analize the index I store the level information into a queue at the same time. Then I analysis the text part. With the level information, we can partition the text part into section and subsections, then translate these sections and subsections into MWAC objects, then insert the corresponding tags.
The main dificulty of this part is to precisely indentify the beginning and endian of each MWAC objects.
There are some parts of the text have misleading information(such as "1.1 Introduction" appears in a text paragraph.), this tool should not be fooled by these kind of misleading information.
 
 

The final algorithm:

 
TAGER:
{
    tags[]={"as","is","as","vs"}
    for i = 0 to 3 do
    {
        Index analysis and tag_adding
        Text analysis and tag_adding
    }
}
 

An HTML file segment Example

 

<body bgcolor="#ffffff" text="#000000" link="#0000FF" Vlink="#660099">

 

<table id="pageTable" width="599" STYLE="position: relative; left: auto; top: auto;"><tr><td>

<nobr>

<div class=ts1p0><span class="ft0p1">Chapter 5.&nbsp; Stacks, Recursion and Backtracking </span></div>

<div class=ts1p2><span class="ft1p1">Frederick Thulin, Knowledge Systems Institute, USA (fthulin&#64;ksi.edu) </span></div>

<div class=ts1p4><span class="ft2p1"> </span></div>

<div class=ts1p5><span class="ft2p1">Chapter Outline </span></div>

<div class=ts1p7><span class="ft1p1"> </span></div>

<div class=ts1p8><span class="ft1p1">5.1.&nbsp; Stacks </span></div>

<div class=ts1p10><span class="ft1p1"> </span></div>

<div class=ts1p11><span class="ft1p1">5.1.1.&nbsp; The LIFO Nature of Stacks </span></div>

<div class=ts1p13><span class="ft1p1"> </span></div>

<div class=ts1p14><span class="ft1p1">5.1.2.&nbsp; Reversing with a Stack </span></div>

<div class=ts1p16><span class="ft1p1"> </span></div>

<div class=ts1p17><span class="ft1p1">5.1.3.&nbsp; Stack Operations </span></div>

<div class=ts1p19><span class="ft1p1"> </span></div>

<div class=ts1p20><span class="ft1p1">5.1.4.&nbsp; Contiguous Implementation </span></div>

<div class=ts1p23><span class="ft1p1"> </span></div>

<div class=ts1p24><span class="ft1p1">5.1.5.&nbsp; Linked Implementation </span></div>

<div class=ts1p26><span class="ft1p1">5.2.&nbsp; Recursion </span></div>

<div class=ts1p28><span class="ft1p1"> </span></div>

<div class=ts1p29><span class="ft1p1">5.2.1.&nbsp; Introduction </span></div>

<div class=ts1p31><span class="ft1p1"> </span></div>

<div class=ts1p32><span class="ft1p1">5.2.2.&nbsp; Procedure Calls and the Run&#45;Time Stack </span></div>

<div class=ts1p36><span class="ft1p1"> </span></div>

<div class=ts1p37><span class="ft1p1">5.2.3.&nbsp; Sum of the First n Positive Integers </span></div>

<div class=ts1p39><span class="ft1p1"> </span></div>

<div class=ts1p40><span class="ft1p1">5.2.4.&nbsp; Factorials </span></div>

<div class=ts1p42><span class="ft1p1"> </span></div>

<div class=ts1p43><span class="ft1p1">5.2.5.&nbsp; Collatz 3x+1 Problem </span></div>

<div class=ts1p45><span class="ft1p1"> </span></div>

<div class=ts1p46><span class="ft1p1">5.2.6.&nbsp; Greatest Common Divisor </span></div>

<div class=ts1p49><span class="ft1p1"> </span></div>

<div class=ts1p50><span class="ft1p1">5.2.7.&nbsp; Towers of Hanoi </span></div>

<div class=ts1p52><span class="ft1p1"> </span></div>

<div class=ts1p53><span class="ft1p1">5.2.8.&nbsp; Reversing a Line of Input </span></div>

<div class=ts1p55><span class="ft1p1">5.3.&nbsp; Backtracking </span></div>

<div class=ts1p57><span class="ft1p1"> </span></div>

<div class=ts1p58><span class="ft1p1">5.3.1.&nbsp; Introduction<span class="ft3p1"> </span></span></div>

<div class=ts1p60><span class="ft1p1"> </span></div>

<div class=ts1p61><span class="ft1p1">5.3.2.&nbsp; The Eight Queens Problem </span></div>

<div class=ts1p63><span class="ft1p1"> </span></div>

<div class=ts1p64><span class="ft1p1">5.3.3.&nbsp; Escape from a Maze </span></div>

<div class=ts1p66><span class="ft1p1">Exercises </span></div>

<div class=ts1p68><span class="ft0p1"> </span></div>

<div class=ts1p69><span class="ft0p1">5.1.&nbsp; Stacks </span></div>

<div class=ts1p71><span class="ft1p1"> </span></div>

<div class=ts1p72><span class="ft2p1">5.1.1.&nbsp; The LIFO Nature of Stacks </span></div>

<div class=ts1p74><span class="ft1p1"> </span></div>

<div class=ts1p75><span class="ft1p1">A stack is a data structure analogous to stacks encountered in everyday life.&nbsp; For example, </span></div>

<div class=ts1p77><span class="ft1p1">consider a stack of books on a desk.&nbsp; One may easily put a new book on top of the stack, and </span></div>

<div class=ts1p78><span class="ft1p1">one may easily remove the top book.&nbsp; Adding books to, or removing them from, the middle of </span></div>

<div class=ts1p79><span class="ft1p1">the stack may be perilous.&nbsp; In the stack data structure accessing items in the middle is </span></div>

<div class=ts1p81><span class="ft1p1">prohibited.&nbsp; Items may be added to or removed from only the top of the stack. </span></div>

<div class=ts1p83><span class="ft1p1"> </span></div>

<div class=ts1p84><span class="ft1p1">Saving an item on a stack is referred to as pushing the item, and retrieving an item is called </span></div>

<div class=ts1p86><span class="ft1p1">popping the item.&nbsp; Popping an item removes the item from the stack.&nbsp; Pushes and pops are done </span></div>

<div class=ts1p87><span class="ft1p1">at the top of the stack, which may be thought of as a distinguished end of the stack.&nbsp; This means </span></div>

<div class=ts1p88><span class="ft1p1">that if two items are pushed and then one popped, the second one pushed will be popped.&nbsp; This </span></div>

<div class=ts1p90><span class="ft1p1">order of data access is called last in, first out or LIFO access. </span></div>

<div class=ts1p92><span class="ft1p1"> </span></div>

<div class=ts1p93><span class="ft2p1">5.1.2.&nbsp; Reversing with a Stack </span></div>

<div class=ts1p95><span class="ft1p1"> </span></div>

<div class=ts1p96><span class="ft1p1">Suppose a sequence of items is presented and it is desired to reverse the sequence.&nbsp; Various </span></div>

<div class=ts1p97><span class="ft1p1">methods could be used and the beginning programmer usually will suggest a solution using an </span></div>

<div class=ts1p99><span class="ft1p1">array.&nbsp; A conceptually very simple solution, however, is based on using a stack.&nbsp; The LIFO </span></div>

<div class=ts1p100><span class="ft1p1">property of stack access guarantees the reversal. </span></div>

<div class=ts2p0><span class="ft0p2"> </span></div>

 

[Chang1] Dr. Chang, http://www.cs.pitt.edu/~chang/365/GB/t13g.htm
 
[Chang2] Shi-Kuo Chang, etc., "MAWC OPERATIONS FOR THE GROWING BOOK", http://www.cs.pitt.edu/~chang/bookds/gbieee.doc
 
[GB] http://www.cs.pitt.edu/~jung/GrowingBook
 
[Peter1] Peter Brusilovsky, CMU, "Methods and techniques of adaptive hypermedia", User Modeling and User Adapted Interaction, 1996, v 6, n 2-3, pp 87-129 [Paul1] Paul De Bra, John Eklund, etc., "Adaptive Hypermedia: Purpose, Methods, and Techniques", 1999, 199 - 200 Series-Proceeding-Article , Darmstadt, Germany Categories