Introduction to Computational Linguistics
Introduction to Computational Linguistics
Introduction to Computational Linguistics
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
2. Practical Remarks Concerning OCaML 3<br />
It then starts the interactive session by giving you a command prompt: #. It is then<br />
waiting for you <strong>to</strong> type in a command. For example<br />
(2) # 4+5;;<br />
It will execute this and return <strong>to</strong> you as follows:<br />
(3)<br />
- : int = 9<br />
#<br />
So, it gives you an answer (the number 9), which is always accompanied by some<br />
indication of the type of the object. (Often you find that you get only the type information,<br />
see below for reasons.) After that, OCaML gives you back the prompt.<br />
Notice that your line must end in ;; (after which you have <strong>to</strong> hit < return >, of<br />
course). This will cause OCaML <strong>to</strong> parse it as a complete expression and it will<br />
try <strong>to</strong> execute it. Here is another example.<br />
(4) # let a = ’q’;;<br />
In this case, the command says that it should assign the character q <strong>to</strong> the object<br />
with name a. Here is what OCaML answers:<br />
(5) val a : char = ’q’<br />
Then it will give you the prompt again. Notice that OCaML answers without<br />
using the prompt, #. This is how you can tell your input from OCaMLs answers.<br />
Suppose you type<br />
(6) # Char.code ’a’;;<br />
Then OCaML will answer<br />
(7) - : int = 113<br />
Then it will give you the prompt again. At a certain point this way of using<br />
OCaML turns out <strong>to</strong> be tedious. For even though one can type in entire programs<br />
this way, there is no way <strong>to</strong> correct mistakes once a line has been entered. Therefore,<br />
the following is advisable <strong>to</strong> do.<br />
First, you need <strong>to</strong> use an edi<strong>to</strong>r (I recommend <strong>to</strong> use either emacs or vim;<br />
vim runs on all platforms, and it can be downloaded and installed with no charge