This project is read-only.
Text Service

The text API provides you with access to Freebase topic and schema descriptions.

Async example
TextServiceResponse result = await _textService.ReadAsync("/en/the_animal");
Sync example
var result = _textService.Read("/en/the_animal");

Selecting a Description
The API will behave differently depending on the type of object you pass in the path.
If you provide an id of an object that's not a content node, e.g. a topic like this:
http://www.freebase.com/inspect/en/kurt_vonnegut
the api will attempt to find the most recent description uploaded for that object and return it. This means that if the description changes, you will automatically get the new description the next time you perform the same call.

This is the most typical use case where you want to fetch the description of a Topic.
If you provide an id of a content node like this:
http://www.freebase.com/inspect/m/07t3z47 the api will always return the exact same content since content nodes are immutable.

Content Format

The format parameter allows you to control the kind of data (text, html) that you want to fetch from the service.
plain
For this format, you 'll get back text that's suitable for display in any application.
  • If the content is marked html then strip all tags and return it.
  • If the content is marked otherwise, return it as is
  • Otherwise returns an error (4xx).
Example:
var result = await _textService.ReadAsync("/music/album", TextFormat.Plain);
You should NOT inject plain formatted content on a web page without escaping it first.
html
This format will return html content that's suitable for display in a web app.
  • If the content is marked html then sanitize and return it.
  • If the content is marked text then wrap in tags and sanitize it.
  • Otherwise returns an error (4xx).
Example:
var result = await _textService.ReadAsync("/music/album", TextFormat.Html);
The html format will attempt to sanitize html content before returning it. This means that it's safe to output this content on a web page even if you don't escape it. The sanitization will leave a small subset of tags intact (such as p, br, b, ul, li) for some limited formatting of the text.
raw
This format will return he original content as-is.
Examples
Get a tiny description
var result = await _textService.ReadAsync("/music/album", TextFormat.Plain, maxLength: 50);

Last edited Jan 2, 2013 at 7:52 PM by F0rc0sigan, version 6

Comments

No comments yet.