Advertisement
sezenspessa

light pseudo-english generator

Dec 31st, 2019
3,425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 5.57 KB | None | 0 0
  1.       ******************************************************************
  2.       * Author: Sezen
  3.       * Date: 12/30/2019
  4.       * Purpose: Pseudo-English word generator
  5.       ******************************************************************
  6.       * Returns:
  7.       *   THEOME  
  8.       *   HATER    
  9.       *   ONSE      
  10.       *   THEATH  
  11.       *   ATYS      
  12.       *   INOPYS    
  13.       *   RIITH    
  14.       *   TOOPING  
  15.       *   THEITY  
  16.       *   HATTERYS
  17.       ******************************************************************
  18.        IDENTIFICATION DIVISION.
  19.        PROGRAM-ID. WORD-GEN.
  20.        ENVIRONMENT DIVISION.
  21.        CONFIGURATION SECTION.
  22.        REPOSITORY.
  23.             FUNCTION ALL INTRINSIC.
  24.        DATA DIVISION.
  25.        FILE SECTION.
  26.        WORKING-STORAGE SECTION.
  27.        01   BLAH            PIC X.
  28.        01   WORD            PIC X(12).
  29.        01   NUM1            PIC 99.
  30.        01   NUM2            PIC 99.
  31.        01   RET-NUM         PIC 9.
  32.        01   SYL-COUNT       PIC 9.
  33.             88 TWO-SYL      VALUE 2.
  34.             88 THREE-SYL    VALUE 3.
  35.        01   FIRST-SYL       PIC 9.
  36.             88 1ST-BIGRAM   VALUE 1 THRU 2.
  37.             88 1ST-TRIGRAM  VALUE 3.
  38.        01   MIDDLE-SYL      PIC 9.
  39.             88 2ND-BIGRAM   VALUE 1 THRU 3.
  40.             88 2ND-TRIGRAM  VALUE 4.
  41.        01   LAST-SYL        PIC 9.
  42.             88 3RD-BIGRAM   VALUE 1.
  43.             88 3RD-TRIGRAM   VALUE 2.
  44.        01   WS-BIGRAM.
  45.             05   WS-FIRST-BIGRAM  VALUE 'POHEINTORERIATARLESECOON'.
  46.                  10   WS-1-SYL    PIC XX OCCURS 12 TIMES.
  47.             05   WS-SEC-BIGRAM    VALUE 'ILOUMEOPINA E SO'.
  48.                  10   WS-2-SYL    PIC XX OCCURS 8 TIMES.
  49.             05   WS-END-BIGRAM    VALUE 'STSETHERATEDTYYS  '.
  50.                  10   WS-3-SYL    PIC XX OCCURS 8 TIMES.
  51.        01   WS-TRIGRAM.
  52.             05   WS-FIRST-TRIGRAM
  53.                  VALUE 'THETHAANDHERINTHATEVESHETHISHIBRORET'.
  54.                  10   WS-1-TRI    PIC XXX OCCURS 12 TIMES.
  55.             05   WS-MID-TRIGRAM   VALUE 'TIOEREATIRANCATSINTER'.
  56.                  10   WS-2-TRI    PIC XXX OCCURS 8 TIMES.
  57.             05   WS-END-TRIGRAM   VALUE 'IONINGOMEITHTERASTATHITY'.
  58.                  10   WS-3-TRI    PIC XXX OCCURS 8 TIMES.
  59.        01   WS-COUNT PIC 99.
  60.        PROCEDURE DIVISION.
  61.        MAIN-PROCEDURE.
  62.             PERFORM UNTIL WS-COUNT = 10
  63.             MOVE SPACES TO WORD
  64.             MOVE 12 TO NUM1
  65.             MOVE 1 TO NUM2
  66.             CALL 'RNG-GEN' USING NUM1,NUM2,RET-NUM
  67.             MOVE 3 TO NUM1
  68.             CALL 'RNG-GEN' USING NUM1, NUM2, FIRST-SYL
  69.             EVALUATE TRUE
  70.             WHEN 1ST-BIGRAM
  71.                STRING TRIM(WS-1-SYL(RET-NUM)),WORD INTO WORD
  72.             WHEN 1ST-TRIGRAM
  73.                STRING TRIM(WS-1-TRI(RET-NUM)),WORD INTO WORD
  74.             END-EVALUATE
  75.             MOVE 2.25 TO NUM1
  76.             MOVE 2 TO NUM2
  77.             CALL 'RNG-GEN' USING NUM1, NUM2, SYL-COUNT
  78.             MOVE 1 TO NUM2
  79.             EVALUATE TRUE
  80.             WHEN TWO-SYL
  81.               MOVE 4 TO NUM1
  82.               MOVE 1 TO NUM2
  83.               CALL 'RNG-GEN' USING NUM1,NUM2,MIDDLE-SYL
  84.               MOVE 8 TO NUM1
  85.               EVALUATE TRUE
  86.               WHEN 2ND-BIGRAM
  87.                  CALL 'RNG-GEN' USING NUM1,NUM2,RET-NUM
  88.                  STRING TRIM(WORD),TRIM(WS-3-SYL(RET-NUM)) INTO WORD
  89.              WHEN 2ND-TRIGRAM
  90.                  CALL 'RNG-GEN' USING NUM1,NUM2,RET-NUM
  91.                  STRING TRIM(WORD),TRIM(WS-3-TRI(RET-NUM)) INTO WORD  
  92.               END-EVALUATE
  93.             WHEN THREE-SYL
  94.               MOVE 4 TO NUM1
  95.               MOVE 1 TO NUM2
  96.               CALL 'RNG-GEN' USING NUM1,NUM2,MIDDLE-SYL
  97.               MOVE 8 TO NUM1
  98.               EVALUATE TRUE
  99.               WHEN 2ND-BIGRAM
  100.                   CALL 'RNG-GEN' USING NUM1,NUM2,RET-NUM
  101.                   STRING TRIM(WORD),TRIM(WS-2-SYL(RET-NUM)) INTO WORD
  102.               WHEN 2ND-TRIGRAM
  103.                   CALL 'RNG-GEN' USING NUM1,NUM2,RET-NUM
  104.                   STRING TRIM(WORD),TRIM(WS-2-TRI(RET-NUM)) INTO WORD
  105.               END-EVALUATE
  106.               MOVE 2 TO NUM1
  107.               CALL 'RNG-GEN' USING NUM1,NUM2,LAST-SYL
  108.               MOVE 8 TO NUM1
  109.               EVALUATE TRUE
  110.               WHEN 3RD-BIGRAM
  111.                  CALL 'RNG-GEN' USING NUM1,NUM2,RET-NUM
  112.                  STRING TRIM(WORD),TRIM(WS-3-SYL(RET-NUM)) INTO WORD
  113.               WHEN 3RD-TRIGRAM
  114.                  CALL 'RNG-GEN' USING NUM1,NUM2,RET-NUM
  115.                  STRING TRIM(WORD),TRIM(WS-3-TRI(RET-NUM)) INTO WORD
  116.               END-EVALUATE
  117.             END-EVALUATE
  118.             IF FIRST-SYL = 1 OR 2 THEN
  119.                 DISPLAY WORD(3:)
  120.             ELSE
  121.                 DISPLAY WORD(4:)
  122.             END-IF
  123.             ADD 1 TO WS-COUNT
  124.             END-PERFORM.
  125.             STOP RUN.
  126.       *
  127.        IDENTIFICATION DIVISION.
  128.        PROGRAM-ID. RNG-GEN.
  129.        DATA DIVISION.
  130.        WORKING-STORAGE SECTION.
  131.        01   WS-RNG-GEN  PIC 9(10).
  132.        LINKAGE SECTION.
  133.        01   LS-1      PIC 99.
  134.        01   LS-2      PIC 99.
  135.        01   LS-RAND   PIC 99 COMP.
  136.        PROCEDURE DIVISION USING LS-1, LS-2, LS-RAND.
  137.            COMPUTE WS-RNG-GEN = FUNCTION RANDOM(FUNCTION CURRENT-DATE (1
  138.       -    5:2)) * 90000000000.
  139.            CALL 'CBL_OC_NANOSLEEP' USING WS-RNG-GEN.
  140.            COMPUTE LS-RAND = FUNCTION RANDOM(WS-RNG-GEN) * LS-1 + LS-2.
  141.            COMPUTE WS-RNG-GEN = FUNCTION RANDOM(FUNCTION CURRENT-DATE (1
  142.       -    5:2)) * 9150040200.
  143.            CALL 'CBL_OC_NANOSLEEP' USING WS-RNG-GEN.
  144.     .
  145.            END PROGRAM RNG-GEN.
  146.            END PROGRAM WORD-GEN.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement