当前位置:文档之家› Esper学习之八:EPL语法(四)

Esper学习之八:EPL语法(四)

Esper学习之八:EPL语法(四)
Esper学习之八:EPL语法(四)

国庆假期之后的工作周,居然苦逼的只有一个休息日,博客没写成不说,打球还把脚给扭了。不仅如此,这周开始疯狂加班了,所以今天这篇拖了又拖。。。

关于EPL,已经写了三篇了,预估计了一下,除了今天这篇,后面还有5篇左右。大家可别嫌多,官方的文档对EPL的讲解有将近140页,我已经尽量将废话都干掉了,再配合我附上的例子,看我的10篇文章比那140

页英文文档肯定舒服多了吧。也请各位原谅我一周一篇的速度,毕竟我还要学习,生活,工作,一个都不能少。

今天讲解的内容包括三块:Order by,Limit,Insert into。大家会SQL的应该很熟悉这三个东西,前两个比较简单,Insert into会有一些差别,篇幅也相对多些。

1.Order by

EPL的Order by和SQL的几乎一模一样,作用都是对输出结果进行排序,但是也有一些需要注意的地方。语法如下:

[plain]view plaincopy

1.order by expression [asc | desc] [, expression [asc |

desc]] [, ...]

expreession表示要排序的字段,asc表示升序排列(从小到大),desc表示降序排列(从大到小)。举个例子:

[plain]view plaincopy

1.// 每进入5个事件输出一次,并且先按照name升序排列,再按照age

降序排列。

2.select * from User output every 5 events order by nam

e, age desc

使用方法很简单,除了和SQL相似的特点外,还有他自己需要注意的几点:

a. 如果不特别说明是升序还是降序,默认情况下按照升序排列。

b. 如果order by的子句中出现了聚合函数,那么该聚合函数必须出现在select 的子句中。

c. 出现在select中的expression或者在select中定义的expression,在order by中也有效。

d. 如果order by所在的句子没有join或者没有group by,则排序结果幂等,否则为非幂等。

2. Limit

Limit在EPL中和在SQL中也基本一样,不过SQL中是用具体的数字来表示限制范围,而EPL可以是常量或者变量来表示限制范围。语法如下:

[plain]view plaincopy

1.limit row_count [offset offset_count]

row_count表示输出多少行,可以是一个整型常量,也可以是一个整型变量,以方便运行时修改。

offset_count表示在当前结果集中跳过n行然后再输出,同样也可以是一个整型变量。如果不使用此参数,则表示跳过0行,即从第一行输出。举例如下:

[plain]view plaincopy

1.// 输出结果集的第3行到第10行

2.select uri, count(*) from WebEvent group by uri output

snapshot every 1 minute order by count(*) desc limit

8 offset 2

除了以上的语法,limit还有一种简化的写法,实际上是参照SQL的标准。[plain]view plaincopy

1.limit offset_count[, row_count]

两个参数的含义和上面的一样,并且我们将上面的例子改写一下:

[plain]view plaincopy

1.// 输出结果集的第3行到第10行

2.select uri, count(*) from WebEvent group by uri output

snapshot every 1 minute order by count(*) desc limit

2, 8

如果这个两个参数是负数会怎么样呢?

row_count为负数,则无限制输出,若为0,则不输出。当row_count是变量表示并且变量为null,则无限制输出。

offset _count是不允许负数的,如果是变量表示,并且变量值为null或者负数,则EPL会把他假设为0。

3. Insert into

3.1 简单用法

EPL的Insert into和SQL的有比较大的区别。SQL是往一张表里插入数据,而EPL是把一个事件流的计算结果放入另一个事件流,然后可以对这个事件流进行别的计算。所以Insert into的一个好处就是可以将是事件流的计算结果不断级联,对于那种需要将上一个业务的结果数据放到下一个业务处理的场景再适合不过了。除此之外,Insert into还有合并多个计算结果的作用。到这里相信大家已经对他越来越好奇了,不急,咱们先来看看语法:

[plain]view plaincopy

1.insert [istream | irstream | rstream] into event_stream_

name [ (property_name [, property_name] ) ]

event_stream_name定义了事件流的名称,在执行完insert的定义之后,我们可以使用select对这个事件流进行别的计算。

istream | irstream | rstream表示该事件流允许另一个事件的输入/输入和输出/输出数据能够进入(解释好像很绕。。一会儿看例子就能明白了)

property_name表示该事件流里包含的属性名称,多个属性名之间用逗号分割,并且用小括号括起来。

上面的说明可能不是很好理解,咱们先看个例子:

[plain]view plaincopy

1.// 将新进入的Asus事件传递到Computer,且Asus的id,size和

Computer的cid,csize对应

2.insert into Computer(cid,csize) select id,size from Asus

3.

4.// 第二种写法

5.insert into Computer select id as cid, size as csize

Asus

从例子中可以看到,insert into需要配合select进行使用,以表明前一个事件流有哪些计算结果将进入insert into定义的事件流。并且在select中的字段要和insert里的事件流的属性要对应(这里指的对应是数据类

型对应,而且属性数量也必须一样)。如果说insert定义的事件流名称在之前已经定义过(insert into中定义的除外),重名是不允许的。

我个人推荐第二种写法,通过as设置的别名即为insert定义的事件流的属性,这样可以避免属性的个数不一致的错误。

刚才说了istream | irstream | rstream的用法,可能有点表述不清楚,这里看一个完整的例子。

[java]view plaincopy

1./**

2.*

3.* @author luonanqin

4.*

5.*/

6.class Asus

7.{

8.private int id;

9.private int size;

10.

11. public int getId()

12. {

13. return id;

14. }

15.

16. public void setId(int id)

17. {

18. this.id = id;

19. }

20.

21.

22. public int getSize()

23. {

24. return size;

25. }

26.

27. public void setSize(int size)

28. {

29. this.size = size;

30. }

31.

32. public String toString()

33. {

34. return "id: " + id + ", size: " + siz

e;

35. }

36.}

37.

38.

39.class InsertRstreamListener implements UpdateListener

40.{

41. public void update(EventBean[] newEvents, EventBean

[] oldEvents)

42. {

43. if (newEvents != null)

44. {

45. for (int i = 0; i < newEvents.le

ngth; i++)

46. {

47. Object id = newEvents[i].get

("cid");

48. System.out.println("Insert Asu

s: cid: " + id);

49. }

50. }

51. if (oldEvents != null)

52. {

53. for (int i = 0; i < oldEvents.le

ngth; i++)

54. {

55. Object id = oldEvents[i].get

("cid");

56. System.out.println("Remove Asu

s: cid: " + id);

57. }

58. }

59. System.out.println();

60. }

61.}

62.

63.public class InsertRstreamTest {

64.

65. public static void main(String[] args) throws Int

erruptedException {

66. EPServiceProvider epService = EPServiceProvi

derManager.getDefaultProvider();

67.

68. EPAdministrator admin = epService.getEPAdmin

istrator();

69.

70. String asus = Asus.class.getName();

71. String insertEPL = "insert rstream into C

omputer(cid,csize) select id,size from " + asus + ".win :length(1)";

72. String insertSelectEPL = "select cid from

Computer.win:length_batch(2)";

73.

74. EPStatement state = admin.createEPL(insertEP

L);

75. EPStatement state1 = admin.createEPL(insertS

electEPL);

76. state1.addListener(new InsertRstreamListener()

);

77.

78. EPRuntime runtime = epService.getEPRuntime()

;

79.

80. Asus apple1 = new Asus();

81. apple1.setId(1);

82. apple1.setSize(1);

83. System.out.println("Send Asus: " + apple1);

84. runtime.sendEvent(apple1);

85.

86. Asus apple2 = new Asus();

87. apple2.setId(2);

88. apple2.setSize(1);

89. System.out.println("Send Asus: " + apple2);

90. runtime.sendEvent(apple2);

91.

92. Asus apple3 = new Asus();

93. apple3.setId(3);

94. apple3.setSize(3);

95. System.out.println("Send Asus: " + apple3);

96. runtime.sendEvent(apple3);

97.

98. Asus apple4 = new Asus();

99. apple4.setId(4);

100.apple4.setSize(4);

101.System.out.println("Send Asus: " + app le4);

102.runtime.sendEvent(apple4);

103.

104.Asus apple5 = new Asus();

105.apple5.setId(5);

106.apple5.setSize(3);

107.System.out.println("Send Asus: " + app le5);

108.runtime.sendEvent(apple5);

109.

110.Asus apple6 = new Asus();

111.apple6.setId(6);

112.apple6.setSize(4);

113.System.out.println("Send Asus: " + app le6);

114.runtime.sendEvent(apple6);

115.}

116.}

执行结果:

[plain]view plaincopy

1.Send Asus: id: 1, size: 1

2.Send Asus: id: 2, size: 1

3.Send Asus: id: 3, size: 3

4.Insert Asus: cid: 1

5.Insert Asus: cid: 2

6.

7.Send Asus: id: 4, size: 4

8.Send Asus: id: 5, size: 3

9.Insert Asus: cid: 3

10.Insert Asus: cid: 4

11.

12.Send Asus: id: 6, size: 4

这个例子中,insertEPL表示当Asus事件从length为1的view 中移除时,把移除的事件放入Computer。 insertSelectEPL是对Computer的事件流进行计算,这里只是在每进入两个事件时才输出这两个事件的cid。而rstream在这里的表现,从执行结果中可以看到,在进入id为1 2 3的事件后,insertSelectEPL的监听器被触发,因为id为1和2的事件是在发送了Asus的id为2和3的事件之后被移除了,之后就进入了 Computer,并满足了length=2,因此在监听器里看到有id为1和2的事件进入了Computer。

如果不显示指定rstream,则insert into只允许istream的事件流进入Computer。如果指定为irstream,那么进入的和移除的Asus都会进入到Computer。

上面的例子都是指定了insert into里事件流会有什么属性,如果不指定会是什么结果呢?请看例句:

[plain]view plaincopy

1.insert into Computer select * from Asus

很容易想到,这里实际上是把进入引擎的Asus事件都传递到Computer定义的事件流中,并且属性什么的完全和Asus一样,可以说是Asus 的一个复制版本,只是名字不一样。也许有人觉得这么做没什么意思,直接计算Asus事件流不就可以了么,实际上在业务处理数据时,这种做法就可以屏蔽掉外部的数据来源,做到业务层上的隔离。

假设Asus中还包含其他的JavaBean,同样也可以将这个Bean 的数据传递到另一个事件流中。例句如下:

[plain]view plaincopy

1.// Lenovo中包含了thinkpad这个JavaBean

2.insert into Computer select thinkpad.* from Lenovo

3.2 Merge Event Stream

insert into除了接收一个流的事件,同时也支持多个流的合并。通俗一点来说,合并的流数据要一致才可以合并。而且在第一次定义insert 的事件流以后,别的事件流想要被合并就必须和之前定义的属性数量和数据类型对应。举例如下:

[plain]view plaincopy

1.// 定义Computer并把Asus的数据输入

2.insert into Computer(cid, csize) select aid,asize from A

sus

3.

4.// 根据之前的Computer定义将Lenovo对应的属性输入

5.insert into Computer(cid, csize) select lid,lsize from L

enovo

如果说select了多个事件流,但是你只想输入其中一个,应该像下面这样写:

[plain]view plaincopy

1.insert into Computer select l.* from Asus as a, Lenovo

as l

除此之外,EPL还支持调用函数转换事件后再输入insert into:

[plain]view plaincopy

1.// 将Lenovo事件转换后输入Computer

2.insert into Computer select Converter.convert(l) from Len

ovo as l

注意,使用自定义函数一定要返回javabean,map,或者Object数组,且不能用as来为转换后的结果设置别名。

3.3 Decorated Events

之前所见到的不是将事件流整体输入insert,就是将事件流的部分属性输入insert。实际上可以将事件流整体和事件流属性组成的复杂表达式一起放入insert。示例如下:

[plain]view plaincopy

1.insert into Computer select *, size*price as sp from A

sus

2.// 第一个*表示Asus,size*price的*表示乘法,两者互不影响

如果说别的事件流想进入此insert,那么事件流属性一定要和第一个*表示的所有属性相同。

3.4 Event Objects Instantiated by insert into

前面的所有例子中,对于insert into的事件结构都是在insert子句中配合select子句进行定义的。如果我们想用已经定义好的事件结构是否可以呢?答案是肯定的。但是如果事件是javabean,并且事先没有注册到引擎,则需要insert子句中写上类的全名。例如:

[plain]view plaincopy

1.insert into https://www.doczj.com/doc/3c2093876.html,puter ...

当然,如果在使用之前有注册过,那么使用注册时的名称也是可以的。

因为事件结构是早就定义好的,所以在写select的时候就必须符合insert事件中的属性了,如果属性名称不一样需要使用as加上别名,一样的可以不用设置别名,且数据类型也要一一对应。例如:

[plain]view plaincopy

1.// Computer中包含cid和csize属性

2.insert into https://www.doczj.com/doc/3c2093876.html,puter select aid as cid, as

ize as csize from Dell

但是这种用法在Computer存在包含了参数的构造方法时就显得没那么必须了。先看一个完整例子,你也许就会明白了。

[java]view plaincopy

1./**

2.*

3.* @author luonanqin

4.*

5.*/

6.class Car

7.{

8.private int size;

9.private String name;

10. private int price;

11.

12. public void setSize(int size)

13. {

14. this.size = size;

15. }

16.

17. public void setName(String name)

18. {

19. https://www.doczj.com/doc/3c2093876.html, = name;

20. }

21.

22. public void setPrice(int price)

23. {

24. this.price = price;

25. }

26.

27. public int getSize()

28. {

29. return size;

30. }

31.

32. public String getName()

33. {

34. return name;

35. }

36.

37. public int getPrice()

38. {

39. return price;

40. }

41.

42.}

43.

44.class Auto

45.{

46. private int autoSize;

47. private String autoName;

48.

49. public Auto(int s, String n)

50. {

51. this.autoSize = s;

52. this.autoName = n;

53. }

54.

55. public String toString()

56. {

57. return "AutoSize: " + autoSize + ", Auto

Name: " + autoName;

58. }

59.}

60.

61.class Benz

62.{

63. private int benzSize;

64. private String benzName;

65.

66. public void setBenzSize(int benzSize)

67. {

68. this.benzSize = benzSize;

69. }

70.

71. public void setBenzName(String benzName)

72. {

73. this.benzName = benzName;

74. }

75.

76. public String toString()

77. {

78. return "BenzSize: " + benzSize + ", Benz

Name: " + benzName;

79. }

80.}

81.

82.class InstantiatePopulateListener implements UpdateListener

83.{

84. public void update(EventBean[] newEvents, EventBean

[] oldEvents)

85. {

86. if (newEvents != null)

87. {

88. Object car = newEvents[0].getUnderly

ing();

89. System.out.println(car);

90. }

91. }

92.}

93.

94.public class InstantiatePopulateTest

95.{

96. public static void main(String[] args) throws Int

erruptedException

97. {

98. EPServiceProvider epService = EPServiceProvi

derManager.getDefaultProvider();

99.

100.EPAdministrator admin = epService.getEP Administrator();

101.

102.String car = Car.class.getName(); 103.String auto = Auto.class.getName(); 104.String benz = Benz.class.getName(); 105.

106.String cartToAutoEpl = "insert into "

+ auto + " select size, name from " + car;

107.String autoEpl = "select * from " + auto;

108.String cartToBenzEpl = "insert into "

+ benz + " select size as benzSize, name as benzNam

e from " + car;

109.// String benzEpl2 = "insert into "

+ benz + "(benzSize,benzName) select size, name from " + car;

 String ben

zEpl = "select * from " + benz;

admin.createEPL(car

tToAutoEpl);EPStatement state1 = admin.createEPL(autoEpl);st

ate1.addListener(new InstantiatePopulateListener());admin.crea

teEPL(cartToBenzEpl);EPStatement state2 = admin.createEPL(be

nzEpl);state2.addListener(new InstantiatePopulateListener());E

PRuntime runtime = epService.getEPRuntime();Car c1 = new Car();c1.setSize(1);c1.setName("car1");c1.setPrice(11);runtim

e.sendEvent(c1);Car c2 = new Car();c2.setSize(2);c2.setName

("car2");c2.setPrice(22);runtime.sendEvent(c2);}}

执行结果:

[plain]view plaincopy

1.AutoSize: 1, AutoName: car1

2.BenzSize: 1, BenzName: car1

3.AutoSize: 2, AutoName: car2

4.BenzSize: 2, BenzName: car2

这里的执行结果很容易理解,关键是carToAutoEpl和carToBenzEpl两个句子。

对于Auto的JavaBean,我们可以发现它包含一个有参数的构造函数且没有属性对应的set方法,在carToAutoEpl中,select的内容并没有和属性名称对应起来。这种写法确实是正确的,正因为Auto中定了含参的构造函数,才使得select可以写的更随意。但是一定要记住,构造函数里的参数顺序一定要和select中的属性的数据类型对应起来,如果这里把name和size 互换位置,必定报错!

对于Benz的JavaBean,可以看到每个属性都有对应的set方法,而没有含参的构造函数,所以select中属性的名称需要as来设置别名。当然,像benzEpl2那种写法,同样可以避免select中设置别名。

一句话总结,如果JavaBean中有含参的构造函数,EPL中不需要显示写出属性名称。如果没有构造函数,那么必须包含set方法,且select 中要写出具体的属性。这几种写法各有各的好处,大家使用时可针对具体的情况选择性使用。

今天的内容总的来说是比较轻松的,insert into也算是今天的重点,希望大家好好学习,用处可是大大滴有哦。

PS:最近项目紧张,连周六也要加班了,所以可能会两周出一篇,还请各位谅解。

英语学习之名词短语

英语句子的核心组成部分——名词短语(noun phrase,简称NP)。从一开始就搞清楚名词短语的构造规则,对于今后的英语学习将是非常重要的。 一、名词短语the core element of a sentence 英语中,短语有很多类,比如动词短语(have been doing)、介词短语(for you)、名词短语(my best friend)等等。其中名词短语最为重要,它是英语造句中不可或缺的元素。 1、名词短语的功能 名词短语的简单定义:名词与它的修饰语一起即构成名词短语。先来看几个简单的例子: ①These red roses are for you . 译:这些红玫瑰是送给你的。 名词短语these red roses在句中充当主语。 ②I have three close friend . 译:我有三个要好的朋友。 名词短语three close friend在句中充当宾语。 ③He is my best friend . 译:他是我最好的朋友。 名词短语my best friend在句中充当表语。 ④There are some red roses on that small table .

译:在那张小餐桌上有一些红玫瑰。 名词短语some red roses在句中充当主语; 名词短语that small table在句中充当介词on的宾语。 以上例句中的名词短语,都包含在英语句子和文章中。可以充当句子中的各个成分。 ※注意:英文中的介词不能单独使用,其后面必须接宾语,所接的宾语往往是名词短语(如例句4)。 the bird in the tree树上的那只小鸟 the map on the wall墙上的地图 the development of China中国的发展 the standard of living生活水平 the south side of the Changjiang river长江南岸 the way to the hotel去旅馆的路 the life in the future未来的生活 名词短语有如此重要的作用,那么这么重要的句子构成要素是怎样构成的呢?下面来详细总结它的构造规律。 2、名词短语的构造 名词短语由名词与它的修饰语一起构成。

现代英语语法 历年真题汇总2(打印版)

动词部分(第5,6,7,8章) 一、单项选择题(本大题共20小题,每小题1分,共20分) Choose the best answer from the choices given and put the letter A, B, C or D in the brackets. 1.2010040 2. My train is going to arrive at Shanghai at about eight o’clock tonight. The plane I’d like to take from there ______ by then. ( ) A. would leave B. will have left C. has left D. had left 2.2010040 3. The young man who has applied for the post ______ in the general manager’s office.( ) A. is interviewing B. is being interviewed C. to be interviewed D. had been interviewed 3.2010040 4. It is essential that all the exam papers ______ back before the end of the term. ( ) A. must be sent B. are sent C. will be sent D. be sent 4.2010040 5. ______ for my illness, I would have got the job in the Disneyland. ( ) A. Not being B. Without being C. Had it not been D. Not having been 5.2010040 6. The car ahead of me suddenly stopped by the roadside. I think it ______ out of gas.( ) A. may run B. may have run C. must run D. should have run 6.2010040 7. The teacher won’t mind ______ the term paper. ( ) A. us to delay handing in B. our delaying handing in C. our delaying to hand in D. us delay to hand in 7.20100408. All the tasks ______ ahead of time, they decided to have a dinner party to celebrate.( ) A. have been finished B. had been finished C. having been finished D. were finished. 8.20100702. It seems that oil ____ from the tank for some time. We’ll have to take the oil tank apart to see what's wrong. () A. had leaked B. is leaking C. leaked D. has been leaking 9.20100703. A great deal of research _____ into the possible cures to AIDS in recent years.() A. is done B. was done C. has been done D. will be done 10.20100704. Gone ____ when the Chinese people had to struggle to make a living and to worry about lack of food all day. () A. the days B. are the days C. have the days D. the days have 11.20100705. Sometimes I wish I ____ extraordinary power to make all the impossible possible.() A. have B. had C. have had D. am having 12.20100706. I've tried several times today, but the line is always busy; someone ____ the telephone. () A. should be using B. must have been using C. must have used D. must be using 13.20100707. It's no use ______ the result of the exam; it's already finished. () A. worrying about B. to worry about C. to worrying about D. having worried about 14.20100708. With so much noise outside, the speaker had to raise his voice to have himself____.() A. hear B. heard C. to be heard D. to hear 15.20110402. The child ought to have a rest; she ______ the piano for nearly three hours. ( ) A. had practiced B. is practicing C. has been practicing D. practices

《赖世雄美语音标》学习感悟

《赖世雄美语音标》学习感悟 《赖世雄美语音标》学习感悟 经过两个月的认真学习,很快乐终于学完《赖世雄美语音标》了,这是我第一本完整从头学到最后的英语教材,期间反复听赖教师的讲解,反复跟读,从一开始简单的句子都无法读顺,到后来越读越顺,单词、句子也都反复听写,从一开始老听错,到后来越来越分辩得清不同的读音,感觉自己的英语学习总算走上了正轨,对以后的英语学习也更有信心了。 我和大多数中国人一样,在学校开始学习英语,自认对外语学习的悟性不高,所以只能跟着书本和跟着教师学,假如书本上没有的,教师没讲解到的,自己是悟不出来的。那时学音标,教师只是匆匆的把每个音标的发音教一次就算完成了,接下去就是学课文了,学课文也就是跟着课本学单词、学语法、读课文、背课文这样一步一步学,最记得教师总是提醒我们不要把单词最后的辅音吃掉,要发清楚,至于s后面的p、k、t要发成b、g、d更是没说清楚,还有懒惰式英语的模糊发音,非重读的an、of、can、before等单词的发音,以及一些音标标注和外国人实际发音的差异等等都没有教,但赖教师的教材都做了很详细的讲解,特别针对中国人经常搞错的元音发音,如U和u的发音,i:和I的发音,还有辅音在字尾的发音,如l发"欧"的音,p发"普"的单等等,都做了非常详细和耐心的说明,并在整个学习音标的过程中不断反复提醒,让学习的人能把这些重点、难点牢牢的掌

握,自然而然的融会贯穿到日常的发音中去。学了赖教师的这套美语音标教材,才知道自己原来的很多发音都是错了,也明白了为什么自己学了这么多年英语,但实际能听懂的单词怎么这么少,现在才知道原来我学的跟美国人实际的发音有这么多的不同,虽然只是学了两个月的音标,但感觉在实际中听到的单词比原来多了,也因此对英语学习更有兴趣和更有信心了。 我对赖教师这套音标教材的最深领会就是赖教师太了解中国人在学习英语过程中碰到的难点和痛点了,因为他也是被那些自己都没有跟外国人交流过的所谓英语教师教过的,这些教师不知道很多单词外国人其实不是按我们的英语课本和字典发音的,完全照本宣科的对着那些中国人自己编的英语教材来教,教出来的学生假如悟性不高,又没有什么时机和外国人交流的话,基本上最利害的也就只能学个哑巴英语,看资料、写篇文章还将就,听和说就完全不行了。而一些悟性高,特别是有时机和外国人交流的学生,很快就能发现这些问习题,并进行调整。为什么大家一直都很认同学习英语要有英语的环境,最好能出国,这样对英语的听和说都会有莫大的帮助,退而求次则参加有外教的培训班,实际上我现在才明白这真是无奈之举,只是我们学校的英语环境出了问习题,所教的英语发音与实际外国人的发音有这么大的差异,才造成了中国的英语学习者花费了这么多年的时间学习英语却连简单的对话都听不明白,自己说的更是让人不知所云,这不能不说是中国式英语教育的悲哀。 赖教师的这套教材正如他在序中提到的,整个内容是他个人几十

自考现代英语语法学习笔记--名词和名词短语

名词和名词短语(2) 限定词和属格 4.1 限定词 Determiner 在名词词组中对名词中心词起特指,类指以及表示数量等限定的词。 Determiners refer to the words which are used in the pre-modification of a noun phrase which typically precede any adj. that pre-modify the head word. 限定词和形容词区别 Difference between Determiner and Adjective 1.前置限定, 限定词在形容词前面.Determiner usually precede adj. in pre-modification. 2.限定词的选择受中心词影响而形容词不受。The choice of Determiner is determined by the head word but not that of adj. 3.形容词表明中心词的特征,而限定词限定中心词的意义数量。Adj. describe the head word by showing its characteristic while determiner determine the head word by identifying or quantifying. 4.形容词可位于中心词后,而限定词不可。 Adj. can post-modify the head word but not Determiner. 5.形容词有比较级而限定词没有(除few, little, many much 外) 。 Adj. has comparative form but not Determiner (except few, little, many much ). 4.1.2 Co-occurrence of Determiners Determiner may co-occurrence in the pre-modification of a noun phrase: two or more determiner may modify one and the same head word. Each determiner takes a fixed position , we identify their relative positions in the case of co-occurrence. 定义 考点1 定义

2010年4月全国自考现代英语语法真题与答案

2010年4月全国自考现代英语语法真题 一、单项选择题(本大题共20小题,每小题1分,共20分) Choose the best answer from the choices given and put the letter A, B, C or D in the brackets. 1:参考答案:A 试题内容:That definition leaves___for disagreement. A:much roomB:a small roomC:many roomsD:a big room 2:参考答案:B 试题内容:My train is going to arrive at Shanghai at about eight o’clock tonight. The plane Id like to take from there___by then. A:would leaveB:will have leftC:has leftD:had left 3:参考答案:B 试题内容:The young man who has applied for the post___in the general managers office. A:is interviewingB:is being interviewedC:to be interviewedD:had been Interviewed 4:参考答案:D 试题内容:It is essential that all the exam papers ______ back before the end of the term. A:must be sentB:are sentC:will be sentD:be sent 5:参考答案:C 试题内容:___for my illness, I would have got the job in the Disneyland. A:Not beingB:Without beingC:Had it not beenD:Not having been 6:参考答案:B 试题内容:The car ahead of me suddenly stopped by the roadside. I think it___out of gas. A:may runB:may have runC:must runD:should have run 7:参考答案:B 试题内容:The teacher won’t mind___the term paper. A:us to delay handing inB:our delaying handing inC:our delaying to hand inD:us delay to hand in 8:参考答案:C 试题内容:All the tasks___ahead of time, they decided to have a dinner party to celebrate. A:have been finishedB:had been finishedC:having been finishedD:were Finished 9:参考答案:A 试题内容:What he has done is___what I have done. A:superior toB:more superior toC:superior thanD:more superior than 10:参考答案:B 试题内容:Mary earns___as Jane does, but she spends less money on cosmetics than Jane. A:twice so muchB:twice as muchC:as much twiceD:so much twice 11:参考答案:C 试题内容:We’ll discuss a___issue before we move on to the problem of our major concern. A:lessB:moreC:lesserD:most12:参考答案:A

abap基本语法汇总

abap 基本语法汇总 数据类型和对象 在ABAP中,可以使用与标准数据声明相似的语法处理数据类型,而与数据对象无关。 在程序中必须声明要使用的全部数据对象。声明过程中,必须给数据对象分配属性,其中最重要的属性就是数据类型。 1.1基本数据类型 对算术运算的非整型结果(如分数)进行四舍五入,而不是截断。 类型P数据允许在小数点后有数字。有效大小可以是从1到 16字节的任何值。将两个十进制数字压缩到一个字节,而最后一个字节包含一个数字和符号。在小数点后最多允许14个数字。 1.2系统定义的数据对象

abap 基本语法汇总 1.3确定数据对象的属性 如果要查明数据对象的数据类型,或者要在程序的运行期间使用其属性,可使用DESCRIBE语句。语法如下: DESCRIBEELD [LENGTHS〉] [TYPE [COMPONENTS^] [OUTPUT-LENGTH ] [DECIMALS ] [EDIT MASK ]. 将由语句的参数指定的数据对象的属性写入参数后的变量。 DESCRIBE FIELDS语句具有下列参数: 1.3.1确定字段长度 要确定数据对象的长度,利用DESCRIBFIELD语句使用LENGTH 参数,如下所示: DESCRIBE FIELD LENGTH . 系统读取字段<f>的长度,并将值写入字段<1>

abap 基本语法汇总 1.3.2 确定数据类型 要确定字段的数据类型,利用DESCRIBE FIELD语句使用TYPE 参数,如下所示: DESCRIBE FIELD TYPE [COMPONENTS ]. 系统读取字段的数据类型,然后将值写入字段。 除返回预定义数据类型C、D、F、I 、N、P、T 和X 外,该语句还返回 s 对于带前导符号的两字节整型 b 对于无前导符号的一字节整型 h 对于内表 C 对于组件中没有嵌套结构的结构 C 对于组件中至少有一个嵌套结构的结构 1.3.3 确定输出长度 要确定字段的输出长度,利用DESCRIBE FIELD语句使用OUTPUT-LENGTH数,如下所示: DESCRIBE FIELD OUTPUT-LENGTH . 系统读取字段的输出长度,并将值写入字段<0>。 1.3.4 确定小数位 若要确定类型P字段的小数位的个数,利用DESCRIBE FIELD语句使用DECIMALS参数,如下所示: DESCRIBE FIELD DECIMALS . 系统读取字段的小数个数,并将值写入字段。 1.3.5 确定转换例程 要确定ABAP/4 词典中某字段的转换例程是否存在,如果存在,名称是什

自考英语语法

本次语法串讲分三个部分,第一,方法篇;第二,命题特点分析;第三,重点章节复习。 第一、方法篇 自学考试英语专业《英语语法》科目是一门理论性和实践性都非常强的课程,旨在考核考生能否熟练掌握现代英语语法的基本理论和概念,掌握词的形态变化和用词造句的规则,以及组句成篇的一般形式和规律。 由于存在着英汉语言体系上的差异、教材的全英版和术语的生僻、语法本身乏味枯燥等外部因素,以及考生英语基础知识薄弱、精读和泛读的阅读数量尚未达到一定量因此不能将一些语法规则变成感性认识加以推演和归纳、甚至还有同学有畏难情绪,一旦跟不上就放弃,或者偷懒,不愿多做一些练习和多记一些概念解释,结果仅以一、二分之差没有及格,令人扼腕。 但是有志者事竟成,这句名言还没有过时。我们举几个成功的例子吧。 我教过的学生中有人刻意让自己爱上语法,首先,她克服困难,把全书通读一遍,可是有那么多不懂的单词和术语怎么办?她问我。我说,把它们暂时放在一边,然后通过例句猜测该词的含义,结果既记住了概念又结合了例句,相辅相成,直到掌握。 比如:什么是extraposition?这个词是由extra-(在……之外,额外)加position(位置),联想到appositive phrase(同位短语),appositive clause (同位语分句)等,那么从该词的外形上可以判定extraposition是“位置放在外围”。 它出现在我们教材中的《信息结构和强调》一章中,我们知道,突出强调信息的几种主要方法(postponement, fronting,inversion, cleaving,existential sentence)之一的后移又有三种后移的方法:passive voice, extraposition and discontinuity。从课本上我们看到这样的例句:To make fun of a disabled man is not funny at all. It is not funny at all to make fun of a disabled man. He found it annoying that his neighbor kept calling him by the wrong name. 你注意到这里有it出现在句中做形式主语和形式宾语,真正的主语和宾语在句末,然后,结合解释“When we re move a clausal subject or object to the final focal position, we use the anticipatory it to fill in the slot. Grammatically speaking, it is the formal subject or object while the extraposed clause is the real or notional subject or object. In function, the extraposed item can be subject or object; in form it can be finite or non-finite. 后移的结果就是满足了末尾重心(end-weight)的原则,达到强调的效果。

现代英语语法笔记整理

现代英语语法笔记整理 下面是我整理出来经常错误的题目 其中选择题20‘填空题30‘改错题8’句型转换题28‘其余名词解释和问答14‘ 要想及格那么选择题、填空题和句型转换题一定得拿55分以上,此三种题型也较容易拿分 注:名词解释题和简单题不再详述,我会在以上4道题中谈到。 一、选择题(20‘)此节还适合于综合英语二 选择题的题型以及考点: 1.关于by the time 用法 By the time 表示“当…的时候” Eg. By the time the course ends, we will have learnt a lot about market money 像此类题我们通常会做成过去完成时,但这样是错误的 记住这句话: 从句用一般时,主句用将来时。 2.need 的用法 记住它有三种方法 “need”作为实义动词时,通常用法是: 人+need +to do 物+need +doing 物+need +to be done Eg. The recorder needs repairing. Or, The recorder needs to be repaired。 此题考法简单,通常会给出这两个答案中的一个,比如要么给出repairing 要么给出 to be repaired。题目可能会变但这三种用法不会变 3.关于a large number of a large amount of a great deal of a large number of a lot of plenty of numerous much many few little 修饰名词的:a large number of 、numerous、many、 few 修饰不可数名词:a large amount of 、a great deal of、much、 little 既修饰可数和不可数:a lot of plenty of 个人认为只要知道修饰可数的和不可数的就行了,黑体字表示容易错的一定要记住。 4.see的用法,此题型经常考 see 有两种用法 such as: 1. see sb doing sth. 强调看见某人正在做某事,着重动作过程 eg, I saw him drawing by the river then.说明他正在看他画画,强调看画画的过程。 2. see sb do sth. 是看见某人做某事,着重于看见这件事的发生 eg. I saw Dr. Smith enter the operating room a moment ago. 说明他看到过Smith进了手术室了. 5.考倒装: 考倒装的范围相当广,一般有这些词需要倒装 1.虚拟语气的倒装

ABAP语法完整版

SAP ABAP / 4 基础知识学习 数据类型 C :字符串 D :日期型格式为 YYYYMMDD 例:'1999/12/03' F : 浮点数长度为8 I :整数 N :数值组成的字符串如:011,'302' P : PACKED数用于小数点数值如:12.00542 T : 时间格式为:HHMMSS 如:'14:03:00' X : 16进制数如:'1A03' *-------------------------------------------------------------------------------------* 变量声明 DATA [] [][decimals] 变量名称 变量类型及长度 初值 小数位数 exp: DATA : COUNTER TYPE P DECIMALS 3. NAME(10) TYPE C VALUE 'DELTA'. S_DATE TYPE D VALUE '19991203'. exp: DATA : BEGIN OF PERSON, NAME(10) TYPE C, AGE TYPE I, WEIGHT TYPE DECIMALS 2,

END OF PERSON. 另外,有关DATA声明的指令还有: CONSTANTS(声明常数)、STATICS(临时变量声明). exp: CONSTANTS PI TYPE P DECIMALS 5 VALUE '3.14159'. STATICS 关键字 声明的变量仅在目前的程序中使用, 结束后会自动释放 语法: STATICS [] [] [] 系统专用变量说明 系统内部专门创建了SYST这个STRUCTURE,里面的栏位存放系统变量,常用的系统变量有: SY-SUBRC: 系统执行某指令后,表示执行成功与否的变量,'0'表示成功 SY-UNAME: 当前使用者登入SAP的USERNAME; SY-DATUM: 当前系统日期; SY-UZEIT: 当前系统时间; SY-TCODE: 当前执行程序的Transaction code SY-INDEX: 当前LOOP循环过的次数 SY-TABIX: 当前处理的是internal table 的第几笔 SY-TMAXL: Internal table的总笔数 SY-SROWS: 屏幕总行数; SY-SCOLS: 屏幕总列数; SY-MANDT: CLIENT NUMBER SY-VLINE: 画竖线 SY-ULINE: 画横线 TYPE 关键字 用来指定资料型态或声明自定资料型态 Example: TYPES: BEGIN OF MYLIST,

2016年4月全国自考《现代英语语法》真题及详解

2016年4月全国自考《现代英语语法》真题 (总分100, 考试时间90分钟) 1. Choose the best answer from the choices given and blacken the corresponding letter A, B, C or D on the ANSWER SHEET. 1. The Niagara Falls_______long been a popular tourist destination, boosted by a number of movies. ( ) A have B having C had D haven't 答案:A 解析:山脉、瀑布、岛屿等地理名词常常被当作复数。这些名词作主语时,谓语动词要用复数,如the Alps,the highlands,the Himalayas,Niagara Falls等。答案为A。 2. There is nothing more wonderful in the world than swimming with a_______of fish around you. ( ) A sack B sheet C staff D school 答案:D 解析:本题考查单位名词。a school of fish一群(小)鱼,很多,a school of=a lot of。答案为D。 3. There are stores on_______sides of the square. ( ) A both B every C each D all 答案:D 解析:the square(广场)是四面的,所以排除仅指两边的both。选项B和C后跟单数名词。答案为D。 4. You have not at all read my points carefully and_______the same mistakes. ( ) A continuously repeat B continuously repeated C are continuously repeating D continuously repeating 答案:C 解析:现在进行体和表示高频率的副词always,constantly,continually,continuously,all the time等连用时,失去了表示暂时性的语义含义,而经常被用来表示一种独特的习惯。答案为C。 5. Then you will come to a level plain, in which the Nile ____ round an island named Tachompso. ( ) A flows B flow C is flowing D flowing 答案:A 解析:表示客观事实用一般现在时。句意为:然后你会来到一个平坦的平原;在那里,尼罗河环绕一座名叫Tachompso的岛屿而流。答案为A。 6. He _______ hurt last year early in the playoffs and never came back. ( ) A got B were

自考英语语法问答题总结

自考《现代英语语法》总结 Chapter One 1.What are the four major types of sentence and what discourse functions are they normally associated with? Statements are normally associated with declaratives and primarily concerned with giving information. Questions are associated with interrogatives and primarily concerned with requiring information. Commands are associated with imperatives and primarily concerned with requiring actions. Exclamations are associated with exclamatives and primarily concerned with expressing the speaker’s impression of something. 2.What are the verbs which transferred negation often occurs with? What is their shared semantic feature? The verbs which transferred negation often occurs with are: think, believe, suppose imagine and expect. They are the verbs that express “opinion”. 3.Explain the differences between a tag question with a final rising tone and one with a final falling tone. With a rising tone, the question expresses the speaker’s neutral expectation of the hearer’s response and invites the hearer to verify the truth of the proposition in the statement. With a falling one, the speaker asks for the hearer’s confirmation of the statement. It can be regarded as similar to an exclamation. Chapter 4 4.Can the definite article be used for generic reference and the indefinite article for specific reference? If they can, give one example for each use. The definite article can be used for generic reference. For example, the panda is a rare animal. The panda here still denotes the whole species. The indefinite artic le can also be used for specific reference. For example, a dog chained at me when I was on my way home last night. Here a dog points to a particular, actual example of the class. Here “a”shows indefinite specific reference. 5.What are some of the constraints that the double genitive is subject to? The second noun in the double genitive almost always refers to persons, never to objects, and the first noun usually has indefinite reference (typically premodified by the indefinite article and the second noun is always definite.) Chapter 5 6.Why do most contemporary English grammarians adopt a two-tense system? Because tense is a verb form. Morphologically only present tense and past tense have their forms of verbs. A language which has no verb forms has no tense. 7.If tense is related to time, what is aspect related to? When ten points to the temporal location of an event or a state of affairs, aspect “reflects the way in which the verb action is regarded or experienced with respect to time.” 8.Why is the past tense often used for politeness? Because the past tense can make a question or a statement or a suggestion less direct. It is more polite to use the past tense on the part of the speaker.

自考英语语法串讲

《英语语法》串讲讲义 课程介绍 一、课程性质 《现代英语语法》是高等教育自学考试英语专业(本科段)的一门选修课,主要面向具有相当于英语专业本科二年级以上水平并有志参加高等教育自学考试英语专业(本科段)考试的学生。《现代英语语法》理论与实践并重,既是一部语法理论著作,有宏观的理论概述,对英语语言结构作了比较系统的描写。又可作为教学参考书,它根据教学要求精选语法项目、设计篇章结构,有取有舍,自成体系,既有知识性,又有实践性。本教程中例子丰富,在历年试题中直接从教材中选择的例句数量相当多,这就要求学员在学习的过程中能确实看懂例子,能真正理解理论并能把理论应用于实践。 二、教材的选用 《现代英语语法》课程所选用教材是全国高等教育自学考试指定教材,该书由李基安主编,外语教学与研究出版社出版。 三、章节体系 为了便于各位学员复习应考,我们的串讲严格按照教材章节来讲。共十六章,每章主要以哪种形式命题以及哪些是高频考点我在讲解的什么都会提到,以帮助大家在以后的复习中做到有的放矢,迅速抓住重点内容,以取得事半功倍的效果。 考情分析 一、历年真题的分布情况 根据对《现代英语语法》近5年考题(注:全国每年统考:4月,有些省份7月还有一次,浙江省每年10月份也有语法考试)分析,可以看出哪些部分是全书的重点章,具体看下列表格中的黑体。

二、题型分析 《现代英语语法》的考试题型包括五种:单项选择题、填空题、改错题、改写句子、简答题。 根据对近5年的试题进行分析,可以发现题型有变化,但总的题量没变,仍然是74个题目。 09年4月前(含09年4月)共7大题型: 一、单项选择题(本大题共20小题,每小题1分,共20分) 二、选择填空题(本大题共8小题,每小题2分,共16分) 如:21. were, was, had, animal, animals Small amounts of land ________ used for keeping ________. (该例选自0904) 三、填空题(本大题共20小题,每小题1分,共20分) A. Fill in the blank with assertive, non-assertive or negative words: 29. I think I’ve lost that green scarf of mine; I can’t find it ________. B. Fill in the blanks with the appropriate form of the verb or verb phrase given: 34. It is time we ________ (think) about drawing up a detailed plan for the project. 四、改错题(本大题共8小题,每小题1分,共8分) 五、改句(本大题共13小题,每小题2分,共26分)Rewrite the following sentences as required. 六、名词解释(本大题共2小题,每小题2分,共4分)Define the following terms with examples. 七、简答题(本大题共3小题,每小题2分,共6分)Answer the following questions. 10年4月开始(含1004)共五大题型: 一、单项选择题(本大题共20小题,每小题1分,共20分) 二、填空题(本大题共28小题,共36分) Section A. Fill in the blanks with the appropriate words given in the group.(共8小题,每小题2分,共16分) Section B. Fill in the blanks with the words given in brackets. Make changes where necessary. (共20小题,每小题1分,共20分) 三、改错题(本大题共l 2小题,每小题1分,共12分) 四、改句题(本大题共1 2小题,每小题2分,共24分) 五、简答题(本大题共2小题,每小题4分,共8分) 从以上题型变化分析,我们可以看出1004把09年4月(前)的第二、三题合成了一个大题,并且少了名词解释的题型,因此总的题型少了两个。 学员答题时要注意以下两点:

相关主题
文本预览
相关文档 最新文档