Nlp 有人类可读的编程语言吗?

Nlp 有人类可读的编程语言吗?,nlp,grammar,Nlp,Grammar,我的意思是,有没有一种带有人类风格编码的编码语言? 例如: Create an object called MyVar and initialize it to 10; Take MyVar and call MyMethod() with parameters. . . 我知道它不是很有用,但创建这样的语法可能会很有趣。Perl,一些人声称 print "hello!" and open my $File, '<', $path or die "Couldn't open the fi

我的意思是,有没有一种带有人类风格编码的编码语言? 例如:

Create an object called MyVar and initialize it to 10;
Take MyVar and call MyMethod() with parameters. . .

我知道它不是很有用,但创建这样的语法可能会很有趣。

Perl,一些人声称

print "hello!" and open my $File, '<', $path or die "Couldn't open the file after saying hello!";

print“hello!”并打开我的$File,AppleScript与此非常接近,尽管这显然取决于平台

下面是打开iTunes并播放播放列表的脚本

tell application "iTunes"
    activate
    play playlist "Party Shuffle"
end tell
资料来源:

很像这样

SET MYVAR TO 10.
EXECUTE MYMETHOD with 10, MYVAR.
维基百科的另一个示例:

ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.
但奇怪的是,尽管它的设计可以像英语一样可读,但大多数程序员完全用奇怪的命名约定破坏了这一点:

SET VAR_00_MYVAR_PIC99 TO 10.
EXECUTE PROC_10_MYMETHOD with 10, VAR_00_MYVAR_PIC99.
:


VB是我能想到的最接近的一个:

如果MyLife.Sucks那么MyLife.End Else MyLife.Continue

在谷歌上搜索“自然语言编程”,你会发现很多信息(包括为什么这是个坏主意)。

有点像这样。

是的。它被称为,人们通常讨厌它。

是为了让管理者阅读,并且有“噪音词”让它更具可读性

SET MYVAR TO 10.
EXECUTE MYMETHOD with 10, MYVAR.
有趣的是,它读起来有点像冗长的DSL。

怎么样


简单本身

让编程语言读起来像(冗长的)普通语言一样,就像要求人们一直用法律语言交谈一样。所有多余的废话都会妨碍你


理想的编程语言应该具有尽可能透明的语法,并让程序背后的概念脱颖而出。显然,在快速学习曲线和最小但模糊的语法(想想Perl,甚至是K)之间存在一种权衡。

通过创建一组规则,可以像这样进行逻辑编程。您可以为特定领域构建(或下载)语法,创建知识库,然后查询它。定义语法后,您可以执行以下操作:

bob is a parent of tim.
mary is a parent of bob.

?- X is a grandparent of tim.
X = mary

?- jim is a parent of bob.
false

所有语言都是“人类可读的”。:)还有谁能创造它呢?也就是说,支持DSL的语言可以非常直观,例如。

这是大约在20世纪80年代初的“下一件大事”,我作为一名程序员的头几年大部分时间都在“自然”领域工作,这被认为是4GL(第四代语言)新产品中最好的一种设计用于使数据访问(在本例中为ADABAS数据库)具有可读性

当然,它完全没有这样做。我们最终得到的只是冗长、结构糟糕的代码。这两种产品仍然存在,但你们从来并没有听说过,这在某种程度上证明了它是一条死胡同

实际上,在那个时期,人们似乎普遍希望超越“编程”,进入某种2001年启发的人工智能天堂。Oracle非常热衷于代码生成,我还饶有兴趣地记得,有一款名为“最后一款”的产品正在向管理者销售,它可以自动生成您想要的任何程序,并让您的所有编程人员都冗余。似乎没有达到预期;-)

值得记住的是,SQL最初是在一些地区销售的,作为一种允许管理层直接查询其数据的方式。我甚至被派去学习基本SQL(在一个大型的国家运输组织中,它运行在铁路上——钢铁品种),其中包括初级管理类型,因为他们计划将基本查询工具放在手中。那真是一场灾难

也许50年后会有所不同,但在当前的游戏编码阶段,需要一定的思路和实现的清晰性,最好通过专门为这些目的设计的语法来进行调节,而不是任何与自然语言的近似,这是不清楚和模棱两可的。最接近的可能是物理学,该学科的本质在于所用的数学(想想物理编程语言),而不是冗长的语言

已添加


我忘了,除了COBOL,还有PL/1,有时被认为是允许美国宇航局将一个人送上月球的原因。它和COBOL一样冗长,而且更努力做到“经理可读”。这就是为什么现在也没有人真正听说过它:-)

我能读C。这意味着它是人类可读的(因为我是人类)。这对一般人来说太简单了。编程语言的一般概念是最大限度地利用计算机在给定行中应该如何操作的信息

这就是为什么Ruby如此受欢迎;它以最少的文本最大化了功能。英语(或任何其他自然语言)是一种非常不精确、信息量/字符量很低的语言


总之,它是:(i)以前做过的,(ii)已知的较弱的想法

表达清晰很重要

但是清晰的思想是非常非常重要的。

Inform 7也许是我觉得最适合人类语言设计的语言。对于编写冒险游戏来说,它是非常特定于应用程序的

它基于基于基于规则的语义,您可以编写大量规则来描述对象及其位置之间的关系。例如,以下部分是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. The description is "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: 
    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.

是我见过的最成功的此类系统。与其他答案中列出的更粗糙的系统相比,它有两个优势:它适用于一个特别适合自然语言(交互式小说)的领域,并且它基于更多的计算语言学知识对输入代码进行了更奇特的分析,不仅仅是一种使用英语单词而不是大括号等的传统编程语言语法。

这实际上是一个热门话题

首先,什么是人类可读的

中国读者看不懂俄语,反之亦然。 如果你把你的领域缩小,比如中国药剂师写一个兵种,你可以围绕这个设计一种语言。这将是人类可读的

这样的
"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. The description is "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: 
    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.
Ingredients.
72 g haricot beans
101 eggs
108 g lard
111 cups oil
32 zucchinis
119 ml water
114 g red salmon
100 g dijon mustard
33 potatoes

Method.
Put potatoes into the mixing bowl. Put dijon mustard into the mixing bowl. 
Put lard into the mixing bowl. Put red salmon into the mixing bowl. Put oil into the mixing bowl. 
Put water into the mixing bowl. Put zucchinis into the mixing bowl. Put oil into the mixing bowl. 
Put lard into the mixing bowl. Put lard into the mixing bowl. Put eggs into the mixing bowl. 
Put haricot beans into the mixing bowl. Liquefy contents of the mixing bowl. 
Pour contents of the mixing bowl into the baking dish.
-module(listsort).
-export([by_length/1]).

 by_length(Lists) ->
    F = fun(A,B) when is_list(A), is_list(B) ->
            length(A) < length(B)
        end,
    qsort(Lists, F).

 qsort([], _)-> [];
 qsort([Pivot|Rest], Smaller) ->
     qsort([ X || X <- Rest, Smaller(X,Pivot)], Smaller)
     ++ [Pivot] ++
     qsort([ Y ||Y <- Rest, not(Smaller(Y, Pivot))], Smaller).
test "Searching google for watin"
    goto "http://www.google.se"
    type "watin" into "q"
    click "btnG"
    assert that text "WatiN Home" exists
    assert that element "res" exists
end
if Time_To_Loop then
   for i in Some_Array loop
      Some_Array(i) := i;
   end loop;
end if;
if (timeToLoop != 0) {
   for (int i=0;i<SOME_ARRAY_LENGTH;i++) {
      someArray[i] = i;
   }
}
SELECT name, address FROM customers WHERE region = 'Europe'