Warning, /education/gcompris/src/activities/grammar_analysis/README.md is written in an unsupported language. File is not indexed.

0001 **GCompris** - grammar_classes and grammar_analysis activities.\
0002 **Instructions to create new content.** 
0003 
0004 [[_TOC_]]
0005 
0006 # Testing your files
0007 
0008 To start and test your translated files:
0009 
0010 * Copy the example files: [grammar_analysis-xx.json](examples/grammar_analysis-xx.json) and [grammar_classes-xx.json](examples/grammar_classes-xx.json) in the directory depending on your operating system (on Linux, it is `$HOME/.local/share/GCompris/`, on Windows it is `C:\Users\Username\AppData\Local\gcompris\`, on Android it is `/Android/data/net.gcompris.full/files/GCompris/`).
0011 * When those files exist, they will be used by default by GCompris.
0012 * Edit the content of those files for your language, starting with the `syntax` section at the end of the file, then the `dataset` section and then the `levels` section. Read below for more details on each section.
0013 
0014 ## Precautions when writing JSON files
0015 
0016 - JSON files must not have any error in the position of quotes `""`, curly brackets `{}` and square brackets `[]`.
0017 - Items in lists must be separated by a comma `,`.
0018 - The last item of a list must not be followed by a comma.
0019 - The JSON language does not contain comments.
0020 
0021 If your file contains that kind of mistake, you will see an error message when starting the activity.\
0022 To locate the errors in your file:
0023 - If you use an advanced text editor it may show you where the problem is.
0024 - The Firefox browser can help you validate a JSON file. Open the file with Firefox, if it's displayed it means it is correct, else a message will tell you on which line the problem is.
0025 - You can use some online JSON analysis tools like [this one](https://jsonformatter.org/json-parser).
0026 
0027 Copy/Paste all the content of your JSON file in the parser, you will get a description of the error.\
0028 Example : `JSON.parse: expected ',' or '}' after property value in object at line 78 column 5 of the JSON data`.
0029 
0030 ## Structure of a JSON file
0031 
0032 A JSON file is composed of 3 parts:
0033 
0034     {
0035       "levels": [...],
0036       "dataset": {...},
0037       "syntax": [...]
0038     }
0039 
0040 In each file, the keys must not be changed (on the left side of ":"), only the content of the values on the right side must be changed.
0041 
0042 ## Declaring the syntax
0043 
0044 The grammatical classes of your language must be defined in the `syntax` part.\
0045 
0046     "syntax" : [
0047       { "code": "nou",
0048         "wordClass": "Noun",
0049         "image": "1.svg"
0050       },
0051       { "code": "dtm",
0052         "wordClass": "Determiner",
0053         "image": "2.svg"
0054       }, ...
0055     ]
0056 
0057 Each grammatical class is defined by 3 values:
0058 
0059 - `code` - this is used to name the grammatical class in the exercises solutions (we advise to use a 3 letters length code, but you can use any length).
0060 - `wordClass` - this is used for the actual name of the grammatical class which will be displayed.
0061 - `image` - the image which will be used to represent this class. It must be one of the images in the directory `resource/svg/` of the `grammar_analysis` activity (you can find the list of images below in the `Available images` section).
0062 
0063 This way you can define the list of grammatical classes in your language.\
0064 You can delete a class which is not used in your language or add new ones if needed.\
0065 The classes will be displayed in the same order as they are declared in the `syntax` section.\
0066 If there are not enough images to represent all your classes, let us know and we will add new ones as needed.
0067 
0068 ### Base grammatical classes
0069 
0070     noun
0071     determiner
0072     adjective
0073     pronoun
0074     verb
0075     adverb
0076     conjunction
0077     preposition
0078     interjection
0079 
0080 ### Available images
0081 - `1.svg`: black triangle, used for nouns in English.
0082 - `2.svg`: small light blue triangle, used for determiners in English.
0083 - `3.svg`: medium dark blue triangle, used for adjectives in English.
0084 - `4.svg`: purple triangle, used for pronouns in English.
0085 - `5.svg`: red circle, used for verbs in English.
0086 - `6.svg`: small orange circle, used for adverbs in English.
0087 - `7.svg`: pink horizontal rectangle, used for conjunctions in English.
0088 - `8.svg`: green arc, used for prepositions in English.
0089 - `9.svg`: yellow exclamation mark, used for interjections in English.
0090 - `10.svg`: inverted small ping triangle, not used in English.
0091 - `11.svg`: inverted medium orange triangle, not used in English.
0092 - `12.svg`: inverted red arc, not used in English.
0093 - `13.svg`: green vertical rectangle, not used in English.
0094 - `14.svg`: inverted red triangle, not used in English.
0095 - `15.svg`: inverted pink triangle, not used in English.
0096 - `16.svg`: half blue circle, not used in English.
0097 - `17.svg`: half small black circle, not used in English.
0098 - `18.svg`: green rhombus, not used in English.
0099 - `19.svg`: small purple rhombus, not used in English.
0100 - `20.svg`: medium dark blue rhombus, not used in English.
0101 - `21.svg`: light blue star, not used in English.
0102 - `22.svg`: small black star, not used in English.
0103 - `23.svg`: small orange plus, not used in English.
0104 - `24.svg`: light blue overlapped circles, not used in English.
0105 
0106 ## Exercises definition
0107 
0108 The exercises are defined in the `dataset` part.
0109 
0110 ### Exercises groups
0111 
0112 Each exercise is defined inside of a named group.\
0113 The example files contain 3 groups `small`, `medium` and `large` to represent the length of the sentences.\
0114 These names are a suggestion but if you want you can rename them, delete some or add new ones.\
0115 You can add as many exercises as you want in each group.
0116 
0117     "dataset" : {
0118       "small" : [
0119         { "sentence": "This vanilla cream smells very good."
0120         , "answer":   "dtm nou nou vrb adv adj"
0121         }, ...
0122       ],
0123       "medium" : [
0124         { "sentence": "The entrance to the college is inaccessible until further notice."
0125         , "answer":   "dtm nou     ppt dtm nou     vrb adj         ppt   adj     nou"
0126         },...
0127       ]
0128     }
0129 
0130 ### Exercises
0131 
0132 Each exercise is composed of a sentence and an answer containing its full syntax analysis.
0133 
0134       { "sentence": "The magpie wanders on the balcony."
0135       , "answer":   "dtm nou vrb ppt dtm nou"
0136       },
0137       { "sentence": "(Ding dong)! The doorbell rings."
0138       , "answer":   "    itj      dtm nou      vrb"
0139       },
0140       { "sentence": "花 は とても きれいです。"
0141       , "answer":   "nou vrb adv adj"
0142       }    
0143 
0144 ### Syntax rules
0145 
0146 * You can add multiple spaces in `sentence` and `answer`, they will be automatically deleted.
0147 * Punctuation signs are not considered.
0148 * Multiple words can be grouped together with parenthesis, like in `(Ding dong)` (but they should be nested).
0149 * Some languages allow to combine several words into one word, with each part of the word keeping its own class. In this case, use the operator `+` between the classes. Examples: `(Isn't) it?` = `vrb+adv prn`, `ശേഷം ആനയോടി.` = `avyayam naamam+kriya`.
0150 * The number of words in a `sentence` should be the same as the number of grammatical classes in `answer`.
0151 * For languages which don't use spaces to separate words, we still need to have spaces between words to identify them in `sentence`. The activity will take care of deleting the spaces before displaying the sentences. The last sentence of the example above will be displayed as `花はとてもきれいです。`.
0152 
0153 ### Space characters management
0154 
0155 If you want you can use space characters to align visually to words and their grammatical codes.
0156 
0157     { "sentence": "The magpie wanders on  the balcony."
0158     , "answer":   "dtm nou    vrb     ppt dtm nou"
0159     }
0160 
0161 For languages with RTL writing systems, it may be better to use syntax codes in the same writing system to keep the same direction, order and alignment in a `sentence` and its `answer`.
0162 
0163     { "sentence": "הפרח יפה מאוד."      // right to left
0164     , "answer":   "שם פועל תואר"        // right to left
0165     },
0166 
0167 ## Levels
0168 
0169 Levels are defined in the `levels` part for each activity.
0170 
0171     "levels": [
0172       {
0173         "objective": "Find nouns and verbs.",
0174         "difficulty": "1",
0175         "exercise": "small",
0176         "goal": "nou vrb"
0177       },
0178       {
0179       "objective": "Find nouns, verbs and determinants.",
0180         "difficulty": "1",
0181         "exercise": "small",
0182         "goal": "nou vrb dtm"
0183       },
0184 
0185 Each level contains 4 values:
0186 
0187 - `objective`    - the description displayed in the activity.
0188 - `difficulty`   - the difficulty level (not used for now).
0189 - `exercise`     - the name of the exercise group to use.
0190 - `goal`         - the list of grammatical classes to identify.
0191 
0192 When the translationMode is activated, all the sentences in the exercise group will be displayed for the level. Else for users, sentences are filtered to use only relevant sentences (see below for the details).
0193 
0194 ### Notes for each activity
0195 
0196 `grammar_classes` is meant to learn each class separately, so the `goal` must contain only one class to identify. If the `goal` contains several classes, only the first one will be used.\
0197 The content of the exercise group will be filtered to use only sentences which contain the class to identify in `goal`.
0198 
0199 `grammar_analysis` is meant to analyze all the words in a sentence, so the `goal` must contain several classes to identify, possibly all of them.\
0200 The content of the exercise group will be filtered to use only sentences which contain at least one class to identify in `goal`.
0201 
0202 ### Exercises order
0203 
0204 When the translationMode is activated, the exercises will be displayed in the same order as they are defined in the JSON files.
0205 
0206 Else for users, the exercises order will be shuffled to display the sentences in random order.
0207 
0208 # Syntax check
0209 
0210 There are several levels of syntax check.
0211 
0212 ## When starting the activity:
0213 
0214 * Check if the syntax of the JSON file (as described above) is correct.
0215 * Check if the 3 main parts (`levels`, `dataset` et `syntax`) are defined.
0216 
0217 In both cases, if there is an error, you will see an error message, and the activity will not load any exercise.
0218 
0219 ## For each exercise:
0220 
0221 * Check that the words count in `sentence` and the count of grammatical codes in `answer` are identical.
0222 * Check that the grammatical classes in `goal` and `answer` exist in `syntax`.
0223 
0224 An error message will tell you if there is any problem when loading an exercise.
0225 
0226 # The translation mode
0227 
0228 People writing JSON files have access to features to help testing the files.
0229 Those features are available when the `translation mode` is activated at compilation time. We will provide special builds with this mode activated.
0230 
0231 The shortcuts `Alt+Right` and `Alt+Left` load respectively the next and previous exercise.
0232 
0233 You can activate the "debug information" with the shortcut `Ctrl+Alt+Return`.\
0234 When "debug information" is activated, you will see the following extra info.
0235 
0236 ## General information
0237 
0238 On the top-left of the screen, some info about the running exercise:
0239 
0240 ![Activity informations](examples/activity-info.png)
0241 
0242 - The name of the activity.
0243 - The selected locale.
0244 - The name of the JSON file used.
0245 - The number of the exercise displayed.
0246 - The `goal` of the exercise.
0247 - The `sentence` displayed.
0248 - The corresponding `answer`.
0249 
0250 ## Info about each word of the sentence
0251 
0252 ![Debug informations](examples/activity-debug.png)
0253 
0254 - The lines above the sentence allow to visualize the words, the separation spaces and the punctuation.
0255 - Above the words, the requested classes for the corresponding slots. A `_` means an empty slot is expected.