Tailor Made Text Mining

Customization and domain adaptation is often crucial to the development of accurate text analytics applications, but building domain specific logic directly into an application often leads to complex and unmaintainable code.

TextRazor allows both developers and domain experts to rapidly add problem specific logic, integrating seamlessly with the TextRazor API and the rest of your application.

Traditional rule based approaches to text mining are often brittle and over complex. TextRazor is different. Our statistical machine learning algorithms create a powerful abstraction over which to add your custom logic, making even simple rules robust to changes in sentence structure or language style.

Named entities, topic tags, synonyms, grammatical syntax - TextRazor's extensive set of algorithms can all be combined and filtered with your own keywords and logic into your own customized system.


TextRazor uses Prolog as its rules engine. Our system was designed to make common patterns easy to build without technical expertise, while keeping the full power and expressiveness of the Prolog language for more complex tasks. We've extended the standard Prolog interpreter with an extensive library of helper rules.

  • Get started writing powerful extraction rules without any programming knowledge.
  • Intuitive and expressive syntax for pattern matching.
  • Separate text extraction logic from your application, making maintenance and enhancement easy. Allow domain experts complete control over the text analysis aspect of your system.
  • Prune and filter results before they are returned to you, resulting in significant savings in bandwidth and latency.
  • Open source core engine, industry standard rules language.
Custom rules run on our infrastructure in a managed environment, automatically scaled up and down with your requests.


Integration with the rest of your project is easy. TextRazor hides all the complex interfaces with the Prolog interpreter, and intelligently binds the links between your rules and other words, entities etc, minimizing boilerplate code.

  • TextRazor processes your document, extracting words, sentences, entities, synonyms and other semantic metadata as required by your rules.
  • These are exposed as Prolog facts.
  • Your rules are parsed, looking for those named in the "extractors" list you've requested. The names of any arguments to the rules are derived automatically where possible.
  • These rules are applied to the facts extracted from your document.
  • Every match is collected, the type of the parameter is automatically deduced.

Sample Applications


TextRazor's statistical topic classifier and entity extractor provide a powerful general purpose tagging solution for search, monitoring, semantic tagging and content creation applications. You may, however, have an existing category ontology or a specific set of topics you're interested in identifying.

In the following rules we're aiming to classify web articles as being about soccer or olympic soccer. You'll see how we make the most of multiple TextRazor annotations to help make a decision about whether this document is about football or not. You'll also see how simple rules can be easily combined into concise but powerful extraction algorithms.

% Any document with an explicit 'Football' tag is about_football.
about_football :-
	topic('Association football').

% Or a document that simply mentions the word 'soccer'.
about_football :-

% Or a document that has been given the 'Leisure' category, and mentions some general
% ball game words, but which doesn't mention other ball games we're not interested in.
about_football :-
		(lemma('kick'), lemma('ball')),
	not lemma('quarterback'),
	not lemma('rugby').

% Or any document that explicitly mentions a soccer player (any will do!)
about_football :-
	entity_freebase_type(EntityId, '/​people/​person/​soccer/​football_player/​').

% Any document that has been tagged as about_football, and which also mentions
% the olympics, is about_olympic_football.
about_olympic_football :-
		sequence('London', '2012'),

Custom Entities/Product Names

If you're interested in extracting facts about a specific company or their products our general purpose knowledgebase may not have enough information to disambiguate them automatically. We can add product names, codes and disambiguating information to TextRazor with custom rules. Here we're adding the 'Product' paramater to our rule, which is matched in the rule body and returned to your application. Note that Prolog treats all words starting with a capital letter as a variable, whenever the rule you have requested matches a variable, all combinations are returned in the response.

% Match a product of interest as any proper noun followed by the word 'Meal',
% contained in a document that we think is about mcdonalds.
interesting_product(Product) :-
	sequence(part_of_speech(Product, 'NNP'), 'Meal'),

about_mcdonalds :-

about_mcdonalds :-
	sequence('Big', 'Mac').

about_mcdonalds :-



Error and warning information from TextRazor and the Prolog interpreter are returned to the caller in the 'customAnnotationOutput' field of the main response.

This field also contains any printed output from your program. To add to the output you can call write(+ToWrite), from your program. nl. writes a newline.


TextRazor intelligently computes the processing dependencies of your program, they do not need to be explicitly specified as extractors if you don't need them. For example, if your script references named entities TextRazor will automatically run its entity recognition logic without you needing to manually add the "entities" extractor to your request.

Bindings and the client libraries

In many applications we're interested in identifying more than whether a certain rule matched or not. TextRazor allows to return additional context from your rules though their arguments. In the above example interesting_product has a "Product" argument, which is matched in the rule. When this rule is triggered in your document, the matching parameter value is returned to your application. This has a number of uses, for classification projects you can return multiple tags in the same rule. For extraction projects you can precisely identify words, entities or other annotations of interest.

The name of the paramater is returned in the response, where an explicit name can't be automatically derived, the paramater is named 'Anonymous'. All unique sets of parameters that match your rules will be returned to you in the TextRazor response. TextRazor automatically identifies the type of the parameter and returns the equivalent type in the response.

