def test_single_image_returns_text(): vision_api_client = main.VisionApi() image_path = TEST_IMAGE_URI texts = vision_api_client.detect_text([image_path]) assert image_path in texts _, document = main.extract_description(texts[image_path]) assert "daughter" in document assert "Bennet" in document assert "hat" in document
def test_single_image_returns_text(cloud_config): vision_api_client = main.VisionApi() image_path = _TEST_IMAGE_URI.format(cloud_config.storage_bucket) texts = vision_api_client.detect_text([image_path]) assert image_path in texts _, document = main.extract_description(texts[image_path]) assert "daughter" in document assert "Bennet" in document assert "hat" in document
def test_entities_list(): vision_api_client = main.VisionApi() image_path = TEST_IMAGE_URI texts = vision_api_client.detect_text([image_path]) locale, document = main.extract_description(texts[image_path]) text_analyzer = main.TextAnalyzer() entities = text_analyzer.nl_detect(document) assert entities etype, ename, salience, wurl = text_analyzer.extract_entity_info( entities[0]) assert ename == 'bennet'
def test_entities_list(cloud_config): vision_api_client = main.VisionApi() image_path = _TEST_IMAGE_URI.format(cloud_config.storage_bucket) texts = vision_api_client.detect_text([image_path]) locale, document = main.extract_description(texts[image_path]) text_analyzer = main.TextAnalyzer() entities = text_analyzer.nl_detect(document) assert len(entities) == 4 etype, ename, salience, wurl = text_analyzer.extract_entity_info( entities[0]) assert ename == 'bennet' assert wurl == 'http://en.wikipedia.org/wiki/Mr_Bennet'
def test_single_nonimage_returns_error(): vision_api_client = main.VisionApi() texts = vision_api_client.detect_text(['README.md']) assert "README.md" not in texts