import processors
print("py-processors version:\t{}".format(processors.__version__))
print("processors-sever recommended version:\t{}".format(processors.__ps_rec__))

"""
Explanation: Introduction
This notebook assumes you installed py-processors with jupyter extras:
pip install py-processors[jupyter]==3.2.1
End of explanation
"""


# from processors import *
# API = ProcessorsBaseAPI(port=8886)

"""
Explanation: Documentation
You can find the documentation here, including a detailed walkthrough example.
Using the docker-based backend
```bash
pull the official image
docker pull myedibleenso/processors-server:3.2.1
run the container in the background and expose the service on port 8886
docker run -d -e _JAVA_OPTIONS="-Xmx3G" -p 127.0.0.1:8886:8888 --name procserv myedibleenso/processors-server:3.1.0
```
Uncomment and run the next block to establish the client connection with the docker container-based backend.
End of explanation
"""


from processors import *
# using the jar-based backend
API = ProcessorsAPI(port=8881, keep_alive=False)

doc = API.annotate("To be loved by unicorns is the greatest gift of all.")

s = doc.sentences[0]

"""
Explanation: Using the java-based backend
End of explanation
"""


from processors.visualization import JupyterVisualizer as viz

viz.display_graph(s,graph_name="stanford-collapsed")

"""
Explanation: Visualizing the parse
End of explanation
"""


viz.display_graph(s, distance=150, graph_name="stanford-basic")

"""
Explanation: Let's see what the parse looks like for stanford basic dependencies ("stanford-basic")...
End of explanation
"""


viz.display_graph(doc.sentences[0], css=viz.parse_css)

print("Corresponding CSS:\n{}".format(viz.parse_css))

"""
Explanation: Styling the graph
You can apply css to the graph via the css parameter.  JupyterVisualizer.parse_css is configured to draw attention to tokens that are nouns ([tag=/^NN/]), verbs ([tag=/^VB/]), or have an entity label of some kind ([!entity=/^O/]).
End of explanation
"""


