1 | sbool ai_findInfixPhrases_debug; |
2 | |
3 | static ItIt<T3<S>> ai_findInfixPhrases(S s, Collection<S> phrases) {
|
4 | final Set<S> set = asCISet(phrases); |
5 | L<S> tok = javaTokNPunctuation(s); |
6 | ret notNulls_iterator( |
7 | // first, split on the left |
8 | nestedIterator(allTokSplits_nOnRight_iterator(tok), |
9 | func(final Pair<LS> p) -> ItIt<T3<S>> {
|
10 | // now split the right part |
11 | if (ai_findInfixPhrases_debug) |
12 | print("Looking at " + join(p.b));
|
13 | L<S> tok2 = javaTokNPunctuation(join(p.b)); |
14 | ret mapI(allTokSplits_nOnLeft_iterator(tok2), |
15 | func(Pair<LS> p2) -> T3<S> {
|
16 | if (ai_findInfixPhrases_debug) |
17 | print(" Looking at " + p2.a);
|
18 | ret set.contains(trimJoin(simpleSpaces(p2.a))) |
19 | ? t3(join(p.a), join(p2.a), join(p2.b)) : null; |
20 | }); |
21 | })); |
22 | } |
Began life as a copy of #1018126
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1018134 |
| Snippet name: | ai_findInfixPhrases - O(nWords^2) |
| Eternal ID of this version: | #1018134/5 |
| Text MD5: | 93a0e1f8c7940351bbc99505229a0914 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-09-02 17:33:17 |
| Source code size: | 858 bytes / 22 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 604 / 643 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |