Blame view

tools/SIGMUND/bin/tagLem2xml.pl 1022 Bytes
e6be5137b   Jean-François Rey   reinitialized pro...
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
67
68
  #!/usr/bin/perl 
  
  if($#ARGV != 1){
  	print("usage : ./tagLemm2xml <fichier.tagLem> <fichier.doc.xml>");
  	exit(1);
  }
  
  
  open(TAG, "<$ARGV[0]");
  open(XML, ">$ARGV[1]");
  
  print XML "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>
  <!DOCTYPE Segmentation>
  <Segmentation>
  <seg>
  ";
  $chaineLem = "";
  $newshow = 0;
  while(<TAG>){
  	$line = $_;
  	chomp($line);
  	@tempo=split(/ /, $line);
  	if($tempo[2] !~ m/#[0-9]*/){
  		print XML "$tempo[0] ";
          $newseg=0;
  		if($tempo[1] !~ m/MOTINC/){
  			if($tempo[1] =~ m/^X.*/){
  				$poids = 10;
  			}
  			else{
  				$poids = 1;
  			}	
  			$chaineLem .= "\t\t<lem poids=\"". $poids ."\"> ".$tempo[2]." </lem>
  " ;
  		}
  		else{
  			$chaineLem .=" ";
  		}
  			
  	}
  	else{
  		if($chaineLem ne "" || $newshow == 1){
  			print XML ".
  \t</wd>
  $chaineLem</phr>
  <phr>
  \t<wd>
  \t\t$tempo[2] ";
  		}
  		else{
  			print XML "$chaineLem<phr>
  \t<wd>
  \t\t$tempo[2] ";
              $newshow=1;
  		}
  		$chaineLem="";
  		
  	}
  }
  
  print XML "
  \t</wd>
  $chaineLem</phr>
  </seg>
  </Segmentation>";
  
  close(XML);
  close(TAG);