From 62cb7faceab2bdf68ef9ffd1d9e35f47dc4b57c0 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 15 Sep 2017 13:42:59 +0200 Subject: [PATCH] fixed location --- build/service/Tesseract.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/build/service/Tesseract.php b/build/service/Tesseract.php index 4d08ab5..5741d0d 100755 --- a/build/service/Tesseract.php +++ b/build/service/Tesseract.php @@ -70,7 +70,7 @@ } /* (5) Manage if empty */ - if( count($lines) < 2 ) + if( count($lines) < 3 ) throw new \Exception("Nothing read"); } @@ -83,10 +83,10 @@ $title = $lines[0]; /* (2) Get last non-empty line */ - for( $i = count($lines)-1 ; $i > 0 ; $i-- ){ + for( $i = 2 ; $i < count($lines) ; $i++ ){ // Amphi ... // - if( preg_match('@^a[nm]([bp][hln])?[ir] ?(.+)$@i', $lines[$i], $m) ) // 'amphi A', 'amphi 600 droit' + if( preg_match('@^a[nm](?:[bp][hln])?[ir] ?(.+)$@i', $lines[$i], $m) ) // 'amphi A', 'amphi 600 droit' return [ $title, "Amphi ${m[1]}" ]; @@ -94,12 +94,15 @@ if( preg_match('@^[S|5] ?(\d+)@i', $lines[$i], $m) ) // 'S10', 'S22' return [ $title, "S. ${m[1]}" ]; + // If not 'Cours', 'CTD', 'TD', 'TP' // + if( preg_match('@^(co[hu][trn][s5]|t[dp|c[mn]|ct[dp])@i', $lines[$i]) ) + continue; } } - return [ $title, null ]; + return [ $title, $lines[2] ]; }