Пример #1
0
//***********************************************************************
void SpecificEntitiesLoader::
init(Common::XMLConfigurationFiles::GroupConfigurationStructure& unitConfiguration,
          Manager* manager)
  
{
  LOGINIT("LP::SpecificEntities");

  m_language=manager->getInitializationParameters().media;
  
  AnalysisLoader::init(unitConfiguration,manager);
  try {
    m_graph=unitConfiguration.getParamsValueAtKey("graph");
  }
  catch (Common::XMLConfigurationFiles::NoSuchParam& ) {} // keep default value

  try {
    // may need to initialize a modex, to know about the entities in external file
    deque<string> modex=unitConfiguration.getListsValueAtKey("modex");
    for (deque<string>::const_iterator it=modex.begin(),it_end=modex.end();it!=it_end;it++) {
      LDEBUG << "loader: initialize modex " << *it;
      string filename=Common::MediaticData::MediaticData::single().getConfigPath()+"/"+*it;
      Common::XMLConfigurationFiles::XMLConfigurationFileParser parser(filename);
      Common::MediaticData::MediaticData::changeable().initEntityTypes(parser);
    }
  }
  catch (Common::XMLConfigurationFiles::NoSuchList& ) {
    LWARN << "loader: no modex specified in parameter: types in file loaded may not be known";
  }

  //  Create a SAX parser object. 
  m_parser = new QXmlSimpleReader();
}
Пример #2
0
void SimpleEventBuilder::init(Common::XMLConfigurationFiles::GroupConfigurationStructure& unitConfiguration,
                              Manager* manager)

{

  EVENTANALYZERLOGINIT;
  MediaId language=manager->getInitializationParameters().media;
  try
  {
    m_segmData=unitConfiguration.getParamsValueAtKey("segmentationData");
  }
  catch (Common::XMLConfigurationFiles::NoSuchParam& ) 
  {
    LERROR << "No segmentationData specified in "<<unitConfiguration.getName()
           <<" configuration group for language " << language << LENDL;
  }
  
  try
  {
    m_segmentType=unitConfiguration.getParamsValueAtKey("segmentType");
  }
  catch (Common::XMLConfigurationFiles::NoSuchParam& ) 
  {
    LERROR << "No segmentType specified in "<<unitConfiguration.getName()
           <<" configuration group for language " << language << LENDL;
  }

  try
  {
    deque<string> entities = unitConfiguration.getListsValueAtKey("entities");
    for(deque<string>::iterator it=entities.begin(),it_end=entities.end();it!=it_end;it++)
    {
      try {
        m_entities.push_back(Common::MediaticData::MediaticData::single().getEntityType(Common::Misc::utf8stdstring2limastring(*it)));
      }
      catch (LimaException& ) {
        LERROR << "Error: unknown entity type '"<< *it << "' : ignored" << LENDL;
      }
    }
  }
  catch (Common::XMLConfigurationFiles::NoSuchParam& ) 
  {
    LERROR << "No entities specified in "<<unitConfiguration.getName()
           <<" configuration group for language " << language << LENDL;
  }
  
}
Пример #3
0
void DotGraphWriter::init(
  Common::XMLConfigurationFiles::GroupConfigurationStructure& unitConfiguration,
  Manager* manager)

{
  /** @addtogroup ProcessUnitConfiguration
   * - <b>&lt;group name="..." class="DotGraphWriter"&gt;</b>
   *    -  trigramMatrix : TrigramMatrix resource
   *    -  bigramMatrix : BigramMatrix resource
   *    -  outputSuffix : suffix for output file name. Default : '.graph.dot'
   */
  PTLOGINIT;
  m_language=manager->getInitializationParameters().media;
  try {
    string trigrams=unitConfiguration.getParamsValueAtKey("trigramMatrix");
    AbstractResource* res=LinguisticResources::single().getResource(m_language,trigrams);
    m_trigramMatrix=static_cast<PosTagger::TrigramMatrix*>(res);
  } catch (NoSuchParam& ) {
    LERROR << "No param 'trigramMatrix' in DotGraphWriter group for language " << (int)m_language;
    throw InvalidConfiguration();
  }
  try {
    string bigrams=unitConfiguration.getParamsValueAtKey("bigramMatrix");
    AbstractResource* res=LinguisticResources::single().getResource(m_language,bigrams);
    m_bigramMatrix=static_cast<PosTagger::BigramMatrix*>(res);
  } catch (NoSuchParam& ) {
    LWARN << "No param 'bigramMatrix' in DotGraphWriter group for language " << (int)m_language;
    throw InvalidConfiguration();
  }
  try
  {
    m_outputSuffix=unitConfiguration.getParamsValueAtKey("outputSuffix");
  }
  catch (NoSuchParam& )
  {
    LWARN << "No param 'outputSuffix' in DotGraphWriter group for language " << (int)m_language;
    LWARN << "use .graph.dot";
    m_outputSuffix=string(".graph.dot");
  }
  try
  {
    m_graphId=unitConfiguration.getParamsValueAtKey("graph");
  }
  catch (NoSuchParam& )
  {
    LWARN << "No param 'graph' in "<<unitConfiguration.getName() << " group for language " << (int)m_language;
    LWARN << "use PosGraph";
    m_graphId=string("PosGraph");
  }
  try
  {
    m_vertexDisplay=unitConfiguration.getListsValueAtKey("vertexDisplay");
  }
  catch (NoSuchList& )
  {
    // empty display
  }
  try 
  {
    m_graphDotOptions = unitConfiguration.getMapAtKey("graphDotOptions");
  }
  catch (NoSuchMap& ) {}
  
  try 
  {
    m_nodeDotOptions = unitConfiguration.getMapAtKey("nodeDotOptions");
  }
  catch (NoSuchMap& ) {}
  
  try 
  {
    m_edgeDotOptions = unitConfiguration.getMapAtKey("edgeDotOptions");
  }
  catch (NoSuchMap& ) {}
}