```python
from langchain.document_loaders import UnstructuredPDFLoader

loader = UnstructuredPDFLoader("example_data/layout-parser-paper.pdf")
data = loader.load()

output_file = "extracted_text.txt"

# Open the file in write mode and write the extracted text to it
with open(output_file, "w") as file:
    file.write(data["text"])
```

Note: If you want to append text to a file instead of overwriting it change the letter `"w"` to the letter `"a"`.
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence