0% found this document useful (0 votes)
119 views38 pages

CSCI 4152/6509 Natural Language Processing: Lab 1: FCS Computing Environment, SVN Tutorial

This document provides an overview and instructions for a lab on natural language processing. The lab introduces students to using the computing environment at Dalhousie University, logging into the school's server, setting up a Subversion repository for submitting assignments, and writing a simple "Hello World" program in Perl. The document guides students through setting up their Subversion repository, checking out and committing files, adding, deleting, and updating files, and resolving conflicts when changes are made in parallel.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
119 views38 pages

CSCI 4152/6509 Natural Language Processing: Lab 1: FCS Computing Environment, SVN Tutorial

This document provides an overview and instructions for a lab on natural language processing. The lab introduces students to using the computing environment at Dalhousie University, logging into the school's server, setting up a Subversion repository for submitting assignments, and writing a simple "Hello World" program in Perl. The document guides students through setting up their Subversion repository, checking out and committing files, adding, deleting, and updating files, and resolving conflicts when changes are made in parallel.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

CSCI 4152/6509

Natural Language Processing

Lab 1:

FCS Computing Environment, SVN Tutorial

http://web.cs.dal.ca/˜vlado/csci6509

Lab Instructor: Dijana Kosmajac, Afsan Gujarati, and Yuhan Fu

Faculty of Computer Science

Dalhousie University

9 and 11-Jan-2019 (1) CSCI 4152/6509 1


Lab Overview

• An objective: Make sure that all students are familiar with


their CSID and how to login to the bluenose server
• Refresh your memory about Linux Command-Line
Interface
• Introduction to your SVN repository for the course
• Introduction to Perl (just ‘hello world’ for now)
• Note 1: Replace CSID with your FCS CS user id (a.k.a.,
CSID)
• Note 2: If you do not know your CSID, lookup at:
https://www.cs.dal.ca/csid

9 and 11-Jan-2019 (1) CSCI 4152/6509 2


Step 1: Logging in to server bluenose

• You can choose Windows, Mac or Linux environment in


some labs
• Windows: you will use PuTTY program
• On Mac: open a Terminal and type:
ssh CSID @bluenose.cs.dal.ca
(instead of CSID use your CS userid )
• On Linux: similarly to Mac, you open the terminal and
type the same command:
ssh CSID @bluenose.cs.dal.ca

9 and 11-Jan-2019 (1) CSCI 4152/6509 3


Running PuTTY

• If you use Windows, then one option is to use PuTTY to


login to the bluenose server
• Double-click the PuTTY icon, and the following window
should appear:

9 and 11-Jan-2019 (1) CSCI 4152/6509 4


9 and 11-Jan-2019 (1) CSCI 4152/6509 5
Review of Some Linux Commands
Step 2: pwd
man pwd
Step 3: mkdir csci4152 or mkdir csci6509
ls
chmod go-rx csci6509
or
chmod go-rx csci4152
Step 4: cd csci6509 or cd csci4152
• Make directory lab1 and change your current directory
to it.

9 and 11-Jan-2019 (1) CSCI 4152/6509 6


Step 5: Using emacs prepare hello.pl
Use an editor: emacs or some other (e.g., vi, pico . . . )

#!/usr/bin/perl

print "Hello world!\n";

Step 6: Running a Perl program


perl hello.pl
Another way to run the program:
chmod u+x hello.pl
./hello.pl

9 and 11-Jan-2019 (1) CSCI 4152/6509 7


Source Control with SVN

• In this tutorial, you will learn or refresh your knowledge


about SVN.
• Performing these steps will be graded as a part of an
assignment
• SVN will be used for assignment submission
• It is possible that not all students have the course SVN
repository. In that case, let the instructor know. You will
be able to finish the tutorial next week.
• This tutorial is slightly modified version of the SVN
tutorial “Source Control with SVN” prepared by Michael
McAllister for CSCI 3171.

9 and 11-Jan-2019 (1) CSCI 4152/6509 8


