Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2602007
move vendor dir outside classmap dirs
Sep 19, 2023
f28b626
extract FileWriter class for export
Sep 21, 2023
0ad37de
fix static call of nonstatic method - trouble in testing
Sep 23, 2023
439281b
unit tests for conll i json export
Sep 26, 2023
e49806f
unit tests with tokens, annotations, relations, lemmas and attributes
Oct 4, 2023
15a5e71
mocked all Ccl input clases for tests
Oct 7, 2023
0f56fd7
export unit tests for elementary Ccl elements
Oct 9, 2023
6da0801
unit test for export with relation
Oct 12, 2023
88eddcf
synchro with relation export startegy change
Oct 20, 2023
f209e0f
tests for lemmas and anntags exports
Oct 21, 2023
42aac8a
XML export output full tests
Oct 27, 2023
b43b39f
more tests and drop unused code
Oct 28, 2023
bcdb002
tests for token setAnnotation
Oct 31, 2023
723adf2
tests for .txt file generation
Nov 8, 2023
614d2ed
extract method for .txt file generation
Nov 13, 2023
7428fbc
extract method for .txt file generation
Nov 14, 2023
58dd9ce
extract lemma checker
Nov 14, 2023
5ef619b
extract relations checker
Nov 15, 2023
8b3f77c
extract method for unique sorting annotations array
Nov 15, 2023
b2c0129
extract method for dispatch elements table
Nov 15, 2023
7c0e502
extract method for generateCcl for export
Nov 16, 2023
656c947
extract updateExtractorStats method
Nov 16, 2023
ba0de59
extract runExtractor method
Nov 16, 2023
fabaf83
more reflection methods in tests
Nov 27, 2023
66f9400
decomposition CclStruct.php to class files
Nov 28, 2023
5fd2b2f
duplicate tokens in test ccl on main level & on tree inside
Nov 30, 2023
c9ec2e0
test lemma in XML with emulated Ccl
Dec 1, 2023
a1402d7
all modules real test for XML export
Dec 1, 2023
eb080ec
remove not really used ExportManager class
Dec 7, 2023
e0f8a9e
Change CclFactory with extended ccl version
Dec 7, 2023
92e9c02
minor warnings that crashed execution
Dec 7, 2023
6c5e9b5
missing name field in DB annotation data changed to type
Dec 9, 2023
b3149a7
correct read from DB obscured by attr user annotation user_id data
Dec 9, 2023
baa9a43
fix tags export
Dec 11, 2023
c1c3a80
in custom export value annotation field is not obligatory
Dec 11, 2023
9944b9a
subcorpora_id in record may be NULL
Dec 11, 2023
293722a
fix usage of unexisting in DB fields
Dec 14, 2023
0b6ab59
getReport call twice in document_export - one call removed
Dec 16, 2023
62a6d4b
change behavior of export lemma from annotation records
Dec 16, 2023
8311b93
add lemmas param do JSON generate method
Dec 18, 2023
753d4df
no lemma export if coresponding annotations doesn't exists
Dec 18, 2023
2ce1052
checking subsets lemma or attributes, forces annotation column check …
Dec 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
engine/templates_c/*
engine/include/vendor
vendor
config/config.local.php
docker/www/config/config.local.php
secured_data/ccls
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"config": {
"platform": {"php":"5.6"},
"vendor-dir": "engine/include/vendor"
"platform": {"php":"5.6"}
},

"autoload": {
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
- ./docker/www/config:/home/inforex/config
- ./secured_data:/home/inforex/secured_data
- ./phpunit:/home/inforex/phpunit
- ./vendor:/home/inforex/vendor
depends_on:
- db
restart: always
Expand Down
4 changes: 2 additions & 2 deletions docker-dev-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

composer update

AUTOLOAD=engine/include/vendor/autoload.php
AUTOLOAD=vendor/autoload.php

if [ -f $AUTOLOAD ]; then
docker-compose build
docker-compose up -d
else
echo -e "[\e[31mERROR\e[0m] $AUTOLOAD not found"
echo -e "Make sure that '\e[32mcomposer\e[0m' is installed in order to run '\e[32mcomposer update\e[0m' and generate $AUTOLOAD"
fi
fi
2 changes: 1 addition & 1 deletion engine/external/pear/HTML/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @link http://pear.php.net/package/HTML_Select
*/

require_once __DIR__ . '/../../../include/vendor/autoload.php';
require_once __DIR__ . '/../../../../vendor/autoload.php';

