-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdemo.html
302 lines (248 loc) · 8.88 KB
/
demo.html
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<html><head><title>JSASTEM - JavaScript Arabic Stemmer - DEMO</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
body { width: 100%; background-color: #DDD; }
body, div { margin: 0; padding: 0; }
/*
a { color: black; text-decoration: none; }
*/
.button {
width: 100%; background-color: silver;
font-size: xx-large; text-align: center;
padding-top: 10px; padding-bottom: 10px;
}
hr { margin: 5px; }
.c_word {
border: 1px silver solid;
}
</style>
<meta name='viewport' content='width=device-width'/>
</head>
<body>
<!--
http://www.openjs.com/scripts/events/keyboard_shortcuts/
<script type="text/javascript" src="jslib/jquery.ba-hashchange.min.js"></script>
<script type="text/javascript" src="jslib/shortcut.js"></script>
-->
<script type="text/javascript" src="jslib/jquery.js"></script>
<script type="text/javascript" src="jslib/xregexp-all-min.js"></script>
<script type="text/javascript" src="jsastem.js"></script>
<!--
<script type="text/javascript" src="aa-ll-data.js"></script>
<script type="text/javascript" src="aa-ls-data.js"></script>
-->
<textarea rows=10 cols=100 id=input style='height: auto; background-color: #ffd;'>
abcdefghijklmnopqrstuvwxyz
01234567890
قنطر قنطار قناطير
فعلال
فعاليل
معلل
مضطرب
فعالل
افعلال
متفعلل
مستفعل - استفعل
تفاعيل - مفاعيل
مفعالة
افتعال
افعوعل
فعالل
مفعلل
افتعل - افاعل
مفعول - مفعال - مفعيل
مفعلة - تفعلة - افعلة
مفتعل - يفتعل - تفتعل
مفاعل - تفاعل
فعولة - فعالة
انفعل - منفعل
افعال
فعلان
تفعيل
فاعول
فواعل
فعائل
فاعلة
فعالي
مفعل
فاعل فعال - فعول - فعيل
فعلة البيت ووعدهم نوركما أكرم
Arabic Pangrams:
صِف خَلقَ خَودِ كَمِثلِ الشَمسِ إِذ بَزَغَت — يَحظى الضَجيعُ بِها نَجلاءَ مِعطارِ (A poem by Al Farāhīdi)
نص حكيم له سر قاطع وذو شأن عظيم مكتوب على ثوب أخضر ومغلف بجلد أزرق
nṣ ḥkym lh sr qāṭʿ uḏu šān ʿẓym mktub ʿala ṯub aẖḍr umġlf bǧld azrq
A wise text which has an absolute secret and great importance, written on a green cloth and covered with blue leather (it has a riddle built into it)
ابجد هوز حطي كلمن سعفص قرشت ثخذ ضظغ
Some other difficult words:
يعد منعت إضربن كتابهما حفظة
بالإستنصارهما مفاتيح مدرسة
فليصمه
ثقفتموهم
etc. etc. etc.
</textarea>
<input type=button onClick='javascript:do_stemming()' value=" Go ">
<textarea rows=10 cols=50 id=debug style=' font-size: 200%;' >
</textarea>
<div id=text style=' display: none;'>
This is some text. Please note it's lots of text. Try clicking on a word.
This is some text. Please note it's lots of text. Try clicking on a word.
This is some text. Please note it's lots of text. Try clicking on a word.
This is some text. Please note it's lots of text. Try clicking on a word.
This is some text. Please note it's lots of text. Try clicking on a word.
This is some text. Please note it's lots of text. Try clicking on a word.
This is some text. Please note it's lots of text. Try clicking on a word.
This is some text. Please note it's lots of text. Try clicking on a word.
This is some text. Please note it's lots of text. Try clicking on a word.
This is some text. Please note it's lots of text. Try clicking on a word.
This is some text. Please note it's lots of text. Try clicking on a word.
This is some text. Please note it's lots of text. Try clicking on a word.
</div>
<hr>
<div id=header style=" font-size: larger; float: right; ">
The Word
</div>
<div id='main'>
</div>
<hr>
<script>
/*
var current_layer = 0;
var layer_colors = [ 'pink', "blue", "yellow", "green", "red", "purple"];
var layer_bgcolors = [ 'black', "#ddf", "#ffd", "#dfd" , "#fdd", "#fdf"];
layers[0][0] = '0_32'; // <- this the $layer_$wordcount of the word that has been clicked in the particular layer
layers[0][1] = 'blah'; // <- This is the actual word that's being displayed in the layer on top, as it may be (slightly) different
layers[1][0] = '1_32';
layers[1][1] = 'nice';
This then becomes the following hash in the window bar for bookmarking, sharing and navigation use.
http://the.url/page.html#0_32,blah,1_32,nice
*/
var layers = new Array();
var JSaStemRegexps =
{ "step 1": {"info" : "This removes suffixes", "regexes": [
["(aa|bb|cc|dd|ee|90)$", "" ],
["xyz$", ""]
]}
};
// main()
// Load initial test data:
do_stemming();
function do_stemming() {
//debug(JSaStemRegexps["step 1"].regexes);
//debug(JSaStemRegexps);
//console.log(JSaStemRegexps);
// Great, \w doesn't match arabic unicode letters! >:(
// But there is XRegExp
//XRegExp.matchRecursive( $("#input").text(),
//XRegExp('[\\p{Latin}\\p{Common}]');
//XRegExp.install('natives');
//$("#input").text().replace( /(\\p{Arabic}+)/g, function( word) {
//$("#input").text().replace( '/(\p{L}+)/g', function( word) {
//stem( word);
//})
//XRegExp.forEach( $("#input").text(), /\p{L}+/, function(match, i) {
XRegExp.forEach( $("#input").text(), XRegExp('[\\p{Arabic}\\p{M}]+'), function(match, i) {
//if (i % 2) this.push(+match[0]);
//debug(match);
var thestem = jsastem(match[0]);
debug( 'STEM returned: ' + thestem);
}, []);
}
/*
var myJSONObject = {"bindings": [
{"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
{"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
{"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
]
};
*/
// =============== end of jsastem.js ====================
function spanify_text( id, source_layer) {
//debug( 'id: ' + id + ' sl: ' + source_layer);
var word_count = 0;
target = source_layer + 1;
$(id).html(
$(id).text().replace( /(\w+)/g, function( word) {
return '<span class=span_' + source_layer + ' id="' + source_layer + '_' + ++word_count + '" '
+ 'onClick="javascript:set_layer(this,'+source_layer+')">' + word + '</span>';
//+ 'onClick="javascript:set_layer(this,'+target+')">' + word + '</span>';
})
);
/*
$(id + ' span').click(function() {
//alert("Handler for .click() called.");
//debug(target);
setup_layer( this, target);
//$("#" + new_layer).remove();
});
$(id + ' span').css( 'border', '1px solid silver');
var text = $(id).text();
var pattern = /(\w+)/g;
var match;
while (match = pattern.exec(text)) {
match = 'T';
}
//$(id).text().replace(/(\w+)/g, '<span class=span_' + source_layer + ' onClick="javascript:setup_layer(this,'+target+')">$1</span>' )
//$(id).text().replace(/(\w+)/g, '<span class=span_' + source_layer + ' onClick="javascript:setup_layer(this,'+target+')">$1</span>' )
$(id).html( text);
//$(id + ' span').prepend(source_layer+':');
//alert("test");
var words = $("#text").text().split(/[\s,]+/);
//$("p").empty();
$.each(words, function(i, v) {
$("#main").append(
"<span class=c_word onClick=javascript:do_something(this)>" + v + "</span> "
);
});
*/
}
function debug( obj) {
$('#debug').append( dump(obj) + "<br>");
//console.log( str);
}
/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
* The level - OPTIONAL
* Returns : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
* Docs: http://www.openjs.com/scripts/others/dump_function_php_print_r.php
*/
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;
//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += " ";
if(typeof(arr) == 'object') { //Array/Hashes/Objects
for(var item in arr) {
var value = arr[item];
if(typeof(value) == 'object') { //If it is an array,
dumped_text += level_padding + "'" + item + "' ...\n";
dumped_text += dump(value,level+1);
} else {
dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
}
}
} else { //Strings/Chars/Numbers etc.
dumped_text = "("+typeof(arr)+")("+arr.length+") => "+arr+" <=\n";
}
return dumped_text;
}
</script>
<!-- YAMLI CODE START -->
<!--
<script type="text/javascript" src="http://api.yamli.com/js/yamli_api.js"></script>
<script type="text/javascript">
if (typeof(Yamli) == "object" && Yamli.init( { uiLanguage: "en" , startMode: "onOrUserDefault" } ))
{
// id of your text box to yamlify
Yamli.yamlify( "test1", { settingsPlacement: "bottomLeft" } );
}
</script>
-->
<!-- YAMLI CODE END -->
</body>
</html>