📄 example.cc
字号:
anno_list.gotoFirst(); if (anno_list.length() != 3) { Console::put(L"invalid annotation graph\n"); } if (anno_list.getFirst() != anno_05) { Console::put(L"invalid annotation graph\n"); } if (anno_list.getNext() != anno_05a) { Console::put(L"invalid annotation graph\n"); } if (anno_list.getLast() != anno_05b) { Console::put(L"invalid annotation graph\n"); } // clear the dynamically allocated anchors // for (boolean more = anchor_list.gotoFirst(); more; more = anchor_list.gotoNext()) { angr_02.deleteAnchor(anchor_list.getCurr()); } // set up an example annotation graph // String gname_03(L"AG1"); AnnotationGraph angr_03(gname_03, gtype_04); String ancrid_07(L"Anchor8"); String ancrid_08(L"Anchor9"); String ancrid_09(L"Anchor10"); String feat_00(L"feature0"); String feat_01(L"feature1"); String feat_02(L"feature2"); String feat_03(L"feature3"); String value_00(L"value0"); String value_01(L"value1"); String value_02(L"value2"); String value_03(L"value3"); Annotation* anno_06; Annotation* anno_07; Anchor* ancr_11; Anchor* ancr_12; Anchor* ancr_13; String atype_04(L"T/see"); String atype_05(L"T/Jane"); newid_00 = angr_03.createAnchor(gname_03, offset_00, unit_00); ancr_11 = angr_03.getAnchorById(newid_00); newid_01 = angr_03.createAnchor(gname_03, offset_01, unit_00); ancr_12 = angr_03.getAnchorById(newid_01); newid_02 = angr_03.createAnchor(gname_03, offset_02, unit_00); ancr_13 = angr_03.getAnchorById(newid_02); newid_00 = angr_03.createAnnotation(gname_03, ancr_11, ancr_12, atype_04); anno_06 = angr_03.getById(newid_00); newid_01 = angr_03.createAnnotation(gname_03, ancr_12, ancr_13, atype_05); anno_07 = angr_03.getById(newid_01); // get the annotation by its offset in the annotation graph // angr_03.getAnnotationSetByOffset(offset_00, anno_list); if (anno_list.getFirst() != anno_06) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnnotationSetByOffset(offset_01, anno_list); if (anno_list.getFirst() != anno_06) { Console::put(L"invalid annotation graph\n"); } if (anno_list.getLast() != anno_07) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnnotationSetByOffset(offset_02, anno_list); if (anno_list.getLast() != anno_07) { Console::put(L"invalid annotation graph\n"); } // get annotation sequence by its offset in the annotation graph // angr_03.getAnnotationSeqByOffset(anno_list, 2.0, 3.4); if (anno_list.getFirst() != anno_06) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnnotationSeqByOffset(anno_list, 0.0, 1.3); if (anno_list.length() != 0) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnnotationSeqByOffset(anno_list, 2.4, 4.9); if (anno_list.getFirst() != anno_06) { Console::put(L"invalid annotation graph\n"); } if (anno_list.getLast() != anno_07) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnnotationSeqByOffset(anno_list, 3.7, 6.7); if (anno_list.getFirst() != anno_07) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnnotationSeqByOffset(anno_list, 5.8, 10.4); if (anno_list.length() != 0) { Console::put(L"invalid annotation graph\n"); } // get the annotation by its offset in the annotation graph // if (angr_03.getAnnotationByOffset(2.3) != (Annotation*)NULL) { Console::put(L"invalid annotation graph\n"); } if (angr_03.getAnnotationByOffset(2.4) != anno_06) { Console::put(L"invalid annotation graph\n"); } if (angr_03.getAnnotationByOffset(3.4) != anno_06) { Console::put(L"invalid annotation graph\n"); } if (angr_03.getAnnotationByOffset(4.9) != anno_06) { Console::put(L"invalid annotation graph\n"); } if (angr_03.getAnnotationByOffset(4.91) != anno_07) { Console::put(L"invalid annotation graph\n"); } if (angr_03.getAnnotationByOffset(5.91) != anno_07) { Console::put(L"invalid annotation graph\n"); } if (angr_03.getAnnotationByOffset(8.9) != anno_07) { Console::put(L"invalid annotation graph\n"); } if (angr_03.getAnnotationByOffset(8.91) != (Annotation*)NULL) { Console::put(L"invalid annotation graph\n"); } // get the nearest offset in the annotation graph // if (!Integral::almostEqual(angr_03.getNearestOffset(2.4), (float)2.4)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(1.2), (float)2.4)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(2.3999), (float)2.4)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(2.4001), (float)2.4)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(3.0), (float)2.4)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(4.9), (float)4.9)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(4.0), (float)4.9)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(4.8999), (float)4.9)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(4.9001), (float)4.9)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(6.0), (float)4.9)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(8.9), (float)8.9)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(7.8), (float)8.9)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(8.8999), (float)8.9)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(8.9001), (float)8.9)) { Console::put(L"invalid annotation graph\n"); } if (!Integral::almostEqual(angr_03.getNearestOffset(10.6), (float)8.9)) { Console::put(L"invalid annotation graph\n"); } // get nearest anchors by its offset in the annotation graph // angr_03.getAnchorSetNearestOffset(2.3, anchor_list); if (anchor_list.getFirst() != ancr_11) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnchorSetNearestOffset(2.4, anchor_list); if (anchor_list.getFirst() != ancr_11) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnchorSetNearestOffset(2.5, anchor_list); if (anchor_list.getFirst() != ancr_11) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnchorSetNearestOffset(4.8, anchor_list); if (anchor_list.getFirst() != ancr_12) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnchorSetNearestOffset(4.9, anchor_list); if (anchor_list.getFirst() != ancr_12) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnchorSetNearestOffset(5.0, anchor_list); if (anchor_list.getFirst() != ancr_12) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnchorSetNearestOffset(8.8, anchor_list); if (anchor_list.getFirst() != ancr_13) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnchorSetNearestOffset(8.9, anchor_list); if (anchor_list.getFirst() != ancr_13) { Console::put(L"invalid annotation graph\n"); } angr_03.getAnchorSetNearestOffset(9.0, anchor_list); if (anchor_list.getFirst() != ancr_13) { Console::put(L"invalid annotation graph\n"); } // set the feature in the annotation graph // if (!angr_03.setFeature(newid_00, feat_00, value_00)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.setFeature(newid_00, feat_01, value_01)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.setFeature(newid_01, feat_02, value_02)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.setFeature(newid_01, feat_03, value_03)) { Console::put(L"invalid annotation graph\n"); } // verify that the feature exists in the annotation graph // if (!angr_03.existsFeature(newid_00, feat_00)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.existsFeature(newid_00, feat_01)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.existsFeature(newid_01, feat_02)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.existsFeature(newid_01, feat_03)) { Console::put(L"invalid annotation graph\n"); } // delete the feature in the annotation graph // if (!angr_03.deleteFeature(newid_00, feat_01)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.deleteFeature(newid_01, feat_03)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.existsFeature(newid_00, feat_00)) { Console::put(L"invalid annotation graph\n"); } if (angr_03.existsFeature(newid_00, feat_01)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.existsFeature(newid_01, feat_02)) { Console::put(L"invalid annotation graph\n"); } if (angr_03.existsFeature(newid_01, feat_03)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.setFeature(newid_00, feat_01, value_01)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.setFeature(newid_01, feat_03, value_03)) { Console::put(L"invalid annotation graph\n"); } // get features in the annotation graph // if (!angr_03.getFeature(newid_00, feat_00).eq(value_00)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.getFeature(newid_00, feat_01).eq(value_01)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.getFeature(newid_01, feat_02).eq(value_02)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.getFeature(newid_01, feat_03).eq(value_03)) { Console::put(L"invalid annotation graph\n"); } // get the feature names in the annotation graph // Vector<String> fnames; if (!angr_03.getFeatureNames(newid_00, fnames)) { Console::put(L"invalid annotation graph\n"); } if (fnames.length() != 2) { Console::put(L"invalid annotation graph\n"); } if (!fnames.contains(&feat_00)) { Console::put(L"invalid annotation graph\n"); } if (!fnames.contains(&feat_01)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.getFeatureNames(newid_01, fnames)) { Console::put(L"invalid annotation graph\n"); } if (fnames.length() != 2) { Console::put(L"invalid annotation graph\n"); } if (!fnames.contains(&feat_02)) { Console::put(L"invalid annotation graph\n"); } if (!fnames.contains(&feat_03)) { Console::put(L"invalid annotation graph\n"); } // unset the features in the annotation graph // if (!angr_03.unsetFeatures(newid_00)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.unsetFeatures(newid_01)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.getFeature(newid_00, feat_00).eq(String::EMPTY)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.getFeature(newid_00, feat_01).eq(String::EMPTY)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.getFeature(newid_01, feat_02).eq(String::EMPTY)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.getFeature(newid_01, feat_03).eq(String::EMPTY)) { Console::put(L"invalid annotation graph\n"); } // set the features in the annotation graph // if (!angr_03.setFeature(anno_06, feat_00, value_00)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.setFeature(anno_06, feat_01, value_01)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.setFeature(anno_07, feat_02, value_02)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.setFeature(anno_07, feat_03, value_03)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.existsFeature(newid_00, feat_00)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.existsFeature(newid_00, feat_01)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.existsFeature(newid_01, feat_02)) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.existsFeature(newid_01, feat_03)) { Console::put(L"invalid annotation graph\n"); } // get the annotation set by feature-value pair in the annotation graph // if (!angr_03.getAnnotationSetByFeature(feat_00, value_00, anno_list)) { Console::put(L"invalid annotation graph\n"); } if (anno_list.length() != 1) { Console::put(L"invalid annotation graph\n"); } if (anno_list.getFirst() != (Annotation*)anno_06) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.getAnnotationSetByFeature(feat_01, value_01, anno_list)) { Console::put(L"invalid annotation graph\n"); } if (anno_list.length() != 1) { Console::put(L"invalid annotation graph\n"); } if (anno_list.getFirst() != (Annotation*)anno_06) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.getAnnotationSetByFeature(feat_02, value_02, anno_list)) { Console::put(L"invalid annotation graph\n"); } if (anno_list.length() != 1) { Console::put(L"invalid annotation graph\n"); } if (anno_list.getFirst() != (Annotation*)anno_07) { Console::put(L"invalid annotation graph\n"); } if (!angr_03.getAnnotationSetByFeature(feat_03, value_03, anno_list)) { Console::put(L"invalid annotation graph\n"); } if (anno_list.length() != 1) { Console::put(L"invalid annotation graph\n"); } if (anno_list.getFirst() != (Annotation*)anno_07) { Console::put(L"invalid annotation graph\n"); } // exit gracefully // Integral::exit();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -