Giter VIP home page Giter VIP logo

apertium's Introduction

Coding challenge scripts

Prereuisites

  • download/install 'libxml' library.

Challenge-1

To Compile
  • g++ -o challenge1 xml2-config --cflags challenge-1.cpp xml2-config --libs
  • ./challenge1 input.html

Output would be:

  • [{<i>}]foo [{<b><i>}]bar

Challenge-2

To Compile and run
  • g++ -o challenge2 xml2-config --cflags challenge-2.cpp xml2-config --libs
  • ./challenge2 input.html

Input1:

  • <p>foo <b>bar fie <i>baz</i> fum</b> fiz</p>

Output1:

  • [<p>]foo [{<b>}]bar fie [{<i><b>}]baz[{<b>}] fum fiz[</p>]

Input2:

  • <p class="class1" id="id2">
      <i>Hello Sir,</i>
      <u style="italic">would you 
      <b>like to play</b>
      <em>football?</em></u>
    </p>
    
```

Updated Output2:

  • [<p class = "class1" id = "id2">]
      [{<i>}]Hello Sir,
      [{<u style = "italic">}]would you 
      [{<b><u style = "italic">}]like to play[{<u style = "italic">}]
      [{<em><u style = "italic">}]football?
    [</p>]
    

[]```

  • have some problem with dealing </b> in the input.

Deformatter and Reformatter

compile and run
  • $> make
  • $> cat/echo file/"input string" |./dheshtml or ./rehtml

Deformatter

Input-1
<div id="id1">
  <p class="class1" id="id2">
    <i>Hello Sir,</i>
    <u style="italic">would you
    <b>like to play</b>
    <em>football?</em></u>
  </p>
</div>
Output-1
<div id = "id1">]
  [<p class = "class1" id = "id2">]
    [{<i>}]Hello Sir,[]
    [{<u style = "italic">}]would you
    [{<b><u style = "italic">}]like to play[]
    [{<em><u style = "italic">}]football?[][]
  [][</p>]
[][</div>]

Input-2
<p>foo <b>bar fie <i>baz</i> fum</b> fiz</p>
Output-2
[<p>]foo [{<b>}]bar fie [{<i><b>}]baz[][{<b>}] fum[] fiz[][</p>]

Reformatter

Input-1
[<div id = "id1">]
  [<p class = "class1" id = "id2">]
    [{<i>}]Hello Sir,[]
    [{<u style = "italic">}]would you
    [{<b><u style = "italic">}]like to play[]
    [{<em><u style = "italic">}]football?[][]
  [][</p>]
[][</div>]

Output-1
<div id = "id1">
  <p class = "class1" id = "id2">
    <i>Hello Sir,</i>
    <u style = "italic">]would you</u>
    <b><u style = "italic">]like to play</u></b>
    <em><u style = "italic">]football?</u></em>
  </p>
</div>
Input-2
[{<i>}]foo [{<b><i>}]bar[][]
Output-2
<i>foo </i><b><i>bar</i></b>

Testing

To run
  • stay in the ./apertium directory.
  • $> python run_test.py

apertium's People

Contributors

silentflame avatar

Watchers

 avatar  avatar  avatar

apertium's Issues

Add Makefile

so we can type "make" instead of copy-pasting from a README

add some tests

You can copy the tests dir from apertium, remove tests/{interchunk,pretransfer,tagger,transfer} and add tests/deformat and tests/reformat. Add all the tests from the README (making sure the expected output is correct as in #4 )

don't crash on broken xml

$ echo '<p>foo <b>bar fie <i>baz</i> fum</b> fiz' |./deformatter
input.xml:2: parser error : Premature end of data in tag p line 1

^
error: could not parse file (null)

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.