Embodiments of the present invention relate to classifying content, and more specifically to searching for one or more predetermined N-grams in a string of bytes representing content written in a non-delimited language.
Today, many entities (e.g., private companies, government, schools, etc.) rely on various content filtering mechanisms to manage and/or control user access to the Internet via facilities provided by the entities. For example, a company typically implements some form of content filtering mechanism to control the use of the company's computers and/or servers to access contents (e.g., web pages and/or emails) from the Internet. Contents as used herein broadly refer to expressive work, which may include one or more of literary, graphics, audio, and video data. Access to content within certain predetermined categories using the company's computers and/or servers may not be allowed during some predetermined periods of time.
Conventionally, a content rating engine or a content classification engine may be installed in a firewall to screen contents coming into a system from an external network, such as email received and web pages retrieved from the Internet. The content rating engine may retrieve rating of the incoming contents from a rating database, if any, and/or attempt to rate the contents in real-time. To rate the content in real-time, the content rating engine may parse the contents to identify some predetermined keywords and/or tokens and then determine a rating for the contents based on the presence and/or absence of the keywords and/or tokens.
For European languages (e.g., English, French, etc.), the spaces between words are often used as delimiters for recognizing word boundaries. Therefore, words in European languages can be readily tokenized and searched using the spaces between the words. As a result, tokenization generally proceeds efficiently for European languages.
However, the above approach typically fails for languages that lack spaces between words, such as Chinese, Japanese, Thai, etc. Such languages are also referred to as non-delimited languages herein. For example, a Chinese sentence is composed of words, which contain a variable number of characters, with no spaces indicating the word boundaries. Below is an example of an excerpt from a Chinese newspaper: “, ” The words are (now) (one) (week) (ago) (Iranian) (government) (began) (implementing) (energy) (rationing) . . . . Note that the characters are not separated by spaces, and a word may include one or more characters. Other examples can be more complicated, with ambiguous sentences where the correct split of text into words can be found only by understanding the context. As a result, spaces may not be reliably used as delimiters for recognizing words in Chinese. Because of the above issue, keyword search in non-delimited languages is typically difficult and time consuming. This is particularly problematic in real-time or on-the-fly content filtering because the keyword search has to be limited to avoid causing a noticeable delay in online content access.
The present invention is illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which:
Described herein are some embodiments of an efficient string search. As mentioned above, content as used herein broadly refers to expressive work, which may include one or more of literary, graphics, audio, and video data. Online content generally refers to content accessible over a network (e.g., an intranet, the Internet, etc.). Some examples of online content include web pages, electronic mails, etc. Furthermore, content may include text in various formats and/or languages. In general, languages may be categorized as delimited languages and non-delimited languages in the current document. Delimited languages refer to languages composed of words that are separated by spaces, where there is no space within a single word. On the contrary, non-delimited languages refer to languages composed of words, where a word may include zero or more spaces within itself. For example, Chinese is a non-delimited language, where a Chinese sentence is composed of words, which contain a variable number of characters, with no spaces indicating the word boundaries. In order to efficiently search for keywords in a non-delimited language, a set of N-grams representing the keywords are used instead of word tokens. Generally speaking, an N-gram is a sequence of N items, where N is an integer. Each N-gram corresponds to a keyword pre-selected for identifying content of a certain type in a particular non-delimited language.
In some embodiments, a string of bytes representing content written in a non-delimited language is received, wherein the content has been classified into a predetermined category. In a single pass through the string of bytes, a set of N-grams is searched for substantially simultaneously. Statistical information on occurrences of the N-grams, if any, in the string of bytes is collected. The efficient string search disclosed herein may be used in various applications, such as generation of models for document classification, classification of documents during screening of online content, etc. More details of some embodiments of the efficient string search are described below.
In the following description, numerous details are set forth. It will be apparent, however, to one skilled in the art, that the present invention may be practiced without these specific details. In some instances, well-known structures and devices are shown in block diagram form, rather than in detail, in order to avoid obscuring the present invention.
Some portions of the detailed descriptions below are presented in terms of algorithms and symbolic representations of operations on data bits within a computer memory. These algorithmic descriptions and representations are the means used by those skilled in the data processing arts to most effectively convey the substance of their work to others skilled in the art. An algorithm is here, and generally, conceived to be a self-consistent sequence of operations leading to a desired result. The operations are those requiring physical manipulations of physical quantities. Usually, though not necessarily, these quantities take the form of electrical or magnetic signals capable of being stored, transferred, combined, compared, and otherwise manipulated. It has proven convenient at times, principally for reasons of common usage, to refer to these signals as bits, values, elements, symbols, characters, terms, numbers, or the like.
It should be borne in mind, however, that all of these and similar terms are to be associated with the appropriate physical quantities and are merely convenient labels applied to these quantities. Unless specifically stated otherwise as apparent from the following discussion, it is appreciated that throughout the description, discussions utilizing terms such as “processing” or “computing” or “calculating” or “determining” or “displaying” or the like, refer to the action and processes of a computer system, or similar electronic computing device, that manipulates and transforms data represented as physical (electronic) quantities within the computer system's registers and memories into other data similarly represented as physical quantities within the computer system memories or registers or other such information storage, transmission, or display devices.
The present invention also relates to apparatus for performing the operations herein. This apparatus may be specially constructed for the required purposes, or it may comprise a general-purpose computer selectively activated or reconfigured by a computer program stored in the computer. Such a computer program may be stored in a machine-readable storage medium, such as, but is not limited to, any type of disk including floppy disks, optical disks, CD-ROMs, and magnetic-optical disks, read-only memories (ROMs), random access memories (RAMs), EPROMs, EEPROMs, magnetic or optical cards, or any type of media suitable for storing electronic instructions, and each coupled to a computer system bus. Such a medium may also be referred to as a machine-accessible medium.
The algorithms and displays presented herein are not inherently related to any particular computer or other apparatus. Various general-purpose systems may be used with programs in accordance with the teachings herein, or it may prove convenient to construct more specialized apparatus to perform the required operations. The required structure for a variety of these systems will appear from the description below. In addition, the present invention is not described with reference to any particular programming language. It will be appreciated that a variety of programming languages may be used to implement the teachings of the invention as described herein.
Referring to
Based on the feature set of N-grams, processing logic defines a set of states (processing block 112). In some embodiments, there is one state for every string that can be a prefix of one or more terms in the keyword list. For example, if the feature set of N-grams include “aab”, “abb” and “aaabb,” where “a” and “b” represent two characters usable to compose different words in a non-delimited language, then there may be states corresponding to “a”, “aa”, “aab”, “ab”, “abb”, “aaa”, “aaab”, and “aaabb” (all possible prefixes of each N-gram in the feature set). Note that a single prefix may pertain to more than one keyword, and also note that whole keywords may be considered to be prefixes of themselves. The set of states may be defined by a simple loop over each keyword examining every prefix. In addition, there may be a “start” and an “end” states defined.
Processing logic then constructs a finite state machine (FSM) from the set of states defined (processing block 114). To construct the FSM, processing logic may connect the states to each other as follows. For every state, processing logic reaches the following state by adding an input symbol corresponding to a new prefix, or returns to the start of any new prefix. Continuing with the example above, for a state corresponding to “aa” and an input symbol “a,” the next state is the one corresponding to “aaa.” If the input symbol is “b” the next state is “aab”, or if the input symbol is “c,” processing logic returns to the “start” state (since “aac” is not a prefix of any keyword in the feature set). If the end of an input string is reached, processing logic returns to the “end” state of the FSM. In some embodiments, processing logic further construct a transition table for the FSM. To construct the transition table, processing logic may step through every state and every possible input symbol and determine whether the new string is a prefix with a corresponding state. If so, processing logic may transition from the old state to the new state over this input. If not, processing logic may add a transition back to the “start” state. One example of a FSM 130 constructed based on the above exemplary feature set of {“aab”, “abb”, “aaabb”} is shown in
Referring back to
Referring to
At processing block 126, processing logic checks whether the end of the string of bytes has been reached. If not, processing logic returns to processing block 122 to continue searching through the string of bytes. Otherwise, the process ends at processing block 128.
The above approach to search for N-grams in the string of bytes is more reliable and efficient than many conventional approaches for non-delimited languages because the above approach does not depend on any delimiters between words. As mentioned above, a non-delimited language may not provide any delimiters between words. Moreover, the above approach simultaneously searches for the N-grams in a single pass through the string of bytes. Thus, this approach remains efficient even for long strings. Such efficient string searching technique has many practical applications, two of which are discussed in details below to illustrate the concept. The first application is model generation and the second application is content classification.
In some embodiments, processing logic performs an efficient string search on a pre-classified document to search for a set of N-grams in the document (processing block 210). Some embodiments of the efficient string search have been described above. The pre-classified document may include a web page, an electronic mail message, etc. The content of the pre-classified document has been classified into a certain category (e.g., pornographic content, violent content, etc.). After performing the efficient string search on the document, processing logic generates a model based on the statistical information on the occurrences of the N-grams in the pre-classified document (processing block 212). The model may be made available to content filters (processing block 214). Using the model, the content filters may classify the content of an incoming string of bytes, and then, may determine if access to the content is allowed under some predetermined policies.
Referring to
While performing the search on the string, statistical information on the occurrences of a set of predetermined N-grams (e.g., the feature set of N-grams discussed above) in the string is collected. Using the statistical information collected and a model (such as the model generated according to
Based on the classification and some predetermined policies, processing logic determines if a user should be allowed to access the string of bytes (processing block 226). For instance, a school may have a policy barring access of pornographic material using school computers. Thus, processing logic may determine to deny access to the string by a user at the school if the content is classified as pornographic.
In some embodiments, processing logic causes a client machine to render the string of bytes if the user is allowed to access the content (processing block 228). For example, processing logic may forward the string of bytes to the client machine, which may execute a network access application (e.g., an Internet browser, an email engine, a document viewing application, etc.) to display the content. Otherwise, if the user is not allowed to access the content, processing logic blocks the string and causes the client machine to render an error message (processing block 229). For example, processing logic may send an error signal to the client machine, which may generate the error message and display the error message via the network access application and/or in a pop-up window.
In some embodiments, the server 310 receives a set of predetermined N-grams. The N-grams may include bytes representing various keywords in a non-delimited language. Note that the N-grams may be of different lengths. The keywords may be chosen based on their likelihood of occurrences in a particular type of content. For example, keywords, such as “kill,” “blood,” “gun,” etc., are more likely to appear in violent content, and thus, these keywords may be included in the set of N-grams. Based on the set of N-grams, the server 310 defines a set of states and constructs the FSM 312. Details of some embodiments of the definition of states based on the N-grams and the construction of the FSM 312 have been described above.
The server 310 further receives a string of bytes 301 representing a pre-selected document (e.g., a web page, an electronic mail message, etc.) in the non-delimited language. The document has been classified into a particular category (e.g., violent content, pornographic content, etc.). The string of bytes 301 is input to the FSM 312 within the server 310, which performs an efficient string search on the string of bytes 301 to search for the set of N-grams, if any. The FSM 312 simultaneously searches for the set of N-grams through the string of bytes 301 in a single pass. As the FSM 312 goes through the string of bytes 301, the FSM 312 may output the matching N-gram(s) found in the string of bytes 301. Details of some embodiments of the efficient string search performed by the FSM 312 have been discussed above.
The output from the FSM 312 is provided to the counting module 314, which counts the number of occurrences of each of the N-grams in the string of bytes 301. Then the counting module 314 sends the numbers of occurrences of the N-grams to the model generator 316. The model generator 316 uses the numbers of occurrences of the N-grams to generate a model for classifying content. The model may be stored in the model repository 318, which may be accessible by content filter clients across a network (e.g., an intranet, the Internet, etc.). Alternatively, the model may be transferred or downloaded to content filter clients, which store the model in storage devices (e.g., ROM, RAM, etc.) within the content filter clients. More details on classifying content using the model are discussed below.
In some embodiments, the content filtering client 320 may be implemented in a set-top box having components, such as, for example, a processor, network interface, one or more storage devices (e.g., RAM, ROM, flash memory, etc.), etc. Alternatively, the content filtering client 320 may be implemented on a proxy server (also referred to as a gateway server). A functional block diagram of the content filtering client 320 is illustrated in
Referring to
In some embodiments, the classifying engine 326 compares the statistical information collected against the model in order to classify the content represented by the string of bytes 331. Details of some embodiments of content classification have been discussed above. After classifying the content, the classifying engine 326 notifies the content filter 328 of the classification of the content. The content filter 328 then decides whether to allow the string 331 to pass through or to block the string 331 based on the classification.
For example, the client machine 330 may be a laptop computer provided by a company to its employee, and thus, the client machine 330 is not allowed to access pornographic materials under company policy. If the classifying engine 326 classifies the string of bytes 331 to be pornographic, then the content filter 328 may block the string of bytes 331 from the client machine 330. Further, the content filter 328 may take additional courses of action, such as generating an error message to inform the user of the client machine 330 that access to the content represented by the string of bytes 331 is denied, reporting the attempted access to a system administrator, recording information of the attempted access (e.g., time of access, user logged into the client machine 330, source of the string 331, etc.).
On the other hand, if the classifying engine 326 classifies the string of bytes 331 to be non-pornographic, the content filter 328 may allow access to the content and forward the string 331 to the client machine 330.
In another example, the classifying engine 326 classifies the string of bytes 331 to be spam and the user has previously requested to block all spam. Then the content filter 328 may block the string of bytes 331 from the client machine 330.
In some embodiments, the client machine 330 may render the content represented by the string of bytes 331 if the string of bytes 331 is forwarded from the content filtering client 320. For example, the client machine 330 may include a display device and an application (e.g., a browser, a document viewing application, etc.) executable on the client machine 330 may render the content via the display device. Otherwise, the client machine 330 may render the error message from the content filter 328 if access to the string 331 is denied because of the classification of the content.
The exemplary computer system 400 includes a processing device 402, a main memory 404 (e.g., read-only memory (ROM), flash memory, dynamic random access memory (DRAM) such as synchronous DRAM (SDRAM) or Rambus DRAM (RDRAM), etc.), a static memory 406 (e.g., flash memory, static random access memory (SRAM), etc.), and a data storage device 418, which communicate with each other via a bus 430.
Processing device 402 represents one or more general-purpose processing devices such as a microprocessor, a central processing unit, or the like. More particularly, the processing device may be complex instruction set computing (CISC) microprocessor, reduced instruction set computing (RISC) microprocessor, very long instruction word (VLIW) microprocessor, or processor implementing other instruction sets, or processors implementing a combination of instruction sets. Processing device 402 may also be one or more special-purpose processing devices such as an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), a digital signal processor (DSP), network processor, or the like. The processing device 402 is configured to execute the processing logic 426 for performing the operations and steps discussed herein.
The computer system 400 may further include a network interface device 408. The computer system 400 also may include a video display unit 410 (e.g., a liquid crystal display (LCD) or a cathode ray tube (CRT)), an alphanumeric input device 412 (e.g., a keyboard), a cursor control device 414 (e.g., a mouse), and a signal generation device 416 (e.g., a speaker).
The data storage device 418 may include a machine-accessible storage medium 430 (also known as a machine-readable storage medium) on which is stored one or more sets of instructions (e.g., software 422) embodying any one or more of the methodologies or functions described herein. The software 422 may also reside, completely or at least partially, within the main memory 404 and/or within the processing device 402 during execution thereof by the computer system 400, the main memory 404 and the processing device 402 also constituting machine-accessible storage media. The software 422 may further be transmitted or received over a network 420 via the network interface device 408.
While the machine-accessible storage medium 430 is shown in an exemplary embodiment to be a single medium, the term “machine-accessible storage medium” should be taken to include a single medium or multiple media (e.g., a centralized or distributed database, and/or associated caches and servers) that store the one or more sets of instructions. The term “machine-accessible storage medium” shall also be taken to include any medium that is capable of storing, encoding or carrying a set of instructions for execution by the machine and that cause the machine to perform any one or more of the methodologies of the present invention. The term “machine-accessible storage medium” shall accordingly be taken to include, but not be limited to, solid-state memories, optical and magnetic media, etc.
Thus, some embodiments of an efficient string search have been described. It is to be understood that the above description is intended to be illustrative, and not restrictive. Many other embodiments will be apparent to those of skill in the art upon reading and understanding the above description. The scope of the invention should, therefore, be determined with reference to the appended claims, along with the full scope of equivalents to which such claims are entitled.
The present application is a continuation and claims the priority benefit of U.S. patent application Ser. No. 15/403,047 filed Jan. 10, 2017, now U.S. Pat. No. 10,460,041, which is a continuation and claims the priority benefit of U.S. patent application Ser. No. 14/326,230 filed Jul. 8, 2014, now U.S. Pat. No. 9,542,387, which is a continuation and claims the priority benefit of U.S. patent application Ser. No. 13/973,859 filed Aug. 22, 2013, now U.S. Pat. No. 8,775,164, which is a continuation and claims the priority benefit of U.S. patent application Ser. No. 13/335,743 filed Dec. 22, 2011, now U.S. Pat. No. 8,577,669, which is a continuation and claims the priority benefit of U.S. patent application Ser. No. 11/881,556 filed Jul. 27, 2007, now U.S. Pat. No. 8,086,441, the disclosures of which are incorporated herein by reference.
Number | Date | Country | |
---|---|---|---|
Parent | 15403047 | Jan 2017 | US |
Child | 16667462 | US | |
Parent | 14326230 | Jul 2014 | US |
Child | 15403047 | US | |
Parent | 13973859 | Aug 2013 | US |
Child | 14326230 | US | |
Parent | 13335743 | Dec 2011 | US |
Child | 13973859 | US | |
Parent | 11881556 | Jul 2007 | US |
Child | 13335743 | US |