# analyze_text

> **Function** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/callbacks/wandb_callback/analyze_text)

Analyze text using textstat and spacy.

## Signature

```python
analyze_text(
    text: str,
    complexity_metrics: bool = True,
    visualize: bool = True,
    nlp: Any = None,
    output_dir: Optional[Union[str, Path]] = None,
) -> dict
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `text` | `str` | Yes | The text to analyze. |
| `complexity_metrics` | `bool` | No | Whether to compute complexity metrics. (default: `True`) |
| `visualize` | `bool` | No | Whether to visualize the text. (default: `True`) |
| `nlp` | `spacy.lang` | No | The spacy language model to use for visualization. (default: `None`) |
| `output_dir` | `str` | No | The directory to save the visualization files to. (default: `None`) |

## Returns

`dict`

`dict` containing the complexity metrics and visualization
files serialized in a wandb.Html element.

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/a6a6079511ac8a5c1293337f88096b8641562e77/libs/community/langchain_community/callbacks/wandb_callback.py#L42)