|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--agentland.device.intelliCD.BrainMatrix
The BrainMatrix talks to the backend database, and handles updates and other information that the matrix uses to keep song associations and reactions up to date. Effectively, it insulates the QuickBrain from the grungy database details. To efficiently process subsets of songs, BrainMatrix will set up a `temporary' table in the database and use it to make sure that any selected song is in the subset of songs we care about. (I use `temporary' in quotes, because this table will tend to stick around for a while unless the BrainMatrix exits cleanly.) the brain matrix looks like this: songs other song1 other song2 other song3 Pos | Neg Pos | Neg Pos | Neg #1 val val vA vB #2 ... vA would be weight for going from #1 to other2 if #1 liked. the history matrix looks like this: song/reaction other song1 other song2 ... #1 / pos v1 v2 where #1 is most recent, #2 is just before. v1 is #1/react to 1 -> other1
QuickBrain
,
ManagedConnection
,
Song
Field Summary | |
static String |
NEG
|
static String |
POS
|
Constructor Summary | |
BrainMatrix(String name,
ManagedConnection cnxn,
int n)
Creates a new BrainMatrix, with a name (used for creating a temporary table in the database, a SQL database connection, and a size for the matrix. |
Method Summary | |
void |
addHistory(Song s,
String colName)
Add a song to the history with a given reaction. |
void |
addNegativeHistory(Song s)
Adds a negative history for a song. |
void |
addNeutralHistory(Song s)
Adds a neutral history for a song. |
void |
addPositiveHistory(Song s)
Adds a positive history for a song. |
String |
colName(int n)
Returns the reaction column name in row n of the matrix. |
String |
convertReaction(double reaction)
Gets a reaction column string, given a reaction code from the QuickBrain. |
void |
finalize()
|
List |
getBestNeighborhood(Song s,
String reacCol,
int len)
|
List |
getLikedSongs(String reacCol,
byte min_val,
int len)
Get a vector of songs that people tend to like. |
byte |
getLocation(int n,
Song s)
Fetches the reaction score for the matrix element in row #n and col #s. |
byte |
getLocation(Song row,
String colName,
Song col)
Gets the value for the match of two songs on the given parameter from the database. |
List |
getNeighborhood(Song s)
|
List |
getNeighborhood(Song s,
String reacCol)
|
List |
getNeighborhood(Song s,
String reacCol,
byte val)
|
List |
getNeighborhood(Song s,
String reacCol,
byte val,
boolean greater,
int len)
Fetches a neighborhood of songs. |
List |
getUnderstoodSongs(int len)
Gets the list of songs that have the most information stored about them, in order. |
void |
preloadSong(Song s)
Notifies the matrix that a song is being played. |
void |
registerSongs(List songs)
Registers the list of songs that the matrix cares about. |
int |
rows()
Gets the number of songs currently recorded in play history. |
void |
setLocation(int n,
Song s,
byte b)
Sets the matrix element to the given value. |
void |
setLocation(Song row,
String colName,
Song col,
byte b)
Sets the value for the match of two songs on the given parameter from the database. |
Song |
song(int n)
Returns the song in row n of the matrix. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static String POS
public static String NEG
Constructor Detail |
public BrainMatrix(String name, ManagedConnection cnxn, int n)
n
- number of rows brain matrix will store.Method Detail |
public void registerSongs(List songs)
public void preloadSong(Song s)
public void addHistory(Song s, String colName) throws Exception
public void addPositiveHistory(Song s) throws Exception
addHistory(Song, String)
public void addNeutralHistory(Song s) throws Exception
addHistory(Song, String)
public void addNegativeHistory(Song s) throws Exception
addHistory(Song, String)
public byte getLocation(int n, Song s)
n
- is the row number for the history 'matrix's
- is the Song to be matched.public void setLocation(int n, Song s, byte b)
n
- is the row number for the history 'matrix's
- is the id for the song to match with.b
- is the value to set.public byte getLocation(Song row, String colName, Song col)
getLocation(int, Song)
public void setLocation(Song row, String colName, Song col, byte b)
setLocation(int, Song, byte)
public String convertReaction(double reaction)
public List getNeighborhood(Song s)
public List getNeighborhood(Song s, String reacCol)
public List getNeighborhood(Song s, String reacCol, byte val)
public List getBestNeighborhood(Song s, String reacCol, int len)
public List getNeighborhood(Song s, String reacCol, byte val, boolean greater, int len)
s
- is the search song.reacCol
- is the name of the column to use for reaction strengthval
- is a target reaction value to use for limiting the
output.greater
- says whether we should return songs that are
greater than val (true means return songs that have a value
greater than the given target value, false means return songs
with a value less than the given target value.len
- is a limit to the list size.public List getLikedSongs(String reacCol, byte min_val, int len)
reacCol
- is the reaction typemin_val
- is the minimum reaction strength allowed in the output.len
- is the limit to the number of songs returned.public List getUnderstoodSongs(int len)
len
- The number of songs to return (maximum)public int rows()
public Song song(int n)
public String colName(int n)
public void finalize()
finalize
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |