Skip to content

Commit

Permalink
adapted to new ElementType implementation, 1 error left!?
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed Dec 3, 2024
1 parent 5748938 commit 1146f1f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/edit_tests.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,11 @@ void edit_test005a( ){
assertTrue( p->isinstance<PosAnnotation>() );

std::vector<Alternative *> alt3;
#if FOLIA_INT_VERSION < 221
assertNoThrow( alt3 = w->alternatives(PosAnnotation_t, pos_set) );
#else
assertNoThrow( alt3 = w->alternatives(ElementType::PosAnnotation_t, pos_set) );
#endif
assertEqual( alt3.size(), 1 );
assertEqual( alt[0] , alt3[0] );

Expand Down
9 changes: 8 additions & 1 deletion src/foliapy_tests.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,18 @@ void Test_E001_Tokens_Structure(){
{
startTestSerie( "Simple Token & Structure Test - Declarations" );
assertTrue( doc.declared(AnnotationType::TOKEN) );
assertTrue( doc.declared(Word_t) ); // same as above, resolves automatically
assertTrue( doc.declared(AnnotationType::TEXT) );
#if FOLIA_INT_VERSION < 221
assertTrue( doc.declared(Word_t) ); // same as above, resolves automatically
assertTrue( doc.declared(TextContent_t) ); //same as above, resolves automatically
assertTrue( doc.declared(Sentence_t) );
assertTrue( doc.declared(Paragraph_t) );
#else
assertTrue( doc.declared(ElementType::Word_t) ); // same as above, resolves automatically
assertTrue( doc.declared(ElementType::TextContent_t) ); //same as above, resolves automatically
assertTrue( doc.declared(ElementType::Sentence_t) );
assertTrue( doc.declared(ElementType::Paragraph_t) );
#endif
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/foliatest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1129,8 +1129,13 @@ void query_test002(){
void query_test003(){
startTestSerie( " Find Words by annotation " );
vector<string> words = { "de", "historisch", "wetenschap", "worden" };
#if FOLIA_INT_VERSION < 221
vector<vector<Word*> >matches = qDoc.findwords( Pattern( words,
LemmaAnnotation_t ) );
#else
vector<vector<Word*> >matches = qDoc.findwords( Pattern( words,
ElementType::LemmaAnnotation_t ) );
#endif
assertEqual( matches.size(), 1 );
assertEqual( len(matches[0]), 4 );

Expand All @@ -1143,7 +1148,12 @@ void query_test003(){
void query_test004(){
startTestSerie( " Find Words using multiple patterns " );
Pattern p1( { "de", "historische", "*", "wordt" } );
#if FOLIA_INT_VERSION < 221
Pattern p2( { "de", "historisch", "wetenschap", "worden" }, LemmaAnnotation_t );
#else
Pattern p2( { "de", "historisch", "wetenschap", "worden" },
ElementType::LemmaAnnotation_t );
#endif
list<Pattern> l;
l.push_back( p1 );
l.push_back( p2 );
Expand Down Expand Up @@ -1270,8 +1280,13 @@ void query_test010b(){
void query_test011(){
startTestSerie( " Find Words by non existing annotation " );
vector<string> words = { "bli", "bla", "blu" };
#if FOLIA_INT_VERSION < 221
vector<vector<Word*> >matches = qDoc.findwords( Pattern(words,
SenseAnnotation_t ) );
#else
vector<vector<Word*> >matches = qDoc.findwords( Pattern(words,
ElementType::SenseAnnotation_t ) );
#endif
assertEqual( matches.size(), 0 );
}

Expand Down
14 changes: 7 additions & 7 deletions src/sanity_tests.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void sanity_test009( ){
#if FOLIA_INT_VERSION < 221
assertTrue( isSubClass( PosAnnotation_t, AbstractTokenAnnotation_t ) );
#else
assertTrue( is_subtype( PosAnnotation_t, AbstractTokenAnnotation_t ) );
assertTrue( is_subtype( ElementType::PosAnnotation_t, ElementType::AbstractTokenAnnotation_t ) );
#endif
#if FOLIA_INT_VERSION <= 215 || FOLIA_INT_VERSION >= 219
bool test = isSubClass<PosAnnotation, AbstractTokenAnnotation>();
Expand Down Expand Up @@ -672,13 +672,14 @@ void sanity_test026a(){
startTestSerie(" Features " );
FoliaElement *w = sanityDoc["WR-P-E-J-0000000001.p.1.s.6.w.1"];
FoliaElement *pos = w->annotation<PosAnnotation>();
#if FOLIA_INT_VERSION <= 215 || FOLIA_INT_VERSION >= 219
#if FOLIA_INT_VERSION <= 215
assertTrue( pos->isSubClass( AbstractTokenAnnotation_t ) );
#endif
#if FOLIA_INT_VERSION < 221
assertTrue( isSubClass( pos->element_id(), AbstractTokenAnnotation_t ) );
#else
assertTrue( is_subtype( pos->element_id(), AbstractTokenAnnotation_t ) );
assertTrue( pos->isSubClass<AbstractTokenAnnotation>() );
assertTrue( is_subtype( pos->element_id(), ElementType::AbstractTokenAnnotation_t ) );
#endif
assertTrue( pos->isinstance<PosAnnotation>() );
assertTrue( pos->cls() == "WW(vd,prenom,zonder)" );
Expand All @@ -689,8 +690,8 @@ void sanity_test026a(){
assertFalse( isSubClass( features[0]->element_id(), Sentence_t ) );
assertTrue( isSubClass( features[0]->element_id(), Feature_t ) );
#else
assertFalse( is_subtype( features[0]->element_id(), Sentence_t ) );
assertTrue( is_subtype( features[0]->element_id(), Feature_t ) );
assertFalse( is_subtype( features[0]->element_id(), ElementType::Sentence_t ) );
assertTrue( is_subtype( features[0]->element_id(), ElementType::Feature_t ) );
#endif
assertTrue( features[0]->isinstance<Feature>() );
assertTrue( features[0]->subset() == "head" );
Expand Down Expand Up @@ -777,7 +778,6 @@ void sanity_test030( ){
FoliaElement *w2= sanityDoc["WR-P-E-J-0000000001.p.1.s.6.w.31"];
assertTrue( w2->text() == "vierkante" );
assertTrue( w2->stricttext() == "vierkante" );

}

void sanity_test030b( ){
Expand Down Expand Up @@ -2105,7 +2105,7 @@ void sanity_test109( ){
#if FOLIA_INT_VERSION < 221
assertTrue( isSubClass( PosAnnotation_t, AbstractTokenAnnotation_t ) );
#else
assertTrue( is_subtype( PosAnnotation_t, AbstractTokenAnnotation_t ) );
assertTrue( is_subtype( ElementType::PosAnnotation_t, ElementType::AbstractTokenAnnotation_t ) );
assertTrue( ( isSubClass<AbstractWord, AbstractStructureElement>() ) );
assertTrue( ( isSubClass<AbstractWord, AbstractElement>() ) );
#endif
Expand Down

0 comments on commit 1146f1f

Please sign in to comment.