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).

1  
!7
2  
3  
concept WordInfo {
4  
  S word;
5  
  int position;
6  
  S fact, wordType;
7  
}
8  
9  
concept Text { S text; }
10  
11  
cmodule InfoAboutWords > DynCRUD<WordInfo> {
12  
  S case;
13  
  S text, comment;
14  
  
15  
  start {
16  
    if (nempty(caseID)) dm_setModuleName(programTitle() + " (" + caseID + ")");
17  
    onChange(r { cset(uniq_sync(Text), +text) });
18  
    text = cget text(conceptWhere(Text));
19  
  }
20  
  
21  
  enhanceFrame {
22  
    internalFramePopupMenu(f/JInternalFrame, voidfunc(JPopupMenu popupMenu) {
23  
      popupMenu.add(jDynamicScrollingMenu("Select case", voidfunc(JPopupMenu menu) {
24  
        addMenuItem(menu, "Default case", rThread { dm_showNewModule(dm_moduleLibID()) });
25  
        for (fS name : subDirectoryNamesWithout(programDir(), "backups"))
26  
          addMenuItem(menu, name, rThread {
27  
            dm_showNewModuleWithParams(dm_moduleLibID(), caseID := name)
28  
          });
29  
      }));
30  
      addMenuItem(popupMenu, "Save as case...", rThread {
31  
        inputText("Case name", numberFileNameNotUsedInDir_startingWith2(programDir()), voidfunc(S caseID) {
32  
          assertNempty(caseID);
33  
          conceptsObject().save();
34  
          copyConceptsFile(programIDWithCase(), programID() + "/" + caseID);
35  
          dm_restartModuleWithParams(module(), +caseID);
36  
        });
37  
      });
38  
    });
39  
  }
40  
41  
  visualize as northCenterSouthSections(
42  
    "Input Text"                      := fontSizeTimes(1.25, dm_centeredTextField('text)),
43  
    "Facts"                           := super.visualize(),
44  
    "Tell me something about a word:" := dm_textFieldAndSubmit('comment, 'submitComment));
45  
46  
  void submitComment {
47  
    S word = unquote(firstWord(comment));   // magic
48  
    int i = indexOfIC_fullWord(text, word); // magic
49  
    if (i < 0) shit: quote(word) + " not found in sentence";
50  
    new Matches m;
51  
    if (match_vbar("* is an adjective|* is an adjective here", comment, m))
52  
      cset(uniq_sync WordInfo(+word, position := i), wordType := "adjective", wordType_info := now());
53  
    uniq_sync WordInfo(+word, position := i, fact := comment);
54  
  }
55  
}

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: 302 / 572
Version history: 19 change(s)
Referenced in: [show references]