발음 할 수있는 넌센스 단어 음절을 길게 생성


15

당신의 임무는 지정된 수의 '음절'로 합리적으로 발음 할 수있는 넌센스 단어를 생성하는 것입니다. 프로그램이 실행될 때마다 다른 의미없는 단어가 발생할 수 있습니다.

발음 성

발음하기 쉬운 단어는 음절로 구성되며, 두 음절 그룹 사이에 삽입 된 모음 그룹으로 구성됩니다. 모든 소리가 모든 위치에서 발음되는 것은 아니며 언어에 따라 다르므로 영어 사용자가 이해할 수있는 패턴을 사용합니다.

자음 그룹 시작 :

b c d f g h j k l m n p r s t v w y z bl br ch cl cr dr dr fr fr gh gl gn gr kn ph pl pr qu sc sh sk sl sm sn sp st th tr wh wr sch scr shm shr squ str thr

모음 그룹 :

a e i o u ae ai ao au ea ee ei eu ia ie io oa oe oi oo ou ui ui

끝 자음 그룹 :

bcdfglmnprstxz bt ch ck ct ft gh gn lb ld lf lk ll lm ln lp lt mb mn mp nk ng nt ph pt rb rc rd rf rg rk rl rl rm rn rp rt rv rz sh sk sp ss st zz lch lsh lth rch rth sch tch

음절 결합

시작 및 끝 자음 그룹은 일반적으로 선택 사항이지만 모음으로 시작하기 직전에 모음으로 끝나는 음절을 배치 할 수는 없습니다.

기권

단순성을 위해 진공, 실로폰, 니모닉, 익룡, 아름다운, blah, 그들, 와우 및 대부분의 복수와 같은 특정 영어 단어는 실제로 이런 방식으로 생성 될 수 없습니다.

개요

이 키를 사용하여 가능한 음절 패턴 :

(SC) = 자음 시작; (V) = 모음 그룹; (EC) = 끝 자음

한 음절의 경우 :

  • (SC) (V) (EC)
  • (V) (EC)
  • (SC) (V)
  • (V)

두 음절로 :

  • (SC) (V) (EC) (SC) (V) (EC)
  • (SC) (V) (EC) (SC) (V)
  • (SC) (V) (EC) (V) (EC)
  • (SC) (V) (EC) (V)

  • (SC) (V) (SC) (V) (EC)

  • (SC) (V) (SC) (V)

  • (V) (EC) (SC) (V) (EC)

  • (V) (EC) (SC) (V)
  • (V) (EC) (V) (EC)
  • (V) (EC) (V)

  • (V) (SC) (V) (EC)

  • (V) (SC) (V)

... 등등

음절 1 개

  • 자선
  • 티그
  • Shriegn
  • eess
  • OO
  • 치즈

2 음절

  • 재즈
  • 먹기
  • 움바
  • 올라
  • 있다
  • 잉소
  • greespheurz
  • bleuspoo

3 음절

  • Brokiompic
  • 분출
  • 자본
  • Opengtrass
  • 이중 생각
  • 큰 형님
  • phoebliaptmoo
  • 스콜 프라우 라우트

4 음절

  • 빨대
  • 패치 워크
  • prearneajoomie
  • 썰매
  • 더블 플러스

코딩

입력 : 생성 할 음절 수의 정수

출력 : 많은 음절이 긴 (아마도) 넌센스 단어

규칙

  • 어떤 형태의 (psuedo) 임의성이 필요합니다. 분포가 균일 할 필요는 없지만 모든 음절 조합 (이론적으로)을 생성 할 수 있어야합니다.
    • 생성기가 비 주기적이라고 가정 할 수 있으므로 가능한 모든 단어를 생성하는 것이 수학적으로 가능할 필요는 없으며 (실제로는 시간이 충분하지 않을 수도 있음) 실제로 생성기는 가능한 모든 단어를 생성 할 수 있습니다.
    • 생성기는 실제로 최소 255 개의 고유 값을 생성 할 수 있어야하므로 생성기가 호출 될 때마다 4를 반환 할 수는 없습니다 .
    • 궁극적으로 중요한 것은 코드에 위의 모든 문자 그룹을 어떻게 든 포함시키고 각 문자 그룹이 0이 아닌 확률을 선택하고 각 음절 패턴이 0이 아닌 확률을 갖도록하는 것입니다 (진정한 임의성이 제공되는 경우).
  • 최대 16 음절을 지원해야합니다
  • 음절 결합 규칙 외에도 출력 단어에는 다음이 없어야합니다.
    • 3 개의 연속 모음 ( a e i o u; qu단어에 발생할 수 있음 )
    • 3 개의 연속 매칭 자음

행운을 빕니다!


이것은 몇 가지 이유로 발음 할 수있는 단어 생성과 는 다릅니다 .

  • 엄격한 10 자 요구 사항이 아닌 입력으로 지정된 음절 수입니다.
  • 이 과제는 (완전히) 인코딩되어야하고 더 많은 변형 음절을 허용하는 비 포괄적 인 문자 그룹을 추가하므로 다른 과제에서 코드를 복사 할 수 없습니다
  • 분출 기. 내가 더 말할 필요가 있습니까?

나는 또한 속임수를 잊어 버렸지 만 이것이 중요하지 않은 테이블에 충분히 새로운 것을 가져온다는 것이 밝혀졌습니다. 결국, 수백 가지의 퀴네 변형 문제가 있습니다.


2
"나는 또한 속임수를 잊어 버렸지 만 이것이 중요하지 않은 테이블에 충분히 새로운 것을 가져온다는 것이 밝혀졌습니다." 누군가 이것을 확인 했습니까? 나는 이것이 항상 사실이 아니라고 생각합니다 ...
Quintec

2
세 개의 긴 자음과 모음 목록을 고려할 때 필요한 "하드 코드"가 많이 줄어듦
Stephen

1
이 과제의 품질에 맞게 doubleplusgood를 추가하는 것이 좋습니다.

1
왜 "더 c 거리는 소리를 내뿜는가"? 연속 자음에 "강점"을 이길 :)
Punintended

답변:


4

자바 스크립트 (ES6)  407  403 바이트

f=n=>/[aeiou]{3}|(.)\1\1/.test(s=(h=k=>k?(g=s=>p=s.match(/.[a-z]*/g)[Math.random()*99|0]||(s>x&&p?'':g(s)))(x+'lBrClCrDrFlFrGlGrHJKKnPlPrQuScScrShmShrSlSmSnSquStrThThrTrVWWhWrY')+g('AAeAiAoAuEEaEeEiEuIIaIeIoOOaOeOiOoOuUUeUi')+g(x+'tCkCtFtLbLchLdLfLkLlLmLnLpLshLtLthMbMnMpNgNkNtPtRbRcRchRdRfRgRkRlRmRnRpRshRstRtRthRvRzSsTchXZz')+h(k-1):'')(n,p=x='BCChDFGGhGnLMNPPhRSSchShSkSpStTZB').toLowerCase())?f(n):s

온라인으로 사용해보십시오!


당신은 확신하는 [^aeiou]{3}올바른? 'matching'이라는 단어와을 squirdshlicker포함 하는 3 음절 예제 를 기반으로 rdshlOP bbb는 일반적으로 3 개의 인접한 자음 대신 3 개의 동일한 자음 (즉 , 허용되지 않음) 만을 의미한다고 생각 합니다.
Kevin Cruijssen

2
@KevinCruijssen 도전에 대한 두 번째 독서에서, 나는 당신의 해석이 옳다는 의심의 여지가 거의 없다고 생각합니다. 따라서 코드를 적절히 업데이트했습니다.
Arnauld

3

05AB1E , 237 234 230 228 바이트

.•O0¦"ÐD›ô:ΓF9—∊‘àÕGÌ•3LŽZв₂в×S£V[1U.µ\µTΩiY.•1θ₆Ω–¸‡ÊΔιÃмº³ô»ÝAïG3_@|å“₄bÒs₃l¬t©ïÙK:≠•3LŽII₂в×S£«Ω1U}XižM•·Áy&ŒGηΩ¼αŸKq•6вèJ•Λ1"•bS>£Ω¼0U}TΩiY.•E–æƵHl¨åñyBY±(ú,ā]JùË‚aEuŒ—[K³|C~ôÙŸ„#¼ÑûĀdš+¢zsÄΘä¹ÊÌ₅ôθ•3LŽAE₆в×S£«Ω1U}J}Dγ€g3‹P#

@MagicOctopusUrn 덕분에 -2 바이트 .

온라인으로 시도 하거나 더 많은 결과를 얻으십시오 .

설명:

.•O0¦"ÐD›ô:ΓF9—∊‘àÕGÌ•
                  "# Push compressed string "bcdfglmnprstzchghgnphshskspstsch"
  3L               # Push list [1,2,3]
    ŽA;            # Push compressed integer 8997
       ₂в          # Converted to Base-26 as list: [13,8,1]
         ×         # Repeat the digits [1,2,3] that many times: ["1111111111111","22222222","3"]
          S        # Convert it to a list of flattened digits
           £       # Split the string into parts of that size
            V      # Pop and store this string-list in variable `Y`
[                  # Start an infinite loop:
 1U                #  Reset variable `X` to 1
                 #  Reset the counter_variable to 0
 \                 #  Discard the top of the stack (if any)
 µ                 #  Loop while the counter_variable is not equal to the (implicit) input:
  TΩi              #   If a random boolean is truthy:
     Y             #    Push the string-list we stored in variable `Y`
     .•1θ₆Ω–¸‡ÊΔιÃмº³ô»ÝAïG3_@|å“₄bÒsl¬t©ïÙK:≠•
                   #    Push compressed string "hjkvwyblbrclcrdrflfrglgrknplprquscslsmsnthtrwhwrscrshmshrsqustrthr"
       3L          #    Push list [1,2,3]
         ŽII       #    Push compressed integer 4608
            ₂в     #    Converted to Base-26 as list: [6,21,6]
              ×    #    Repeat the digits [1,2,3] that many times: ["111111","222222222222222222222","333333"]
               S   #    Convert it to a list of flattened digits
                £  #    Split the string into parts of that size
     «             #    Merge it with list `Y`
      Ω            #    Pop and push a random starting consonant group from this list
     1U            #    And set variable `X` to 1
    }              #   Close the if-statement
  Xi               #   If variable `X` is 1:
    žM             #    Push builtin string "aeiou"
      •·ÁyGηΩ¼αŸKq
                   #    Push compressed integer 13814931869773709280202935082102
        6в         #    Converted to Base-6 as list: [1,0,1,1,1,2,1,4,0,1,0,2,0,3,0,4,2,0,2,1,2,3,3,0,3,1,3,2,3,3,3,4,4,1,4,2,0,1,2,3,4]
          èJ       #    Index each into the string "aeiou", and join together: "aeaiaoaueaeeeieuiaieiooaoeoiooouueuiaeiou"
      •Λ1"•       "#    Push compressed integer 8388576
           b       #    Converted to binary: "11111111111111111100000"
            S>     #    Split into a list of digits, and each increased by 1
              £    #    Split the string into parts of that size
               Ω   #    Pop and push a random vowel group from this list
    ¼              #    Increase the counter_variable by 1
    0U             #    And then set variable `X` to 0
   }               #   Close the if-statement
  TΩi              #   If a random boolean is truthy:
     Y             #    Push the string-list we stored in variable `Y`
     .•E–æƵHl¨åñyBY±(ú,ā]JùË‚aEuŒ—[K³|C~ôÙŸ„#¼ÑûĀdš+¢zsÄΘä¹ÊÌ₅ôθ•
                   #    Push compressed string "xbtckctftlbldlflklllmlnlpltmbmnmpnkngntptrbrcrdrfrgrkrlrmrnrprtrvrzsszzlchlshlthrchrshrstrthtch"
       3L          #    Push list [1,2,3]
         ŽAE       #    Push compressed integer 2564
            ₆в     #    Converted to Base-36 as list: [1,35,8]
              ×    #    Repeat the digits [1,2,3] that many times: ["1","222...222","33333333"]
               S   #    Convert it to a list of flattened digits
                £  #    Split the string into parts of that size
     «             #    Merge it with list `Y`
      Ω            #    Pop and push a random ending consonant group from this list
     1U            #    And set variable `X` to 1
    }              #   Close the if-statement
  J                #   Join all strings on the stack together
 }D                #  After the while-loop: duplicate the resulting string
   γ               #  Split the copy into chunks, with adjacent characters that are
                   #  the same grouped together
    g             #  Get the length of each chunk
      3           #  Check for each length if it's smaller than 3
        P          #  Check if all are truthy by taking the product, and if it is:
         #         #   Stop the infinite loop
                   # (after which the string at the top of the stack is output implicitly)

압축 부분의 작동 방식을 이해하려면 이 05AB1E 팁 ( 사전의 일부가 아닌 문자열을 압축하는 방법? , 큰 정수 를 압축하는 방법 ?정수 목록을 압축하는 방법? ) 을 참조하십시오.


1
또한 žM•ô#‰¦λu¢!¡°gU€•6BS<èJ4보다 작습니다 .•!m1±P1Ÿ6ºZ dâ4∍m–G¢”ãÔ2g•(AEIOU에 기본 제공되는 기본 6 변환 및 교체). TIO 링크가 너무 깁니다.
Magic Octopus Urn

