Difference: SdProject2 (1 vs. 9)

Revision 92017-03-01 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="Spring2017"

Line: 11 to 11
 

Goal

Changed:
<
<
To take the code from project one that allows the looking up of words in Shakespeare though an inverted index, and create a web page version. Reather then write this from scratch you will reuse and modify the code provided for the US Census name server program.
>
>
To take the code from project one that allows the looking up of words in Shakespeare though an inverted index, and create a web page version. Rather then write this from scratch you will reuse and modify the code provided for the US Census name server program.
 

US Census Name data program

You have been given the code to look up names in the US Census data. The architecture of the solution is seen below:

Revision 82017-02-17 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="Spring2017"

Line: 53 to 55
 

Create a new project

You will need to make a copy of the nameserver folder to use as the wtarting point for the new Shakespeare project. From your main directory make a copy:

Changed:
<
<
cd ~

>
>
cd ~

 cp -r namesclientserver shakeproject
Added:
>
>
 You will then need to change the file names, and then change the Makefile to make the changes in the filenames. You are required to use a makefile for this project.

Communication through Fifo's

Line: 135 to 139
  Below is a list of features you can put in your program, along with the points. Notice that people with Data Structures must do more than studnets with only the introduction course to get 100 points (the perfect score) on the program. If you do more than 100 points, you getr extra credit.
Changed:
<
<
Requirement Data Structures Intro Prog Done
Program displays matching lines for each word entered on the web page* 40 50  
Well designed User Interface* 20 20  
Program broken up into functionally cohesive functions* 10 20  
Program has meaningful comments, good variable names, and good formatting* 10 10  
Program uses appropriate classes 10 10  
Program highlights the words as bold in the output. 10 10  
Program allows the seraching for two words on the same line. 10 20  
Program shows book that each match is found in (show book name only once per book) 10 20  
>
>
Requirement Data Structures Intro Prog Comments Score
Program displays matching lines for each word entered on the web page* 40 50    
Well designed User Interface* 20 20    
Program broken up into functionally cohesive functions* 10 20    
Program has meaningful comments, good variable names, and good formatting* 10 10    
Program uses appropriate classes 10 10    
Program highlights the words as bold in the output. 10 10    
Program allows the searching for two words on the same line. 10 20    
Program shows book that each match is found in (show book name only once per book) 10 20    
 *These are required in order to get extra credit.

Turn in

Added:
>
>
  1. The program must be runnable. You must run the server with the "nohup ./shakespeareserver &" command (use your program name).
 
  1. All source files you authored
  2. A writeup with the table above, and an indicated of which was included. Paste table into Moodle text field, and put X's in to options you attempted. Also include a statement of the highest computer science course you have taken.
  3. Several runs showing all features.

Revision 72017-02-12 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="Spring2017"

Line: 52 to 50
 
  1. Make the project: make
  2. Run the server: ./nameserver
  3. Go to your folder with a browser, and open name_stats_ajax.html
Added:
>
>

Create a new project

You will need to make a copy of the nameserver folder to use as the wtarting point for the new Shakespeare project. From your main directory make a copy:

cd ~
cp -r namesclientserver shakeproject
You will then need to change the file names, and then change the Makefile to make the changes in the filenames. You are required to use a makefile for this project.
 

Communication through Fifo's

The Fifos are special communication files that allow the CGI program to talk to the Name Server. This must be changed or we will all use the same Fifo's, and they will interfere with each other.

Line: 116 to 122
 
  1. Modify the testclient.cpp file to test out the server.
  2. Modify the the HTML program (renamed from name_stats_ajax.html) to send a request with a single word, and then display the results after calling the CGI program.
  3. Modify the CGI program (renamed from namefetchajax.cpp) to receive a word from the web page, and send it to the name server through the Fifo. Then it will recieve the matching lines back, and send them to the web page.
Added:
>
>

Running the sever in the background

When you turn in your Shakespeare lab please set your server program to run continuously in the background so I can test it out. Assuming the name of your server is shakeserver do the following command:

nohup ./shakeserver &

The nohup command makes sure the program will continue to run after you log out. The & will make the program run in the background.

Don't run this way until the program is running reliably and is well tested.

 

Grading

Below is a list of features you can put in your program, along with the points. Notice that people with Data Structures must do more than studnets with only the introduction course to get 100 points (the perfect score) on the program. If you do more than 100 points, you getr extra credit.

Revision 62017-02-07 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="Spring2017"

Line: 106 to 109
 You will need to make a copy of the namesclientserver folder with a new name, and copy the file over
  1. Go to your home directory: cd ~
  2. From your home directory make a new folder: mkdir project2
