def main(input_dir):
"""Walk through all the not-yet-processed image files in the given
directory, extracting any text from them and adding that text to an
inverted index.
"""
# Create a client object for the Vision API
vision = VisionApi()
# Create an Index object to build query the inverted index.
index = Index()
allfileslist = []
# Recursively construct a list of all the files in the given input
# directory.
for folder, subs, files in os.walk(input_dir):
for filename in files:
allfileslist.append(os.path.join(folder, filename))
fileslist = []
for filename in allfileslist:
# Look for text in any files that have not yet been processed.
if index.document_is_processed(filename):
continue
fileslist.append(filename)
for filenames in batch(fileslist):
get_text_from_files(vision, index, filenames)
# [END get_text]
评论列表
文章目录