Giter Club home page Giter Club logo

ner_historical_texts's Introduction

Named Entity Recognition (NER) Web app for Historical Texts of Project Gutenberg

This Python script performs Named Entity Recognition (NER) on historical texts from Project Gutenberg. It allows users to either enter a URL or upload a text file, preprocesses the text by removing unnecessary characters and tokenizing into individual words, labels named entities using the NLTK library, extracts features and trains a Naive Bayes classifier, and then labels named entities using the trained classifier. Finally, it displays the named entities found in the text along with their labels.

The script uses several Python libraries, including string, nltk, streamlit, urllib.request, and BeautifulSoup. The NLTK library is used to perform NER, as well as to tokenize words and part-of-speech tag them. The streamlit library is used to create a user-friendly interface for entering URLs or uploading text files, while the urllib.request library is used to download the text from a URL and the BeautifulSoup library is used to parse the HTML and extract the text.

The script first preprocesses the text by removing unnecessary characters such as punctuation and newlines, and converts the text to lowercase. It then tokenizes the text into individual words using the word_tokenize function from NLTK. Next, it labels named entities in the text using the ne_chunk function from NLTK, which labels words with their part-of-speech tags and combines them into chunks based on their syntactic structure.

After labeling the named entities, the script extracts features from them, including the length of the word, its part-of-speech tag, and whether or not it is capitalized. These features are used to train a Naive Bayes classifier using the NaiveBayesClassifier function from NLTK. The data is split into training and testing sets, and the accuracy of the classifier is measured using the accuracy function from NLTK.

Finally, the script labels named entities using the trained classifier by iterating over each sentence in the text, tokenizing it into words, part-of-speech tagging the words, and chunking them into named entities. If a chunk is labeled with a recognized label, such as "PERSON" or "LOCATION", it is added to a list of named entities along with its label. The named entities and their labels are then displayed using the streamlit library.

ner_historical_texts's People

Contributors

yashwantbangde avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.