Source Control with SVN
• Subversion (or SVN) source control system
• SVN can be accessed using command line interface on
bluenose (Linux system); similarly on Mac
• GUI interfaces exist (including Windows)
• Development companies use some form of source
control
• SVN is relatively popular, open-source system
• git is another newer open-source system (e.g., used for
Linux kernel)
• Some commercial software: Perforce and ClearCase
• Predecessors: SCCS, RCS, CVS

9 and 11-Jan-2019 (1) CSCI 4152/6509 9


Objectives

1. checkout projects in SVN


2. add a subproject (subdirectory) to SVN
3. add, delete files in SVN; and commit your changes
4. change files in SVN, and merge changes from different
copies
5. resolve conflicts that may result from parallel changes
6. revert changes and retrieve older versions of the files

9 and 11-Jan-2019 (1) CSCI 4152/6509 10


Repository and Working Copy

• SVN uses remote directory system called repository to


store files and history of their changes
• You can review changes and retrieve older versions
• Files can be shared among users and SVN can be used
for collaborative work
• SVN uses notion of working copy of the files
• We send (or commit) files to the repository when we are
happy with their state
• For example, we generally do not commit program
unless they can be compiled

9 and 11-Jan-2019 (1) CSCI 4152/6509 11


A Couple Notes

• Replace CSID with your CS user id (a.k.a., CSID)


• Important Security Note: Each time that you enter an
SVN command in this lab, you will be asked for your
bluenose password. Enter it. When asked if you want to
store the password, answer “no” each time, since the
password is not stored safely currently.
• If you are sure that you know what you are doing, you
may temporarily say yes to make SVN use easier, but
then make sure that only you have access permissions
to the the directory ˜./subversion, and it is a good
idea to delete the whole directory after each session.

9 and 11-Jan-2019 (1) CSCI 4152/6509 12


Step 7: Set-up Before SVN Tutorial

• Log into bluenose in two different windows (use putty


twice (windows) or ssh from two terminals (mac os)).
• Call one window your primary window and the other
window your secondary window.
• In your course directory in subdirectory lab1, create two
subdirectories, one called primary and another called
secondary.
• In your primary window, make primary the working
directory. In your secondary window, make secondary
the working directory.

9 and 11-Jan-2019 (1) CSCI 4152/6509 13


Step 8: Checkout and Adding a Directory

• We use checkout command to retrieve a working copy


• In your primary window run (in one line):
svn checkout
https://svn.cs.dal.ca/nlp-course/CSID
• You will be asked to enter the password
• Change directory using: cd CSID
• List directory using: ls -a
• Notice .svn directory
• Create directory: mkdir svnlab
• Add it to the repository: svn add svnlab
• You should see output: A svnlab
9 and 11-Jan-2019 (1) CSCI 4152/6509 14
Step 9: Commit Command
• The svnlab directory is not in the repository yet
• We must execute commit to send it to the repository (all
in one line):
svn commit -m "Creating a project for my
SVN lab"
• You should see the output:
Adding svnlab

Committed revision 2.

• Check the following URL using your browser:


https://svn.cs.dal.ca/nlp-course/CSID /svnlab
9 and 11-Jan-2019 (1) CSCI 4152/6509 15
SVN Log Messages
• -m "xx" part adds a message to the repository
• All commit commands require a log message

9 and 11-Jan-2019 (1) CSCI 4152/6509 16


Step 10.a: Adding Files: Preparing Files

• Create a file name hello.pl with the following content:


#!/usr/bin/perl
print "Hello world!\n";
• Create two copies of this file:
cp hello.pl hello2.pl
cp hello.pl tmp.pl

9 and 11-Jan-2019 (1) CSCI 4152/6509 17


Step 10.b: Adding Files

• Add two files: svn add hello.pl hello2.pl


• We see the output:
A hello.pl
A hello2.pl
• Run command: svn status
• Output:
A hello.pl
A hello2.pl
? tmp.pl

9 and 11-Jan-2019 (1) CSCI 4152/6509 18


Step 10.c: Adding Files: Commit

• Commit files (one line):


svn commit -m "Adding the first version
of my sample files."
• Enter: svn status
• Output:
? tmp.pl

9 and 11-Jan-2019 (1) CSCI 4152/6509 19


