usage.rst 1.74 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Usage
-----

The easiest and recommended way is to just use the command-line tool to load your plugins and launch the server.

.. code:: bash

   senpy

Or, alternatively:

.. code:: bash

    python -m senpy


This will create a server with any modules found in the current path.
Ignacio Corcuera's avatar
Ignacio Corcuera committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

Useful command-line options
===========================

In case you want to load modules, which are located in different folders under the root folder, use the next option.

.. code:: bash

    python -m senpy -f .

The default port used by senpy is 5000, but you can change it using the option `--port`.

.. code:: bash

    python -m senpy --port 8080

Also, the host can be changed where senpy is deployed. The default value is `127.0.0.1`.

.. code:: bash

    python -m senpy --host 0.0.0.0

40
41
42
For more options, see the `--help` page.

Alternatively, you can use the modules included in senpy to build your own application.
Ignacio Corcuera's avatar
Ignacio Corcuera committed
43
44
45
46
47
48
49
50

Senpy server
============

Once the server is launched, there is a basic endpoint in the server, which provides a playground to use the plugins that have been loaded.

In case you want to know the different endpoints of the server, there is more information available in the NIF API section_.

51
52
CLI
===
Ignacio Corcuera's avatar
Ignacio Corcuera committed
53
54
55
56
57
58
59
60

This video shows how to use senpy through command-line tool.

https://asciinema.org/a/9uwef1ghkjk062cw2t4mhzpyk

Request example in python
=========================

61
This example shows how to make a request to the default plugin:
Ignacio Corcuera's avatar
Ignacio Corcuera committed
62
63
64

.. code:: python

65
    from senpy.client import Client
Ignacio Corcuera's avatar
Ignacio Corcuera committed
66

67
68
69
70
71
    c = Client('http://127.0.0.1:5000/api/')
    r = c.analyse('hello world')

    for entry in r.entries:
          print('{} -> {}'.format(entry.text, entry.emotions))
Ignacio Corcuera's avatar
Ignacio Corcuera committed
72
73
74
75
76



.. _section: http://senpy.readthedocs.org/en/latest/api.html

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
77
78
79
80

Conversion
==========
See :doc:`conversion`