Changeset 37139


Ignore:
Timestamp:
2023-01-15T00:58:22+13:00 (13 days ago)
Author:
davidb
Message:

Need to replace spaces with underscore _

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/structured-image/trunk/perllib/plugins/GoogleVisionAPIConverter.pm

    r37117 r37139  
    310310        $ocr_text = $decoded_json->{'labelAnnotations'};   
    311311        foreach my $label (@{$ocr_text}) {
    312             # write to metadata : 'description'='Book' 'score'='0.9' 'topicality'='0.9' 'mid'='/m/0123'
     312            # Write to metadata : 'description'='Book' 'score'='0.9' 'topicality'='0.9' 'mid'='/m/0123'
    313313            $doc_obj->add_utf8_metadata($section, "description", $label->{'description'});
    314314            $doc_obj->add_utf8_metadata($section, "score",       $label->{'score'});
     
    316316            $doc_obj->add_utf8_metadata($section, "mid",         $label->{'mid'});
    317317
    318         # write to metadata : 'descriptions'='Book' 'Book_score'='0.9' 'Book_topicality'='0.9' 'Book_mid'='/m/0123'
     318        # Write to metadata, e.g.,: 'descriptions'='Book' 'Book_score'='0.9' 'Book_topicality'='0.9' 'Book_mid'='/m/0123'
     319        #
     320        # ... but first generate a 'safe' metadata name, derived from the metadata value for 'description'
     321        my $description_mdvalue = $label->{'description'};
     322        my $description_mdname = $description_mdvalue;
     323        $description_mdname = s/\s/_/g; # replace spaces with underscores
     324       
    319325            $doc_obj->add_utf8_metadata($section, "descriptions", $label->{'description'});
    320             $doc_obj->add_utf8_metadata($section, $label->{'description'} . "_score", $label->{'score'});
    321             $doc_obj->add_utf8_metadata($section, $label->{'description'} . "_topicality", $label->{'topicality'});
    322             $doc_obj->add_utf8_metadata($section, $label->{'description'} . "_mid", $label->{'mid'});
     326            $doc_obj->add_utf8_metadata($section, $description_mdname . "_score", $label->{'score'});
     327            $doc_obj->add_utf8_metadata($section, $description_mdname . "_topicality", $label->{'topicality'});
     328            $doc_obj->add_utf8_metadata($section, $description_mdname . "_mid", $label->{'mid'});
    323329
    324330        }
Note: See TracChangeset for help on using the changeset viewer.