Skip to content

Commit

Permalink
feat(admin/mapping): add synonym filter and implement into demo (ems-…
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 authored Sep 24, 2024
1 parent a99ccff commit 5761edf
Show file tree
Hide file tree
Showing 23 changed files with 176 additions and 23 deletions.
18 changes: 18 additions & 0 deletions EMS/core-bundle/src/Form/Field/FilterOptionsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
Expand Down Expand Up @@ -34,6 +35,9 @@ class FilterOptionsType extends AbstractType
'asciifolding' => [
'preserve_original',
],
'synonym' => [
'synonyms',
],
];

/**
Expand All @@ -50,6 +54,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'Stemmer' => 'stemmer',
'Elision' => 'elision',
'ASCII Folding' => 'asciifolding',
'Synonym' => 'synonym',
],
'attr' => [
'class' => 'fields-to-display-by-input-value',
Expand Down Expand Up @@ -174,6 +179,19 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
])->add('articles', TextareaType::class, [
'attr' => ['class' => 'filter_option fields-to-display-for fields-to-display-for-elision'],
'required' => false,
])->add('synonyms', CollectionType::class, [
'entry_type' => TextType::class,
'attr' => [
'class' => 'a2lix_lib_sf_collection filter_option fields-to-display-for fields-to-display-for-synonym',
'data-lang-add' => 'Add synonyms',
'data-lang-remove' => 'X',
'data-entry-remove-class' => 'btn btn-danger',
],
'entry_options' => [
'label' => false,
],
'allow_add' => true,
'allow_delete' => true,
]);

$textArea2Array = new CallbackTransformer(
Expand Down
2 changes: 1 addition & 1 deletion demo/configs/admin/analyzer/dutch_for_highlighting.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"type": "custom",
"tokenizer": "standard"
},
"orderKey": 2
"orderKey": 3
},
"replaced": []
}
24 changes: 24 additions & 0 deletions demo/configs/admin/analyzer/dutch_with_synonyms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"class": "EMS\\CoreBundle\\Entity\\Analyzer",
"arguments": [],
"properties": {
"name": "dutch_with_synonyms",
"dirty": true,
"label": "Dutch (synonyms)",
"options": {
"filter": [
"standard",
"lowercase",
"dutch_stemmer",
"dutch_stop",
"empty_elision",
"business_synonyms"
],
"char_filter": [],
"type": "custom",
"tokenizer": "standard"
},
"orderKey": 2
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/analyzer/english_for_highlighting.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"type": "custom",
"tokenizer": "standard"
},
"orderKey": 3
"orderKey": 5
},
"replaced": []
}
24 changes: 24 additions & 0 deletions demo/configs/admin/analyzer/english_with_synonyms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"class": "EMS\\CoreBundle\\Entity\\Analyzer",
"arguments": [],
"properties": {
"name": "english_with_synonyms",
"dirty": true,
"label": "English (synonyms)",
"options": {
"filter": [
"standard",
"lowercase",
"empty_elision",
"english_stemmer",
"english_stop",
"business_synonyms"
],
"char_filter": [],
"type": "custom",
"tokenizer": "standard"
},
"orderKey": 4
},
"replaced": []
}
4 changes: 2 additions & 2 deletions demo/configs/admin/analyzer/french_for_highlighting.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"options": {
"filter": [
"standard",
"asciifolding",
"lowercase",
"french_elision",
"french_stop",
"french_stemmer",
"french_stop"
],
Expand All @@ -20,7 +20,7 @@
"type": "custom",
"tokenizer": "standard"
},
"orderKey": 4
"orderKey": 7
},
"replaced": []
}
24 changes: 24 additions & 0 deletions demo/configs/admin/analyzer/french_with_synonyms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"class": "EMS\\CoreBundle\\Entity\\Analyzer",
"arguments": [],
"properties": {
"name": "french_with_synonyms",
"dirty": true,
"label": "French (synonyms)",
"options": {
"filter": [
"standard",
"lowercase",
"french_elision",
"french_stop",
"french_stemmer",
"business_synonyms"
],
"char_filter": [],
"type": "custom",
"tokenizer": "standard"
},
"orderKey": 6
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/analyzer/german_for_highlighting.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"type": "custom",
"tokenizer": "standard"
},
"orderKey": 5
"orderKey": 9
},
"replaced": []
}
24 changes: 24 additions & 0 deletions demo/configs/admin/analyzer/german_with_synonyms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"class": "EMS\\CoreBundle\\Entity\\Analyzer",
"arguments": [],
"properties": {
"name": "german_with_synonyms",
"dirty": true,
"label": "German (synonyms)",
"options": {
"filter": [
"standard",
"lowercase",
"empty_elision",
"german_stemmer",
"german_stop",
"business_synonyms"
],
"char_filter": [],
"type": "custom",
"tokenizer": "standard"
},
"orderKey": 8
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/analyzer/html_strip.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "custom",
"tokenizer": "standard"
},
"orderKey": 6
"orderKey": 10
},
"replaced": []
}
21 changes: 21 additions & 0 deletions demo/configs/admin/analyzer/standard_with_synonyms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"class": "EMS\\CoreBundle\\Entity\\Analyzer",
"arguments": [],
"properties": {
"name": "standard_with_synonyms",
"dirty": true,
"label": "Standard (with synonyms)",
"options": {
"type": "custom",
"tokenizer": "standard",
"char_filter": [],
"filter": [
"standard",
"lowercase",
"business_synonyms"
]
},
"orderKey": 11
},
"replaced": []
}
18 changes: 18 additions & 0 deletions demo/configs/admin/filter/business_synonyms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"class": "EMS\\CoreBundle\\Entity\\Filter",
"arguments": [],
"properties": {
"name": "business_synonyms",
"dirty": true,
"label": "business_synonyms",
"options": {
"type": "synonym",
"synonyms": [
"ipod, i-pod, i pod",
"ElasticMS, Elastic MS"
]
},
"orderKey": 1
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/filter/dutch_stemmer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "stemmer",
"name": "dutch"
},
"orderKey": 1
"orderKey": 3
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/filter/dutch_stop.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "stop",
"ignore_case": false
},
"orderKey": 2
"orderKey": 4
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/filter/empty_elision.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"type": "elision",
"articles_case": false
},
"orderKey": 3
"orderKey": 2
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/filter/english_stemmer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "stemmer",
"name": "english"
},
"orderKey": 4
"orderKey": 5
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/filter/english_stop.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "stop",
"ignore_case": false
},
"orderKey": 5
"orderKey": 6
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/filter/french_elision.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"type": "elision",
"articles_case": false
},
"orderKey": 6
"orderKey": 7
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/filter/french_stemmer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "stemmer",
"name": "light_french"
},
"orderKey": 7
"orderKey": 8
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/filter/french_stop.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "stop",
"ignore_case": false
},
"orderKey": 8
"orderKey": 9
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/filter/german_stemmer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "stemmer",
"name": "light_german"
},
"orderKey": 9
"orderKey": 10
},
"replaced": []
}
2 changes: 1 addition & 1 deletion demo/configs/admin/filter/german_stop.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "stop",
"ignore_case": false
},
"orderKey": 10
"orderKey": 11
},
"replaced": []
}
Loading

0 comments on commit 5761edf

Please sign in to comment.