-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.pl
executable file
·66 lines (48 loc) · 1.67 KB
/
post.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
print header(-charset => 'UTF-8');
my %form;
foreach my $p (param()) {
$form{$p} = param($p);
print "$p = $form{$p}<br>\n";
}
$form{source_name} =~s/files_//i;
#get first and last parts of original xml file
#open(F, "c:/work/mike/scripts/gloss/product/$form{file_name}") || die "$!";
#open(F, "c:/work/mike/scripts/$form{source_name}/product/$form{file_name}") || die "$!";
open(F, "projects/$form{source_name}/product/$form{file_name}") || die "$!";
undef $/;
$data = <F>;
close F;
$data =~s/\n/\^\^\^/g;
$top = $1 if ($data =~ /(<record.+?<text>)/);
$bottom = $1 if ($data =~ /(<\/text>.+?<\/record>)/);
$top =~s /\^\^\^/\n/g;
$bottom =~s /\^\^\^/\n/g;
#open(FILE, ">uploads/text/$form{file_name}");
open(FILE, ">c:/work/mike/scripts/$form{source_name}/product/$form{file_name}");
$counter_p = 0;
$counter_s = 1;
foreach $p(@paragraphs = split(/\n\n/,$form{response})){
$counter_p++;
$xml .= qq( <paragraph n = "$counter_p" language = "Russian">\n);
foreach $s(@sentences = split(/\n/,$p)){
$counter_s++;
@timestamps = split(/:/,$s);
@s = split(/::/,$s);
$s[1]=~s/^\s+//;
$xml .= qq ( <sentence n = "$counter_p.$counter_s" start = "$timestamps[0]" end = "$timestamps[1]">$s[1]<\/sentence>\n);
}
$xml .= qq( <\/paragraph>\n);
}
# print FILE $form{response};
# $top = Encode::decode('utf16',$top);
# $top = encode_utf8($top);
print FILE "$top\n$xml\n$bottom\n";
#foreach my $p (param()) {
# $form{$p} = param($p);
# print FILE "$p ... $form{$p}\n";
#}
close FILE;
print end_html