Giter VIP home page Giter VIP logo

xml-sax-parser-4-xlif's Introduction

xml-sax-parser-4-xlif

The purpose of this application is to identify the most probable language of a <target>target sentence</target> in an xliff, and then create an excel output file with the confidence of each sentence. The confidence value is issued by the IBM Watson Translator offered on IBM Cloud.

Usuallly, all target sentences in the xliff should be of the same target language, but due some errors, file could be ended with a mix of languages. This program, will identify these setences.

Here an example of the xliff with mix of PT and ES in target sentences.

Usually, due the large number of words, does not look a good option to manually inspect the full file, so DL/AI is good option here to use a "language identification". Several services offer language identification, as the Google’s Cloud Translation (https://cloud.google.com/translate). But in is proposed solution we will use the IBM Watson Language Translator that is offered in IBM Cloud (https://cloud.ibm.com/apidocs/language-translator).

Using python, the main steps will be:

  • Source and target content extraction: Source XLIF will parsed using a SAX parser implement in python. This parser is event based, that allow us to capture the start and end of tags like <source> and <target>. Using these handlers we will get the source/target content. XML.SAX is supported by default in python.
  • Target analysis: Send the <target> content (the sentences we want to find the most probable language), to the IBM Watson Language Translator. The service will return a json file with languages ordered by confidence.
  "languages" : [ {
    "language" : "es",
    "confidence" : 0.9955377581001156
  }, {
    "language" : "it",
    "confidence" : 0.002488014556859667
  }, {
    "language" : "eo",
    "confidence" : 5.747564458215991E-4
    .
    .
  • Last step is to extract the response information, and create an excel file with ES or PT depending of the confidence value, the confidence values for ES and PT, source and target.

Final result is an excel very similar as this one (in this screen capture, only format has been changed). Notice how the Excel can easily allow as to find what are the trouble segments. This allows solve in large the issue. Notice in the screen capture, the most probable ES or PT pair and the confidence.

Requirements:

-In order to run this, you need an IBM Cloud account (free) and IBM Watson Language Translator (Lite version free) in IBM Cloud. Credentials are stored in the code.

(C) 2022 miguel canals (http://www.mknals.com) MIT License

xml-sax-parser-4-xlif's People

Contributors

miguelknals avatar

Watchers

 avatar  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.