|
RiTa index |
|
| Name | RiTaServer |
| Description | Another way of using the RiTa objects is in a server mode. In server mode,
the RiTaServer keeps running indefinitely; it accepts commands via a socket,
executes these commands, and sends the results back through the socket.
You can start the RiTaServer by double-clicking on the run-server script
for your platform (see below) found within the standard RiTa distibution
(or from the command line).
One common use of the RiTaServer is for objects that may have expensive initialization routines (e.g. building a large n-gram model from text files). Rather than incurring this loading cost each time the program is run (in development, for example), the RiTaServer enables the model to remain in memory while your program can be stopped and started as often as you like. For example: RiTa.useServer(); // add this one line
RiMarkov rm = new RiMarkov(this, 3);
rm.loadFile("war_peace.txt");
String[] sents = rm.generateSentences(10);
for (int i = 0; i < sents.length; i++)
System.out.println(sents[i]);
Note: before enabling the server from your code (as above), make sure to start the server using either run-server.sh (mac/linux) or run-server.bat (win), both of which can be found in the SKETCH_FOLDER/libraries/rita/ folder (On the Mac, this is (most likely): ~/Documents/Processing/libraries/rita/)
Note: although the default (and most common case) is to run the server locally, it may also be run on a remote machine, and can even provide content for publicly accessible applets.
|
| Constructors | |
| Usage | Web & Application |