Changed:
<
<
  1. Copy the contents of the demo names system to the folder: cp namesclientserver/ project2/*
>
>
  1. Copy the contents of the demo names system to the folder: cp namesclientserver/* project2/
 Next you will need to modify the program to serve up Shakespeare matches
  1. Rename the files as appropriate, change the Makefile to reflect these changes
  2. Change the server program (renames from nameserver.cpp) to receive a single word, and return a series of matching lines. Remove the name maps, replace with the shakespeare map.

Revision 52017-02-06 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="Spring2017"

Line: 19 to 19
 NamesWebArchtecture.png

The code for this US Census Name Data lookup system is located on cslab.kenyon.edu in the folder: /home/class/SoftDev/namesclientserver

Added:
>
>

Copy the program to your folder

  1. Go to /home/class/SoftDev/ folder
  2. Copy the directory to your folder: cp -r namesclientserver ~
  3. Go to your folder cd ~
  4. Go to the new project folder: cd namesclientserver
 

Change the names

Changed:
<
<
You will need to change the programs in three files to make it work correctly for you.
>
>
You will need to change the programs in three files to make it work correctly for you. You can use textwrangler or notepad++
 
1. Change the Makefile

Copy this project into a new folder in your folder. Then change the "user= skon" in the Makefile to be "user=username" where username is your server username.

Line: 38 to 43
 
const string SIG = "Skon_";
Changed:
<
<
So that Skon is your username.
>
>
So that Skon is changed to you username.

Run the program

To run the system go to the project folder (see above) in a ssh terminal.

  1. Make the project: make
  2. Run the server: ./nameserver
  3. Go to your folder with a browser, and open name_stats_ajax.html
 

Communication through Fifo's

The Fifos are special communication files that allow the CGI program to talk to the Name Server. This must be changed or we will all use the same Fifo's, and they will interfere with each other.

Changed:
<
<
The CGI program is called from the Apache2 web server, so it must be in a special folder where web programs are allowed to run. This is the "/usr/lib/cgi-bin/" dolder. The program running the lookups with the inverted index can be located in your own directory.
>
>
The CGI program is called from the Apache2 web server, so it must be in a special folder where web programs are allowed to run. This is the "/usr/lib/cgi-bin/" folder. The program running the lookups with the inverted index can be located in your own directory.
  Communication between the CGI program that is called from the web server to the name server program is enabled by the FiFo communications object. This is a interprocess communication component that utilizes Linux system "pipes".
Line: 78 to 89
 } %ENDCODE%
Added:
>
>
Fifo Use

The fifo's in the sample program for the US census senda single request, and waits for a single response, which is a comma delimited list of 30 values. For example, if the user request the name Smith, the server responds with:

SHON,0.004,1208,SID,0.004,1199,SIDNEY,0.052,274,SILAS,0.009,719,SIMON,0.026,404,SOL,0.005,1050,SOLOMON,0.013,592,SON,0.012,608,SONNY,0.008,772,SPENCER,0.030,384

For this project what is returned is MUCH larger, for example the work king returns 3174's lines. The problem is that the fifo's can only handle 2000 characters at a time. The solution? You will need to send one line at a time back from the server to the client. This can be done with loop on both sides, with the server sending the lines, and the client receiving them, and then sending the, to the web page with a cout. However, the client need to know when the server is done sending. This can be done by sending a unique string that will never be in the data. Something like $END will work. Thus the client loops receiving strings until the server sends a $END.

Another problem is that the separation of the lines into separate lines in the bowser screens. An easy solution is the insert a between every line. This will cause the browser to place each line on a separate line.

 

Shakespeare Program

In project 1 you created code to lookup words in Shakespeare. You will combine that code with the code from this US Name data system to make a web version of your Shakespeare lookup program.

Deleted:
<
<
Method
  1. Modify the the HTML program (name_stats_ajax.html) to request a word, and display the results after callin the CGI program.
  2. Modify the name server program (nameserver.cpp) to serve up Line from Shakespreare when a word is sent through the Fifo.
  3. Modify the CGI program (namefetchajax.cpp) to receive a word from the web page, and send it to the name server through the Fifo. Then it will recieve the matching lines back, and send them to the web page.
 
Changed:
<
<

Assignment

>
>
You will need to make a copy of the namesclientserver folder with a new name, and copy the file over
  1. Go to your home directory: cd ~
  2. From your home directory make a new folder: mkdir project2
  3. Copy the contents of the demo names system to the folder: cp namesclientserver/ project2/*
Next you will need to modify the program to serve up Shakespeare matches
  1. Rename the files as appropriate, change the Makefile to reflect these changes
  2. Change the server program (renames from nameserver.cpp) to receive a single word, and return a series of matching lines. Remove the name maps, replace with the shakespeare map.
  3. Modify the testclient.cpp file to test out the server.
  4. Modify the the HTML program (renamed from name_stats_ajax.html) to send a request with a single word, and then display the results after calling the CGI program.
  5. Modify the CGI program (renamed from namefetchajax.cpp) to receive a word from the web page, and send it to the name server through the Fifo. Then it will recieve the matching lines back, and send them to the web page.

Grading

  Below is a list of features you can put in your program, along with the points. Notice that people with Data Structures must do more than studnets with only the introduction course to get 100 points (the perfect score) on the program. If you do more than 100 points, you getr extra credit.

Requirement Data Structures Intro Prog Done
Program displays matching lines for each word entered on the web page* 40 50  
Changed:
<
<
Input and output is well designed and formatted* 20 20  
>
>
Well designed User Interface* 20 20  
 
Program broken up into functionally cohesive functions* 10 20  
Program has meaningful comments, good variable names, and good formatting* 10 10  
Program uses appropriate classes 10 10  
Program highlights the words as bold in the output. 10 10  
Program allows the seraching for two words on the same line. 10 20  
Changed:
<
<
Program shows book that each match is found in 10 20  
>
>
Program shows book that each match is found in (show book name only once per book) 10 20  
 *These are required in order to get extra credit.

Turn in

  1. All source files you authored

Revision 42017-02-04 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="Spring2017"

Project 2

Shakespeare Lookup from Web Page
Changed:
<
<
Due: February 6 - 11:55 pm
>
>
Due: February 10 - 11:55 pm
 Moodle Link
Screen_Shot_2017-01-26_at_9.14.36_AM.png shake.gif

Revision 32017-01-27 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="Spring2017"

Line: 34 to 35
 so that skon is now your username. This makes sure your code is copied to the right directories, and with the correct names.
3. Change the Fifo names
Changed:
<
<
In figo.h change line 33:
>
>
In fifo.h change line 33:
 
const string SIG = "Skon_";

Revision 22017-01-26 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="Spring2017"
Added:
>
>

 

Project 2

Shakespeare Lookup from Web Page
Due: February 6 - 11:55 pm
Changed:
<
<
Moodle Link
>
>
Moodle Link
Screen_Shot_2017-01-26_at_9.14.36_AM.png shake.gif
 

Goal

To take the code from project one that allows the looking up of words in Shakespeare though an inverted index, and create a web page version. Reather then write this from scratch you will reuse and modify the code provided for the US Census name server program.

Line: 90 to 92
 
Requirement Data Structures Intro Prog Done
Program displays matching lines for each word entered on the web page* 40 50  
Changed:
<
<
Input and output is well designed and formatted* 10 20  
>
>
Input and output is well designed and formatted* 20 20  
 
Program broken up into functionally cohesive functions* 10 20  
Program has meaningful comments, good variable names, and good formatting* 10 10  
Program uses appropriate classes 10 10  
Changed:
<
<
Program highlights the words as bold in the output. 10 10  
Program gives you the number of matches 20 20  
Program reads file into program, and works on an array (large string) (mutually exclusive with above) 5 10  
Program shows book that each match is found in 20 20  
>
>
Program highlights the words as bold in the output. 10 10  
Program allows the seraching for two words on the same line. 10 20  
Program shows book that each match is found in 10 20  
 *These are required in order to get extra credit.

Turn in

  1. All source files you authored
Line: 105 to 106
 
  1. Several runs showing all features.

META FILEATTACHMENT attachment="NamesWebArchtecture.png" attr="" comment="" date="1485405384" name="NamesWebArchtecture.png" path="NamesWebArchtecture.png" size="59259" user="JimSkon" version="3"
Added:
>
>
META FILEATTACHMENT attachment="shake.gif" attr="" comment="" date="1485440176" name="shake.gif" path="shake.gif" size="37508" user="JimSkon" version="1"
META FILEATTACHMENT attachment="Screen_Shot_2017-01-26_at_9.14.36_AM.png" attr="" comment="" date="1485440198" name="Screen_Shot_2017-01-26_at_9.14.36_AM.png" path="Screen_Shot_2017-01-26_at_9.14.36_AM.png" size="317818" user="JimSkon" version="1"

Revision 12017-01-26 - JimSkon

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="Spring2017"

Project 2

Shakespeare Lookup from Web Page
Due: February 6 - 11:55 pm

Moodle Link

Goal

To take the code from project one that allows the looking up of words in Shakespeare though an inverted index, and create a web page version. Reather then write this from scratch you will reuse and modify the code provided for the US Census name server program.

US Census Name data program

You have been given the code to look up names in the US Census data. The architecture of the solution is seen below:

NamesWebArchtecture.png

The code for this US Census Name Data lookup system is located on cslab.kenyon.edu in the folder: /home/class/SoftDev/namesclientserver

Change the names

You will need to change the programs in three files to make it work correctly for you.

1. Change the Makefile

Copy this project into a new folder in your folder. Then change the "user= skon" in the Makefile to be "user=username" where username is your server username.

2. Change the reference to the CGI program in the HTML file

In name_stats_ajax.html change the line:

     XMLHttp.open("GET", "/cgi-bin/skon_namefetchajax.cgi?"

so that skon is now your username. This makes sure your code is copied to the right directories, and with the correct names.

3. Change the Fifo names

In figo.h change line 33:

const string SIG = "Skon_";

So that Skon is your username.

Communication through Fifo's

The Fifos are special communication files that allow the CGI program to talk to the Name Server. This must be changed or we will all use the same Fifo's, and they will interfere with each other.

The CGI program is called from the Apache2 web server, so it must be in a special folder where web programs are allowed to run. This is the "/usr/lib/cgi-bin/" dolder. The program running the lookups with the inverted index can be located in your own directory.

Communication between the CGI program that is called from the web server to the name server program is enabled by the FiFo communications object. This is a interprocess communication component that utilizes Linux system "pipes".

  • Fifo Pipes: The use of named pipes in C++. The demo code given to you includes a wrapper class "Fifo" which encapsulates the use of pipes for easy interprocess communication is C++. Please careful review the use in the demo code above it's use. Also note - creation of a pipe creates a special files in the /tmp folder on the Linex file system. In order to prevent file naming collisions you MUST modify the code in Fifo.h to use your username for the pipe "SIG" string constant. This is appended to the pipe names, assuring that all pipes are private for your program. Fifo methods
<-- SyntaxHighlightingPlugin -->
{
  Fifo();             // Default Constructor                                     
  Fifo(string);       // Construct from pipe name string                         
                      // If a pipe already exists, does nothing                  
                      // Otherwise it creates the names pipe                     

  void openread();    // Open a pipe for reading (recv)                          
                      // openread allows other readers but                       
                      // blocks writers from the pipe                            

  void openwrite();   // Start a pipe for writing (send)                          
                      // openwrite block all other opens to the pipe             
                      // blocked opens proceed with previous user                

  void fifoclose();   // Close the pipe                                          
                      // Frees the pipe for other users (processes)              

                      // You MUST call openread() before recv                    
  string recv();      // Receives - get the next record from the pipe            
                      // Process will vlock until pipe has data.                 

                      // You MUST call openwrite() before a send                 
  void send(string);  // Sends - a record into the pipe                          
                      // Does not block - always writes and returned 

}
<-- end SyntaxHighlightingPlugin -->

Shakespeare Program

In project 1 you created code to lookup words in Shakespeare. You will combine that code with the code from this US Name data system to make a web version of your Shakespeare lookup program.

Method
  1. Modify the the HTML program (name_stats_ajax.html) to request a word, and display the results after callin the CGI program.
  2. Modify the name server program (nameserver.cpp) to serve up Line from Shakespreare when a word is sent through the Fifo.
  3. Modify the CGI program (namefetchajax.cpp) to receive a word from the web page, and send it to the name server through the Fifo. Then it will recieve the matching lines back, and send them to the web page.

Assignment

Below is a list of features you can put in your program, along with the points. Notice that people with Data Structures must do more than studnets with only the introduction course to get 100 points (the perfect score) on the program. If you do more than 100 points, you getr extra credit.

Requirement Data Structures Intro Prog Done
Program displays matching lines for each word entered on the web page* 40 50  
Input and output is well designed and formatted* 10 20  
Program broken up into functionally cohesive functions* 10 20  
Program has meaningful comments, good variable names, and good formatting* 10 10  
Program uses appropriate classes 10 10  
Program highlights the words as bold in the output. 10 10  
Program gives you the number of matches 20 20  
Program reads file into program, and works on an array (large string) (mutually exclusive with above) 5 10  
Program shows book that each match is found in 20 20  
*These are required in order to get extra credit.

Turn in

  1. All source files you authored
  2. A writeup with the table above, and an indicated of which was included. Paste table into Moodle text field, and put X's in to options you attempted. Also include a statement of the highest computer science course you have taken.
  3. Several runs showing all features.

META FILEATTACHMENT attachment="NamesWebArchtecture.png" attr="" comment="" date="1485405384" name="NamesWebArchtecture.png" path="NamesWebArchtecture.png" size="59259" user="JimSkon" version="3"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback