다음은 긴 줄의 RiveScript 코드를 작성할때 여러 줄로 나누어 사용해야 할 때가 있습니다.
이 경우 ^커멘드(Continuation)를 사용하면 됩니다. ^커멘드는 자동으로 이전 행의 데이터를 확장합니다.
+ tell me a poem - Little Miss Muffit sat on her tuffet,\n ^ In a nonchalant sort of way.\n ^ With her forcefield around her,\n ^ The Spider, the bounder,\n ^ Is not in the picture today.
Continuation 커멘드는 이전 행과 연송 행 사이에 공백을 자동으로 삽입하지 않습니다. 다음 예제를 참고하세요.
// There will be no space between "programmed" and "using"! + what are you - I am an artificial intelligence programmed ^ using RiveScript.
공백을 표시할 위치에서 \s를 사용하면 정상적으로 공백 처리가 됩니다.
// This one will have a space. + what are you - I am an artificial intelligence programmed\s ^ using RiveScript.
"tell me a poem" 예제에서 \n를 사용하면 공백 대신 줄 바꿈 처리가 됩니다. 그렇지만 연속적인 공백이나 줄바꿈을 매번 입력해줘야 된다면 매우 불편할 것입니다. RiveScript에서는 ! local concat를 통해서 연속적인 처리를 자동으로 수행 할 수 있습니다.
// Tell the parser to join continuation lines with line breaks ! local concat = newline // Now we don't need to explicitly write the \n characters every time! + tell me a poem - Little Miss Muffit sat on her tuffet, ^ In a nonchalant sort of way. ^ With her forcefield around her, ^ The Spider, the bounder, ^ Is not in the picture today. // Now change the concat mode to spaces ! local concat = space // Here we don't have to use \s like in the earlier example. + what are you - I am an artificial intelligence programmed ^ using RiveScript. // Go back to the default concatenation mode (which doesn't insert ANY // character when joining lines) ! local concat = none
예제에서 볼 수 있듯이 ! local concat명령을 통해서 다음 그룹에서 처리해야할 명령을 자동으로 설정 할 수 있습니다.
https://play.rivescript.com/ 위의 예제를 테스트를 하면 정상적으로 동작되지 않지만
https://www.rivescript.com/try 에서 테스트를 하면 정상적으로 출력이 됩니다.
The supported options for this are:
none
-- the default, nothing is added when continuation lines are joined together.space
-- continuation lines are joined by a space character (\s
)newline
-- continuation lines are joined by a line break character (\n
)
'프로그래밍 > RiveScript' 카테고리의 다른 글
[Tutorial] TRIGGERS (0) | 2017.03.07 |
---|---|
[Tutorial] The Begin File (0) | 2017.03.07 |
[Tutorial] FIRST STEPS - Random Replies (0) | 2017.03.06 |
[Tutorial] FIRST STEPS - Hello, Human! (0) | 2017.03.06 |
What is RiveScript? (0) | 2017.03.06 |