Difference between revisions of "Task ideas for Google Code-in/Comment XML"

From Apertium
Jump to navigation Jump to search
(Created page with " Given an XML file on standard input like: <e><p><l>foo</l><r>bar</r></p></e> <e><p><l>baz</l><r>baa</r></p></e> <e><p><l>foa</l><r>yuo</r></p></e> <e><p><l>g...")
 
(fix)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:


Given an XML file on standard input like:
Given an XML file on standard input like:
<pre>

<e><p><l>foo</l><r>bar</r></p></e>
<e><p><l>foo</l><r>bar</r></p></e>
<e><p><l>baz</l><r>baa</r></p></e>
<e><p><l>baz</l><r>baa</r></p></e>
<e><p><l>foa</l><r>yuo</r></p></e>
<e><p><l>foa</l><r>yuo</r></p></e>
<e><p><l>gae</l><r>yaa</r></p></e>
<e><p><l>gae</l><r>yaa</r></p></e>
</pre>

And a list in a file (filename given as the first argument to the script) like
And a list in a file (filename given as the first argument to the script) like
<pre>

foo:
foo:
:yaa
:yaa
</pre>

Print the following XML file to standard output:
Print the following XML file to standard output:
<pre>

<!--<e><p><l>foo</l><r>bar</r></p></e>-->
<!--<e><p><l>foo</l><r>bar</r></p></e>-->
<e><p><l>baz</l><r>baa</r></p></e>
<e><p><l>baz</l><r>baa</r></p></e>
<e><p><l>foa</l><r>yuo</r></p></e>
<e><p><l>foa</l><r>yuo</r></p></e>
<!--<e><p><l>gae</l><r>yaa</r></p></e>-->
<!--<e><p><l>gae</l><r>yaa</r></p></e>-->
</pre>



The task should also take into account:
The task should also take into account:


tags:
tags:
<pre>

foo<n>: = foo<s n="n"/>
foo<n>: = foo<s n="n"/>
</pre>

spaces:
spaces:
<pre>

foo bar<n>: = foo<b/>bar<s n="n"/>
foo bar<n>: = foo<b/>bar<s n="n"/>
</pre>

grouped elements:
grouped elements:
<pre>

foo# bar<n>: = foo<g><b/>bar</g><s n="n"/>
foo# bar<n>: = foo<g><b/>bar</g><s n="n"/>
</pre>

You can use any programming language you want, but Python is recommended.
You can use any programming language you want, but Python is recommended.


==Example==

A more complete test example:
A more complete test example:
<pre>
<pre>
Line 49: Line 49:
<e><p><l>gae<s n="n"/></l><r>yaa<s n="n"/></r></p></e>
<e><p><l>gae<s n="n"/></l><r>yaa<s n="n"/></r></p></e>
<e><p><l>bah<s n="vblex"/></l><r>yah<s n="vblex"/></r></p></e>
<e><p><l>bah<s n="vblex"/></l><r>yah<s n="vblex"/></r></p></e>
<e><p><l>bah<s n="n"/></l><r>yah<s n="n"/></r></p></e>
<e><p><l>bah<s n="n"/></l><r>rah<s n="n"/></r></p></e>
<e><p><l>bah<s n="n"/></l><r>meh<s n="n"/></r></p></e>
<e><p><l>bah<s n="n"/></l><r>meh<s n="n"/></r></p></e>
<e><p><l>dum<g><b/>bum</g><s n="n"/></l><r>rum<s n="n"/></r></p></e>
<e><p><l>dum<g><b/>bum</g><s n="n"/></l><r>rum<s n="n"/></r></p></e>

Latest revision as of 12:57, 2 January 2016

Given an XML file on standard input like:

    <e><p><l>foo</l><r>bar</r></p></e>
    <e><p><l>baz</l><r>baa</r></p></e>
    <e><p><l>foa</l><r>yuo</r></p></e>
    <e><p><l>gae</l><r>yaa</r></p></e>

And a list in a file (filename given as the first argument to the script) like

    foo:
    :yaa

Print the following XML file to standard output:

    <!--<e><p><l>foo</l><r>bar</r></p></e>-->
    <e><p><l>baz</l><r>baa</r></p></e>
    <e><p><l>foa</l><r>yuo</r></p></e>
    <!--<e><p><l>gae</l><r>yaa</r></p></e>-->

The task should also take into account:

tags:

    foo<n>: = foo<s n="n"/>

spaces:

    foo bar<n>: = foo<b/>bar<s n="n"/>

grouped elements:

    foo# bar<n>: = foo<g><b/>bar</g><s n="n"/>

You can use any programming language you want, but Python is recommended.

Example[edit]

A more complete test example:

    $ <input.dix python3 script.py to-be-commented.txt >output.dix

input.dix:

    <e><p><l>foo<s n="n"/></l><r>bar<s n="n"/></r></p></e>
    <e><p><l>noo<s n="n"/></l><r>foo<s n="n"/></r></p></e>
    <e><p><l>foo<s n="vblex"/></l><r>yuo<s n="vblex"/></r></p></e>
    <e><p><l>yaa<s n="n"/></l><r>yum<s n="n"/></r></p></e>
    <e><p><l>gae<s n="n"/></l><r>yaa<s n="n"/></r></p></e>
    <e><p><l>bah<s n="vblex"/></l><r>yah<s n="vblex"/></r></p></e>
    <e><p><l>bah<s n="n"/></l><r>rah<s n="n"/></r></p></e>
    <e><p><l>bah<s n="n"/></l><r>meh<s n="n"/></r></p></e>
    <e><p><l>dum<g><b/>bum</g><s n="n"/></l><r>rum<s n="n"/></r></p></e>

to-be-commented.txt:

    foo<n>:
    :yaa<n>
    bah:rah
    dum# bum<n>:

output.dix:

    <!-- <e><p><l>foo<s n="n"/></l><r>bar<s n="n"/></r></p></e> -->
    <e><p><l>noo<s n="n"/></l><r>foo<s n="n"/></r></p></e>
    <e><p><l>foo<s n="vblex"/></l><r>yuo<s n="vblex"/></r></p></e>
    <e><p><l>yaa<s n="n"/></l><r>yum<s n="n"/></r></p></e>
    <!-- <e><p><l>gae<s n="n"/></l><r>yaa<s n="n"/></r></p></e> -->
    <!-- <e><p><l>bah<s n="vblex"/></l><r>rah<s n="vblex"/></r></p></e> -->
    <!-- <e><p><l>bah<s n="n"/></l><r>rah<s n="n"/></r></p></e> -->
    <e><p><l>bah<s n="n"/></l><r>meh<s n="n"/></r></p></e>
    <!-- <e><p><l>dum<g><b/>bum</g><s n="n"/></l><r>rum<s n="n"/></r></p></e> -->

Note how "bah:rah" comments out both the vblex and n entries (no tags in that pattern), but not the line that has "meh" in it's <r> element. Also, note how :yaa<n> does not comment out the line that has "yaa" in its <l> element.