in reply to create an xml file from column file
#!/usr/bin/perl use warnings; use strict; use constant { WORD => 0, TYPE => 1, }; my @annotations; while (<DATA>) { my ($word, $type) = split; $type =~ s/.-*//; push @annotations, [ $word, $type ]; } print '<text>'; print join ' ', map $_->[WORD], @annotations; print '</text>'; for my $annotation (@annotations) { print '<annotation>'; print '<type>', $annotation->[TYPE], '</type>'; print '<text>', $annotation->[WORD], '</text>'; print '</annotation>'; } __DATA__ how B-NP are I-NP you I-NP
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: create an xml file from column file
by lakssreedhar (Acolyte) on Jul 24, 2013 at 12:10 UTC | |
by hdb (Monsignor) on Jul 24, 2013 at 13:21 UTC | |
by lakssreedhar (Acolyte) on Jul 25, 2013 at 06:11 UTC | |
by hdb (Monsignor) on Jul 25, 2013 at 07:58 UTC | |
by lakssreedhar (Acolyte) on Jul 25, 2013 at 09:19 UTC | |
|