~jtv/corpusfiltergraph/cross-python

« back to all changes in this revision

Viewing changes to trunk/lib/corpusfg/graphs/sa-champollion/hn/Htokenize

  • Committer: tahoar
  • Date: 2012-05-02 15:46:23 UTC
  • Revision ID: svn-v4:bc069b21-dff4-4e29-a776-06a4e04bad4e::266
new layout. need to update code to use the new layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -p
 
2
#
 
3
# Purpose: tokenize hindi text, put spaces around numbers,
 
4
#          ascii punctuations, and hindi end of sentence marks.
 
5
#          Can be piped into another process to split at spaces
 
6
#          to get a token array.
 
7
# Author : Xiaoyi Ma, 6/5/2003
 
8
$| = 1; # disable Perl output buffering
 
9
 
 
10
#use utf8;
 
11
 
 
12
 
 
13
#$Usage = "Usage: $0 [filename]\n";
 
14
#die $Usage if ( @ARGV > 1 or ( @ARGV == 1 and ! -f $ARGV[0] ));
 
15
 
 
16
if ( @ARGV ) {
 
17
    open( STDIN, shift );
 
18
}
 
19
 
 
20
binmode STDIN, ":utf8";
 
21
binmode STDOUT, ":utf8";
 
22
 
 
23
 
 
24
# put space after any period that's followed by a non-number
 
25
s/\.([^0-9])/\. $1/g;
 
26
# put space before any period that's followed by a space
 
27
# the following space is introduced in the previous command
 
28
s/\. / \. /g;
 
29
 
 
30
# put space around colons and comas, unless they're surrounded by numbers
 
31
s/([0-9])\:([0-9])/$1<CLTKN>$2/g;
 
32
s/\:/ \: /g;
 
33
s/([0-9])<CLTKN>([0-9])/$1\:$2/g;
 
34
s/([0-9])\,([0-9])/$1<CMTKN>$2/g;
 
35
s/\,/ \, /g;
 
36
s/([0-9])<CMTKN>([0-9])/$1\,$2/g;
 
37
 
 
38
 
 
39
# put space around any other punctuation
 
40
s/([^ ])\!/$1 \! /g;
 
41
s/([^ ])\?/$1 \? /g;
 
42
s/([^ ])\;/$1 \; /g;
 
43
s/([^ ])\"/$1 \" /g;
 
44
s/([^ ])\)/$1 \) /g;
 
45
s/([^ ])\(/$1 \( /g;
 
46
s/\(/ \( /g;
 
47
s/([^ ])\//$1 \/ /g;
 
48
 
 
49
# put spaces around special symbols
 
50
s/([^ ])\@/$1 \@ /g;
 
51
s/([^ ])\%/$1 \% /g;
 
52
s/([^ ])\$/$1 \$ /g;
 
53
s/([^ ])\+/$1 \+ /g;
 
54
s/([^ ])\-/$1 \- /g;
 
55
s/([^ ])\#/$1 \# /g;
 
56
s/([^ ])\*/$1 \* /g;
 
57
s/([^ ])\[/$1 \[ /g;
 
58
s/([^ ])\]/$1 \] /g;
 
59
s/([^ ])\>/$1 \> /g;
 
60
s/([^ ])\</$1 \< /g;
 
61
s/([^ ])\_/$1 \_ /g;
 
62
s/([^ ])\\/$1 \\ /g;
 
63
s/([^ ])\|/$1 \| /g;
 
64
s/([^ ])\=/$1 \= /g;
 
65
 
 
66
# put spaces around hindi end of sentence marks
 
67
s/\x{0964}|\x{0965}/ $& /g;