Skip to content

Commit 3eb9ad0

Browse files
docs: updated main example
1 parent ed84c21 commit 3eb9ad0

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

readme.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,28 @@ For more detailed instructions on installing augmenty, including specific langua
3535
The following shows a simple example of how you can quickly augment text using Augmenty. For more on using augmenty see the [usage guides].
3636

3737
```python
38-
import spacy
3938
import augmenty
39+
import spacy
4040

4141
nlp = spacy.load("en_core_web_md")
4242
# if not installed run: python -m spacy download en_core_web_md
4343

44-
docs = nlp.pipe(["Augmenty is a great tool for text augmentation"])
44+
doc = nlp("Augmenty is a great tool for text augmentation")
45+
46+
# check that the pipeline detects the entities (this done by SpaCy and is not a 100%)
47+
print(doc.ents)
48+
# (Augmenty,) is detected as an entity
49+
50+
doc.ents[0].label_
51+
# 'GPE'. Depending on the model, the label might be different (e.g. 'ORG')
4552

46-
entity_augmenter = augmenty.load("ents_replace_v1",
47-
ent_dict = {"GPE": [["spaCy"], ["spaCy", "Universe"]]}, level=1)
53+
entity_augmenter = augmenty.load(
54+
"ents_replace_v1", ent_dict={"GPE": [["spaCy"], ["spaCy", "Universe"]]}, # label=GPE,
55+
level=1
56+
)
4857

49-
for doc in augmenty.docs(docs, augmenter=entity_augmenter, nlp=nlp):
50-
print(doc)
58+
for augmented_doc in augmenty.docs([doc], augmenter=entity_augmenter, nlp=nlp):
59+
print(augmented_doc)
5160
```
5261

5362
```

0 commit comments

Comments
 (0)