protegeproject / cellfie-plugin

Protégé plugin for creating OWL ontologies from spreadsheets
104 stars 27 forks source link

Replacing multiple strings using mm:replaceAll #60

Closed Rawrversio closed 8 years ago

Rawrversio commented 8 years ago

I have imported a Human Activity Recognition dataset using Celfie plugin in Protege 5.0 The sensors are specified using numeric IDs in the excel sheet, While importing I want to replace all the IDs with their respective sensor names. For example 9 -> Bathroom_Door 24 -> Microwave

Problem is that mm:replaceAll allows only one value to be replaced. the syntax goes something like this Types: @D* (mm:replaceAll( "9","Bathroom_Door"))

I tried multiple possibilities such as

Types: @D* (mm:replaceAll( {24,'Bedroom_Door'}, {9,'Plates_Cupboard'} )) AND Types: @D* (mm:replaceAll( "24","Bedroom_Door", "9","Plates_Cupboard" )) AND Types: @D* (mm:replaceAll( "9","Bathroom_Door")) followed by Types: @D* (mm:replaceAll( "24","Microwave"))

None seems to be doing it.

Any suggestions on how to do it ?

csnyulas commented 8 years ago

The mm:replaceAll function replaces all occurrences that match a regular expression with another string: https://github.com/protegeproject/mapping-master/wiki/MappingMasterDSL#processing-cell-content

There is no support for what you are trying to do. Incorporating such maps in transformation rules that would work for the general use case would be too complicated, and I don't think Cellfie/MappingMaster will ever provide this capability.

As of alternative solutions, I would do this mapping in the spreadsheet, if possible. This would be the simplest, most straightforward way. Another solution would be to use IRIs in the ontology that incorporate these IDs in them, and use the human readable names as their label. If you would choose this solution you could write a transformation rule like:

...
    Types: @D*(rdf:ID=("http://your_sensor_name_prefix", @D*))

The labels could come from a separate sheet, even a separate spreadsheet, which you have control over.

Class: @A*(rdf:ID=("http://your_sensor_name_prefix", @A*) rdfs:label=@B*)