--------------------------------------------------------------------DATE - > 17.09.2024----------------------------------------------------------------------
INITIAL PIPELINE:


initialize_queue( setup traversal, start with initial URL and target concepts )
→ find_aggregators( detect candidate aggregator pages, look for links containing plural concept names and verify them by extracting children )
→ create_aggregator( validate aggregator, open candidate page and collect links that point to actual concept instances )
→ expand_children( improve recall, optionally add more children using geometry alignment and homepage resolution )
→ resolve_links( clean results, normalize and deduplicate child URLs after redirects )
→ enqueue_children( recursive exploration, push child pages with remaining concepts to continue hierarchical search )
→ handle_dynamic_menus( uncover hidden navigation, follow menu-like links such as “faculties” or “institutions” )
→ repeat_loop( breadth-first traversal, continue until no pages remain in queue )
→ disambiguate_children( resolve conflicts, assign children to the most likely concept based on text matching )
→ return_results( output structure, provide all discovered aggregator pages with their children )

The evaluation of the old ude_predictions data shown the results:

UDE
---
F1-Score (WITH domain FILTER) -> faculties:1.0, institutes:0.6444, chairs:0.6912

+Evaluating ConceptType.FACULTY
  Predictions 12 Truth 12
  TP 12 FP 0 FN 0
  P 1.0 R 1.0 F1 1.0
 
+Evaluating ConceptType.INSTITUTE
Predictions 46 Truth 45
   TP 29 FP 16 FN 16
P 0.6444444444444445 R 0.6444444444444445 F1 0.6444444444444445

+Evaluating ConceptType.CHAIR
  Predictions 418 Truth 423
  TP 290 FP 126 FN 133
  P 0.6971153846153846 R 0.6855791962174941 F1 0.6912991656734208
---

TUD
---
F1-Score (WITH domain FILTER) -> faculties:0.7391, institutes:0.1666, chairs:0.2914 -> low scores

**Evaluating ConceptType.FACULTY
  Predictions 29 Truth 17
    TP 17 FP 12 FN 0
  P 0.5862068965517241 R 1.0 F1 0.7391304347826086
**Evaluating ConceptType.INSTITUTE
  Predictions 4 Truth 32
   TP 3 FP 1 FN 29
  P 0.75 R 0.09375 F1 0.16666666666666666
**Evaluating ConceptType.CHAIR
  Predictions 127 Truth 271
  TP 58 FP 69 FN 213
  P 0.4566929133858268 R 0.2140221402214022 F1 0.2914572864321608
---

MUE
---
F1-Score (WITH domain FILTER) -> faculties:0.4745, institutes:0.6933, chairs:0.4865 
**Evaluating ConceptType.FACULTY
  Predictions 44 Truth 15
    TP 14 FP 30 FN 1
  P 0.3181818181818182 R 0.9333333333333333 F1 0.47457627118644075
**Evaluating ConceptType.INSTITUTE
  Predictions 166 Truth 135
   TP 104 FP 61 FN 31
  P 0.6303030303030303 R 0.7703703703703704 F1 0.6933333333333334
**Evaluating ConceptType.CHAIR
  Predictions 271 Truth 436
  TP 172 FP 99 FN 264
  P 0.6346863468634686 R 0.3944954128440367 F1 0.48656294200848654
---



##############################################################################################################################################
ml_multi_algorithm.ipynb:

It was tested if a machine learning algorithm can classify pages based on their first 10 <heads>(headings like h1,h2...) 
We took truth files and all pages inside of it, then we downloaded all the pages and extracted their <heads>.
Then we fitted the <heads> into a SGDClassifier (0.75/0.25 train/test) to observe if the pages can be classified correctly(aggregator/faculty/chair/institute) 
---------------------------------------------------------------(UNBALANCED)-------------------------------------------------------

Results for all unis:
				precision    recall  f1-score   support

  AGGREGATOR       0.57      0.44      0.50        18
       CHAIR       0.88      0.91      0.89       243
     FACULTY       0.82      0.69      0.75        13
   INSTITUTE       0.53      0.51      0.52        51

    accuracy                           0.81       325
   macro avg       0.70      0.64      0.67       325
weighted avg       0.80      0.81      0.81       325

Obsevations: not bad results for FACULTY and CHAIR (F1 > 0.75) but not satisfying results for AGGREGATOR and INSTITUTE (F1=~0.50)


#MUENSTER ONLY-----------------------------------------------------------------
chairs 375
institutes 136
faculties 15
aggs 60
              precision    recall  f1-score   support

  AGGREGATOR       0.50      0.75      0.60        12
       CHAIR       0.88      0.76      0.82       102
     FACULTY       1.00      0.67      0.80         6
   INSTITUTE       0.53      0.70      0.60        27

    accuracy                           0.75       147
   macro avg       0.73      0.72      0.70       147