트윗 담아 가기 그리고를 사용하여 2 바이트를 더 절약했습니다 žM•·Áy&ŒGηΩ¼αŸKq•6вèJ. :) PS : 대부분의 다른 SE와 달리 PPCG에서 tinyurl.com 과 같은 URL 단축기를 사용할 수 있습니다 . :)
Kevin Cruijssen

1

젤리 , 231 바이트

e€ØẹŒrḢƇ,ŒɠF>2Ẹ
“yŒʠT¬ḅɼṬɦṀUżGv¶æɲCĊQ>ṙȦẇɼṄ0IḤhDẋDċṀĊṪɗĖƇẊ;1JƒṾỊżỵhṖ8>Ȯ⁶]¦Qṭ|Ṛṇẹm⁵ØKƈBNɦÇȯ¢ṣḟPṇMʠ¬YėĊÇẒỊĿXJÑḷÞeȮȮɼ$ỴœeṂṠɲẓḊ⁺ċŻ⁽⁶Ẓ⁹<>#nẇṬ⁴\¤ÐṡḞF5ƙẇwḶȤYḍ¡¢~ṚⱮ-ṃƲ⁻Ṙ6ɱṬ?İẆḌỊþEØ»Ḳµe€ØẹIkḣ3)Z;€“squ“qu”$1¦
“ئµ£‘ḃ3$Xµ³Ð¡ḊFµ⁺wØ2$¿ịÇX€Fß¹Ñ?

온라인으로 사용해보십시오!

단일 음절, 필요한 음절 수를 취하는 전체 프로그램.

설명

이것의 핵심은 66 단어 압축 사전 문자열입니다. 단어가 자음과 모음 그룹으로 나뉘어 있고 각 단어에 대해 처음 3 개의 그룹이 있으면 질문에서 원하는 시작, 모음 및 끝 그룹을 생성합니다. 예외는 있습니다 qu그리고 squ그들이에서 모음을, 그래서 때문에 이러한 수동으로 추가됩니다. 단어 목록은 Python 스크립트를 사용하여 Jelly 사전에서 알고리즘 적으로 작성되었습니다. 일부 문자 그룹이 반복되지만 문제는 출력이 가능한 각 조합을 균일하게 나타내지 못하게합니다. 이것이 바람직한 경우, 2 바이트 ( Q€) 의 비용으로 각 그룹을 고유하게 만드는 것이 간단합니다 .

도우미 링크 1 : 한 줄에 3 개 이상의 모음이 있는지 또는 한 줄에 같은 문자가 3 개 이상 있는지 확인
                | Sample input: branggag
e€Øẹ            | For each letter, is it a vowel? [0, 0, 1, 0, 0, 0, 1, 0]
    Œr          | Run-length encode [[0, 2], [1, 1], [0, 3], [1, 1], [0, 1]]
      ḢƇ        | Filter only those with true first value, popping first value [[1], [1]]
        ,       | Pair with
         Œɠ     | Run lengths of input [[[1], [1]], [1, 1, 1, 1, 2, 1, 1]
           F    | Flatten [1, 1, 1, 1, 1, 1, 2, 1, 1]
            >2  | Greater than 2 [0, 0, 0, 0, 0, 0, 0, 0, 0]
              Ẹ | Any 0
도우미 링크 2 : 세 그룹의 문자열
“yŒʠ...þEØ»                          | Compressed string: shmooze gaolbird hailshot shriech waeful furze ghaut cruelness stealthier gneiss shoeshine wheelchair wring build priorship knosp spoilfive karst through coalpit teschenite schoolkid theurgic zabtieh skiamachies yirth snazzier slimnastics scripted smirch droskies strift blepharism chaulmoogra glegness scarf fratch clerk brank jarvey flourless vorpal grex nard plumb larn philter sorbo tractabilities parcel mart damp rearm back bast bag bant baba boll bad bap becap basal ban bail bare
           Ḳ                         | Split at spaces
            µ        )               | For each word: e.g. hailshot
             e€Øẹ                    |   Check whether each character is a vowel [0, 1, 1, 0, 0, 0, 1, 0]
                 I                   | Increments of this [1, 0, -1, 0, 0, 1, -1]
                  k                  |   Split word at truthy values of this [h, ai, lsh, o, t]
                   ḣ3                |   Take the first three [h, ai, lsh]
                      Z              | Transpose (so now have three lists, start consonants, vowels, end consonants)
                        €        $1¦ | For the first group
                       ; “squ“qu”    | Append squ and qu
메인 링크
          µ³Ð¡                     | Repeat the following the input number of times, collecting results:
