Snažím se přijít na cvičení na řetězec manipulace a třídění. Výkon žádá, aby extrahovat slova, která mají referenční čas (např. hodiny, dny) z textu a seřadit řádky na základě času, extrahované v ascendent pořadí. Příklad dat je:
Customer Text
1 12 hours ago — the customer applied for a discount
2 6 hours ago — the customer contacted the customer service
3 1 day ago — the customer reported an issue
4 1 day ago — no answer
4 2 days ago — Open issue
5
V tomto úkolu jsem identifikovala několik problémů:
- time reference can be expressed as hours/days/weeks
- there are null values or no reference to time
- get a time format suitable and more general, e.g., based on the current datetime
Na první bod jsem uvedl, že obecně data jsou před —, zda je přítomen, takže to může být snadno extrahovat. Na druhý bod, jestliže prohlášení by zabránilo chybové zprávy důsledku neúplné/chybějící pole. Já nevím, jak odpovědět na třetí bod, ačkoli.
Můj očekávaný výsledek by byl:
Customer Text Sort by
1 12 hours ago — the customer applied for a discount 1
2 6 hours ago — the customer contacted the customer service 2
3 1 day ago — the customer reported an issue 2
4 1 day ago — no answer 2
4 2 days ago — Open issue 3
5