Parsers enable programs to recognize patterns matching formal grammars. More specifically, parsers can perform syntactic analysis of an input sequence in multiple steps. First, a sequence of characters can be lexically analyzed to recognize tokens such as keywords, operators, and identifiers, among others. In other words, an input sequence is preprocessed. For example, consider the following input sequence including whitespaces: “{, v, a, r, , x, , =, , x, , +, , 1, ;,}.” Lexical analysis can produce the following sequence of tokens “{,” “var,” “x,” “=,” “x,” “+,” “1,” “;” “}.” Next, these tokens can be employed to produce a parse tree or more compact abstract syntax tree (AST) as a function of a programming language grammar, which can be employed for subsequent analysis, optimization, and code generation. Further to the above example, “{var x=x+1;}” can be represented in a hierarchical format
Parsing is conventionally a pull-based computation. For example, the parser can request the next token. In response, a lexer, performing lexical analysis, pulls on an input sequence to read the next one or more characters that form a token that is provided back to the parser. Subsequently, the parser asks for the next token and the process continues. The input sequence typically exists in a string or file, for example, and the process of discovering a pattern or structure in the input is pull-based. Whenever a consuming process needs to know more, it asks for the next value. For example, the parser asks for the next token, and the lexer asks for the next character.
Many parsers are written by hand while others are generated automatically. For example, a grammar can be provided from which a parser is generated. In particular, regular expressions can be utilized to facilitate automatic generation of a parser based on the grammar, wherein regular expressions provide a concise means for finding or matching a sequence of characters in an existing string or file, for example. Regardless, parsers as well as regular expressions are pull-based such that a consumer of input is in control of data acquisition.
Furthermore, both parsers and regular expression engines can employ arbitrary look ahead and/or backtracking (negative look ahead) to facilitate recognition of a pattern of input. For instance, with respect to parsing, a look ahead specifies a maximum number of tokens that can be utilized before deciding what grammar rule to utilize. Backtracking refers to utilization of one or more previously acquired tokens to identify an appropriate grammar rule. In the case of look ahead and backtracking, such functionality can be implemented by simply moving a pointer in an input sequence forward or backward and subsequently pulling input from the sequence at the position identified by the pointer.
The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed subject matter. This summary is not an extensive overview. It is not intended to identify key/critical elements or to delineate the scope of the claimed subject matter. Its sole purpose is to present some concepts in a simplified form as a prelude to the more detailed description that is presented later.
Briefly described, the subject disclosure generally pertains to parsing observable collections. More particularly, parsing technology is utilized to facilitate recognition of patterns with respect to observable collections. In accordance with one embodiment, a combinator parser can be generated and employed to recognize patterns in one or more observable collections. Furthermore, items from two or more observable collections can be added to a single observable collection to facilitate processing, and time can be captured by annotating observable collection items with time or generating time items.
To the accomplishment of the foregoing and related ends, certain illustrative aspects of the claimed subject matter are described herein in connection with the following description and the annexed drawings. These aspects are indicative of various ways in which the subject matter may be practiced, all of which are intended to be within the scope of the claimed subject matter. Other advantages and novel features may become apparent from the following detailed description when considered in conjunction with the drawings.
Details below are generally directed toward parsing observable collections. Conventionally, parsers are employed to operate over strings, files, or other pull-based or enumerable collections. However, parsers can also be utilized to identify patterns over push-based data, or in other words, observable collections such as event streams. In one embodiment, a combinator parser can be employed, which is a parser that is constructed piecewise from primitive or less complex parsers. In other words, parser combinators can be employed that utilize basic parsers to build more complex parsers and complex parsers to build parsers that are even more complex. Further yet, multiple observable collections can be combined into a single observable collection, and observable collection items can be annotated with time or separate time items can be generated to facilitate parsing.
Conventional parser technology can be adapted to facilitate employment over push-based or observable collections. Backtracking and look ahead are commonly utilized by conventional parsing systems over pull-based or enumerable collections. However, the asynchronous nature of observable or push-based data makes backtracking or buffering of input difficult or impossible. Furthermore, a parser is not able to look ahead with respect to push-based data that has not yet been provided. Nevertheless and as described further herein, limited backtracking and look ahead functionality can be provided, if needed, to parse observable collections.
Various aspects of the subject disclosure are now described in more detail with reference to the annexed drawings, wherein like numerals refer to like or corresponding elements throughout. It should be understood, however, that the drawings and detailed description relating thereto are not intended to limit the claimed subject matter to the particular form disclosed. Rather, the intention is to cover all modifications, equivalents, and alternatives falling within the spirit and scope of the claimed subject matter.
Referring initially to
The observable collection 110 can be thought of, or represented as, a stream of data because of the collection's dynamic nature. Accordingly, events or, in other words, event streams can be one type of observable collection 110. For example, the observable collection 110 can be a stream of stock prices or weather data provided at arbitrary times. Of course, the observable collection 110 is not limited to events. Other push-based collections that are not conventionally viewed as events can be a type of observable collection 110 such as but not limited to results of asynchronous computations.
Furthermore, in one particular embodiment, the observable collection 110 can refer a collection of data with respect to an “IObservable” interface or the like of programming languages such as but not limited to C#®, which provides a generalized mechanism for push-based notification, also known as the observer design pattern. More specifically, an “IObservable” interface can expose an “IObserver” interface, wherein “IObservable<T>” represents a class that sends notifications (provider) and “IObserver<T>” represents a class that receives the notifications (observer). Here, “T” represents the class or type of notification.
The data processing system 100 also includes a collection-processor component 130 communicatively coupled with the observable collection 110 and configured to perform some action on the observable collection 110. For example, the collection-processor component 130 can perform some pre-processing on the observable collection 110 to facilitate further processing by a recognizer component 140.
The recognizer component 140 is communicatively coupled with the observable collection 110 and configured to analyze the observable collection and output a recognized pattern, an error, or other message. As will be described further hereinafter, the recognizer component 140 can utilize parser technology heretofore reserved for the processing of strings, files or other pull-based or enumerable data collections.
Among other things, the function functionality provided by the recognizer component 140 can allow patterns amongst push-based data at a lower abstraction level to be discovered and utilized to create patterns at a higher abstraction level, among other things. For example, suppose in an event stream of mouse events it is desirable to detect that a mouse has moved over some control by looking for the pattern “mouseover, . . . , mousemove, mouseout.” This pattern can now be replaced with a higher level of abstraction, such as “mouse over control events.”
Turning to
By way of example and not limitation, an event stream can provide stock price events and the combiner component 210 can generate new events from the stock price events to be added to a stream that notes the fact that the event is a stock price and includes data such as the actual stock and price. In this manner, this event can be distinguished in a single stream from other events provided from other streams such as a stream that provides weather related events, for example. More abstractly, three event streams “A,” “B,” and “C” with respective events “A1,” “B1,” and “C1” can be combined into a single stream “D” that includes events “A1, B1, and C1.”
Time component 220 captures item times. Data items by pushed to an observable collection at arbitrary times, and the significance of data provided by items can be time dependent (e.g., time item was provided, duration of time between items . . . ). The time component 220 can capture times associated with provisioning of items in various ways.
In one instance, upon receipt of an item from a source, the time the event was received can be noted and added to the event in some manner. For example, an item can be annotated with a time stamp. As a result, capturing duration between items of data becomes irrelevant since the time between items can be easily computed.
Turning attention briefly to
In another embodiment, the time component 220 can inject time items into a new or existing observable collection (e.g., time stream). For instance, the time item can represent some significant time relevant to other items. By way of example, a pattern can specify that two items were acquired within a particular timeframe. More particularly, a pattern can specify a match if an item “M” occurs within five minutes of event ‘B.”
Notice that the time component 220 of
Referring to
Furthermore, the parser component 410 and the regular expression component 420 can be combinatory and compositional in nature. In particular, the parser component 410 can be embodied as a combinator parser wherein parser combinators (a.k.a. operators in some contexts) are used to define basic parsers, which in turn are utilized to build more complex parsers that can be utilized to build parsers that are even more complex. In other words, parses can be built up piecewise from primitive or less complex parsers. For example, consider the following sample parser combinators:
Furthermore, with respect to regular expression pattern matching a deterministic finite state machine can be generated that transitions between states depending on the next incoming item. However, in general, it is desirable to recognize the same pattern repeatedly. To do this efficiently, a variant of the Boyer-Moore string matching algorithm can be employed by starting a new recognizing finite state machine (or pre-computing a parallel composition of a finite state machine) when the next incoming value can start a pattern. However, this can assume a finite alphabet by creating a transition “R→x→S” for each proper prefix “R” or a pattern “P” and each character “x ∈ Σ” where “S” is the longest prefix of the pattern “P” that is also a suffix of “Rx.”
Two consequences of working with observable collections are that arbitrary backtracking and look ahead cannot be employed as is conventionally done with strings, files or the like. More specifically, since items of data are being emitted at arbitrary times, one cannot look ahead to items that have not yet been provided. As well, the amount of backtracking can be unbounded and thus it is not desirable to buffer items in the conventional manner to allow for backtracking.
Nevertheless, in accordance with an aspect of the subject disclosure, limited look ahead and backtracking can be utilized if necessary. As per look ahead, this can be accomplished by time shifting a collection of items such that the current item being evaluated is not the most recent item. With respect to backtracking, left factoring can be employed. Here, if a parser, for example, fails without consuming any input (as opposed to succeeding with a value) another parser can “go back” or look at the unconsumed input. In other words, state information can be maintained regarding the failure without consumption of input.
Referring briefly to
Furthermore, it should be appreciated that the parser component 410 can be a monad, or more specifically a monadic combinator parser, for observable collections, wherein a monad is a type of abstract data type constructor that represents computations rather than data. As a practical side effect, other monads can be mapped to a monadic combinator parser such as monad comprehensions or query comprehensions that specify monadic primitives for filtering, transforming, joining, grouping, and aggregating over arbitrary collections of data. Consequently, various query operators (e.g., Where, Select, Join, Take, Skip . . . ) or query expressions employing the query operators can be utilized to express parsers in a more easily comprehensible and familiar form than would otherwise be required. In one particular implementation, a parser can be specified with a language integrated query (LINQ), wherein query operators can be utilized to specify query expressions within a primary programming language (e.g., C#®, Visual Basic® . . . ).
More specifically, the recognizer component 140 can implement LINQ sequence operators so that the recognizer component 140 can be defined with a LINQ query. For parsers, a significant operator can be “choice:”
In accordance with one implementation, the service component 630 can be network accessible service such as a Web service. Furthermore, the service component 630 can provide varying functionality based on credentials supplied by the subscriber component 620 which may reflect election of different features, for instance as a result of payment or non-payment of fees associated with the service. By way of example, limits can be controlled with respect to the number of events that are to be processed or the number of events that filtered out, among other things. Further, yet the complexity of the recognizer component 140 can be modified and storage associated with limited backtracking can be set and adjusted to levels corresponding to particular credentials. In other words, services can be divided and proportioned at arbitrary or predetermined levels.
The aforementioned systems, architectures, environments, and the like have been described with respect to interaction between several components. It should be appreciated that such systems and components can include those components or sub-components specified therein, some of the specified components or sub-components, and/or additional components. Sub-components could also be implemented as components communicatively coupled to other components rather than included within parent components. Further yet, one or more components and/or sub-components may be combined into a single component to provide aggregate functionality. Communication between systems, components and/or sub-components can be accomplished in accordance with either a push and/or pull model. The components may also interact with one or more other components not specifically described herein for the sake of brevity, but known by those of skill in the art.
Furthermore, as will be appreciated, various portions of the disclosed systems above and methods below can include or consist of artificial intelligence, machine learning, or knowledge or rule-based components, sub-components, processes, means, methodologies, or mechanisms (e.g., support vector machines, neural networks, expert systems, Bayesian belief networks, fuzzy logic, data fusion engines, classifiers . . . ). Such components, inter alia, can automate certain mechanisms or processes performed thereby to make portions of the systems and methods more adaptive as well as efficient and intelligent. By way of example and not limitation, the recognizer component 140 can be implemented with such mechanisms to enable intelligent specification and identifications of patterns over push-based data.
In view of the exemplary systems described supra, methodologies that may be implemented in accordance with the disclosed subject matter will be better appreciated with reference to the flow charts of
Referring to
By way of example and not limitation, in the context of events, if a pattern specifies that a first event occur within five minutes of second event, a time event can be inserted into a stream every five minutes. To determine if there is a matching pattern, the analysis can determine whether a time event occurred between the first and second events. If there is a time event between two events then there is no match, as more than five minutes has passed. However, if a time event does not exist then there is a match, since five or less minutes have passed between the occurrences of the first and second events.
Aspects of the disclosed subject matter are distinct from a few conventional technology that may appear at least on their face to be similar, namely push and pull-based parsing of XML (eXtensible Markup Language), and complex event processing, streaming, and continuous queries in a database context.
Push- and pull-based parsing of XML refers to the way a parser communicates with its consumers. More particularly, streaming pull parsing refers to a programming model in which a client application calls methods on an XML parsing library when it needs to interact with an XML information set (an abstract data model that represents an XML document as a set of information items). That is, the client only gets (pulls) XML data when it explicitly asks for it. Streaming push parsing, on the other hand, refers to a programming model in which an XML parser sends (pushes) XML data to the client as the parser encounters elements in an XML information set. That is, the parser sends data whether or not the client is ready to use the data at that time. This disclosure pertains to a mechanism for recognizing patterns in observable collections as opposed to the traditional parsing and recognition of patterns that pertain to enumerable collections (e.g., in-memory collections).
Complex event processing (CEP), streaming, and continuous queries are popular in the database community. The model there is that of querying tables to which new rows are added and removed continuously. However, queries are typically done over the tables not over event streams directly.
A problem observable collections face compared to traditional parsing and regular expression matching is that the asynchronous nature makes backtracking or buffering the input difficult or impossible. Moreover, since observable collections are push-based, it is not practical to look ahead at input, which is common with respect to conventional recognizers. Accordingly, patterns need to be recognized with limited or no backtracking or look ahead.
As used herein, the terms “component” and “system,” as well as forms thereof are intended to refer to a computer-related entity, either hardware, a combination of hardware and software, software, or software in execution. For example, a component may be, but is not limited to being, a process running on a processor, a processor, an object, an instance, an executable, a thread of execution, a program, and/or a computer. By way of illustration, both an application running on a computer and the computer can be a component. One or more components may reside within a process and/or thread of execution and a component may be localized on one computer and/or distributed between two or more computers.
The word “exemplary” or various forms thereof are used herein to mean serving as an example, instance, or illustration. Any aspect or design described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other aspects or designs. Furthermore, examples are provided solely for purposes of clarity and understanding and are not meant to limit or restrict the claimed subject matter or relevant portions of this disclosure in any manner It is to be appreciated a myriad of additional or alternate examples of varying scope could have been presented, but have been omitted for purposes of brevity.
As used herein, the term “inference” or “infer” refers generally to the process of reasoning about or inferring states of the system, environment, and/or user from a set of observations as captured via events and/or data. Inference can be employed to identify a specific context or action, or can generate a probability distribution over states, for example. The inference can be probabilistic—that is, the computation of a probability distribution over states of interest based on a consideration of data and events. Inference can also refer to techniques employed for composing higher-level events from a set of events and/or data. Such inference results in the construction of new events or actions from a set of observed events and/or stored event data, whether or not the events are correlated in close temporal proximity, and whether the events and data come from one or several event and data sources. Various classification schemes and/or systems (e.g., support vector machines, neural networks, expert systems, Bayesian belief networks, fuzzy logic, data fusion engines . . . ) can be employed in connection with performing automatic and/or inferred action in connection with the claimed subject matter.
Furthermore, to the extent that the terms “includes,” “contains,” “has,” “having” or variations in form thereof are used in either the detailed description or the claims, such terms are intended to be inclusive in a manner similar to the term “comprising” as “comprising” is interpreted when employed as a transitional word in a claim.
In order to provide a context for the claimed subject matter,
While the above disclosed system and methods can be described in the general context of computer-executable instructions of a program that runs on one or more computers, those skilled in the art will recognize that aspects can also be implemented in combination with other program modules or the like. Generally, program modules include routines, programs, components, data structures, among other things that perform particular tasks and/or implement particular abstract data types. Moreover, those skilled in the art will appreciate that the above systems and methods can be practiced with various computer system configurations, including single-processor, multi-processor or multi-core processor computer systems, mini-computing devices, mainframe computers, as well as personal computers, hand-held computing devices (e.g., personal digital assistant (PDA), phone, watch . . . ), microprocessor-based or programmable consumer or industrial electronics, and the like. Aspects can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. However, some, if not all aspects of the claimed subject matter can be practiced on stand-alone computers. In a distributed computing environment, program modules may be located in one or both of local and remote memory storage devices.
With reference to
The processor(s) 1220 can be implemented with a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general-purpose processor may be a microprocessor, but in the alternative, the processor may be any processor, controller, microcontroller, or state machine. The processor(s) 1220 may also be implemented as a combination of computing devices, for example a combination of a DSP and a microprocessor, a plurality of microprocessors, multi-core processors, one or more microprocessors in conjunction with a DSP core, or any other such configuration.
The computer 1210 can include or otherwise interact with a variety of computer-readable media to facilitate control of the computer 1210 to implement one or more aspects of the claimed subject matter. The computer-readable media can be any available media that can be accessed by the computer 1210 and includes volatile and nonvolatile media and removable and non-removable media. By way of example, and not limitation, computer-readable media may comprise computer storage media and communication media.
Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to memory devices (e.g., random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM) . . . ), magnetic storage devices (e.g., hard disk, floppy disk, cassettes, tape . . . ), optical disks (e.g., compact disk (CD), digital versatile disk (DVD) . . . ), and solid state devices (e.g., solid state drive (SSD), flash memory drive (e.g., card, stick, key drive . . . ) . . . ), or any other medium which can be used to store the desired information and which can be accessed by the computer 1210.
Communication media typically embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. The term “modulated data signal” means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, RF, infrared and other wireless media. Combinations of any of the above should also be included within the scope of computer-readable media.
System memory 1230 and mass storage 1250 are examples of computer-readable storage media. Depending on the exact configuration and type of computing device, system memory 1230 may be volatile (e.g., RAM), non-volatile (e.g., ROM, flash memory . . . ) or some combination of the two. By way of example, the basic input/output system (BIOS), including basic routines to transfer information between elements within the computer 1210, such as during start-up, can be stored in nonvolatile memory, while volatile memory can act as external cache memory to facilitate processing by the processor(s) 1220, among other things.
Mass storage 1250 includes removable/non-removable, volatile/non-volatile computer storage media for storage of large amounts of data relative to the system memory 1230. For example, mass storage 1250 includes, but is not limited to, one or more devices such as a magnetic or optical disk drive, floppy disk drive, flash memory, solid-state drive, or memory stick.
System memory 1230 and mass storage 1250 can include, or have stored therein, operating system 1260, one or more applications 1262, one or more program modules 1264, and data 1266. The operating system 1260 acts to control and allocate resources of the computer 1210. Applications 1262 include one or both of system and application software and can exploit management of resources by the operating system 1260 through program modules 1264 and data 1266 stored in system memory 1230 and/or mass storage 1250 to perform one or more actions. Accordingly, applications 1262 can turn a general-purpose computer 1210 into a specialized machine in accordance with the logic provided thereby.
All or portions of the claimed subject matter can be implemented using standard programming and/or engineering techniques to produce software, firmware, hardware, or any combination thereof to control a computer to realize the disclosed functionality. By way of example and not limitation, collection-processor component 130 and recognizer component 140 can be, or form part, of an application 1262, and include one or more modules 1264 and data 1266 stored in memory and/or mass storage 1250 whose functionality can be realized when executed by one or more processor(s) 1220, as shown.
The computer 1210 also includes one or more interface components 1270 that are communicatively coupled to the system bus 1240 and facilitate interaction with the computer 1210. By way of example, the interface component 1270 can be a port (e.g., serial, parallel, PCMCIA, USB, FireWire . . . ) or an interface card (e.g., sound, video . . . ) or the like. In one example implementation, the interface component 1270 can be embodied as a user input/output interface to enable a user to enter commands and information into the computer 1210 through one or more input devices (e.g., pointing device such as a mouse, trackball, stylus, touch pad, keyboard, microphone, joystick, game pad, satellite dish, scanner, camera, other computer . . . ). In another example implementation, the interface component 1270 can be embodied as an output peripheral interface to supply output to displays (e.g., CRT, LCD, plasma . . . ), speakers, printers, and/or other computers, among other things. Still further yet, the interface component 1270 can be embodied as a network interface to enable communication with other computing devices (not shown), such as over a wired or wireless communications link.
What has been described above includes examples of aspects of the claimed subject matter. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the claimed subject matter, but one of ordinary skill in the art may recognize that many further combinations and permutations of the disclosed subject matter are possible. Accordingly, the disclosed subject matter is intended to embrace all such alterations, modifications, and variations that fall within the spirit and scope of the appended claims.