|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectrita.RiObject
rita.support.MsNGramClient
public class MsNGramClient
A REST client for the Microsoft Web N-Gram Service.
Arguments:
'apiKey' - your Microsoft-supplied authorization key for the service
'model' - the specific model you wish to use. If the argument is not provided a default model is used (currently 'bing-body/jun09/3').
'serviceURI' - can be left to the default unless the service location has changed.
| Field Summary |
|---|
| Fields inherited from interface processing.core.PConstants |
|---|
A, AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD, QUAD_STRIP, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, SUBTRACT, SW, TAB, TARGA, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z |
| Constructor Summary | |
|---|---|
MsNGramClient()
|
|
MsNGramClient(processing.core.PApplet pApplet)
|
|
| Method Summary | |
|---|---|
java.lang.String[] |
generate(java.lang.String phrase)
|
java.lang.String[] |
generate(java.lang.String phrase,
int maxResultSize)
Given a phrase (a sequence of space-separated words), find the words that are the most likely to follow the phrase. |
java.lang.String[] |
generate(java.lang.String phrase,
java.lang.String cookie)
|
java.lang.String |
generateWords(java.lang.String startOfPhrase,
int numWords)
|
java.lang.String |
getApiKey()
|
java.lang.String[] |
getAvailableModels()
Get a list of currently supported N-Gram models |
float |
getBackoffValue()
The backoff value is made available in the event that you wish to call generate() with a shortened phraseContext, so as to make the returned values compare-able. |
float |
getConditionalProbability(java.lang.String phrase)
Finds the conditional probability of the words in a phrase (a sequence of space-separated words) using the current model. |
java.lang.String |
getModel()
|
float |
getProbability(java.lang.String phrase)
Finds the joint probability of the words in a phrase (a sequence of space-separated words), in the current model. |
java.lang.String |
getServiceUri()
// doesn't seem to work at moment Returns the generated cookie (an opaque placeholder to facilitate subsequent calls) from a the last call to generate(). |
java.lang.String |
getUserAgent()
|
static void |
main(java.lang.String[] args)
|
java.lang.String |
nextWord(java.lang.String phrase)
|
void |
setApiKey(java.lang.String apiKey)
|
void |
setModel(java.lang.String model)
Should be of the form returned by #getModels() |
void |
setServiceUri(java.lang.String serviceUri)
|
void |
setUserAgent(java.lang.String userAgent)
|
| Methods inherited from class rita.RiObject |
|---|
dispose, getId, getPApplet, nextId |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MsNGramClient()
public MsNGramClient(processing.core.PApplet pApplet)
| Method Detail |
|---|
public java.lang.String[] generate(java.lang.String phrase,
int maxResultSize)
The returned String[] contains words in decreasing probability order.
Note:
For a model of order N, if phraseContext contains more than N-1 words, the
excess words at the beginning of phrase are ignored.
public java.lang.String nextWord(java.lang.String phrase)
public java.lang.String[] generate(java.lang.String phrase)
public java.lang.String[] generate(java.lang.String phrase,
java.lang.String cookie)
public float getProbability(java.lang.String phrase)
The base-10 log of the joint probability of the word sequence.
For instance, if you have the following word sequence:
w1, w2, …, wn
The return value is the log of the following:
P(w1) P(w2|w1) … P(wn | wn-m+1…wn-1)
Notes:
The token represents the beginning of a phrase.
Punctuation is generally ignored.
public float getConditionalProbability(java.lang.String phrase)
The base-10 log of the conditional probability of the last word in a sequence, in a given context.
For instance, for the following word sequence (for an ngram-model of size m):
w1, w2, …, wn
The return value is the log of the following:
P(wn | wn-m+1…wn-1)
Notes:
If n=0, the return value is Float.NaN.
If n>m, the words at the beginning of phrase are ignored.
public java.lang.String[] getAvailableModels()
public java.lang.String getApiKey()
public void setApiKey(java.lang.String apiKey)
public java.lang.String getUserAgent()
public void setUserAgent(java.lang.String userAgent)
public java.lang.String getServiceUri()
public void setServiceUri(java.lang.String serviceUri)
public java.lang.String getModel()
public void setModel(java.lang.String model)
public float getBackoffValue()
Before the first call to generate(), getBackoffValue() will return an empty string.
public java.lang.String generateWords(java.lang.String startOfPhrase,
int numWords)
public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||