Simanalix343

Stupid word thing

Oct 10th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 10.02 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8"><meta name="viewport" content="width=device-width">
  5.   <title>I can do this</title>
  6.   <style>
  7. div {
  8.   font-size: 30px;
  9.   border: 4px solid blue;
  10.   margin: 5px;
  11.   border-radius: 15px;
  12.   padding: 10px;
  13. }
  14.  
  15. #aaa,#aaa * {
  16.   color: #a11;
  17.   font-size: 24px;
  18.   border: 2px solid black;
  19.   margin: 0px;
  20.   border-radius: 0px;
  21.   padding: 2px;
  22. }
  23.   </style>
  24. </head>
  25. <body>
  26.   <p>
  27. Type the next word in here. If this is empty, the code will generate a random word.
  28.   </p>
  29.   <textarea id="aaat1"></textarea>
  30.   <p>
  31. Teach a new word to the program here. Write it as [word name],,,[what words can come after it],,,[what words can be before it],,,[words that should not be before it]. Add multiple at once by separating them using ;;;.
  32.   </p>
  33.   <textarea id="aaat2"></textarea>
  34.   <!-- To do list:
  35. = Add before, after, start, and end to groups.
  36. = Allow groups within groups.
  37. = Automatic group making, as in automate grouping of words during paragraph analysis.
  38. = Automate groups of groups (maybe?).
  39. = Use more types of patterns when making groups (not just before and after).
  40. = Allow for conditionals in groups (like swapping a verb form if it comes after "he", "she", or "it").
  41. = Automate use of conditionals when making groups.
  42. = Compare groups to find similar types of patterns. Maybe this could try to use to simplify them.
  43. = Store "context" information as text is generated, and make groups inherit/know the context.
  44. = Create a learn mode that uses self generated examples and a score given by the user to learn over time.
  45. = Allow for promts which get generate replies. Add a toggle to turn on/off auto promting and auto replying.
  46. = Detect that somtheing looks like a prompt followed by a reply and learn patterns between the prompt and reply.
  47. -->
  48.   <div id="aaaB1">
  49. Next word
  50.   </div>
  51.   <div id="aaaB2">
  52. Clear outputs
  53.   </div>
  54.   <div id="aaaB3">
  55. Add new word
  56.   </div>
  57.   <div id="aaaB4">
  58. Export words data
  59.   </div>
  60.   <div id="aaaB5">
  61. Import words data
  62.   </div>
  63.   <div id="aaaB6">
  64. Learn from the paragraph!
  65.   </div>
  66.   <div id="aaaB7">
  67. Add new word (to group)
  68.   </div>
  69.   <div id="aaaB8">
  70. Next word (from group)
  71.   </div>
  72.   <div id="aaa"></div>
  73.   <script>
  74. //HTML functions
  75. function sssf(dddw, dddc) {
  76.   if (!dddw&&!dddc) {
  77. dddw = document.body;
  78.   }
  79.   if (dddc) {
  80. if (!dddw) {
  81.   return document.querySelectorAll("*");
  82. } else {
  83.   return document.querySelectorAll(dddw);
  84. }
  85.   } else {
  86. return document.getElementById(dddw);
  87.   }
  88. }
  89. //creat a new dddwhat, named dddid. It will be put in dddwhere (0 will put it at the end of the document, and no dddwhere will put it in "aaaMAIN").
  90. function sssc(dddwhat, dddid, dddclass, dddwhere) {
  91.   dddwhat=document.createElement(dddwhat);
  92.   dddwhat.id=dddid;
  93.   dddwhat.className=dddclass;
  94.   if(dddwhere===0){
  95.     document.body.appendChild(dddwhat);
  96.   }
  97.   else if(typeof dddwhere==="object"&&dddwhere.appendChild!==undefined){
  98.    dddwhere.appendChild(dddwhat);
  99.   }
  100.   else{
  101.     sssf(dddwhere).appendChild(dddwhat);
  102.   }
  103. }
  104. function sssk(dddid,dddt){
  105.   if(dddt){
  106.     dddt=sssf(dddid,dddt);
  107.     for(dddid=0;dddid<dddt.length;dddid++){
  108.      dddt[dddid].remove();
  109.    }
  110.  }
  111.  else{
  112.    sssf(dddid).remove();
  113.  }
  114. }
  115.  
  116. function sssAEL(dddwhat,dddevent,dddact){
  117.  if(!dddwhat.addEventListener){
  118.    dddwhat=sssf(dddwhat);
  119.  }
  120.  /*sssquick([dddwhat,dddevent,dddact]);*/
  121.  dddwhat.addEventListener(dddevent,dddact)
  122. }
  123. function sssREL(dddwhat,dddevent){}
  124.  
  125. var bbbout=0;
  126. function sssout(dddwhat){
  127.  bbbout++;
  128.  if (typeof dddtype!=="string"){
  129.    dddtype="1"
  130.  };
  131.  sssf("aaa").innerHTML+="Output # "+bbbout+"<br>"+dddwhat+"</div>";
  132. }
  133. console.log("Functions loaded");
  134. /*New structure of word dictiomairy (includes gruoups)
  135. bbbc=[
  136.   group 0:[
  137.     start words:[
  138.       a:[name,[can come after],[can come before],[like after],[like before],fallback],
  139.       j:[name,[can come after],[can come before],[like after],[like before],fallback],
  140.       d:[name,[can come after],[can come before],[like after],[like before],fallback]
  141. ],
  142.     words:[
  143.       c:[name,[can come after],[can come before],[like after],[like before],fallback],
  144.       a:[name,[can come after],[can come before],[like after],[like before],fallback],
  145.       h:[name,[can come after],[can come before],[like after],[like before],fallback],
  146.       h:[name,[can come after],[can come before],[like after],[like before],fallback],
  147.       f:[name,[can come after],[can come before],[like after],[like before],fallback],
  148.       d:[name,[can come after],[can come before],[like after],[like before],fallback],
  149.       z:[name,[can come after],[can come before],[like after],[like before],fallback],
  150.       j:[name,[can come after],[can come before],[like after],[like before],fallback]
  151.     ]
  152.   ],
  153.   group 1:,
  154.   group 2:,
  155.   group 3:,
  156.   group 4:
  157. ]
  158. */
  159. var bbbc=[
  160.   [
  161.     [
  162.       [
  163.         "a",
  164.         ["b","ba","aab","and"],
  165.         ["end","caa"],
  166.         [0.3,0.4,0.5,0.6],
  167.         [1,0.3],
  168.         "lend"
  169.       ],
  170.       [
  171.         "b",
  172.         ["brrrr","and","zeb"],
  173.         ["a","lend"],
  174.         [0.5,0.5,0.5],
  175.         [1,0.25],
  176.         "ands"
  177.       ]
  178.     ],
  179.     [
  180.       [
  181.         "a",
  182.         ["b","ba","aab","and"],
  183.         ["end","caa"],
  184.         [0.3,0.4,0.5,0.6],
  185.         [1,0.3],
  186.         "lend"
  187.       ],
  188.       [
  189.         "b",
  190.         ["brrrr","and","zeb"],
  191.         ["a","lend"],
  192.         [0.5,0.5,0.5],
  193.         [1,0.25],
  194.         "ands"
  195.       ],
  196.       [
  197.         "c",
  198.         ["caa","baac"],
  199.         ["ca","and","lend"],
  200.         [0.42,0.7],
  201.         [0.6,0.65,0.75],
  202.         "ca"
  203.       ],
  204.       [
  205.         "and",
  206.         ["a","b","c"],
  207.         ["a","b","c","ba"],
  208.         [0.33,0.44,0.55],
  209.         [0.22,0.33,0.44,0.66],
  210.         "baac"
  211.       ],
  212.       [
  213.         "baac",
  214.         ["aaa","bbbc"],
  215.         ["c","aaa"],
  216.         [1,0.1],
  217.         [0.22,0.39,0.43],
  218.         "ands"
  219.       ],
  220.       [
  221.         "lend",
  222.         ["aaa","ba","ca"],
  223.         ["a","b","c"],
  224.         [0.81,0.4,0.6],
  225.         [0.63,0.2,2],
  226.         "a"
  227.       ],
  228.       [
  229.         "aaa",
  230.         ["baaac","lends","ands"],
  231.         ["lend","baac",],
  232.         [0,0,0],
  233.         [0,0,0],
  234.         "lend"
  235.       ],
  236.       [
  237.         "ands",
  238.         ["aaa","lends","brrrr"],
  239.         ["a","ba","b"],
  240.         [0,0,0],
  241.         [0,0,0],
  242.         "end"
  243.       ],
  244.       [
  245.         "lends",
  246.         ["bbbc","baaac"],
  247.         ["ands","and","aaa"],
  248.         [0,0,0],
  249.         [0.7,0.4,0.48],
  250.         "end"
  251.       ],
  252.       [
  253.         "brrrr",
  254.         ["end",false,"ba"],
  255.         ["b","ands",],
  256.         [0.3,1,0.35],
  257.         [0.44,0.6],
  258.         "baaac"
  259.       ],
  260.       [
  261.         "baaac",
  262.         ["end"],
  263.         ["brrrr","lends","aaa"],
  264.         [1],
  265.         [0.23,0.34,0.45],
  266.         false
  267.       ],
  268.       [
  269.         "ba",
  270.         ["end","ands","and"],
  271.         ["a","b","c","brrrr","ca"],
  272.         [0.6,0.3,0.1],
  273.         [0.44,0.2,0.53,0.78,1],
  274.         "end"
  275.       ],
  276.       [
  277.         "ca",
  278.         ["end","c","caa"],
  279.         ["lend","caa"],
  280.         [0.4,0.4,0.6],
  281.         [0.37,0.2],
  282.         "ba"
  283.       ],
  284.       [
  285.         "caa",
  286.         ["a","c","ca"],
  287.         ["end","ca"],
  288.         [0.4,0.4,0.6],
  289.         [0.37,0.2],
  290.         "ba"
  291.       ],
  292.       [
  293.         "end",
  294.         [false],
  295.         ["baaac","brrrr","lends","ands","ba","ca","aaa","a","b","c"],
  296.         [2],
  297.         [0.4,0.4,0.4,0.4,0.4,0.4,0.4,1,1,1],
  298.         false
  299.       ]
  300.     ]
  301.   ]
  302. ];
  303.  
  304. var bbbgroup=0,bbba=["a"],bbbi;
  305. console.log("group:",bbbgroup);
  306. function sssnG(a1){
  307.   let ddd,dddc=bbbc,
  308.   dddi=-1,
  309.   _a,
  310.   _b;
  311.   if (typeof a1 === "string"){
  312.     bbba.push(a1);
  313.   }
  314.   //typeof a1==="number"
  315.   else{
  316.     //"word finder" code
  317.     bbbi=bbba.length-1;
  318.    
  319.     a1=false;
  320.     for(let i=0;i<bbbc.length&&bbbgroup===undefined;i++){
  321.      for(let ii=0;ii<bbbc[i][1].length;ii++){
  322.        if(bbbc[i][1][ii][0]===bbba[bbbi]){
  323.          bbbgroup=i;
  324.          dddi=ii;
  325.        }
  326.      }
  327.    }
  328.    if(dddi===-1) {
  329.      for(let ii=0;ii<bbbc[bbbgroup][1].length;ii++){
  330.        if(bbbc[bbbgroup][1][ii][0]===bbba[bbbi]){
  331.          ddd=ii;
  332.        }
  333.      }
  334.    }
  335.    //end of "word finder"
  336.    
  337.    //bbbfrom is a word object, like:
  338.      //[name,[can come after],[can come before],[likea after],[like before]]
  339.    bbbfrom=bbbc[bbbgroup][1][ddd];
  340.    ddd=Math.floor(Math.random()*bbbfrom[2].length);
  341.    let dontLoop=0;
  342.    //while we don't have a feasable next word:
  343.    while(dontLoop<100){
  344.      dontLoop++;
  345.      //bbbfrom[2][ddd] is the word to test
  346.        //if we ran out of words, then we need to use the fallback, bbbfrom[5]
  347.      _a=bbbfrom[1][ddd];
  348.      
  349.      //test the word, setting the boolean for the while loop:
  350.        //find the word with "word finder" code.
  351.      let dddgroup,dddb
  352.        for(let i=0;i<bbbc.length&&dddgroup===undefined;i++){
  353.          
  354.          for(let ii=0;ii<bbbc[i][1].length;ii++){
  355.            
  356.            if(bbbc[i][1][ii][0]===_a){
  357.              dddgroup=i;
  358.              dddi=ii;
  359.            }
  360.          }
  361.        }
  362.        
  363.        if(dddi===-1){
  364.          for(let ii=0;ii<bbbc[dddgroup][1].length;ii++){
  365.            if(bbbc[dddgroup][1][ii][0]===_a){
  366.              dddi=ii;
  367.            }
  368.          }
  369.        }
  370.      _b=bbbc[dddgroup][1][dddi];
  371.      _a=bbbfrom;
  372.      
  373.      //RECAP: bbbfrom selected the name _a, and we found _b as the object with the name of _a. _b and bbbfrom will now be "compared".
  374.      //---
  375.      //this comparison is IMPORTANT, consider changijng it in the future
  376.      //---
  377.      //now if the current attraction of each word to the other word is higher than a random number, the test succeeds, stopping the loop.
  378.    
  379.      _c=_a[3][_a[1].indexOf(_b[0])]+_b[4][_b[2].indexOf(_a[0])];
  380.      
  381.      if(_c>=Math.random()){
  382.         break;
  383.       }
  384.       //our comparison failed, so destroy the current ddd and ...
  385.       bbbfrom[1].splice(ddd,1);
  386.       bbbfrom[3].splice(ddd,1);
  387.       //...select a new ddd
  388.       ddd=Math.floor(bbbfrom[1].length*Math.random());
  389.     }
  390.   }
  391.   bbbc=dddc;
  392. }
  393.  
  394.  
  395. </script>
  396. </body>
  397. </html>
Add Comment
Please, Sign In to add comment