-
Notifications
You must be signed in to change notification settings - Fork 0
/
nbsp-script.php
131 lines (126 loc) · 3.91 KB
/
nbsp-script.php
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/**
* @param $input_text
* @return string
*/
function nbsp2preposition($input_text) {
$nbspStrings = [
//one-letter prepositions
' a ' => ' a ',
'(a ' => '(a ',
' A ' => ' A ',
'A ' => 'A ',
'(A ' => '(A ',
' i ' => ' i ',
'(i ' => '(i ',
' I ' => ' I ',
'I ' => 'I ',
'(I ' => '(I ',
' o ' => ' o ',
'(o ' => '(o ',
' O ' => ' O ',
'O ' => 'O ',
'(O ' => '(O ',
' u ' => ' u ',
'(u ' => '(u ',
' U ' => ' U ',
'U ' => 'U ',
'(U ' => '(U ',
' s ' => ' s ',
'(s ' => '(s ',
' S ' => ' S ',
'S ' => 'S ',
'(S ' => '(S ',
' z ' => ' z ',
'(z ' => '(z ',
' Z ' => ' Z ',
'Z ' => 'Z ',
'(Z ' => '(Z ',
' k ' => ' k ',
'(k ' => '(k ',
' K ' => ' K ',
'K ' => 'K ',
'(K ' => '(K ',
' v ' => ' v ',
'(v ' => '(v ',
' v ' => ' v ', //two prepositions can happen here
' V ' => ' V ',
'V ' => 'V ',
'(V ' => '(V ',
//shortenings
' str. ' => ' str. ',
' hod.' => ' hod.',
' obr. ' => ' obr. ',
' tab. ' => ' tab. ',
' s. ' => ' s. ',
' č. ' => ' č. ',
'§ ' =>'§ ',
'# ' =>'# ',
' * ' =>' * ',
' † ' =>' † ',
//units
' m²' =>' m²',
' cm²' =>' cm²',
' dm²' =>' dm²',
' mm²' =>' dm²',
' m³' =>' m³',
' cm³' =>' cm³',
' dm³' =>' dm³',
' mm³' =>' dm³',
' kg' =>' kg',
' h' =>' h',
' %' =>' %',
' °C' =>' °C',
' Kč' =>' Kč',
' €' =>' €',
//abbreviations
' a. ' => ' a. ', //for a. s.
' o. ' => ' o. ',
' mn. ' => ' mn. ', //for mn. č.
' př. ' => ' př. ', //for př. n. l
' l. ' => ' l. ', //for př. n. l
'tj. ' =>'tj. ',
'tzv. ' =>'tzv. ',
'tzn. ' =>'tzn. ',
//degrees
' Bc. ' =>' Bc. ',
' BcA. ' =>' BcA. ',
' Ing. ' =>' Ing. ',
' Ing. arch. ' =>' Ing. arch. ',
' ICDr. ' =>' ICDr. ',
' JUDr. ' =>' JUDr. ',
' MDDr. ' =>' MDDr. ',
' Mgr. ' =>' Mgr. ',
' MgA. ' =>' MgA. ',
' MSDr. ' =>' MSDr. ',
' MUDr. ' =>' MUDr. ',
' MVDr. ' =>' MVDr. ',
' PaedDr. ' =>' PaedDr. ',
' PhDr. ' =>' PhDr. ',
' PhMr. ' =>' PhMr. ',
' RCDr. ' =>' RCDr. ',
' RNDr. ' =>' RNDr. ',
' RSDr. ' =>' RSDr. ',
' RTDr. ' =>' RTDr. ',
' ThDr. ' =>' ThDr. ',
' ThLic. ' =>' ThLic. ',
' ThMgr. ' =>' ThMgr. ',
' akad. ' =>' akad. ',
' ArtD. ' =>' ArtD. ',
' CSc. ' =>' CSc. ',
' Dr. ' =>' Dr. ',
' DrSc. ' =>' DrSc. ',
' DSc. ' =>' DSc. ',
' Ph.Dd. ' =>' Ph.D. ',
' Th.Dd. ' =>' Th.D. ',
' as. ' =>' as. ',
' odb. as. ' =>' odb. as. ',
' doc. ' =>' doc. ',
' prof. ' =>' prof. ',
];
return strtr($input_text, $nbspStrings);
}
// This can take $_GET or $_POST value from PHP form or any other text
// You will probably want to remove this line and use just the function for your purpose
echo nbsp2preposition($_GET["originalText"]);
?>