Step 11: Deleting Files

• (11.a) Delete a file: svn delete hello2.pl


• Output:
D hello2.pl
• Enter: svn status
• Output:
? tmp.pl
D hello2.pl

9 and 11-Jan-2019 (1) CSCI 4152/6509 20


Step 11.b: Deleting a File (2)

• Enter in one line:


svn commit -m "File hello2.pl was added
by mistake earlier. It was just a backup
copy of hello.pl"
• The file is deleted, but it can be retrieved from the
repository

9 and 11-Jan-2019 (1) CSCI 4152/6509 21


Step 12: Checking out Second Copy

• Go the secondary window and make sure you are in the


directory: . . . /lab1/secondary/
• You can check this using command: pwd
• In secondary window get the second working copy:
svn checkout https://svn.cs.dal.ca/
nlp-course/CSID /svnlab
• Change directory: cd svnlab
• List the contents: ls -la

9 and 11-Jan-2019 (1) CSCI 4152/6509 22


Step 13: Changing Files (13.a)

• In your primary window edit hello.pl to become the


following file:
#!/usr/bin/perl

for my $i (1..10) {
print "Hello world!\n";
}
• Run: svn commit
• In the secondary window run: svn update
• Verify that the file has been updated

9 and 11-Jan-2019 (1) CSCI 4152/6509 23


13.b: Modifying a File

• In your primary window: edit your copy of hello.pl and


change the for loop to iterate 15 times rather than 10
tiems, and save the file.
• Run: svn status
• You should get the following output:
M hello.pl
? tmp.pl
• M indicates that the file has some modifications which
are not in the repository

9 and 11-Jan-2019 (1) CSCI 4152/6509 24


Step 13.c: svn diff command

• Run: svn diff hello.pl


• Output will show differences between working version
and repository version
• Commit the change:
svn commit -m "Use a longer loop iteration"
• Try again svn diff hello.pl
• No output. Why?
• In the secondary window look at hello.pl

9 and 11-Jan-2019 (1) CSCI 4152/6509 25


Step 13.d: Update

• In the secondary window run: svn update


• Output:
Updating ’.’:
U hello.pl
Updated to revision 36.
• U means that there is a more recent copy in the
repository
• Check again file hello.pl

9 and 11-Jan-2019 (1) CSCI 4152/6509 26


Step 13.e: Delete

• Let us remove a file: rm hello.pl


• Check that it does not exist: ls
• (Still in secondary window) Run: svn status
• Output: ! hello.pl
• ! is an indicator that the file is missing
• Run: svn update
• The file hello.pl is restored

9 and 11-Jan-2019 (1) CSCI 4152/6509 27


Step 13.f: Parallel Changes

• Let us change hello.pl in both windows:


• In primary window add a print statement before the loop:
print "I am about to start the loop\n";
• In secondary window add a print statement after the
loop:
print "I have finished the loop\n";
• In each windows use svn status to verify that the
working file is different from the repository copy
(indicator M)

9 and 11-Jan-2019 (1) CSCI 4152/6509 28


Step 13.g: Merging Changes

• In primary window commit changes, e.g.:


svn commit -mprimary
• Try to commit changes in secondary window, e.g.:
svn commit -msecondary
• Commit fails since the repository copy changed since
our last update
• Run: svn update
• Output:
G hello.pl
Updated to revision 37.
• G indicates that changes have been merged

9 and 11-Jan-2019 (1) CSCI 4152/6509 29


Step 13.g (cont): Merging Changes

• (Still in secondary window)


• Edit file hello.pl to make sure you are happy with merged
changes
• Run: svn commit -m"merged changes"
• This will submit merged changes to repository
• In both windows run: svn update
• Now both windows contain the latest copy in repository

9 and 11-Jan-2019 (1) CSCI 4152/6509 30


Step 13.h: Conflicting Changes

• In primary window change hello.pl so that the loop


iterates 30 times
• Commit the change
• In secondary window change hello.pl so that the loop
iterates 5 times
• Try to commit the change
• Similarly as before commit fails, so we need to do update
first
• Run svn update
• However, changes are not merged this time

