# Entity detection using DBpedia and Python

**URL:** <https://forum.dbpedia.org/t/entity-detection-using-dbpedia-and-python/2074>\
**Category:** Uncategorized\
**Created:** [January 26, 2023, 3:58pm UTC](https://forum.dbpedia.org/t/entity-detection-using-dbpedia-and-python/2074 "2023-01-26T15:58:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mustimoger](https://forum.dbpedia.org/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@mustimoger](https://forum.dbpedia.org/u/mustimoger)\
**Post date:** [January 26, 2023, 3:58pm UTC](https://forum.dbpedia.org/t/entity-detection-using-dbpedia-and-python/2074/1 "2023-01-26T15:58:39Z")

</div>

Hi, I am a beginner Python developer.

I simply want to extract entities from an input text. But I could not make this work although I tried many DBpedia python wrappers from Github.

Can you please provide a sample python code or forward me to a resource I can learn how to make this work?

Thank you.

---

<div class="post-metadata">

**Author:** ![deborahdjon](https://forum.dbpedia.org/letter_avatar_proxy/v4/letter/d/47e85d/32.png) [@deborahdjon](https://forum.dbpedia.org/u/deborahdjon)\
**Post date:** [March 4, 2023, 10:47pm UTC](https://forum.dbpedia.org/t/entity-detection-using-dbpedia-and-python/2074/2 "2023-03-04T22:47:56Z")

</div>

> [@mustimoger](#):
>
> I simply want to extract entities from an input text. But I could not make this work although I tried many DBpedia python wrappers from Github.
> 
> Can you please provide a sample python code or forward me to a resource I can learn how to make this work?

Hi,  
what exactly is your input? Is it just a text?  
This is a very simple example of a named entity extraction using spacy, a robust and sophisticated python library for natural language processing:

```python
import spacy
from spacy import display

# Class for recognising named entities uses 
NER = spacy.load("en_core_web_sm")

# Sample text form a Wikipedia article
raw_text="The Indian Space Research Organisation or is the national space agency of India, headquartered in Bengaluru. It operates under Department of Space which is directly overseen by the Prime Minister of India while Chairman of ISRO acts as executive of DOS as well."
text1= NER(raw_text)

# Print named entities
for word in text1.ents:
    print(word.text,word.label_)

```

Output:

```bash
The Indian Space Research Organisation ORG
the national space agency ORG
India GPE
Bengaluru GPE
Department of Space ORG
India GPE
ISRO ORG
DOS ORG

```

The code is from [this](https://www.analyticsvidhya.com/blog/2021/06/nlp-application-named-entity-recognition-ner-in-python-with-spacy/) article. Check it out, I found it quite helpful.

And [this](https://spacy.io/usage/models) may be helpful regarding specy’s trained pipelines.
