asm*_*rer 10 applescript nlp programming-languages
我主要是一个Python程序员,它经常被描述为"可执行的伪代码".我使用了一点AppleScript,它似乎是我见过的最类似英语的编程语言,因为几乎所有运算符都可以是单词,它可以让你在任何地方使用"the"(例如,这个愚蠢的例子我只是想出了:
set the firstnumber to 1
set the secondnumber to 2
if the firstnumber is equal to the secondnumber then
set the sum to 5
end if
Run Code Online (Sandbox Code Playgroud)
是一个有效的AppleScript程序.有没有比这些更像英语的编程语言?
J S*_*J S 12
莎士比亚的回答让我想起了Inform 7,它是一种用于编写交互式小说的严肃的编程语言.它可能是最接近英语的语言,并且具有明确定义的语义.
以下是维基百科的示例:
"Hello Deductible" by "I.F. Author"
The story headline is "An Interactive Example".
The Living Room is a room. "A comfortably furnished living room."
The Kitchen is north of the Living Room.
The Front Door is south of the Living Room.
The Front Door is a door. The Front Door is closed and locked.
The insurance salesman is a man in the Living Room. "An insurance salesman in a tacky polyester suit. He seems eager to speak to you." Understand "man" as the insurance salesman.
A briefcase is carried by the insurance salesman. The description is "A slightly worn, black briefcase." Understand "case" as the briefcase.
The insurance paperwork is in the briefcase. The description is "Page after page of small legalese." Understand "papers" or "documents" or "forms" as the paperwork.
Instead of listening to the insurance salesman for the first time:
say "The salesman bores you with a discussion of life insurance policies. From his briefcase he pulls some paperwork which he hands to you.";
move the insurance paperwork to the player.
Run Code Online (Sandbox Code Playgroud)
该示例使用了广泛的对象库,可供用户使用.但是语言本身实际上是图灵完成的,你可以定义具有任何行为的对象.
冒着被肆无忌惮的手指摇摆的风险:我声称自然语言就像编程语言一样糟糕.具体来说,自然语言话语的目标是影响世界,以便其他人想要吻你而不是打你; 这是从一种编程语言语句,其目的是在一台计算机或其他人可以评估一个定义良好的域明确声明的目标有很大不同.一个更好的问题可能是:哪种编程语言最难以意外地射击自己?
......当然,这根本不是你问的.
COBOL一直被认为是非常"自然的语言".这是99瓶啤酒页面的摘录:
move spaces to buffer bb1
move 1 to j
divide i by 10 giving k remainder l
string bb8(k + 1) delimited space into bb1 pointer j
if j > 1
then move bb7(l + 1) to bb1(j + 1:)
else move bb7(i + 1) to bb1
end-if
Run Code Online (Sandbox Code Playgroud)
当然,"自然语言"并不总是(通常是?)编程语言中的一种美德,其中精确性是一天的顺序(自然语言几乎总是模棱两可的 - 增加编程语言所需的精确性只会使它变得冗长) .