Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1021421 // ai_applyWordSplitPattern1 - match "$Redakteur{}in" with "Gärtnerin"

JavaX fragment (include)

static LS ai_applyWordSplitPattern1(LS tokP, LS tokI) {
  L<Int> indices = indicesOfSubList(tokP, ll("", "{}", ""));
  if (empty(indices)) ret tokI;
  LS tokI_original = tokI;
  tokI = cloneList(tokI);
  for (int i : indices) {
    //if (l(tokI) < i+2) ret tokI_original;
    S l = get(tokP, i-1), r = get(tokP, i+3);
    if (startsWith(l, "$") && isIdentifier(l) && isIdentifier(r)) {
      S x = get(tokI, i-1);
      if (!ewic(x, r)) ret tokI_original; // fail
      tokI.set(i-1, dropLast(x, l(r)));
      tokI.add(i, "");
      tokI.add(i+1, "{}");
      tokI.add(i+2, "");
      tokI.add(i+3, takeLast(x, l(r)));
    }
  }
  ret tokI;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021421
Snippet name: ai_applyWordSplitPattern1 - match "$Redakteur{}in" with "Gärtnerin"
Eternal ID of this version: #1021421/4
Text MD5: 2a1105ed0adc07f9777d9f3894564e78
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-13 23:01:32
Source code size: 661 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 317 / 366
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)