Main
EKEEL Video Annotation Server Backend
This module implements a Flask web server for video annotation and analysis. It provides functionality for:
-
User Management:
- Registration and authentication
- Profile management
-
Video Processing:
- YouTube video processing
- Transcript extraction
- Video segmentation
-
Annotation Features:
- Manual concept mapping
- Definition creation
- Vocabulary management
-
Analysis Tools:
- Burst analysis (automatic/semi-automatic)
- Inter-annotator agreement
- Gold standard creation
- Linguistic analysis
-
Data Management:
- MongoDB storage integration
- JSON-LD export format
- SKOS vocabulary support
analysis()
Handle various types of annotation analysis requests.
This endpoint processes different types of analysis on video annotations: - Data summary: Statistical analysis of concept maps and definitions - Agreement: Compare annotations between two annotators - Linguistic: Analyze linguistic properties of annotations - Fleiss: Calculate inter-annotator agreement using Fleiss' kappa
Parameters:
Name | Type | Description | Default |
---|---|---|---|
analysis_type
|
str
|
Type of analysis to perform: - 'data_summary': Statistical summary - 'agreement': Inter-annotator comparison - 'linguistic': Linguistic analysis - 'fleiss': Fleiss' kappa calculation |
required |
video
|
str
|
Video identifier for analysis |
required |
annotator
|
str
|
Annotator ID for data_summary and linguistic analysis |
required |
annotator1
|
str
|
First annotator ID for agreement analysis |
required |
annotator2
|
str
|
Second annotator ID for agreement analysis |
required |
Returns:
Type | Description |
---|---|
str
|
Rendered HTML template with analysis results: - On GET: analysis_selection.html with video choices - On POST: analysis_results.html with computed results |
Source code in apps/annotator/code/main.py
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 |
|
burst()
Process burst analysis requests for video annotations.
This endpoint handles burst analysis of videos, which can be either: - Semi-automatic: Extracts transcript and processes text for annotations - Automatic: Extracts keywords only
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
YouTube video ID from form |
required |
type
|
str
|
Analysis type from form: - 'semi': Semi-automatic analysis with transcript - 'auto': Automatic analysis with keywords only |
required |
Returns:
Type | Description |
---|---|
str
|
On GET: Rendered 'burst.html' template with: - form : BurstForm Form for burst analysis parameters - videos : list Available videos for analysis On POST: Rendered 'burst_results.html' template with: - result : list Processed subtitles (semi-automatic only) - video_id : str YouTube video identifier - language : str Detected video language - concepts : list Extracted keywords - title : str Video title - lemmatized_subtitles : list Processed subtitle text (semi-automatic only) - type : str Analysis type performed |
Source code in apps/annotator/code/main.py
867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 |
|
burst_launch()
Process and store burst analysis results with optional synonym expansion.
This endpoint handles the processing of burst analysis results, storing them in the database, and computing comparison metrics with existing annotations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
JSON request data containing: - id : str Video identifier - concepts : list List of extracted concepts - conceptVocabulary : dict Mapping of concepts to synonyms - syn_burst : bool Whether to include synonym expansion - burst_type : str Type of burst analysis ('auto' or 'semi') |
required |
Returns:
Type | Description |
---|---|
dict
|
JSON response containing: - concepts : list Processed concept list - concept_map : dict Generated concept relationships - definitions : dict Concept definitions - data_summary : dict Statistical summary of results - downloadable_jsonld_graph : dict JSON-LD formatted graph data - agreement : dict Comparison metrics including: - name : str Annotator name - K : float Agreement score - VEO : float Vector embedding overlap - GED : float Graph edit distance - pageRank : float PageRank similarity - LO : float Learning outcome score - PN : float Prerequisite network score - can_be_refined : bool Whether video supports refinement |
Source code in apps/annotator/code/main.py
947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 |
|
confirm_code()
Handle the confirmation code process for new users.
Returns:
Type | Description |
---|---|
str
|
The rendered HTML content of the confirmation code page if the form is not submitted/valid. |
Response
|
A redirect response to the login page if the confirmation code is valid. |
Source code in apps/annotator/code/main.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
confirm_email(token)
Handle the email confirmation process for new users.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token
|
str
|
The confirmation token sent to the user's email. |
required |
Returns:
Type | Description |
---|---|
str
|
The rendered HTML content of the index page after confirming the email. |
Source code in apps/annotator/code/main.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
delete_annotation()
Delete user-specific annotations for a video.
This endpoint removes all annotation data associated with a specific video and user combination from the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_id
|
str
|
Unique identifier of the video whose annotations should be deleted |
required |
user
|
dict
|
Dictionary containing user information: - id : str MongoDB user identifier - name : str User's full name |
required |
Returns:
Type | Description |
---|---|
dict
|
JSON response containing: - done : bool True if deletion successful, False if error occurred |
Source code in apps/annotator/code/main.py
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 |
|
delete_video()
Delete a video and its associated data from the database.
This endpoint handles video deletion requests. It removes the video entry and all associated annotations from MongoDB storage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_id
|
str
|
Unique identifier of the video to delete, passed in request JSON |
required |
Returns:
Type | Description |
---|---|
dict
|
JSON response containing: - done : bool True if deletion successful, False if error occurred |
Source code in apps/annotator/code/main.py
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
|
forgot_password()
Handle the forgot password process for users.
Returns:
Type | Description |
---|---|
str
|
The rendered HTML content of the forgot password page if the form is not submitted/valid. |
Response
|
A redirect response to the password reset page if the form is submitted and valid. |
Source code in apps/annotator/code/main.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
get_concept_vocabulary()
Retrieve concept vocabulary and their synonyms.
This endpoint handles requests to get synonyms for a list of concepts using NLTK Wordnet. Accepts POST requests with JSON data containing concepts and returns a vocabulary mapping.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
concepts
|
list
|
List of concept strings to find synonyms for, passed in request JSON |
required |
Returns:
Type | Description |
---|---|
dict
|
JSON response containing: - conceptVocabulary : dict Mapping of concepts to their synonyms from Wordnet |
Source code in apps/annotator/code/main.py
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 |
|
gold_standard()
Create gold standard annotations from multiple annotators' work.
This endpoint handles the creation of consensus annotations by combining the work of multiple annotators based on agreement thresholds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video
|
str
|
Selected video identifier from form |
required |
annotators
|
list
|
List of selected annotator IDs from form |
required |
agreements
|
float
|
Agreement threshold for including annotations in gold standard |
required |
name
|
str
|
Name for the gold standard annotation set |
required |
Returns:
Type | Description |
---|---|
str
|
Rendered HTML template 'gold_standard.html' containing: - video_choices : dict Available videos and their metadata - form : GoldStandardForm Form for gold standard creation parameters |
Source code in apps/annotator/code/main.py
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 |
|
index()
Render the index page.
Returns:
Type | Description |
---|---|
str
|
The rendered HTML content of the index page. |
Source code in apps/annotator/code/main.py
68 69 70 71 72 73 74 75 76 77 78 |
|
lemmatize_term()
Lemmatize a term in the specified language.
This endpoint processes a concept term to extract its semantic structure and returns the lemmatized form along with linguistic information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
language
|
str
|
Language code for lemmatization |
required |
concept
|
str
|
Term to be lemmatized |
required |
Returns:
Type | Description |
---|---|
dict
|
JSON response containing: - text : str Original input text - lemma : str Lemmatized form of the text - pos : str Part of speech tag - dep : str Dependency relation - head : str Head word in dependency relation |
Source code in apps/annotator/code/main.py
1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 |
|
login()
Handle the login process for users.
Returns:
Type | Description |
---|---|
str
|
The rendered HTML content of the login page if the user is not authenticated or the form is not submitted/valid. |
Response
|
A redirect response to the next page if the user is authenticated or the form is submitted and valid. |
Source code in apps/annotator/code/main.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
logout()
Handle the logout process for users.
Returns:
Type | Description |
---|---|
str
|
The rendered HTML content of the index page after logging out the user. |
Source code in apps/annotator/code/main.py
111 112 113 114 115 116 117 118 119 120 121 122 |
|
password_reset(token)
Handle the password reset process for users.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token
|
str
|
The password reset token sent to the user's email. |
required |
Returns:
Type | Description |
---|---|
str
|
The rendered HTML content of the password reset page if the form is not submitted/valid. |
Response
|
A redirect response to the index page if the token is invalid or expired. |
Source code in apps/annotator/code/main.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
prepare_annotated_graph()
Prepare concept graph annotations for download in JSON-LD format.
This endpoint receives annotation data, converts it to JSON-LD format with SKOS vocabulary, and prepares it for client-side download. The function creates a collection of concepts and their relationships in a standardized semantic web format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
annotations
|
dict
|
JSON data containing: - id : str Video identifier - conceptVocabulary : dict Dictionary mapping concepts to their vocabulary - language : str Language code for the annotations |
required |
Returns:
Type | Description |
---|---|
dict
|
JSON-LD formatted data containing: - @context : dict JSON-LD context definitions - @graph : list List of nodes in the concept graph including: - Concept definitions - Relationships - SKOS vocabulary collection |
Source code in apps/annotator/code/main.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 |
|
register()
Handle the registration process for new users.
Returns:
Type | Description |
---|---|
str
|
The rendered HTML content of the registration page if the form is not submitted/valid. |
Response
|
A redirect response to the confirmation code page if the form is submitted and valid. |
Source code in apps/annotator/code/main.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
upload_annotated_graph()
Upload and store annotated concept graph in JSON-LD format. The annotator can be anyone based on the provided name.
This endpoint receives annotation data for a video, converts it to JSON-LD format, and stores it in MongoDB. The annotations include concept relationships, vocabulary, and metadata about the annotation process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
annotations
|
dict
|
JSON data containing: - id : str Video identifier - conceptVocabulary : dict Mapping of concepts to synonyms - language : str Language of annotations - is_completed : bool Whether annotation is complete |
required |
Returns:
Type | Description |
---|---|
dict
|
JSON response containing: - done : bool True if upload successful, False if error occurred |
Source code in apps/annotator/code/main.py
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
|
video_segmentation_refinement()
Refine video segmentation and update concept definitions.
This endpoint processes video segments to refine concept definitions and timestamps, storing updated annotations in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
JSON request data containing: - id : str Video identifier - conceptVocabulary : dict Mapping of concepts to synonyms - definitions : dict Current concept definitions with timestamps - concept_map : dict Current concept relationships |
required |
Returns:
Type | Description |
---|---|
dict
|
JSON response containing: - definitions : dict Updated concept definitions with refined timestamps - downloadable_jsonld_graph : dict JSON-LD formatted graph containing: - @context : dict JSON-LD context definitions - @graph : list Updated nodes including: - Concept definitions - Relationships - SKOS vocabulary |
Source code in apps/annotator/code/main.py
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 |
|
video_selection()
Handle video selection and processing for annotation purposes.
This function manages the video selection interface and processes new video submissions. It handles both GET requests to display the video selection page and POST requests to process new video submissions. For new videos, it:
-
Downloads the video
-
Extracts and processes the transcript
-
Segments the video
-
Creates thumbnails
-
Processes concepts and vocabulary based on user selection (edit his own or last annotator's annotations)
-
Sets up the annotation environment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
URL of the video to be processed (from addVideoForm) |
required |
Returns:
Type | Description |
---|---|
str
|
On GET or failed form validation: renders video_selection.html template showing existing videos and upload form |
Response
|
On successful POST: renders mooc_annotator.html template with processed video data and annotation interface |
Source code in apps/annotator/code/main.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
|