Subversion Repositories wimsdev

Rev

Rev 7190 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7190 Rev 17348
Line 14... Line 14...
14
!endif
14
!endif
15
 
15
 
16
<h2>Symtext documentation</h2>
16
<h2>Symtext documentation</h2>
17
 
17
 
18
!href cmd=help&special_parm=symtext,list List of symtext styles
18
!href cmd=help&special_parm=symtext,list List of symtext styles
19
.
19
.
20
<p>
20
<p>
21
 
21
 
22
Symtext is a natural language parsing syntax. It is designed to make it
22
Symtext is a natural language parsing syntax. It is designed to make it
23
easier to identify different ways to say the same thing in natural language,
23
easier to identify different ways to say the same thing in natural language,
24
and its main purpose is for the recognition of freely typed or composed
24
and its main purpose is for the recognition of freely typed or composed
Line 69... Line 69...
69
correct use of this feature can solve most of the problems related to typing
69
correct use of this feature can solve most of the problems related to typing
70
errors and unexpected answers.
70
errors and unexpected answers.
71
</li>
71
</li>
72
</ul>
72
</ul>
73
 
73
 
74
<hr /><h3>
74
<hr><h3>
75
How it works</h3>
75
How it works</h3>
76
<p>
76
<p>
77
Symtext deals with the problem of comparing two sentences. The first is the
77
Symtext deals with the problem of comparing two sentences. The first is the
78
<em>sample</em> which is typically the answer given to an exercise. It is
78
<em>sample</em> which is typically the answer given to an exercise. It is
79
compared to the second sentence, the <em>tester</em>, which is typically the
79
compared to the second sentence, the <em>tester</em>, which is typically the
Line 97... Line 97...
97
characters will be reduced to one space.
97
characters will be reduced to one space.
98
</p><p>
98
</p><p>
99
 
99
 
100
A set of basic <em>builtin rules</em> are defined in the symtext syntax. For
100
A set of basic <em>builtin rules</em> are defined in the symtext syntax. For
101
example, the rule <span class="tt">[Iperm:x,and,y]</span> matches both samples "x and y"
101
example, the rule <span class="tt">[Iperm:x,and,y]</span> matches both samples "x and y"
102
and "y and x". Rules can be nested:
102
and "y and x". Rules can be nested:
103
<pre>neither [Aperm:[Alt:I,me,we,us],nor,our teacher]</pre>
103
<pre>neither [Aperm:[Alt:I,me,we,us],nor,our teacher]</pre>
104
matches the following 8 cases.
104
matches the following 8 cases.
105
</p><p>
105
</p><p>
106
 
106
 
107
"neither I nor our teacher", "neither our teacher nor I", "neither me nor
107
"neither I nor our teacher", "neither our teacher nor I", "neither me nor
Line 154... Line 154...
154
the whole sample. Match does not occur if the tester only matches a part of
154
the whole sample. Match does not occur if the tester only matches a part of
155
the sample. However, wildcard rules can be included in the tester if part of
155
the sample. However, wildcard rules can be included in the tester if part of
156
the sample needs to be ignored.
156
the sample needs to be ignored.
157
</p>
157
</p>
158
 
158
 
159
<hr /><h3>Details of the syntax</h3>
159
<hr><h3>Details of the syntax</h3>
160
 
160
 
161
<b>Definitions</b>. <ul>
161
<b>Definitions</b>. <ul>
162
<li>A <em>tstring</em> is a succession of <em>atoms</em>.
162
<li>A <em>tstring</em> is a succession of <em>atoms</em>.
163
</li><li>An <em>atom</em> is either a <em>word</em>, a <em>bracket block</em> or
163
</li><li>An <em>atom</em> is either a <em>word</em>, a <em>bracket block</em> or
164
a positional macro name.
164
a positional macro name.
Line 180... Line 180...
180
 
180
 
181
Syntax of the matching rule: <span class="tt">[rule_name:parameters]</span>.
181
Syntax of the matching rule: <span class="tt">[rule_name:parameters]</span>.
182
<em>rule_name</em> must start with the first character of the block, it must
182
<em>rule_name</em> must start with the first character of the block, it must
183
be a valid rule name, and the colon must immediately follow the name (no
183
be a valid rule name, and the colon must immediately follow the name (no
184
spaces inserted). Otherwise the block will be treated as a normal tstring
184
spaces inserted). Otherwise the block will be treated as a normal tstring
185
rather than a rule.
185
rather than a rule.
186
</p><p>
186
</p><p>
187
 
187
 
188
<em>Parameters</em> is a comma-separated list of strings. Each parameter can
188
<em>Parameters</em> is a comma-separated list of strings. Each parameter can
189
be a tstring itself (hence can contain nested subrules), except in some
189
be a tstring itself (hence can contain nested subrules), except in some
190
special cases of builtin rules where some of the parameter has a special
190
special cases of builtin rules where some of the parameter has a special
Line 205... Line 205...
205
equivalent to <span class="tt">[Wild:* *]</span>, etc. A block falls into this category if
205
equivalent to <span class="tt">[Wild:* *]</span>, etc. A block falls into this category if
206
the first character is a '<span class="tt">*</span>'.
206
the first character is a '<span class="tt">*</span>'.
207
 
207
 
208
</ul>
208
</ul>
209
 
209
 
210
<hr /><h3>Builtin rules</h3>
210
<hr><h3>Builtin rules</h3>
211
<p>
211
<p>
212
A builtin rule is a matching rule where the first character of the name is
212
A builtin rule is a matching rule where the first character of the name is
213
upper-case.
213
upper-case.
214
</p><p>
214
</p><p>
215
 
215
 
216
Any parameter may include the comma character, as long as it is enclosed by
216
Any parameter may include the comma character, as long as it is enclosed by
217
a pair of parentheses or brackets.
217
a pair of parentheses or brackets.
218
</p>
218
</p>
219
 
219
 
220
 
220
 
221
 
221
 
222
!read tabletheme
222
!read tabletheme
223
!set wims_backslash_insmath=yes
223
!set wims_backslash_insmath=yes
224
$table_header
224
$table_header
225
$table_hdtr
225
$table_hdtr
226
<th>name</th>
226
<th>name</th>
227
<th><small>Number of<br />parameters</small></th>
227
<th><small>Number of<br>parameters</small></th>
228
<th>Effect</th>
228
<th>Effect</th>
229
<th>Detail</th>
229
<th>Detail</th>
230
</tr>
230
</tr>
231
$table_tr
231
$table_tr
232
<td>Alt</td>
232
<td>Alt</td>
Line 255... Line 255...
255
<td>Dic</td>
255
<td>Dic</td>
256
<td align=middle>\(1)</td>
256
<td align=middle>\(1)</td>
257
<td>Dictionary check</td>
257
<td>Dictionary check</td>
258
<td><span class="tt">[Dic:wordtype transitive verb]</span> matches any word or group of
258
<td><span class="tt">[Dic:wordtype transitive verb]</span> matches any word or group of
259
words that is defined in the dictionary "wordtype", with a definition that
259
words that is defined in the dictionary "wordtype", with a definition that
260
contains an item "transitive verb".
260
contains an item "transitive verb".
261
 
261
 
262
Note. No word transformation is performed on the parameter of this rule.
262
Note. No word transformation is performed on the parameter of this rule.
263
</td></tr>
263
</td></tr>
264
$table_tr
264
$table_tr
265
<td>Dperm</td>
265
<td>Dperm</td>
Line 403... Line 403...
403
arbitrary words. For example, <br/>
403
arbitrary words. For example, <br/>
404
<span class="tt">[Wild:* * **3]</span> matches between 2 to 5 words (inclusive).
404
<span class="tt">[Wild:* * **3]</span> matches between 2 to 5 words (inclusive).
405
</td></tr>
405
</td></tr>
406
$table_end
406
$table_end
407
 
407
 
408
<hr /><h3>Construction of styles</h3>
408
<hr><h3>Construction of styles</h3>
409
<p>
409
<p>
410
A style corresponds to a directory and its contents. Under WIMS, the style
410
A style corresponds to a directory and its contents. Under WIMS, the style
411
can either be shared among all modules in the public_html/scripts/symtext
411
can either be shared among all modules in the public_html/scripts/symtext
412
directory, or be special to one module, in the module's directory.
412
directory, or be special to one module, in the module's directory.
413
</p><p>
413
</p><p>
414
 
