Giter VIP home page Giter VIP logo

corpus-excersice's Introduction

Unigram Tagger and Evaluation

This repository contains the implementation of a Unigram Tagger and its evaluation as part of the "Programmieren II: Fortgeschrittene (Python)" course in the University of Heidelberg. The tasks involve reading text files, training a Unigram Tagger, evaluating it, and addressing method resolution order (MRO) concepts.

Features

  • Custom Corpus Handling: Efficiently read and process text data using custom classes.
  • Unigram Tagger Implementation: Train a Unigram Tagger from scratch, handling unseen words with a basic strategy.
  • Evaluation Framework: Evaluate the tagger's performance with a custom evaluation method, providing detailed accuracy metrics.
  • Object-Oriented Design: Utilize classes and methods to structure the code, ensuring maintainability and scalability.

Project Structure

  • corpus_utils.py: Defines classes to read and handle the corpus data.
  • tagger_models.py: Contains the Unigram Tagger implementation.
  • eval_utils.py: Includes the evaluation logic for the tagger.
  • main.py: The main script to execute training and evaluation.
  • train.tsv: Training dataset.
  • test.tsv: Test dataset.

Corpus Handling

Implemented in corpus_utils.py, the Corpus, Sentence, and Token classes provide:

  • Reading the Corpus: Load and process the TSV file format.
  • Corpus Statistics: Methods to get the number of sentences and access specific sentences.
  • Iteration Support: Iterate through sentences in the corpus seamlessly.

Unigram Tagger

Implemented in tagger_models.py, the UnigramTagger class provides:

  • Training: Train the tagger using the most frequent PoS tags for each word form.
  • Tagging: Predict PoS tags for new sentences, handling unseen words efficiently.
  • Callable Instances: Use the tagger instance as a function to tag sentences.

Evaluation

Implemented in eval_utils.py, the TaggerTester class provides:

  • Performance Evaluation: Compare predicted tags with actual tags and calculate accuracy.
  • Detailed Metrics: Output accuracy and other relevant metrics to assess performance.

Code Highlights

  • No External Libraries: The implementation avoids libraries like collections, nltk, and pandas, showcasing pure Python solutions.
  • Modular Design: Each class and method is designed for reusability and clarity.
  • Error Handling: Robust error handling for unseen words and other edge cases.

corpus-excersice's People

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.