Skip to content

Commit

Permalink
small fantastico parsing improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Nov 4, 2023
1 parent caec36e commit 67ecbe7
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class AlcoholController(
val cdnUrl = cdnUploader.upload(productKey, picUrl!!)
product.copy(picUrl = cdnUrl)
} catch (ex: Exception) {
log.error("Error while uploading to CDN. Will fallback to Google search result")
log.error("Error while uploading to CDN. Will fallback to Google search result", ex)
product.copy(picUrl = picUrl)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class FantasticoProductsExtractor : PdfProductsExtractor {
",\\s*\$".toRegex(RegexOption.IGNORE_CASE),
"➥+".toRegex(RegexOption.IGNORE_CASE),
"количествата са лимитирани".toRegex(RegexOption.IGNORE_CASE),
"предложението е валидно.*цени".toRegex(RegexOption.IGNORE_CASE)
"предложението е валидно(.*цени)?".toRegex(RegexOption.IGNORE_CASE),
"от.*до.*г\\.".toRegex(RegexOption.IGNORE_CASE)
)

private val productSectionResolver: Map<ProductSection, (TextWithCoordinates) -> Boolean> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ internal class FantasticoProductsExtractorTest {
"fantastico_test_10.pdf,expected_10.json",
"fantastico_test_11.pdf,expected_11.json",
"fantastico_test_12.pdf,expected_12.json",
"fantastico_test_13.pdf,expected_13.json"
"fantastico_test_13.pdf,expected_13.json",
"fantastico_test_14.pdf,expected_14.json"
)
fun `test extracting products`(inputFile: String, expectedFile: String) {
val testPdf = getPath("/extractors/fantastico/$inputFile")
Expand Down
132 changes: 132 additions & 0 deletions src/test/resources/extractors/fantastico/expected_14.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
[
{
"name": "Чипс от царевица GRIVAS различни вкусове от един и същи вкус",
"quantity": "2 бр х 100 г",
"price": 2.28,
"oldPrice": 4.56,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
},
{
"name": "Крекер CHIO Party Mix",
"quantity": "2 бр х 200 г",
"price": 3.98,
"oldPrice": 7.96,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
},
{
"name": "Печен чипс LAY`S различни вкусове",
"quantity": "125 г",
"price": 2.59,
"oldPrice": 5.35,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
},
{
"name": "Бира STELLA ARTOIS амбалаж",
"quantity": "500 мл 0.20 лв бутилка",
"price": 1.55,
"oldPrice": 2.59,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
},
{
"name": "Бира CORONA Екстра",
"quantity": "355 мл",
"price": 1.89,
"oldPrice": 3.29,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
},
{
"name": "Бира HEINEKEN Classic; Silver",
"quantity": "мултипак, кен 4 бр х 500 мл",
"price": 4.99,
"oldPrice": 7.47,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
},
{
"name": "Водка КРЕСКОВА",
"quantity": "1 л",
"price": 0.1,
"oldPrice": 21.99,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
},
{
"name": "MARTINI Fiero; Bianco Torino",
"quantity": "750 мл",
"price": 11.99,
"oldPrice": 19.99,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
},
{
"name": "Вермут Напитка ABSOLUT Passion Fruit Martini; Малинова Лимонада от един и същи вид",
"quantity": "кен, 2 бр х 250 мл",
"price": 3.78,
"oldPrice": 7.56,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
},
{
"name": "Печено кашу ROIS",
"quantity": "2 бр х 140 г",
"price": 6.88,
"oldPrice": 13.76,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
},
{
"name": "Печени бадеми KRONOS",
"quantity": "2 бр х 70 г",
"price": 4.28,
"oldPrice": 8.56,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
},
{
"name": "Ядки AYA",
"quantity": "парти 500 г",
"price": 2.99,
"oldPrice": 5.99,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
},
{
"name": "Тиквени семки DETELINA",
"quantity": "2 бр х 100 г",
"price": 2.58,
"oldPrice": 5.16,
"category": null,
"picUrl": null,
"validFrom": null,
"validUntil": null
}
]
Binary file not shown.

0 comments on commit 67ecbe7

Please sign in to comment.