weighted avg       0.79      0.75      0.76       147

#UDE ONLY------------------------------------------------------------------
chairs 309
institutes 46
faculties 12
aggs 30
              precision    recall  f1-score   support

  AGGREGATOR       0.50      0.25      0.33         8
       CHAIR       0.86      0.93      0.89        76
     FACULTY       0.80      0.80      0.80         5
   INSTITUTE       0.25      0.18      0.21        11

    accuracy                           0.79       100
   macro avg       0.60      0.54      0.56       100
weighted avg       0.76      0.79      0.77       100

#TUD ONLY-----------------------------------------------------------------
chairs 266
institutes 32
faculties 17
aggs 29
              precision    recall  f1-score   support

  AGGREGATOR       0.80      0.67      0.73         6
       CHAIR       0.82      0.97      0.89        65
     FACULTY       0.50      0.20      0.29         5
   INSTITUTE       0.50      0.10      0.17        10

    accuracy                           0.80        86
   macro avg       0.65      0.48      0.52        86
weighted avg       0.76      0.80      0.76        86




####################################################################################################
#PAGE CONTENT APPROACH -> (Dont extract heads, just take the page content)

#MUENSTER ONLY TRAFILATURA-----------------------------------------------------
chairs 375
institutes 136
faculties 15
aggs 60
			precision    recall  f1-score   support

  AGGREGATOR       0.67      0.33      0.44        18
       CHAIR       0.80      0.93      0.86        99
     FACULTY       1.00      1.00      1.00         2
   INSTITUTE       0.57      0.43      0.49        28

    accuracy                           0.76       147
   macro avg       0.76      0.67      0.70       147
weighted avg       0.74      0.76      0.74       147


#UDE ONLY TRAFILATURA-----------------------------------------------------
chairs 309
institutes 46
faculties 12
aggs 30
			precision    recall  f1-score   support

  AGGREGATOR       0.75      0.38      0.50         8
       CHAIR       0.86      0.94      0.89        77
     FACULTY       1.00      0.67      0.80         3
   INSTITUTE       0.44      0.36      0.40        11

    accuracy                           0.82        99
   macro avg       0.76      0.59      0.65        99
weighted avg       0.81      0.82      0.80        99
#TUD ONLY TRAFILATURA----------------------------------------------------
chairs 266
institutes 32
faculties 17
aggs 29
              precision    recall  f1-score   support

  AGGREGATOR       0.33      0.09      0.14        11
       CHAIR       0.78      0.95      0.86        61
     FACULTY       0.50      0.33      0.40         6
   INSTITUTE       0.00      0.00      0.00         7

    accuracy                           0.72        85
   macro avg       0.40      0.34      0.35        85
weighted avg       0.64      0.72      0.66        85

The results has shown that the number of labels is unbalanced (CHAIR has the greatest number of labels - UNBALANCED)

Lets balance the labels and do the tests again.
---------------------------------------------------------------(BALANCED)-------------------------------------------------------
#MUE ONLY --------------------------------------------------------------
chairs 375
institutes 136
faculties 15
aggs 60
              precision    recall  f1-score   support

  AGGREGATOR       0.91      0.97      0.94        99
       CHAIR       0.96      0.84      0.90        94
     FACULTY       1.00      1.00      1.00        90
   INSTITUTE       0.90      0.96      0.93        92

    accuracy                           0.94       375
   macro avg       0.94      0.94      0.94       375
weighted avg       0.94      0.94      0.94       375

#MUE ONLY TRAFILATURA----------------------------------------------------
chairs 375
institutes 136
faculties 15
aggs 60
			  precision    recall  f1-score   support

  AGGREGATOR       0.92      0.97      0.94        97
       CHAIR       0.98      0.93      0.96       104
     FACULTY       1.00      1.00      1.00        88
   INSTITUTE       0.94      0.94      0.94        85

    accuracy                           0.96       374
   macro avg       0.96      0.96      0.96       374
weighted avg       0.96      0.96      0.96       374

#UDE ONLY --------------------------------------------------------------
chairs 309
institutes 46
faculties 12
aggs 30
              precision    recall  f1-score   support

  AGGREGATOR       0.95      0.94      0.95        84
       CHAIR       1.00      0.94      0.97        69
     FACULTY       1.00      1.00      1.00        87
   INSTITUTE       0.92      0.99      0.95        69

    accuracy                           0.97       309
   macro avg       0.97      0.97      0.97       309
weighted avg       0.97      0.97      0.97       309

UDE ONLY TRAFILATURA----------------------------------------------------
chairs 309
institutes 46
faculties 12
aggs 30
              precision    recall  f1-score   support

  AGGREGATOR       0.91      1.00      0.95        87
       CHAIR       1.00      0.99      0.99        84
     FACULTY       1.00      1.00      1.00        69
   INSTITUTE       0.98      0.87      0.92        69

    accuracy                           0.97       309
   macro avg       0.97      0.96      0.97       309
