render_parse_tree_graphviz_test.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright 2017 Google Inc. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ==============================================================================
  15. """Tests for ....dragnn.python.render_parse_tree_graphviz."""
  16. from __future__ import absolute_import
  17. from __future__ import division
  18. from __future__ import print_function
  19. from tensorflow.python.platform import googletest
  20. from dragnn.python import render_parse_tree_graphviz
  21. from syntaxnet import sentence_pb2
  22. class RenderParseTreeGraphvizTest(googletest.TestCase):
  23. def testGiveMeAName(self):
  24. document = sentence_pb2.Sentence()
  25. document.token.add(start=0, end=0, word='hi', head=1, label='something')
  26. document.token.add(start=1, end=1, word='there')
  27. contents = render_parse_tree_graphviz.parse_tree_graph(document)
  28. self.assertIn('<polygon', contents)
  29. self.assertIn('text/html;charset=utf-8;base64', contents)
  30. self.assertIn('something', contents)
  31. self.assertIn('hi', contents)
  32. self.assertIn('there', contents)
  33. if __name__ == '__main__':
  34. googletest.main()