Adding nodes
We need to add nodes that are missing. As Alice in Wonderland is a fantasy story, and NER models tend to be trained with more modern and realistic text, the NER struggled to identify some important entities, including the Queen of Hearts. There are a few lessons here:
- First, don’t blindly trust models, ever. The data that they were trained on will have an impact on what they do and don’t do very well.
- Second, domain knowledge is very important. If I did not know the story of Alice in Wonderland, I might not even have noticed that the royalty was missing.
- Finally, even with flaws, NER and these approaches will do most of the work in converting text into networks, but your domain knowledge and critical thinking will lead to the best results.
Just as with removing nodes, networkx
has two methods for adding nodes: one at a time, or several at once:
- We can add just
'Queen
of Hearts'
:G.add_node('Queen of Hearts&apos...