weighted avg       0.97      0.97      0.97       309


#TUD ONLY----------------------------------------------------

chairs 266
institutes 32
faculties 17
aggs 29
		precision    recall  f1-score   support

  AGGREGATOR       1.00      0.94      0.97        72
       CHAIR       1.00      0.95      0.97        61
     FACULTY       0.99      1.00      0.99        73
   INSTITUTE       0.91      1.00      0.95        60

    accuracy                           0.97       266
   macro avg       0.97      0.97      0.97       266
weighted avg       0.98      0.97      0.97       266

#TUD ONLY TRAFILATURA----------------------------------------------------
chairs 266
institutes 32
faculties 17
aggs 29
              precision    recall  f1-score   support

  AGGREGATOR       1.00      0.87      0.93        67
       CHAIR       0.97      1.00      0.99        70
     FACULTY       1.00      1.00      1.00        65
   INSTITUTE       0.89      1.00      0.94        59

    accuracy                           0.97       261
   macro avg       0.97      0.97      0.96       261
weighted avg       0.97      0.97      0.97       261
---------------------------------------------------------------(END OF BALANCED)-------------------------------------------------------

We added OTHER category to represent the False Positives, so that not every page is considered as right prediction
  
  
 
 --ADDED OTHER CATEGORY BALANCED--
 
               precision    recall  f1-score   support

  AGGREGATOR       0.89      0.91      0.90        70
       CHAIR       0.85      0.89      0.87        89
     FACULTY       0.99      1.00      0.99        78
   INSTITUTE       0.94      0.91      0.92        66
       OTHER       0.85      0.80      0.82        84

    accuracy                           0.90       387
   macro avg       0.90      0.90      0.90       387
weighted avg       0.90      0.90      0.90       387

ML APPROACH.
What if we use the model to predict the aggregators and concepts for us?
We replaced the initial heuristic approach with the model trained on headings of aggregators pages and concepts (and others later on)

Results below:
Replacing with predictions:
Replacing Aggs search with predictions->results in 0 aggs -> 0 concepts //(because of wrong matching the iterative loop cant discover further agg links)



Replacing Concepts ONLY with predictions -> results below

   Replacing with predictions:
  ----------PREDICTING----------
  Evaluating ConceptType.FACULTY
  Predictions 1 Truth 12
  TP 1 FP 0 FN 11
  P 1.0 R 0.08333333333333333 F1 0.15384615384615385

Evaluating ConceptType.INSTITUTE
  Predictions 0 Truth 45
  TP 0 FP 0 FN 45
  P 0 R 0.0 F1 0

Evaluating ConceptType.CHAIR
  Predictions 29 Truth 423
     FP Kontakt https://www.msm.uni-due.de/lehrstuehle/
      FP News https://www.msm.uni-due.de/news/
      FP Forschung https://www.msm.uni-due.de/forschung/
      FP Data Analytics https://www.da.msm.uni-due.de/startseite/
      FP Studium https://www.msm.uni-due.de/studium/
      FP Prüfungen https://www.css.msm.uni-due.de/pruefungsorganisation/
      FP Beratung https://www.css.msm.uni-due.de/studienberatung/
      FP Impressum https://www.msm.uni-due.de/impressum/
  TP 21 FP 8 FN 402
  P 0.7241379310344828 R 0.04964539007092199 F1 0.09292035398230089
-------------------------------------------------------------------------------




Hmm, the replacement didnt work out. 
What if we DONT REPLACE, but EXPAND our initial aggs search and concepts classification with model predictions?

Validating with predictions:
Validate Aggs and concepts? ->

Evaluating ConceptType.FACULTY
  Predictions 1 Truth 12
  TP 1 FP 0 FN 11
  P 1.0 R 0.08333333333333333 F1 0.15384615384615385

Evaluating ConceptType.INSTITUTE
  Predictions 0 Truth 45
  TP 0 FP 0 FN 45
  P 0 R 0.0 F1 0

Evaluating ConceptType.CHAIR
  Predictions 9 Truth 423

  TP 0 FP 9 FN 423
  P 0.0 R 0.0 F1 0
  Not satisfying results, predictions make the searching for aggregators and concepts stricter.
  -----------------------------------
Validate concepts only? ->Allow searching for aggregators in the initial way, but try to predict at least concepts by the page contents->results below
(PGDClassifier)

Replacing with additional validation.
 ----------VALIDATING----------
  Evaluating ConceptType.FACULTY
  Predictions 1 Truth 12
 TP 1 FP 0 FN 11
  P 1.0 R 0.08333333333333333 F1 0.15384615384615385