9 and 11-Jan-2019 (1) CSCI 4152/6509 31


• We get the following message
Conflict discovered in ’hello.pl’.
Select: (p) postpone, (df) diff-full, (e) edit,
(mc) mine-conflict, (tc) theirs-conflict,
(s) show all options:
• df—see differences, or different options of editing or fixing the file
• Let us choose to postpone, enter: p
• We can see now several files in secondary window by running: ls
• The files are (likely with different version numbers):
– hello.pl — the hello.pl file with the ”diff” information embedded
– hello.pl.mine — your modified code
– hello.pl.r38 — the original copy of the code that you modified in
this working directory (revision 38)
– hello.pl.r39 — the most recent version of the code in the
repository (revision 39)

9 and 11-Jan-2019 (1) CSCI 4152/6509 32


Step 13.i: Examining Conflict

• (Still in secondary window) Run status command


• Output will include line:
C hello.pl
• C indicates conflict that needs to be resolved
• Examine the log using log command: svn log hello.pl
• The output shows log messages (which demonstrate why it is useful
to write descriptive log messages)
• Additional information can be obtained using diff command:
svn diff hello.pl
• A part of the output is:
+<<<<<<< .mine
+for my $i (1..5) {
+=======
for my $i (1..30) {
+>>>>>>> .r39

9 and 11-Jan-2019 (1) CSCI 4152/6509 33


Step 13.j: Resolving Conflict

• Fix hello.pl file. Usually, you can either:


– Edit hello.pl directly (delete extra lines, etc.)
– Choose our version: cp hello.pl.mine hello.pl
– Choose repository version: cp hello.pl.r39 hello.pl
– Choose original last updated version: cp hello.pl.r38
hello.pl
• We can simply choose: cp hello.pl.mine hello.pl
• To indicate that the conflict has been resolved, and hello.pl is the
version that we want submitted to the repository, we issue svn
resolved command:
svn resolved hello.pl
• Other files (hello.pl.mine and hello.pl.rX) are removed
• Finally, we commit the change:
svn commit -m"conflict resolved"

9 and 11-Jan-2019 (1) CSCI 4152/6509 34


Step 14: Retrieving copies of previous work

14.a: Sometimes we make changes to a program and want to undo them


• It is useful to make commit each time we reach a stable point
• Aside: If collaborating with someone, it is useful to do frequent
updates and commits
• In secondary window: Introduce error in file hello.pl; e.g., change
word print to pprint
• Save the file but do not commit
• Suppose that we want to undo the change to the last “saved” copy in
the repository. We already know three options:
– make checkout elsewhere and get the fresh copy from there
– delete hello.pl and run update
– use diff to identify changes and manually reverse them
• All these involve unnecessary work; much easier:
svn revert hello.pl

9 and 11-Jan-2019 (1) CSCI 4152/6509 35


Step 14.b: Retrieving Older Versions

• How to retrieve older versions of a file?


• We can use -r option with the update command:
svn update -r 34 hello.pl
• We can use log command (svn log hello.pl) to find
“interesting” revision numbers
• Check the contents of hello.pl
• If you change this file and try to commit, it will not work as a newer
version is in the repository. You would need to make an update, and
likely resolve any conflicts.
• Instead, simply run: svn update
• This will get the latest version from the repository

9 and 11-Jan-2019 (1) CSCI 4152/6509 36


Step 14.c: Retrieving by Timestamps

• Sometimes we do not know exact revision number, but we know


time when the directory was last stable.
• We can specify time to retrieve the latest version that existed at this
time
• For example:
svn update -r "{2014-01-22 13:00:00}"

9 and 11-Jan-2019 (1) CSCI 4152/6509 37


Step 15: End of the Lab

• After finishing with commits, you can even delete primary and the
secondary directory, since all required updates are submitted to the
SVN. If you want, you can still keep them until Assignment 1 is
marked, just to be sure.
• To delete the directories, you will need to be in their parent directory,
and use the command rm -r primary secondary
• End of the lab.

9 and 11-Jan-2019 (1) CSCI 4152/6509 38

You might also like