@@ -724,3 +724,35 @@ The steps to create an analyzer are:
...
@@ -724,3 +724,35 @@ The steps to create an analyzer are:
## Quick path for adding a new analyzer
If your analyzer just needs to process a list of inputs (e.g., texts from metadata) and return one result per input, you can extend `SimpleAnalyzer` and optionally register it for easy instantiation:
1) Extend `textflow.SimpleAnalyzer.SimpleAnalyzer` and implement `compute(items)`.
2) Optionally set `apply_to_metadata = False` if you want to analyze children sequences rather than metadata items.
3) (Optional) Register with a name using the decorator `@textflow.register_analyzer("my_analyzer")`, then instantiate with `textflow.create_analyzer("my_analyzer", **kwargs)`.
Minimal example:
```python
fromtextflow.SimpleAnalyzerimportSimpleAnalyzer
fromtextflowimportregister_analyzer
@register_analyzer("word_count")
classWordCountAnalyzer(SimpleAnalyzer):
apply_to_metadata=True# expects list of texts from metadata