Evaluating ConceptType.INSTITUTE
  Predictions 0 Truth 45
TP 0 FP 0 FN 45
  P 0 R 0.0 F1 0
Evaluating ConceptType.CHAIR
  Predictions 23 Truth 423
     FP Data Analytics https://www.da.msm.uni-due.de/startseite/
      FP Impressum https://www.msm.uni-due.de/impressum/
  TP 21 FP 2 FN 402
  P 0.9130434782608695 R 0.04964539007092199 F1 0.09417040358744395
  
  
Less FPs compared to Non-others tests
13->8
3->2




#--------------------------------------------------CMS STATISTICS-----------------------------------------
UDE stats: 
Faculties
    IMPERIA 9.2.14: 83.33%
    TYPO3 CMS: 16.67%
Institutes
    IMPERIA 9.2.14: 90.59%
    TYPO3 CMS: 9.41%
Chairs
    IMPERIA 9.2.14: 79.59%
    TYPO3 CMS: 19.05%
    Hugo 0.159.2: 0.51%
    WordPress 6.8.3: 0.34%
    WordPress 6.9.4: 0.34%
    Drupal 7 (http://drupal.org): 0.17%

Münster stats:
Faculties
    IMPERIA 11.7.0: 50.00%
    IMPERIA 11.5.4: 30.00%
    TYPO3 CMS: 13.33%
    Mura CMS 6.2: 3.33%
    IMPERIA 11.4.3: 3.33%
Institutes
    TYPO3 CMS: 42.03%
    IMPERIA 11.7.0: 28.26%
    IMPERIA 11.5.4: 25.72%
    Mura CMS 6.2: 1.45%
    IMPERIA 11.4.3: 1.45%
    IMPERIA 11.5.3: 1.09%
Chairs
    IMPERIA 11.5.4: 47.91%
    IMPERIA 11.7.0: 38.08%
    Mura CMS 6.2: 6.90%
    TYPO3 CMS: 2.72%
    IMPERIA 11.4.3: 1.26%
    IMPERIA 11.5.3: 0.84%
    WordPress 6.9.4: 0.42%
    WPML ver:4.6.7 stt:1,3;: 0.42%
    WordPress 6.7.5: 0.21%
    qTranslate-XT 3.12.0: 0.21%
    IMPERIA 11.5.1: 0.21%
    IMPERIA 8.6.35: 0.21%
    WordPress 6.8.3: 0.21%
    WordPress.com: 0.21%
    Drupal 9 (https://www.drupal.org): 0.21%

TUD stats:
Faculties
    TYPO3 CMS: 100.00%
Institutes
    TYPO3 CMS: 100.00%
Chairs
    TYPO3 CMS: 99.75%
    Infopark CMS Fiona; 7.0.1; 53616c7465645f5fb14a315e7e8b33048d3c428086aedb09: 0.25%
#--------------------------------------------------END OF CMS STATISTICS-----------------------------------------


--------------------------------------------------------------------DATE - > 03.10.2024----------------------------------------------------------------------
-----------------------------------------------------------------------------FURTHER CHANGES---------------------------------------------------------------------------
little adjustement added -> fixes the bug where an url ends with multiple '//' and it ends in an infinite loop

*some persistent concepts adjusted.
* added new concepts for KOELN, AACHEN, BONN, BIELEFELD, DORTMUND, HHU DUESSELDORF, PADERBORN, RUB Bochum, WUPPERTAL, SIEGEN

Now we do have more uni-prediction.jsons, but what about validating?
-----------------------------------------
FOR:  uni_prediction-test-ude.json
-----------------------------------------
faculties 12
institutes 47
chairs 614
-----------------------------------------
FOR:  uni_prediction-test-muenster.json
-----------------------------------------
faculties 44
institutes 196
chairs 275
-----------------------------------------
FOR:  uni_prediction-test-koeln.json
-----------------------------------------
faculties 6
institutes 11
chairs 55
-----------------------------------------
FOR:  uni_prediction-test-aachen.json
-----------------------------------------
faculties 0
institutes 0
chairs 0
-----------------------------------------
FOR:  uni_prediction-test-hhu.json
-----------------------------------------
faculties 1
institutes 15
chairs 22
-----------------------------------------
FOR:  uni_prediction-test-paderborn.json
-----------------------------------------
faculties 0
institutes 0
chairs 0
-----------------------------------------
FOR:  uni_prediction-test-bielefeld.json
-----------------------------------------
faculties 0
institutes 0
chairs 0
-----------------------------------------
FOR:  uni_prediction-test-rub.json (endless prediction read why?)
-----------------------------------------
faculties 0
institutes 0
chairs 0
-----------------------------------------
FOR:  uni_prediction-test-siegen.json
-----------------------------------------
faculties 0
institutes 0
chairs 0
-----------------------------------------
FOR:  uni_prediction-test-bonn.json
-----------------------------------------
faculties 0
institutes 0
chairs 0
-----------------------------------------
FOR:  uni_prediction-test-wuppertal.json
-----------------------------------------
faculties 7
institutes 34
chairs 404
-----------------------------------------
FOR:  uni_prediction-test-dortmund.json
-----------------------------------------
faculties 29
institutes 8
chairs 260
-----------------------------------------

-----------------------------------------------------------------------------DATE - > 14.10.2024---------------------------------------------------------------------------
Tests for UDE,TUD, MUE after adding pagedepth(number of urls the algorithm needed to go through to get to the goal page), removing footer from pages, geometry fixes.
Faculties deduplication in evaluation2.

UDE
---
F1-Score (WITH domain FILTER) -> faculties:1.0, institutes:0.6904(> was 0.64), chairs:0.6052(< was 0.69)

**Evaluating ConceptType.FACULTY
  Predictions 12 Truth 12
  TP 12 FP 0 FN 0
  P 1.0 R 1.0 F1 1.0
**Evaluating ConceptType.INSTITUTE
  Predictions 40 Truth 45
  TP 29 FP 10 FN 16
  P 0.7435897435897436 R 0.6444444444444445 F1 0.6904761904761906
**Evaluating ConceptType.CHAIR
  Predictions 381 Truth 423
  TP 243 FP 137 FN 180
  P 0.6394736842105263 R 0.574468085106383 F1 0.6052303860523038
---

TUD
---
F1-Score (WITH domain FILTER) -> faculties:0.7391, institutes:0.2564(> was 0.16), chairs:0.2717(< was 0.29) -> low scores

**Evaluating ConceptType.FACULTY
  Predictions 29 Truth 17
	TP 17 FP 12 FN 0
  P 0.5862068965517241 R 1.0 F1 0.7391304347826086                                                      
**Evaluating ConceptType.INSTITUTE
  Predictions 8 Truth 31
   TP 5 FP 3 FN 26
  P 0.625 R 0.16129032258064516 F1 0.2564102564102564
**Evaluating ConceptType.CHAIR
  Predictions 210 Truth 261
  TP 64 FP 146 FN 197
  P 0.3047619047619048 R 0.24521072796934865 F1 0.27176220806794055
---

MUE
---
F1-Score (WITH domain FILTER) -> faculties:0.8333(>> was 0.47), institutes:0.7320(> was 0.69), chairs:0.4479(< was 0.48) 
**Evaluating ConceptType.FACULTY
  Predictions 21 Truth 15
  TP 15 FP 6 FN 0
  P 0.7142857142857143 R 1.0 F1 0.8333333333333333
**Evaluating ConceptType.INSTITUTE
  Predictions 131 Truth 135
    TP 97 FP 33 FN 38
  P 0.7461538461538462 R 0.7185185185185186 F1 0.7320754716981133
**Evaluating ConceptType.CHAIR
  Predictions 205 Truth 429
   TP 142 FP 63 FN 287
  P 0.6926829268292682 R 0.331002331002331 F1 0.44794952681388017
---



Predictions test for other unis:
-----------------------------------------
FOR:  uni_prediction-test-ude.json
-----------------------------------------
faculties 12
institutes 69
chairs 537
-----------------------------------------
FOR:  uni_prediction-test-mue.json
-----------------------------------------
faculties 21
institutes 141
chairs 214
-----------------------------------------
FOR:  uni_prediction-test-koeln2.json
-----------------------------------------
faculties 6
institutes 11
chairs 53
-----------------------------------------
FOR:  uni_prediction-test-aachen.json
-----------------------------------------
faculties 0
institutes 0
chairs 0
-----------------------------------------
FOR:  uni_prediction-test-hhu.json
-----------------------------------------
faculties 0
institutes 0
chairs 0
-----------------------------------------
FOR:  uni_prediction-test-paderborn.json (endless prediction read)
-----------------------------------------
faculties 0
institutes 0
chairs 0
-----------------------------------------
FOR:  uni_prediction-test-bielefeld.json
-----------------------------------------
faculties 0
institutes 0
chairs 0
-----------------------------------------
FOR:  uni_prediction-test-rub.json
-----------------------------------------
faculties 0
institutes 0
chairs 0
-----------------------------------------
FOR:  uni_prediction-test-bonn.json (+)
-----------------------------------------
faculties 6
institutes 11
chairs 53
-----------------------------------------
FOR:  uni_prediction-test-siegen.json
-----------------------------------------
faculties 0
institutes 0
chairs 0
-----------------------------------------
FOR:  uni_prediction-test-wuppertal.json
-----------------------------------------
faculties 7
institutes 30
chairs 404
-----------------------------------------
FOR:  uni_prediction-test-tud.json
-----------------------------------------
faculties 29
institutes 8
chairs 222
-----------------------------------------



------------------------------------------------------------------------------NEXT COMMIT - > 08.11.2024---------------------------------------------------------------------------
MOTIVATION: if we cant find faculties for a uni, we probably wont find chairs and institutes either -> improve faculties search.
-> WIDTHS_SEARCH: if no aggregator pages are found, try to find some with depth search
Start URL
  └── Depth 1: crawl page → find aggregator candidates
        └── Depth 2: crawl linked pages → find more candidates
              └── Depth 3: crawl further → find more candidates
			  
UDE:
Evaluating ConceptType.FACULTY
  Predictions 12 Truth 12
  TP 12 FP 0 FN 0
  P 1.0 R 1.0 F1 1.0
Evaluating ConceptType.INSTITUTE
  Predictions 46 Truth 45
  TP 28 FP 18 FN 17
  P 0.6086956521739131 R 0.6222222222222222 F1 0.6153846153846154
Evaluating ConceptType.CHAIR
  Predictions 399 Truth 423
  TP 221 FP 167 FN 202
  P 0.5695876288659794 R 0.5224586288416075 F1 0.5450061652281134
  
  
MUE:
Evaluating ConceptType.FACULTY
  Predictions 21 Truth 15
  TP 15 FP 6 FN 0
  P 0.7142857142857143 R 1.0 F1 0.8333333333333333
Evaluating ConceptType.INSTITUTE
  Predictions 141 Truth 135
  TP 96 FP 44 FN 39
  P 0.6857142857142857 R 0.7111111111111111 F1 0.6981818181818182
Evaluating ConceptType.CHAIR
  Predictions 316 Truth 427
  TP 169 FP 147 FN 258
  P 0.5348101265822784 R 0.3957845433255269 F1 0.4549125168236877
 
 
 TUD:
Evaluating ConceptType.FACULTY
  Predictions 17 Truth 17
  TP 16 FP 1 FN 1
  P 0.9411764705882353 R 0.9411764705882353 F1 0.9411764705882353
Evaluating ConceptType.INSTITUTE
  Predictions 8 Truth 31
  TP 3 FP 5 FN 28
  P 0.375 R 0.0967741935483871 F1 0.15384615384615383
Evaluating ConceptType.CHAIR
  Predictions 316 Truth 266
  TP 69 FP 249 FN 197
  P 0.2169811320754717 R 0.2593984962406015 F1 0.2363013698630137
 
 OTHER UNIS:
 ---
uni_prediction-test-ude2.json
faculties 12
institutes 46
chairs 387
---
uni_prediction-test-mue2.json
faculties 21
institutes 151
chairs 318
---
 uni_prediction-test-koeln.json
faculties 1
institutes 10
chairs 0
---
uni_prediction-test-aachen.json
faculties 17
institutes 0
chairs 0
---
uni_prediction-test-hhu.json
faculties 6
institutes 4
chairs 51
---
uni_prediction-test-paderborn.json -> endless predictions read.
faculties 0
institutes 0
chairs 0
---
uni_prediction-test-siegen.json -> endless predictions read.
faculties 0
institutes 0
chairs 0
---
uni_prediction-test-bielefeld.json
faculties 59
institutes 0
chairs 0
---
uni_prediction-test-wuppertal2.json
faculties 19
institutes 31
chairs 659
--------------------------------------DISTILBERT AND FLAN--------------------------------------
WIDTHS_SEARCH -> DISTILBERT & FLAN for FACulties
MOTIVATION: Similar to ML-Approach -> take URL + page depth + headings + body text of faculty web pages and OTHER web pages and train a distilbert on it. Then try to predict.
Trained and tested on wep pages (UDE +Münster +  Additional faculty URLs from TUD, Bielefeld, Paderborn, RUB, HHU Düsseldorf, Cologne, RWTH Aachen, Bonn, Siegen, Wuppertal)

<-------------------DISTILBERT 636/160 (80/20) TEST FOR 500 UNI PAGES------------------------->

number of faculties: 298
number of others: 498
number of db entries: 500
So we take 298 FACULTY entries and ~500 OTHERS and make a dataset of it.

->
all: 160

true_pos: 27
true_neg: 96
false_pos: 4
false_neg: 33

precision: 0.8709677419354839
recall: 0.45
-->f1_score: 0.5934065934065934


<--------------------DISTILBERT 1034/260 (80/20)TEST FOR 1000 UNI PAGES------------------------>


number of faculties: 298
number of others: 996
number of db entries: 1000
So we take 298 FACULTY entries and ~1000 OTHERS and make a dataset of it.
->
all: 260

true_pos: 19
true_neg: 200
false_pos: 0
false_neg: 41

precision: 1.0
recall: 0.31666666666666665
-->f1_score: 0.4810126582278481


<-------------FLAN_t5_BASE 437/110 (80/20)TEST FOR 500 UNI PAGES-------------------------->


----------------------------------------------FLAN-T5-----------------------------------------
Why so bad? Not much faculties as true positives given. Reason? Additional wasn't added like in DiSTILBERT.


(ADDED FACS)
-------------------------------------------T5 500 636/160-----------------
number of faculties: 298
number of others: 498
number of db entries: 500
So we take 298 FACULTY entries and ~500 OTHERS and make a dataset of it.
all: 160

true_pos: 54
true_neg: 63
false_pos: 35
false_neg: 7

precision: 0.6067415729655347
recall: 0.885245901494222
-->f1_score: 0.7199999950782222

-------------------------------------------T5 1000 1034/260 ---------------
number of faculties: 298
number of others: 996
number of db entries: 1000
So we take 298 FACULTY entries and ~1000 OTHERS and make a dataset of it.
all: 260

true_pos: 59
true_neg: 111
false_pos: 83
false_neg: 6

precision: 0.4154929577172188
recall: 0.9076923075526628
-->F1_score: 0.5700483048155149
(ADDED FACS)
------------------------------------------------------------------------------------------------

-----------------------------------------------------------------NEXT ----------------------------------------------------------------------------
Moving on to llms: previous approaches didnt lead us to satisfying results. 
MOTIVATION: What if we let LLM decide whether a web page is a faculty, institute, chair main page or not based on its content?
Using LLama feed the page text to llm and let it predict the concept of the page.

Prompt for faculties:
System prompt="""
"You are a classification assistant. You will be given attributes\n",
    "                                of university webpages as key value pairs. These attributes include: 'url' (url of a web page), \n",
    "                                'pagedepth' (distance of a webpage from the main university homepage, a lower page depth indicates a higher probability of a faculty landing page, while a higher page depth indicates a lower probability),\n",
    "                                'found_link_text_flag' (whether there exists a text in previous webpages that also pointed to the current webpage and also exists on the currently considering webpage),\n",
    "                                'headings' (the headings of the webpage, this attribute is important),\n",
    "                                'text': the extracted content of a webpage,\n",
    "                                'label': whether it is a faculty landing webpage or not.\n",
    "                                You will use these attributes to determine, whether a webpage attributes is 0 (no faculty main landing page) or 1 (is a faculty main landing page).\n",
    "                                \n",
    "                                You will answer only with Positive or Negative\"\"\"\n"
"""
User prompt="""
Classify the following webpages as faculty landing page (positive) or no faculty landing page (negative):\\n\\n\"\n",
    "                    \"Here are some Examples:\\n\"\n",
    "                    f\"1. url : '{url_faculty[0]}', pagedepth: '{pagedepth_faculty[0]}', found_link_text_flag: '{found_link_text_flag_faculty[0]}', headings: '{headings_faculty[0]}', text: '{text_faculty_single}' -> Positive (label: 1)\\n\"\n",
    "                    f\"2. url : '{url_others[0]}', pagedepth: '{pagedepth_others[0]}', found_link_text_flag: '{found_link_text_flag_others[0]}', headings: '{headings_others[0]}', text: '{text_others_single}' -> Negative (label: 0)\\n\"\n",
    "                    f\"3. url : '{example_institute_url}', pagedepth: '{example_institute_pagedepth}', found_link_text_flag: '{example_institute_found_link_text_flag}', headings: '{example_institute_headings}', text: '{example_institute_text_content_single}' -> Negative (label: 0)\\n\\n\"\n",
    "                    f\"Now classify this message:\\n{text_single}\\n\"\n"
"""
Prompt for institutes/chairs:
User prompt="""
prompt = (\n",
    "        \"Classify the following webpages as institute landing page (positive) or chair landing page (positive) or no institute and chair landing page (negative):\\n\\n\"\n",
    "        \"Here are some Examples:\\n\"\n",
    "        f\"1. url : '{url_institutes[0]}', pagedepth: '{pagedepth_institutes[0]}', found_link_text_flag: '{found_link_text_flag_institutes[0]}', headings: '{headings_institutes[0]}', text: '{text_institutes_single[0]}' -> Positive (label: 1)\\n\"\n",
    "        f\"1. url : '{url_chairs[0]}', pagedepth: '{pagedepth_chairs[0]}', found_link_text_flag: '{found_link_text_flag_chairs[0]}', headings: '{headings_chairs[0]}', text: '{text_chairs_single[0]}' -> Positive (label: 1)\\n\"\n",
    "        f\"2. url : '{url_others[0]}', pagedepth: '{pagedepth_others[0]}', found_link_text_flag: '{found_link_text_flag_others[0]}', headings: '{headings_others[0]}', text: '{text_others_single}' -> Negative (label: 0)\\n\\n\"\n",
    "        f\"Now classify this message:\\n{text_single}\\n\"\n",
"""
System prompt="""
You are a classification assistant. You will be given attributes\n",
    "                                of university webpages as key value pairs. These attributes include: 'url' (url of a web page), \n",
    "                                'pagedepth' (distance of a webpage from the main university homepage),\n",
    "                                'found_link_text_flag' (whether there exists a text in previous webpages that also pointed to the current webpage and also exists on the currently considering webpage),\n",
    "                                'headings' (the headings of the webpage, this attribute is important),\n",
    "                                'text': the extracted content of a webpage,\n",
    "                                'label': whether it is a institute or chair landing webpage or not.\n",
    "                                You will use these attributes to determine, whether a webpage attributes is 0 (no institute or chair main landing page) or 1 (is a institute or chair main landing page)\n",
    "                                You will answer only with Positive or Negative\"\"\"\n",
"""
RESULTS BELOW:

<-----------------------------------------------------------------UDE------------------------------------------------------------------------------>
<-----------------------OLD RESULTS (TAKE THIS) (come from the results file created 2 years ago------------------------>
+-----------------------------------------------+-----------+------------+---------+
| Run                                           | Faculty F1| Institute F1 | Chair F1|
+-----------------------------------------------+-----------+------------+---------+
| ude_nothing                                   | 0.9565    | 0.6429     | 0.4041  |
| ude_only_geometry                             | 1.0000    | 0.6818     | 0.6014  |
| ude_only_disambiguate                         | 0.9565    | 0.6429     | 0.4068  |
| ude_only_direct                               | 0.9565    | 0.6429     | 0.4525  |
| ude_only_indirect                             | 0.9565    | 0.6429     | 0.4014  |
| ude_only_meta                                 | 0.9565    | 0.6429     | 0.5193  |
| ude_only_dynamic                              | 0.9565    | 0.6429     | 0.4188  |
| ude_only_widths_search                        | 0.9565    | 0.6265     | 0.4041  |
| ude_only_using_llm                            | 1.0000    | 0.7593     | 0.6289  |<-- best results overall
| ude_all                                       | 1.0000    | 0.7207     | 0.2644  |
| ude_all_no_width                              | 0.9231    | 0.7069     | 0.2355  |
+-----------------------------------------------+-----------+------------+---------+



------------------------------------------------------------------------------------MUENSTER-------------------------------------------------------------------

<-----------------------OLD RESULTS (TAKE THIS) (come from the results file created 2 years ago------------------------>
+------------------------+----------+------------+--------+
| Run          |       FACULTY F1  | INSTITUTE F1  | CHAIR F1  |
+------------------------+----------+------------+--------+
| nothing                | 0.966    | 0.484      | 0.423  |
| only_geometry          | 1.000    | 0.483      | 0.445  |<-- best for faculties
| only_disambiguate      | 0.966    | 0.486      | 0.423  |
| only_direct            | 0.966    | 0.484      | 0.423  |
| only_indirect          | 0.966    | 0.477      | 0.414  |
| only_meta              | 0.800    | 0.484      | 0.421  |
| only_dynamic           | 0.966    | 0.484      | 0.450  |<-- best chairs
| only_widths_search     | 0.966    | 0.484      | 0.423  |
| only_using_llm         | 0.909    | 0.509      | 0.404  |
| all                    | 0.857    | 0.571      | 0.418  |<-- best for Institutes
| all_no_width           | 0.882    | 0.317      |   -    |
+------------------------+----------+------------+--------+


------------------------------------------------------------------------------------DORTMUND-------------------------------------------------------------------
<-----------------------NEW RESULTS------------------------>
|Run                                   | Faculty F1 | Institute F1 | Chair F1 |
|--------------------------------------+------------+--------------+-------|---
|nothing                               | 0.0000     | 0.1714       | 0.0821|
|only_geometry                         | 0.0000     | 0.1714       | 0.1190|
|only_disambiguate                     | 0.0000     | 0.1714       | 0.0821|
|only_direct                           | 0.0000     | 0.1579       | 0.0821|
|only_indirect                         | 0.9412     | 0.1579       | 0.1636|
|only_meta                             | 0.0000     | 0.1714       | 0.1020|
|only_dynamic                          | 0.0000     | 0.1538       | 0.1604|
|only_widths_search                    | 0.0000     | 0.1714       | 0.0821|
|only_using_llm                        | 0.0000     | 0.1714       | 0.0821|
|all                                   | 0.9412     | 0.0000       | 0.0000|
|all_no_width                          | 0.9412     | 0.0000       | 0|.0000

The LLM-only approach doest scale well. It shows acceptable results for UDE, but fails for MUENSTER and DORTMUND



