...
Developers would write a function that takes an input or data (and probably the logger used by simple extractor) and returns a JSON dict with any new files, metadata, previews etc. that result from the function:
So here, the simple extractor would handle everything and call the configured function (configured on initialization) with the data to get a result, then parse the result in a standard way.
The result dict would have a structure that allows users to define outputs for their function:
So in this example response object:
...
Now we can run the following command to test the word count code:
Code Block | ||||
---|---|---|---|---|
| ||||
python -c "import wordcount; print wordcount.wordcount(\"poem.txt\")" |
It will show the output as:
Code Block | ||||
---|---|---|---|---|
| ||||
{'metadata': {'lines': 5', 'characters': 182', 'words': '37'}} |
Running wordcount.py as extractor
...