/
bear
/
aot
Обзор
Документация
Войти
/
bear
/
aot
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Source/windows/TestSynanCOM/TestSynanCOM.cpp
70 строк
2 KB
sokirko74
fix includes
01 дек 2021, 21:44
01 дек 2021, 21:44
03ae069
Код
Авторство
О чём код?
/* This is an example of how to use windows-interfaces of Dialing Syntax. The program processes a sentence, and then prints all found syntax groups */ #include "windows/common/COMSyntaxHolder.h" #include "morph_dict/common/utilit.h" #include <fstream> int main(int argc, char* argv[]) { ::CoInitialize(0); { // loading Russian syntax CCOMSyntaxHolder SyntaxHolder; if (!SyntaxHolder.LoadSyntax(morphRussian)) { std::cerr << "cannot initialize syntax\n"; return 1; } std::string inputFile = argv[1]; assert(access(inputFile.c_str(), 0) != -1); std::cout << "Loading file " << inputFile << "\n"; // processing one Russian sentence (from Graphematics to Syntax) if (!SyntaxHolder.GetSentencesFromSynAn(inputFile.c_str(), TRUE, TRUE, FALSE)) { std::cerr << "cannot process the input file\n"; return -1; } // printing all syntax groups // going through all sentences std::ofstream outp(inputFile + ".synan", std::ios::binary); for(int i = 0 ; i < SyntaxHolder.m_piSentCollection->SentencesCount ; i++ ) { auto piSent = SyntaxHolder.m_piSentCollection->GetSentence(i); // going through all clauses in this sentence for(int j = 0 ; j < piSent->ClausesCount ; j++ ) { auto piClause = piSent->Clause[j]; // getting the first morphological variant if (piClause->VariantsCount == 0) { std::cerr << " Error! A clause with no morph. variant is found\n"; continue; }; // going through all syntax groups for(int k = 0 ; k < piClause->ClauseVariant[0]->GroupsCount ; k++ ) { auto piGroup = piClause->ClauseVariant[0]->Group[k]; auto s = piGroup->FirstWord; auto l = piGroup->LastWord; outp << piGroup->TypeStr << "[" << s << ", " << l << "]\n"; } } } } ::CoUninitialize(); return 0; }