Where a TextRazor internal ID is matched (for example a Word ID or Entity ID), a link is generated to the relevant annotation in the response.

Lists in the output are automatically flattened to a single list, so for example president([['Barack'], ['Obama']])., will be interpreted the same as president(['Barack', 'Obama']).. This makes it easy to combine the output of several rules without worrying about the format of the output.


In order to ensure the scalability of your requests, and to preserve the integrity of the TextRazor backend, we place limits on certain functionality from your rules.

  • No filesystem access beyond the YAP standard library.
  • 500mb memory cap per request.
  • 3 second request timeout per request.
  • Limited access to system calls and machine hardware.
We find that the vast majority of applications fit within this system, but if you have more specific requirements please get in touch at support@textrazor.com.


TextRazor's full set of extracted metadata instances is exposed through a range of Prolog predicates and built in helper rules. Each instance has an ID, which can be used to join with others. When an instance ID is returned in a parameter it's returned to the caller and linked to the relevant type in the client API.

For convenience each rule has two forms, linking the fact to its ID, and a convenience method that just checks for the existence of the fact without matching the ID.

TextRazor runs standard ISO Prolog using the YAP interpreter. This makes the whole YAP standard library available for use in your rules where needed, read more here.


Must match at least one of Expression. This is strictly equivalent to the prolog (ExpressionA ; ExpressionB; ExpressionC; ...). Note that any rules with the same name are implicitly treated as an 'or', it may be cleaner to separate complex or statements into multiple rules.


Must match all of Expression. This is strictly equivalent to the Prolog (ExpressionA, ExpressionB, ExpressionC,...). Multiple terms in the same rule separated by a ',' are implicitly treated as an 'and'.


Matches a single raw token string.


Matches a token's Part of Speech part_of_speech_overlap matches other TextRazor annotations that have this PartOfSpeech.


Matches a token's position in the document. position_overlap matches other TextRazor annotations' position.


Matches a token's stemmed form. stem_overlap matches the stems used in words that make up other TextRazor annotations.


Matches a token's morphological root. lemma_overlap matches the lemmas used in words that make up other TextRazor annotations.


Matches a token's parent ID in the dependency tree. Optionally matches the grammatical relation to the parent. parent_overlap matches the parents of words used in other TextRazor annotations.


Matches a sequence of tokens in their order in the document. Useful for matching specific product names, people etc. Paramaters can be any of the token rules above, with or without the matching Token ID.

% Matches the literal 'Barack Hussein Obama'.  Doesn't return a link to the matched text, but useful
% in classification problems.
president :-
	sequence('Barack', 'Hussein', 'Obama').

president :-
	sequence(lemma('president'), 'Obama').

% Matches a likely president name, matching two proper nouns occurring after the lemma 'president', and returning
% links to the matching tokens.
president(PresidentName) :-
	sequence(lemma('president'), part_of_speech(PresidentFirstName, 'NNP'), part_of_speech(PresidentSurname, 'NNP')),
	PresidentName = [PresidentFirstName, PresidentSurname].

% Matches all part of speech tags that occur after the lemma 'president', eg 'NNP'.
president_tag(Tag) :-
	sequence(lemma('president'), part_of_speech(Tag)).


Matches a sentence ID with the list of words that are part of it. Optionally matches one of the other TextRazor annotations that are from this sentence.


Matches a sentence ID with its position in the processed document.


Matches a sentence ID with its position in the processed document.


Matches a relation with a list of words that make up its predicate.


Matches a relation with a list of words that make up its predicate, and various combinations of params and param types where needed. overlap_* rules allow more flexible matching of relations between different annotation types.


Matches a relation with one of its paramaters. Matches the type of the param (SUBJECT or OBJECT), and a list of Word IDs that make up the parameter. relation_param_overlap matches params containing words that make up other TextRazor annotations.


Matches a property with a list of words that make up the target and source words. property_overlap matches properties containing words that make up other TextRazor annotations.


Matches a noun phrase with a list of words. noun_phrase_overlap matches noun phrases that contain words used in other annotations.


Matches a contextual entailment with a source and entailed word. entailment_overlap matches entailements who's source words are linked to other TextRazor annotations.


Matches a contextual entailment with its prior score.


Matches a contextual entailment with its contextual score.


Matches a contextual entailment with its combined score.


Matches a topic tag, optionally with its ID.


Matches a topic's relevance score.

Matches a topic's wikipedia link (if available).


Matches a coarse topic tag, optionally with its ID.


Matches a coarse topic's relevance score.

Matches a coarse_topic's wikipedia link (if available).


Matches an entity ID label, optionally with its ID.


Matches an entity with its tokens. entity_tokens_overlap matches entities who's tokens are used in other annotations.


Matches an entity's dbpedia type, optionally with its ID


Matches an entity's freebase type, optionally with its ID


Matches an entity's confidence score.

Matches an entity's wikipedia link, if it has one


Matches the raw text string that identified this entity.


Matches the disambiguated freebase id for this entity.


Matches the relevance of this entity to the processed page.


Matches the English language Wikipedia article title for this entity.