FreeLing  4.0
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
freeling::csr_kb Class Reference

class kb: Store information associated to a knowledge base More...

#include <csr_kb.h>

Collaboration diagram for freeling::csr_kb:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 csr_kb (const std::wstring &, int, double, double)
 create from file + pagerank params
size_t get_vertex (const std::wstring &) const
 get vertex index given its id (or VERTEX_NOT_FOUND if not there)
void pagerank (std::vector< double > &) const
 use graph to rank given weigthed vertices. Ranks are returned in the same vector
size_t size () const
 get number of vertices of the graph

Static Public Attributes

static const size_t VERTEX_NOT_FOUND = -1
 const value for failed id searches

Private Member Functions

size_t add_vertex (const std::wstring &)
 helper to load grap
void fill_CSR_tables (size_t, std::list< std::pair< size_t, size_t > > &)
 helper to load grap

Private Attributes

int MaxIterations
 pagerank: maximum number of iterations to perform
double Threshold
 pagerank: threshold to detect that changes are residual
double Damping
 pagerank: Damping factor
std::map< std::wstring, size_t > vertex_index
 index to access vertices by name
std::vector< double > out_coef
 output coefficent for each vertex (1/num_edges)
std::vector< size_t > first_edge
 CSR: position in edge table where first edge for this vertex is found.
std::vector< size_t > num_edges
 CSR: num of edges for this vertex.
std::vector< size_t > edges
 CSR: edge table, containing edge targets.
size_t num_vertices
 graph size

Detailed Description

class kb: Store information associated to a knowledge base


Constructor & Destructor Documentation

freeling::csr_kb::csr_kb ( const std::wstring &  kbFile,
int  nit,
double  thr,
double  damp 
)

create from file + pagerank params

Constructor: create kb, loading data from given file.

---------------------------------------------------- Class KB functions

References add_vertex(), ERROR_CRASH, fill_CSR_tables(), num_vertices, and freeling::util::open_utf8_file().


Member Function Documentation

size_t freeling::csr_kb::add_vertex ( const std::wstring &  ) [private]

helper to load grap

Auxiliary for constructor: add a synset to vertices list, and return position in vector where it is added (or where found if already there)

References num_vertices, and vertex_index.

Referenced by csr_kb().

void freeling::csr_kb::fill_CSR_tables ( size_t  ,
std::list< std::pair< size_t, size_t > > &   
) [private]

helper to load grap

Fill up graph CSR representation from given list of edges.

References edges, first_edge, num_edges, and out_coef.

Referenced by csr_kb().

size_t freeling::csr_kb::get_vertex ( const std::wstring &  vid) const

get vertex index given its id (or VERTEX_NOT_FOUND if not there)

References vertex_index, and VERTEX_NOT_FOUND.

Referenced by freeling::ukb::extract_ranks_to_sentences(), and freeling::ukb::init_synset_vector().

void freeling::csr_kb::pagerank ( std::vector< double > &  ) const

use graph to rank given weigthed vertices. Ranks are returned in the same vector

Use graph to rank given weigthed vertices.

Ranks are returned in the same map.

References Damping, edges, first_edge, num_edges, num_vertices, out_coef, and Threshold.

Referenced by freeling::ukb::analyze().

size_t freeling::csr_kb::size ( ) const

get number of vertices of the graph

Size of the graph (number of vertices)

References num_vertices.

Referenced by freeling::ukb::init_synset_vector().


Member Data Documentation

double freeling::csr_kb::Damping [private]

pagerank: Damping factor

Referenced by pagerank().

std::vector<size_t> freeling::csr_kb::edges [private]

CSR: edge table, containing edge targets.

Referenced by fill_CSR_tables(), and pagerank().

std::vector<size_t> freeling::csr_kb::first_edge [private]

CSR: position in edge table where first edge for this vertex is found.

Referenced by fill_CSR_tables(), and pagerank().

pagerank: maximum number of iterations to perform

std::vector<size_t> freeling::csr_kb::num_edges [private]

CSR: num of edges for this vertex.

Referenced by fill_CSR_tables(), and pagerank().

graph size

Referenced by add_vertex(), csr_kb(), pagerank(), and size().

std::vector<double> freeling::csr_kb::out_coef [private]

output coefficent for each vertex (1/num_edges)

Referenced by fill_CSR_tables(), and pagerank().

double freeling::csr_kb::Threshold [private]

pagerank: threshold to detect that changes are residual

Referenced by pagerank().

std::map<std::wstring,size_t> freeling::csr_kb::vertex_index [private]

index to access vertices by name

Referenced by add_vertex(), and get_vertex().

const size_t freeling::csr_kb::VERTEX_NOT_FOUND = -1 [static]

const value for failed id searches

Auxiliar const value to be returned when an non-existing vertex id is requested.

Referenced by freeling::ukb::extract_ranks_to_sentences(), get_vertex(), and freeling::ukb::init_synset_vector().


The documentation for this class was generated from the following files: