// TODO: ignore N tokens static LS tok_groupPhrase(LS tok, S phrase) { LS tokPhrase = dropFirstAndLast(javaTok_cached(phrase)); L<Int> l = indicesOfSubListIC(tok, tokPhrase); for (int i : l) { int j = i+l(tokPhrase)-1; if (i == 1 && j == l(tok)-2) continue; S pre = get(tok, i-1), post = get(tok, j+1); if (endsWith(pre, "{") && startsWith(post, "}")) continue; tokPrepend(tok, i, "{"); tokAppend(tok, j, "}"); } ret tok; } sS tok_groupPhrase(S s, S phrase) { ret join(tok_groupPhrase(javaTok(s), phrase)); }
Began life as a copy of #1018199
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1021553 |
Snippet name: | tok_groupPhrase |
Eternal ID of this version: | #1021553/13 |
Text MD5: | 15f4035b1d9fc730f960c126f389e62c |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-09 14:24:07 |
Source code size: | 569 bytes / 19 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 345 / 373 |
Version history: | 12 change(s) |
Referenced in: | [show references] |