Quantcast

Search & replace property values?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Search & replace property values?

Sean Gordon
I'm looking for a way to search & replace specific property values on a SMW (Version 1.8.0.4) built with Semantic Forms (2.5.2). For example, I want to capitalize the first letter of a property (development > Development) on all existing pages with that property value (this seems necessary when changing the property type from string to page).

I found the Replace Text extension, but I don't see a way to limit the search/replace to a particular property. I've started writing a mwclient python script to query the relevant pages and parse the semantic structure, but I'm thinking others must have already faced this issue (although I couldn't find anything on this list)?

Thanks - Sean
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Search & replace property values?

Neill Mitchell
Hi Sean.

You just need to ensure your search term is explicit so it doesn't
replace the wrong text. Luckily, this is easy to do.
You need to specify the full field in your template. Open a page
containing the value you want to change using the edit tab instead of
edit with form. You will then see the "raw" page with all your template
fields in it.

So for example, if the property name is hasDepartment and the value is
development, in the page you'll see:

|hasDepartment=development

So in ReplaceText search for hasDepartment=development and replace it
with hasDepartment=Development (no need for the | char)
Ensure the replacement text is the full field definition and not just
the value!

Remember to replace development with Development in the property
definition page as well. It might be worth backing up your database
before doing all this to be safe.

Finally, you will have to run the SMW_refreshData.php maintenance script
to ensure all the new property spellings are picked up.

Cheers
Neill.

On 26/06/13 03:30, Sean Gordon wrote:

> I'm looking for a way to search & replace specific property values on a SMW
> (Version 1.8.0.4) built with Semantic Forms (2.5.2). For example, I want to
> capitalize the first letter of a property (development > Development) on all
> existing pages with that property value (this seems necessary when changing
> the property type from string to page).
>
> I found the Replace Text extension, but I don't see a way to limit the
> search/replace to a particular property. I've started writing a mwclient
> python script to query the relevant pages and parse the semantic structure,
> but I'm thinking others must have already faced this issue (although I
> couldn't find anything on this list)?
>
> Thanks - Sean
>
>
>
>
> --
> View this message in context: http://wikimedia.7.x6.nabble.com/Search-replace-property-values-tp5007856.html
> Sent from the Semantic Mediawiki - User mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> Semediawiki-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Search & replace property values?

Sean Gordon
Hi Neill,

Thanks for the great instructions on using the Replace_Text extension. I
struggled a bit with replacing a value in a multi-valued field (built using
arraymap), but these regular expressions seem to work:

To replace one value with another:
Original text: (Property name=.*)badvalue(.*\n)
Replacement text: $1goodvalue$2

To remove a value (must remove delimiter too):
Original text: (Property name=.*)badvalue,|,badvalue(.*\n)
Replacement text: $1$2

Sean



------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Loading...