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

55
LINES

< > BotCompany Repo | #1021034 // Info about words v2 [with cases, dev.]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (17704L/96K).

!7

concept WordInfo {
  S word;
  int position;
  S fact, wordType;
}

concept Text { S text; }

cmodule InfoAboutWords > DynCRUD<WordInfo> {
  S case;
  S text, comment;
  
  start {
    if (nempty(caseID)) dm_setModuleName(programTitle() + " (" + caseID + ")");
    onChange(r { cset(uniq_sync(Text), +text) });
    text = cget text(conceptWhere(Text));
  }
  
  enhanceFrame {
    internalFramePopupMenu(f/JInternalFrame, voidfunc(JPopupMenu popupMenu) {
      popupMenu.add(jDynamicScrollingMenu("Select case", voidfunc(JPopupMenu menu) {
        addMenuItem(menu, "Default case", rThread { dm_showNewModule(dm_moduleLibID()) });
        for (fS name : subDirectoryNamesWithout(programDir(), "backups"))
          addMenuItem(menu, name, rThread {
            dm_showNewModuleWithParams(dm_moduleLibID(), caseID := name)
          });
      }));
      addMenuItem(popupMenu, "Save as case...", rThread {
        inputText("Case name", numberFileNameNotUsedInDir_startingWith2(programDir()), voidfunc(S caseID) {
          assertNempty(caseID);
          conceptsObject().save();
          copyConceptsFile(programIDWithCase(), programID() + "/" + caseID);
          dm_restartModuleWithParams(module(), +caseID);
        });
      });
    });
  }

  visualize as northCenterSouthSections(
    "Input Text"                      := fontSizeTimes(1.25, dm_centeredTextField('text)),
    "Facts"                           := super.visualize(),
    "Tell me something about a word:" := dm_textFieldAndSubmit('comment, 'submitComment));

  void submitComment {
    S word = unquote(firstWord(comment));   // magic
    int i = indexOfIC_fullWord(text, word); // magic
    if (i < 0) shit: quote(word) + " not found in sentence";
    new Matches m;
    if (match_vbar("* is an adjective|* is an adjective here", comment, m))
      cset(uniq_sync WordInfo(+word, position := i), wordType := "adjective", wordType_info := now());
    uniq_sync WordInfo(+word, position := i, fact := comment);
  }
}

Author comment

Began life as a copy of #1021017

download  show line numbers  debug dex  old transpilations   

Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

-
Snippet ID: #1021034
Snippet name: Info about words v2 [with cases, dev.]
Eternal ID of this version: #1021034/20
Text MD5: 7493073baaef24dd7f7081410985c4fb
Transpilation MD5: 485496dfad400d3fb65a15d3455ad4ac
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-19 17:46:02
Source code size: 2047 bytes / 55 lines
Pitched / IR pitched: No / No
Views / Downloads: 303 / 573
Version history: 19 change(s)
Referenced in: