How to adjust translations

First import the soilpulsecore package and get storage connection through NullConnector - the project structure and all project-related data will be loaded from dedicated filesystem directory in user’s home directory.

Load existing project by providing user_id and the project id.

note: in case of filesystem stored SoilPulse project (using NullConnector) the user_id parameter is not relevant and all projects are accessible to local user.

[2]:
from soilpulsecore.db_access import NullConnector
from soilpulsecore.project_management import *
from soilpulsecore.resource_managers import filesystem, data_structures, json

dbcon = NullConnector()
project = ProjectManager(dbcon, user_id=1, id=1)
> Crawler type 'zero' registered.
Container type 'filesystem' registered
* Keywords database soilpulse\databases\keywords_filesystem registered as 'filesystem'
Container type 'file' registered
Container type 'directory' registered
Container type 'archive' registered
> Crawler type 'filesystem' registered.
> Crawler type 'csv' registered.
> Crawler type 'txt' registered.
Container type 'table' registered
> Crawler type 'table' registered.
Container type 'column' registered
> Crawler type 'column' registered.
Container type 'json' registered
* Keywords database soilpulse\databases\keywords_json registered as 'json'
> Crawler type 'json' registered.
failed to load concept vocabulary 'AGROVOC' from 'vocabularies\agrovoc.json'
failed to load concept vocabulary 'TestConceptVocabulary' from 'vocabularies\_concepts_vocabulary_1.json'
failed to load method vocabulary 'TestMethodsVocabulary' from 'vocabularies\_methods_vocabulary_1.json'
loaded methods vocabularies:
failed to load units vocabulary 'TestUnitsVocabulary' from 'vocabularies\_units_vocabulary_1.json'
loaded units vocabularies:

To make sure that the project is correctly loaded we can again show its contents:

[3]:
project.showContainerTree()

================================================================================
SoilPulse testing
container tree:
--------------------------------------------------------------------------------
1 - runoffdb_excerpt.csv (file, 56.2 kB, 18.11.2024/18.11.2024) [1]  >root
. 2 - runoffdb_excerpt (table - table) [20] ^1
. . 3 - locality (column - column) [0] ^2
      concepts:
        locality: 'locality' locality@ownvocab (*own)
. . 4 - latitude (column - column) [0] ^2
. . 5 - longitude (column - column) [0] ^2
. . 6 - run ID (column - column) [0] ^2
. . 7 - date (column - column) [0] ^2
      concepts:
        date: 'date of experiment' date_of_experiment@ownvocab (methodic)
. . 8 - plot ID (column - column) [0] ^2
. . 9 - simulator (column - column) [0] ^2
      concepts:
        simulator: 'rainfall simulator' rainfall_simulator@ownvocab (*own)
. . 10 - crop (column - column) [0] ^2
. . 11 - crop type (column - column) [0] ^2
. . 12 - initial cond. (column - column) [0] ^2
. . 13 - init. moisture (column - column) [0] ^2
      concepts:
        init. moisture: 'initial moisture' initial_moisture@ownvocab (*own)
. . 14 - canopy cover (column - column) [0] ^2
      concepts:
        canopy cover: 'canopy cover' canopy_cover@ownvocab (*own)
. . 15 - BBCH (column - column) [0] ^2
      concepts:
        bbch: 'BBCH' bbch@ownvocab (*own)
. . 16 - rain intensity [mm.h^-1] (column - column) [0] ^2
. . 17 - time to runoff (column - column) [0] ^2
      concepts:
        time to runoff: 'time to runoff' time_to_runoff@ownvocab (*own)
. . 18 - bulk density [g.cm^-3] (column - column) [0] ^2
. . 19 - total time [s] (column - column) [0] ^2
. . 20 - total rainfall [mm.h^-1] (column - column) [0] ^2
. . 21 - total discharge [l] (column - column) [0] ^2
. . 22 - total soil loss [g] (column - column) [0] ^2
================================================================================


Now we fine tune the concepts, methods and units assigned to the containers. Add or remove translation assignments from the container by appropriate methods.

[5]:
# get reference to a container to work with
cont = project.getContainerByID(15)
# remove all concepts currently assigned to the container
cont.removeAllConcepts()
print(cont)
# create a concept to be assigned
new_concept = {"term": "phenophase", "vocabulary": "ad_hoc_vocabulary", "uri": "this/is/non/existent/uri"}
# assign the
cont.addStringConcept("BBCH", new_concept)
print(cont)

|  # 15  |  name: 'BBCH'  |  parent: 2
|  class: ColumnContainer|  crawler class: ColumnCrawler
|  string-concept translations: -
|  string-method translations: -
|  string-unit translations: -


|  # 15  |  name: 'BBCH'  |  parent: 2
|  class: ColumnContainer|  crawler class: ColumnCrawler
|  string-concept translations: |       "BBCH"|         {'term': 'phenophase', 'vocabulary': 'ad_hoc_vocabulary', 'uri': 'this/is/non/existent/uri'}
|  string-method translations: -
|  string-unit translations: -