/**
* Class to dynamically create an HTML SELECT
Expand Down
2 changes: 1 addition & 1 deletion engine/include.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
$include_paths[] = get_include_path();
set_include_path( implode(PATH_SEPARATOR, $include_paths) );

require_once __DIR__ . '/include/vendor/autoload.php';
require_once __DIR__ . '/../vendor/autoload.php';
4 changes: 2 additions & 2 deletions engine/include/database/CDbAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static function getAnnotationTypesBySets($report_ids, $relation_ids){

static function getAnnotationsBySets($report_ids=null, $annotation_layers=null, $annotation_names=null, $stage = null){
global $db;
$sql = "SELECT *, raa.`value` AS `prop` " .
$sql = "SELECT ra.*, at.*, raa.annotation_id, raa.annotation_attribute_id, raa.`user_id` AS `attr_user_id`, raa.`value` AS `prop` " .
" FROM reports_annotations ra" .
" LEFT JOIN annotation_types at ON (ra.type=at.name) " .
" LEFT JOIN reports_annotations_attributes raa ON (ra.id=raa.annotation_id) ";
Expand Down Expand Up @@ -203,7 +203,7 @@ static function getAnnotationsBySets($report_ids=null, $annotation_layers=null,
*/
static function getAnnotationsBySubsets($report_ids=null, $annotation_subset_ids=null){
global $db;
$sql = "SELECT *, ra.type, raa.`value` AS `prop` " .
$sql = "SELECT ra.*, at.*, raa.annotation_id, raa.annotation_attribute_id, raa.`user_id` AS `attr_user_id`, raa.`value` AS `prop` " .
" FROM reports_annotations ra" .
" LEFT JOIN annotation_types at ON (ra.type=at.name) " .
" LEFT JOIN reports_annotations_attributes raa ON (ra.id=raa.annotation_id) ";
Expand Down
36 changes: 14 additions & 22 deletions engine/include/database/CDbCorpusRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,28 +163,20 @@ static function getRelationsByRelationSetIds($relation_set_ids){
return $db->fetch_rows($sql);
}

//TODO to delete
static function getRelationsBySets($report_ids, $relation_type_ids){
global $db;
$sql = "SELECT reports_annotations.report_id as report_id, rel.id, rel.relation_type_id, rel.source_id, rel.target_id, relation_types.name " .
"FROM " .
"(SELECT * " .
"FROM relations " .
"WHERE source_id IN " .
"(SELECT id " .
"FROM reports_annotations " .
"WHERE report_id IN('" . implode("','",$report_ids) . "')) " .
"AND relation_type_id " .
"IN (".implode(",",$relation_type_ids).")) rel " .
"LEFT JOIN relation_types " .
"ON rel.relation_type_id=relation_types.id " .
"LEFT JOIN reports_annotations " .
"ON rel.source_id=reports_annotations.id ";
return $db->fetch_rows($sql);
}

static function getRelationsBySets2($report_ids=null, $relation_set_ids=null, $relation_type_ids=null, $stage_ids=null, $user_ids=null){
static function getRelationsBySets($report_ids=null, $relation_set_ids=null, $relation_type_ids=null, $stage_ids=null, $user_ids=null, $relation_stages=array()){
global $db;

// if $relation_stages not set is equal $stage_ids - stages of
// relation are identical as stages of annotations
if( is_array($relation_stages) && (count($relation_stages)==0)) {
$relation_stages = $stage_ids;
} // if not set

if (is_array($relation_stages) && (count($relation_stages)>0)) {
$relationStages = "stage IN('".implode("','",$relation_stages)."') AND";
} else { // if $relation_stages==null default is 'final'
$relationStages = "stage = 'final' AND";
}
$sql = "SELECT reports_annotations.report_id as report_id, " .
" rel.id, " .
" rel.relation_type_id, " .
Expand All @@ -196,7 +188,7 @@ static function getRelationsBySets2($report_ids=null, $relation_set_ids=null, $r
"FROM " .
"(SELECT * " .
"FROM relations " .
"WHERE stage = 'final' AND source_id IN " .
"WHERE ".$relationStages." source_id IN " .
"(SELECT id " .
"FROM reports_annotations " .
"WHERE report_id IN('0','" . implode("','",$report_ids) . "')) " .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@
* See LICENCE
*/

class CclFactory{
class CclExportDocument extends CclDocument {

/**
* $report --- tablica asocjacyjna z atrybutami dokumentu (jak z tabeli reports)
* $tokens --- tablica asocjacyjna z wartościami 'from', 'to' i 'eos'
* $tags ---
* function creates ccl document using 'eos' token attributes to match end of sentence
* see: createFromReportAndTokensSentence
* see: createFromReportAndTokensSentence, was createFromReportAndTokens()
*/
function createFromReportAndTokens(&$report, &$tokens, &$tags){
public function __construct(&$report, &$tokens, &$tags){
$fileName = str_pad($report['id'],8,'0',STR_PAD_LEFT);

$ccl = new CclDocument();
$ccl->setFileName($fileName);
$ccl->setSubcorpus(preg_replace("/[^\p{L}|\p{N}]+/u","_",$report['name']));
$ccl->setReport($report);
$this->setFileName($fileName);
$this->setSubcorpus(
// SW ?? there are not 'name' column in DB table reports
isset($report['name'])
? preg_replace("/[^\p{L}|\p{N}]+/u","_",$report['name'])
: ""
);
$this->setReport($report);

$chunkList = explode('<\\chunk>', $report['content']);

Expand All @@ -34,7 +38,10 @@ function createFromReportAndTokens(&$report, &$tokens, &$tags){
$chunk = str_replace(">","> ",$chunk);
preg_match_all($pattern, $chunk, $matches);
$type = "p";
if (is_array($matches) && array_key_exists(1, $matches))
if (is_array($matches)
&& array_key_exists(1, $matches)
&& array_key_exists(0,$matches[1])
)
$type = $matches[1][0];
$tmpStr = trim(preg_replace("/\s\s+/"," ",custom_html_entity_decode(strip_tags($chunk))));
$tmpStr2 = preg_replace("/\n+|\r+|\s+/","",$tmpStr);
Expand Down Expand Up @@ -93,7 +100,7 @@ function createFromReportAndTokens(&$report, &$tokens, &$tags){
}

$s->addToken($t);
$ccl->addToken($t);
$this->addToken($t);
if ( $token['eos'] ){
$c->addSentence($s);
$s = new CclSentence();
Expand All @@ -108,37 +115,36 @@ function createFromReportAndTokens(&$report, &$tokens, &$tags){
else
$sentenceIndex--;
}
$ccl->addChunk($c);
$this->addChunk($c);
}

return $ccl;
}
} // __construct()


function setAnnotationLemmas(&$ccl, &$annotation_lemmas){
protected function setAnnotationLemmas($annotation_lemmas){
if (empty($annotation_lemmas)){
return false;
}

foreach($annotation_lemmas as $lemma){
$ccl->setAnnotationLemma($lemma);
$this->setAnnotationLemma($lemma);
}
}

function setAnnotationProperties(&$ccl, &$annotation_properties){
protected function setAnnotationProperties($annotation_properties){
if (empty($annotation_properties)){
return false;
}

foreach($annotation_properties as $property){
$ccl->setAnnotationProperty($property);
$this->setAnnotationProperty($property);
}
}

/**
*
*/
function setAnnotationsAndRelations(&$ccl, &$annotations, &$relations){
protected function setAnnotationsAndRelations(&$annotations, &$relations){
if (empty($annotations)) return false;
$annotationsById = array();
$continuousAnnotationIds = array();
Expand All @@ -157,7 +163,7 @@ function setAnnotationsAndRelations(&$ccl, &$annotations, &$relations){

foreach ($annotations as &$annotation){
if ( !in_array($annotation['id'], $continuousAnnotationIds)){
$ccl->setAnnotation($annotation);
$this->setAnnotation($annotation);
} else {
$continuousAnnotations[$annotation['id']] =& $annotation;
}
Expand All @@ -169,7 +175,7 @@ function setAnnotationsAndRelations(&$ccl, &$annotations, &$relations){
$target_id = $cRelation['target_id'];
if (array_key_exists($source_id, $annotationsById) &&
array_key_exists($target_id, $annotationsById)){
$ccl->setContinuousAnnotation2(
$this->setContinuousAnnotation2(
$continuousAnnotations[$source_id],
$continuousAnnotations[$target_id]);
} else if (array_key_exists($source_id, $annotationsById) ||
Expand All @@ -179,7 +185,7 @@ function setAnnotationsAndRelations(&$ccl, &$annotations, &$relations){
$e->setFunctionName("setAnnotationsAndRelations");
$e->addObject("relation", $cRelation);
$e->addComment("008 no source or target annotation in a continuous relation");
$ccl->addError($e);
$this->addError($e);
}
}

Expand All @@ -188,7 +194,7 @@ function setAnnotationsAndRelations(&$ccl, &$annotations, &$relations){
$target_id = $nRelation['target_id'];
if (array_key_exists($source_id, $annotationsById) &&
array_key_exists($target_id, $annotationsById)){
$ccl->setRelation(
$this->setRelation(
$annotationsById[$nRelation['source_id']],
$annotationsById[$nRelation['target_id']],
$nRelation);
Expand All @@ -198,10 +204,21 @@ function setAnnotationsAndRelations(&$ccl, &$annotations, &$relations){
$e->setFunctionName("setAnnotationsAndRelations");
$e->addObject("relation", $nRelation);
$e->addComment("009 no source or target annotation in a normal relation");
$ccl->addError($e);
$this->addError($e);
}
}
return true;
}

}
public function setCclProperties(&$annotations, &$relations, $lemmas, $attributes ) {

$this->setAnnotationsAndRelations($annotations, $relations);
// Lemmas will be added only if annotations are too
if(is_array($annotations) && (count($annotations)>0)) {
$this->setAnnotationLemmas($lemmas);
}
$this->setAnnotationProperties($attributes);

} // setCclProperties()

} // CclExportDocument class
Loading