मैं कोशिश कर रहा हूँ बाहर आंकड़ा करने के लिए एक व्यायाम पर स्ट्रिंग हेरफेर और छँटाई । व्यायाम करने के लिए पूछता है निकालने के शब्दों है कि समय के संदर्भ में (उदाहरण के लिए, घंटे, दिन) से पाठ, प्रकार, और पंक्तियों के आधार पर समय में निकाली गई एक ascendent आदेश. डेटा का एक उदाहरण है:
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
इस कार्य में मैं पहचान कर सकते हैं कई कठिनाइयों:
- 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
पहला बिंदु पर, मैं ने कहा कि आम तौर पर तारीखों से पहले कर रहे हैं — है, चाहे मौजूद है, तो यह आसान हो सकता है, उन्हें निकालने के लिए. दूसरे बिंदु पर, एक अगर बयान से बचने के सकता है त्रुटि संदेश के कारण अधूरा/लापता क्षेत्रों. मैं नहीं जानता कि कैसे करने के लिए जवाब करने के लिए तीसरी बात है, हालांकि.
मेरी उम्मीद परिणाम के लिए किया जाएगा:
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