Skip to content

i-timur/AnnotateWithMicrodata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Annotate With Microdata

Table of contents

About the project 📌

This project aims to provide a simple way to annotate HTML with microdata by utilizing Deep Learning methods.

The main motivation behind this project is to manage the tedious task of annotating HTML with microdata. Microdata is part of the WHATWG HTML Standard and is used to nest metadata within existing content on web pages. Search engines greatly benefit from microdata and boost web pages in search results.

This project is made as part of thesis work in Institute of Information Technologies and Intelligent Systems for a bachelor's degree

(back to top)

Getting started 📌

Prerequisites 📌

  • Python == 3.7
  • pip 24.0+
  • python3-virtualenv if running Linux

Installation 📌

  • Clone repository
    git clone git@github.com:i-timur/annotate-with-microdata.git
  • Setup virtual environment
    • MacOS
      python3 -m venv venv
      source venv/bin/activate
    • Windows
      python3 -m venv venv
      .\venv\Scripts\activate
    • Linux
      virtualenv venv
      source venv/bin/activate
  • Install dependencies
    pip install -r requirements.txt
  • Install this package
  • Install the package globally
    pip install -e .

(back to top)

Usage 📌

Annotate HTML with microdata

HTML used for commands below requires the following minimal structure:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Page Title</title>
  </head>
  <body>
    <!-- Content -->
  </body>

Annotate HTML by passing a URL to the shell command:

microdata annotate https://example.com

or by passing a path to the file with HTML:

microdata annotate ./path/to/file.html

IMPORTANT: DO NOT format HTML, when saving it to a file, pass it as is.

or by passing HTML directly to the shell command (NOT RECOMMENDED):

microdata annotate <HTML>

IMPORTANT: DO NOT format HTML, when passing it directly to the shell command, pass it as is.

Set output file with --output option:

microdata annotate ./path/to/file.html --output ./path/to/annotated_file.html

Use --skip <CLASS>,<OTHER_CLASS> option to skip items that are related to the specified classes:

microdata annotate ./path/to/file.html --skip Product,Book

Various texts may have similar semantic meanings, so for situations where the user already knows that certain classes have a high level of semantic similarity with other classes, or when the classification of a specific class is not required for other reasons, use this flag.

The confusion matrix below can give you the insight of the usage of this flag:

Confusion matrix

The model can misclassify a lot of entities as products. You can also see that the model struggles with choosing between the book and movie entities. This flag can help to avoid this issue.

You can set confidence threshold with --threshold option (NOT RECOMMENDED). The default value is 0.75.

You can also pass --save-preprocessed flag to save the preprocessed HTML to a file.

Following entities are currently supported:

  • Product
  • Book
  • Event
  • Hotel
  • JobPosting
  • Movie
  • Recipe
  • Restaurant
  • Organization
  • Place
  • Person
  • PostalAddress
  • Creative Work
  • LocalBusiness
  • Painting

Examples 📌

Example 1

Roadmap 📌

  • Add HTML validation

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing 📌

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License 📌

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact 📌

Timur - Telegram - i.timur0701@gmail.com

Project Link: https://github.com/i-timur/AnnotateWithMicrodata

(back to top)

Acknowledgments 📌

(back to top)