“ئµ£‘                             |   18, 5, 9, 2
      ḃ3$                          |   bijective base 3: [1,2,3],[1,2],[2,3],[2]
         X                         |   Take one at random
              Ḋ                    | Remove first item (which will be the input to the link because if the way С works
               F                   | Flatten; we now have e.g. [1,2,3,2,3,1,2,3,2]. This corresponds to SC V EC V EC AC V EC V
                µ⁺    ¿            | Do everything so far once and then repeat while:
                  wØ2$             |   The output contains two twos (i.e. vowel-vowel)
                       ịÇ          | Look these up in the previous link, so we now have a group of letter groups for each position
                         X€F       | Pick a random letter group for each position
                            ß¹Ñ?   | If helper link 1 is true, retry the whole of this link again. Otherwise implicitly output

1
설명이 궁금하지만, 맞습니까? gnuignaalfbiinput에 대한 출력 을 얻지 4aa문제를 올바르게 이해하면 불가능합니다. 음절을 결합한 절 에는 " ... 그러나 모음으로 시작하기 직전에 모음으로 끝나는 음절을 배치 할 수 없습니다. "
Kevin Cruijssen

@KevinCruijssen은 그것을 놓쳤다. 이제 그 요구 사항도 충족해야합니다. 지적 해 주셔서 감사합니다
Nick Kennedy

1
좋은 대답, 나는 당신이 모든 그룹을 만드는 데 사용했던 사전 문자열을 좋아합니다. Jelly의 사전 shmooze gaolbird hailshot shriech waeful furze ghaut에 haha 같은 단어가 왜 포함되어 있는지 잘 모르겠습니다 . xD 어쨌든 Jelly의 사전은 얼마나 큽니까?
Kevin Cruijssen

1
@KevinCruijssen Large. 6 자 미만의 20453 단어와 큰 단어 227845가 있습니다.
Nick Kennedy

0

파이썬 2 , 522510 바이트

from random import*
import re
c=choice
S,V,E=[map(str.lower,re.findall('[A-Z][a-z]*',x))for x in'BCDFGHJKLMNPRSTVWYZBlBrChClCrDrFlFrGhGlGnGrKnPhPlPrQuScShSkSlSmSnSpStThTrWhWrSchScrShmShrSquStrThr','AeAiAoAuEaEeEiEuIaIeIoOaOeOiOoOuUeUiAEIOU','BCDFGLMNPRSTXZBtChCkCtFtGhGnLbLdLfLkLlLmLnLpLtMbMnMpNkNgNtPhPtRbRcRdRfRgRkRlRmRnRpRtRvRzShSkSpSsStZzLchLshLthRchRshRstRthSchTch']
def f(n):w=c(['',c(S)]);exec"e=c(E);w+=c(V)[-(w[-1:]in V):]+c([c(S),e,e+c([x for x in S if x[0]*2!=e])])*(n>1);n-=1;"*n;return w+c(['',e])

온라인으로 사용해보십시오!


0

Pyth, 346 335 바이트

McG.u+NYr9,VHSlH1smjOgs@L"eaiou"jC" ¤E̽]¢¨¦l#"5,4 17*Vd,Og"bcdfghjklmnprstvwyzblbrchclcrdrflfrghglgngrknphplprquscshskslsmsnspstthtrwhwrschscrshmshrsqustrthr"[18 29 6)Og"bcdfglmnprstxzbtchckctftghgnlbldlflklllmlnlpltmbmnmpnkngntphptrbrcrdrfrgrkrlrmrnrprtrvrzshskspssstzzlchlshlthrchrshrstrthschtch"[13 43 8)tuaGO<W!eeG^,1Z2 2Q]1

여기에서 온라인으로 사용해보십시오 .


0

루비 , 381 379 375 바이트

지저분한 정규식 일치를 사용하여 자음 그룹을 가져옵니다. 아마도 최적화되었을 수 있습니다.

->n,w=?a..s='zzz',a=[1]{s=(1..n).map{a=[w.grep(/^([^aeiouq]|[bcfgp][lr]|s?ch|dr|gn|kn|ph|s?qu|s[ct]r?|sh[mr]?|th?r?|s[klmnp]|wh|wr|gh)$/)+(a[-1]?[p]:[]),w.grep(/^[aeiou]{,2}$/),w.grep(/^([^aeiouqhjkvwy]|[bcflnprs]t|ck|gh|gn|l[bdfk-np]|m[bnp]|nk|ng|ph|r[bcdfgk-npvz]|[lr]?[stc]h|s[kps]|zz|rst|[st]ch)$/)<<p].map(&:sample)}*''while s=~/[aeiou]{3}|(.)\1\1|aa|eo|ii|iu|u[aou]/;s}

온라인으로 사용해보십시오!

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.