Beispiel #1
0
bool IniParser::WriteToFile(const string& filename)
{
 string content;
 if(WriteToString(content))
    return FilePutContent(filename,content);
 return false;
}
Beispiel #2
0
bool CRusSemStructure::CheckCollocItemGramFet(long CollocNo, long ItemNo, long NodeNo)
{
	assert (NodeNo != -1); 

	CCollocItem& I = m_pData->m_RusCollocs[CollocNo].Items[ItemNo];
	if (    !I.RelOperator1.empty()
		&&  !m_Nodes[NodeNo].HasRelOperator(I.RelOperator1)
		)
		return false;

	if (    !I.RelOperator2.empty()
		&&  !m_Nodes[NodeNo].HasRelOperator(I.RelOperator2)
		)
		return false;

	// проверка частицы "не"
	// факультативно частицу "не" может принимать только первое слово словосочетания
	if (    ( (I.RelOperator1 == "НЕ") || (I.RelOperator2 == "НЕ") )
		&&  m_Nodes[NodeNo].HasRelOperator("НЕ")
		&&  (ItemNo > 0)
		)
		return false;

	// проверка предлога
	vector<CRossInterp> Preps;
	m_pData->GetPrepsFromArticle (GetRoss(CollocRoss), m_pData->m_RusCollocs[CollocNo].UnitNo, 0, ItemNo+1, Preps);
	long l=0;
	for (; l <Preps.size(); l++)
		if (m_Nodes[NodeNo].HasThePrep(Preps[l].m_UnitNo)) 
			break;
	if ( (Preps.size() > 0) && (l == Preps.size())) 
		return false;


	// проверка граммем
	CSemPattern P;
	P.InitSemPattern(GetRossHolder(CollocRoss), m_pData->m_RusCollocs[CollocNo].UnitNo, 0, ItemNo+1);
	P.LoadGramFromDict();
	if (P.m_GramCorteges.empty())  return true;

	long GramCortegeNo=0;
	for (; GramCortegeNo < P.m_GramCorteges.size(); GramCortegeNo++)
	{
		TCortege& C = P.m_GramCorteges[GramCortegeNo];
		DWORD Pose;
		QWORD Grammems;
		string GramFet = WriteToString(GetRoss(CollocRoss), (char*)(GetRoss(CollocRoss)->Fields[C.m_FieldNo].m_Signats[C.GetSignatNo()].sFrmt), C);
		Trim(GramFet);
		m_pData->GetCustomGrammems(GramFet, Grammems, Pose);
		if (   m_Nodes[NodeNo].HasGrammems (Grammems) 
			&& ((m_Nodes[NodeNo].m_Words[m_Nodes[NodeNo].m_MainWordNo].m_Poses & Pose) >  0)
		 )
		 break;

	};


	return  GramCortegeNo < P.m_GramCorteges.size();
};
Beispiel #3
0
bool  CRusSemStructure::ReadAuxiliaryArticles()
{
   if ( GetRoss(Ross) == NULL) return false;

   WORD UnitNo = GetRossHolder(Ross)->LocateUnit("_коэф",1);
   if (UnitNo == ErrUnitNo) return false;

   if (!GetRoss(Ross)->IsEmptyArticle(UnitNo))
	  for (size_t i = GetRoss(Ross)->GetUnitStartPos(UnitNo); i<= GetRoss(Ross)->GetUnitEndPos(UnitNo); i++)
	  {
		TCortege C = GetCortege(GetRoss(Ross), i);
		string S = WriteToString(GetRoss(Ross), (char*)(GetRoss(Ross)->Fields[C.m_FieldNo].m_Signats[C.GetSignatNo()].sFrmt), C);
		Trim(S);
		if (!m_SemCoefs.ReadOneCoef (S.c_str()))
		  {
			  ErrorMessage (string(S) + string(" is not recognized as a semantic coefficient"));
		  };
	  };

   UnitNo = GetRossHolder(Ross)->LocateUnit("_weak_syn_rel",1);
   if (UnitNo == ErrUnitNo) return false;
   m_WeakSynRels.clear();

   if (!GetRoss(Ross)->IsEmptyArticle(UnitNo))
	  for (size_t i = GetRoss(Ross)->GetUnitStartPos(UnitNo); i<= GetRoss(Ross)->GetUnitEndPos(UnitNo); i++)
	  {
   		long ItemNo = GetCortege(GetRoss(Ross),i).m_DomItemNos[0];
		if (ItemNo != -1)
		{
          string OneSynRel =  GetRossHolder(Ross)->GetDomItemStrInner(ItemNo);
		  m_WeakSynRels.push_back(OneSynRel);
		};
	  };

   sort(m_WeakSynRels.begin(), m_WeakSynRels.end());

   return true;

};
Beispiel #4
0
void Representation::toString(prim::String& destination)
{
  destination.Clear();
  WriteToString(destination);
}
Beispiel #5
0
bool CSemanticsHolder::ReadAbstractArticles(DictTypeEnum type)
{
	vector<CAbstractArticle> Articles;
	long UnitNo = GetRoss(type)->UnitsLowerBound("+");
	long UnitsCount = GetRoss(type)->GetUnitsSize();
	while  (    (UnitNo < UnitsCount) 
		  &&  (UnitNo != ErrUnitNo)
		)
	{
	  CAbstractArticle A;
	  A.m_UnitStr = GetRoss(type)->GetEntryStr(UnitNo);
  
	  if ( (unsigned char)A.m_UnitStr[0] !=  '+') break;

	  if (!GetRoss(type)->IsEmptyArticle(UnitNo))
	  {
		 for (size_t i = GetRoss(type)->GetUnitStartPos(UnitNo); i<= GetRoss(type)->GetUnitEndPos(UnitNo); i++)
		 {
			TCortege C = GetCortege(GetRoss(type), i);
			string FieldStr = (const char*)GetRoss(type)->Fields[C.m_FieldNo].FieldStr;
			if  ( FieldStr == "TYP" ) 
			{
				string S = WriteToString(GetRoss(type), (char*)(GetRoss(type)->Fields[C.m_FieldNo].m_Signats[C.GetSignatNo()].sFrmt), C);
				Trim(S);
				if (S == "ДОБАВЛЕНИЕ")
					A.m_Type = atAdditionArticle;
				else
				   if (S == "ЗАГЛУШКА")
					 A.m_Type = atArticlePlug;
				   else
					   A.m_Type = atEmptyType;

			}

			if  ( FieldStr == "VAL" ) 
  			  A.m_Vals.push_back(CValency (C, GetRossHolder(type)->MainWordVarNo, GetRossHolder(type)));
			
			if (C.IsEqual())
			{
				if  (FieldStr == "GF" ) 
				{
				  CGramInfo I;
				  string GramFet = WriteToString(GetRoss(type), (char*)(GetRoss(type)->Fields[C.m_FieldNo].m_Signats[C.GetSignatNo()].sFrmt), C);
				  GetCustomGrammems(GramFet, I.m_Grammems, I.m_PartOfSpeechMask);
				  A.m_GramInfos.push_back(I);
				};
				
				if  ( FieldStr == "CLAUSE") 
				{
					string S = WriteToString(GetRoss(type), (char*)(GetRoss(type)->Fields[C.m_FieldNo].m_Signats[C.GetSignatNo()].sFrmt), C);
					Trim(S);
					long  Type =  GetRusGramTab()->GetClauseTypeByName(S.c_str());
					A.m_ClauseTypes.push_back (Type);
				};

				if  ( FieldStr == "CAT" ) 
				{
					string S = WriteToString(GetRoss(type), (char*)(GetRoss(type)->Fields[C.m_FieldNo].m_Signats[C.GetSignatNo()].sFrmt), C);
					Trim(S);
					A.m_SemTypes.push_back(S);
				};
				if  ( FieldStr == "SF" ) 
				{
					string S = WriteToString(GetRoss(type), (char*)(GetRoss(type)->Fields[C.m_FieldNo].m_Signats[C.GetSignatNo()].sFrmt), C);
					Trim(S);
					A.m_SemFets.push_back(S);
				};

				if  ( FieldStr == "LEX" ) 
				{
					string S = WriteToString(GetRoss(type), (char*)(GetRoss(type)->Fields[C.m_FieldNo].m_Signats[C.GetSignatNo()].sFrmt), C);
					Trim(S);
					A.m_LexFets.push_back(S);
				};

           

			}
			else
			 A.m_Article.push_back (C);
		 };
		 A.m_UnitNo = UnitNo;
		 Articles.push_back(A);

	  };
	  UnitNo++;


	};

	m_AbstractArticles[type] = Articles;
	return  true;
};