Libraryless. Click here for Pure Java version (3496L/24K/77K).
!7 sS text1 = [[ Player A rolled a 5. The second player rolled a 3. Player A won. The second player cried a lot. ]]; static L<Pair<S>> actions1 = ll( pair("Player A", "rolled a 5"), pair("The second player", "rolled a 3"), pair("Player A", "won"), pair("The second player", "cried a lot")); p { L<Pair<S>> actions = ai_findActionsInText(text1); print("Actions found:\n" + indentx(structureLines(actions))); assertContainsAll(actions, actions1); print("Yo!"); } static L<Pair<S>> ai_findActionsInText(S text) { L<S> sentences = map(f dropPunctuationAtEnd, splitIntoSentences_v3(text)); new L<Pair<S>> actions; new Matches m; Set<S> verbs = knownVerbs(); for (S s : sentences) { L<S> tok = javaTok(s); int i = indexOfAny(allToLower(tok), verbs); if (i >= 0) actions.add(pair(trimJoinSubList(tok, 0, i), trimJoinSubList(tok, i))); } ret actions; }
Began life as a copy of #1009501
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1009503 | 
| Snippet name: | Find actions in text [OK] | 
| Eternal ID of this version: | #1009503/7 | 
| Text MD5: | 36d6d49596b790557fce98b61c142c65 | 
| Transpilation MD5: | 6e41664e3e481e0698f44d210390fbf2 | 
| Author: | stefan | 
| Category: | javax / a.i. | 
| Type: | JavaX source code | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2017-08-05 02:48:33 | 
| Source code size: | 930 bytes / 35 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 747 / 950 | 
| Version history: | 6 change(s) | 
| Referenced in: | [show references] |