414
 
415
The style must contain an index file, named <span class="tt">def</span>. It defines the
415
The style must contain an index file, named <span class="tt">def</span>. It defines the
416
basic configuration choices of the style. Every line of the file is a
416
basic configuration choices of the style. Every line of the file is a
417
definition under the format <span class="tt">name=value</span>.
417
definition under the format <span class="tt">name=value</span>.
418
</p><p>
418
</p><p>
419
 
419
 
420
The <span class="tt">def</span> file must contain a definition <span class="tt">style_exists=yes</span>,
420
The <span class="tt">def</span> file must contain a definition <span class="tt">style_exists=yes</span>,
421
otherwise the existence of the style will not be recognized. All the rest is
421
otherwise the existence of the style will not be recognized. All the rest is
422
optional.
422
optional.
423
</p><p>
423
</p><p>
424
 
424
 
425
It may contain a definition of <em>option</em>, that lists option words that
425
It may contain a definition of <em>option</em>, that lists option words that
426
will always be activated for the style.
426
will always be activated for the style.
427
</p><p>
427
</p><p>
428
 
428
 
429
It can also define general dictionaries using the name
429
It can also define general dictionaries using the name
430
<em>dictionaries</em>. The value must be a list of words, each corresponding
430
<em>dictionaries</em>. The value must be a list of words, each corresponding
431
to a dictionary file in the style. The number of general dictionaries is
431
to a dictionary file in the style. The number of general dictionaries is
Line 534... Line 534...
534
if one of the items in the definition is equal to the value given in the
534
if one of the items in the definition is equal to the value given in the
535
parameter of the rule.
535
parameter of the rule.
536
 
536
 
537
</p>
537
</p>
538
 
538
 
539
<hr /><h3>The command line program</h3>
539
<hr><h3>The command line program</h3>
540
 
540
 
541
The command line program <em>symtext</em> is specially built for WIMS, so that
541
The command line program <em>symtext</em> is specially built for WIMS, so that
542
all the input data are sent through environment variables. It can also be
542
all the input data are sent through environment variables. It can also be
543
used as a standalone program, but in this case it is better that a wrapper
543
used as a standalone program, but in this case it is better that a wrapper
544
script be used to put the input-output into a more *nix flavor.
544
script be used to put the input-output into a more *nix flavor.
Line 550... Line 550...
550
<th>Comments</th>
550
<th>Comments</th>
551
</tr>
551
</tr>
552
$table_tr
552
$table_tr
553
<td>wims_exec_parm</td>
553
<td>wims_exec_parm</td>
554
<td>The main data input</td>
554
<td>The main data input</td>
555
<td>A multi-line string.
555
<td>A multi-line string.
556
<ul>
556
<ul>
557
<li>Line 1: command followed by options. Valid commands:
557
<li>Line 1: command followed by options. Valid commands:
558
 <ul>
558
 <ul>
559
  <li><span class="tt">match</span> check matching.
559
  <li><span class="tt">match</span> check matching.
560
  </li>
560
  </li>
561
  <li><span class="tt">debug</span> check matching with debug information.
561
  <li><span class="tt">debug</span> check matching with debug information.
562
  </li>
562
  </li>
Line 575... Line 575...
575
</td></tr>
575
</td></tr>
576
 
576
 
577
$table_tr
577
$table_tr
578
<td>module_dir</td>
578
<td>module_dir</td>
579
<td>Directory to current module</td>
579
<td>Directory to current module</td>
580
<td>Automatically defined if called by WIMS. If this variable is undefined,
580
<td>Automatically defined if called by WIMS. If this variable is undefined,
581
then w_symtext must give the complete path of the style.
581
then w_symtext must give the complete path of the style.
582
</td></tr>
582
</td></tr>
583
 
583
 
584
$table_tr
584
$table_tr
585
<td>w_module_language</td>
585
<td>w_module_language</td>