Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/content/60/9972860/html/smf/Sources/Load.php(225) : runtime-created function on line 3
capitalize the fist letter of location
The DAM Forum
Welcome, Guest. Please login or register.
November 22, 2019, 12:11:38 AM

Login with username, password and session length
Search:     Advanced search
28033 Posts in 5147 Topics by 2904 Members
Latest Member: kbroch
* Home Help Search Login Register
+  The DAM Forum
|-+  Software Discussions
| |-+  Media Pro & Expression Media
| | |-+  capitalize the fist letter of location
« previous next »
Pages: [1] Print
Author Topic: capitalize the fist letter of location  (Read 3910 times)
mantra
Jr. Member
**
Posts: 57


View Profile
« on: December 30, 2009, 01:14:28 AM »

Hi
i 'm tring to make a script to capitalize the first letter of location
it's only an example , because i would like to do it with city and so on

i found a great john script and i edit it
but i doesn't work
i tried with iview 3.1.3

the script is this


Code:
Const kMsgBoxTitle = "Capitalise location"

Set ivApp = CreateObject("iView.Application")
   
If (ivApp.Catalogs.Count = 0) Then
 MsgBox "Please launch iView MediaPro.", vbCritical, kMsgBoxTitle
Else
 Main
End If

Sub Main()
 Set ivCat = ivApp.ActiveCatalog
 For Each ivItem In ivCat.Selection
  If ivItem.Annotations.location <> "" Then
   ivItem.Annotations.location = ProperCase(ivItem.Annotations.location)
  End If
 Next
End Sub

Function ProperCase(location)
 location = Ucase(Left(location,1)) & Lcase(Mid(location,2))
 For bit = 2 To (Len(location)-1)
  If Mid(location,bit,1) = ";" Then
   location = Left(location,bit) & Ucase(Mid(location,bit+1,1)) & Mid(location,bit+2)
  End If
 Next
 ProperCase = location
End Function


thanks
Giovanni
Logged

Giovanni
ianw
Full Member
***
Posts: 162


View Profile
« Reply #1 on: December 30, 2009, 06:52:16 AM »

Giovanni,

It is possible to do a script that will capitalise the first letter of a location but I'm not sure it's the wisest solution.

I recognise the script you have posted as it looks a bit like one of mine, although maybe I cribbed it from John first!  The original version was for capitalising keywords.  It's one thing to capitalise keywords but locations is a different issue.

For example if I have new york then capitalising the first letter gives me New york, which is a worse result.  It's easy to modify the script to capitalise the first letter of each word, giving me New York.

The problem is that not all words are separated by spaces and not all words should be capitalised.

A few months ago I was visiting friends in France and exploring the area.  While I was in haute-vienne I visited oradour-sur-glane and took some pictures at the church - eglise d'oradour-sur-glane.  This real example highlights the problems in trying to script a case change.  While the script is easy I won't get the results I want.  I do want Haute-Vienne.  I prefer Oradour-sur-Glane to Oradour-Sur-Glane.  However I don't want Eglise D'oradour-Sur-Glane as that is definitely incorrect, as it should be Eglise d'Oradour-sur-Glane.

I guess you are geo-tagging your images and using a script to pull location details in from an online database.  I do the same.  However I don't always like the results I get so I correct them manually, which is easy to do within the place finder details.  An alternative, if you don't like the results you get from the script, is to improve the data in the online database.  The script I have for getting location details uses the GeoNames database at www.geonames.org and the quality of the data there is only as good as that supplied to it.  So if you don't like it or spot errors then register for the site and go and update or correct the data.  I remember a post some time ago where you didn't agree with the location return for an image of yours in Venice.  That was purely down to the quality of the data at GeoNames.

One issue you may have is that while the site allows for adding names in multiple languages - Venice has 63 names listed, some in languages I have not heard of - the iView script only gets the default name, which I believe is the first name given to a place which is usually the English one.  I don't think that GeoNames has a service to return the results in a chosen language.

Ian
Logged
mantra
Jr. Member
**
Posts: 57


View Profile
« Reply #2 on: December 31, 2009, 09:24:53 AM »

Giovanni,

It is possible to do a script that will capitalise the first letter of a location but I'm not sure it's the wisest solution.

I recognise the script you have posted as it looks a bit like one of mine, although maybe I cribbed it from John first!  The original version was for capitalising keywords.  It's one thing to capitalise keywords but locations is a different issue.

For example if I have new york then capitalising the first letter gives me New york, which is a worse result.  It's easy to modify the script to capitalise the first letter of each word, giving me New York.

The problem is that not all words are separated by spaces and not all words should be capitalised.

A few months ago I was visiting friends in France and exploring the area.  While I was in haute-vienne I visited oradour-sur-glane and took some pictures at the church - eglise d'oradour-sur-glane.  This real example highlights the problems in trying to script a case change.  While the script is easy I won't get the results I want.  I do want Haute-Vienne.  I prefer Oradour-sur-Glane to Oradour-Sur-Glane.  However I don't want Eglise D'oradour-Sur-Glane as that is definitely incorrect, as it should be Eglise d'Oradour-sur-Glane.

I guess you are geo-tagging your images and using a script to pull location details in from an online database.  I do the same.  However I don't always like the results I get so I correct them manually, which is easy to do within the place finder details.  An alternative, if you don't like the results you get from the script, is to improve the data in the online database.  The script I have for getting location details uses the GeoNames database at www.geonames.org and the quality of the data there is only as good as that supplied to it.  So if you don't like it or spot errors then register for the site and go and update or correct the data.  I remember a post some time ago where you didn't agree with the location return for an image of yours in Venice.  That was purely down to the quality of the data at GeoNames.

One issue you may have is that while the site allows for adding names in multiple languages - Venice has 63 names listed, some in languages I have not heard of - the iView script only gets the default name, which I believe is the first name given to a place which is usually the English one.  I don't think that GeoNames has a service to return the results in a chosen language.

Ian
Hi Ian
i see you remember of me
how are you ? hope fine
well i got you
indeed i would like to use the script only with location like Rome , Florence , Paris and so on
so select the photo and run the script
but the script doesn't work Sad
gave me an error
and i'm still using iview , i don't like em

by the way for the name like Eglise D'oradour-Sur-Glane you can use the freeware geosetter (what i don't like about geosetter is the add the timezone , i did not find the way to disable it)


Happy New Year
Logged

Giovanni
ianw
Full Member
***
Posts: 162


View Profile
« Reply #3 on: December 31, 2009, 10:18:52 AM »

Giovanni,

I think the problem in your script is that the location details are held in a property called Location, and not location.  It is very case-specific.  You need to change ivItem.Annotations.location to ivItem.Annotations.Location.  If you improve the script to do the same for the city and state then you need to use ivItem.Annotations.City and ivItem.Annotations.State

You can also remove the code from For bit through to Next as this was for dealing with Keywords being a 2-dimensional property i.e. you can have multiple keywords.  There can only be a single value in Location.  It won't affect your results, unless a location has a semi-colon in it!  However it will slow the script down a lot if you leave it in.

I do use GeoSetter sometimes and have also had fun with the timezone that it adds.  I haven't found a way around this either, but it doesn't cause me any issues at the moment.

Ian
Logged
mantra
Jr. Member
**
Posts: 57


View Profile
« Reply #4 on: December 31, 2009, 11:04:31 AM »

Giovanni,

I think the problem in your script is that the location details are held in a property called Location, and not location.  It is very case-specific.  You need to change ivItem.Annotations.location to ivItem.Annotations.Location.  If you improve the script to do the same for the city and state then you need to use ivItem.Annotations.City and ivItem.Annotations.State

You can also remove the code from For bit through to Next as this was for dealing with Keywords being a 2-dimensional property i.e. you can have multiple keywords.  There can only be a single value in Location.  It won't affect your results, unless a location has a semi-colon in it!  However it will slow the script down a lot if you leave it in.

I do use GeoSetter sometimes and have also had fun with the timezone that it adds.  I haven't found a way around this either, but it doesn't cause me any issues at the moment.

Ian
Ian

this script works
Quote
Const kMsgBoxTitle = "Capitalise location"

Set ivApp = CreateObject("iView.Application")
   
If (ivApp.Catalogs.Count = 0) Then
 MsgBox "Please launch iView MediaPro.", vbCritical, kMsgBoxTitle
Else
 Main
End If

Sub Main()
 Set ivCat = ivApp.ActiveCatalog
 For Each ivItem In ivCat.Selection
  If ivItem.Annotations.location <> "" Then
   ivItem.Annotations.location = ProperCase(ivItem.Annotations.location)
  End If
 Next
End Sub

Function ProperCase(string)
 string = Ucase(Left(string,1)) & Lcase(Mid(string,2))
 For bit = 2 To (Len(string)-1)
  If Mid(string,bit,1) = ";" Or Mid(string,bit,1) = " " Then
   string = Left(string,bit) & Ucase(Mid(string,bit+1,1)) & Mid(string,bit+2)
  End If
 Next
 ProperCase = string
End Function

but i would like to  make a script to capitalize more annotation in one script
for example i would like to capitalize location , state , city and country

i tried this script

Quote
Set ivApp = CreateObject("iView.Application")
   
If (ivApp.Catalogs.Count = 0) Then
 MsgBox "Please launch iView MediaPro.", vbCritical, kMsgBoxTitle
Else
 Main
End If

Sub Main()
 Set ivCat = ivApp.ActiveCatalog
 For Each ivItem In ivCat.Selection
  If ivItem.Annotations.location <> "" Then
   ivItem.Annotations.location = ProperCase(ivItem.Annotations.location)
  End If
 Next
End Sub

Function ProperCase(string)
 string = Ucase(Left(string,1)) & Lcase(Mid(string,2))
 For bit = 2 To (Len(string)-1)
  If Mid(string,bit,1) = ";" Or Mid(string,bit,1) = " " Then
   string = Left(string,bit) & Ucase(Mid(string,bit+1,1)) & Mid(string,bit+2)
  End If
 Next
 ProperCase = string

If (ivApp.Catalogs.Count = 0) Then
 MsgBox "Please launch iView MediaPro.", vbCritical, kMsgBoxTitle
Else
 Main
End If

Sub Main()
 Set ivCat = ivApp.ActiveCatalog
 For Each ivItem In ivCat.Selection
  If ivItem.Annotations.city <> "" Then
   ivItem.Annotations.city = ProperCase(ivItem.Annotations.city)
  End If
 Next
End Sub

Function ProperCase(string)
 string = Ucase(Left(string,1)) & Lcase(Mid(string,2))
 For bit = 2 To (Len(string)-1)
  If Mid(string,bit,1) = ";" Or Mid(string,bit,1) = " " Then
   string = Left(string,bit) & Ucase(Mid(string,bit+1,1)) & Mid(string,bit+2)
  End If
 Next
 ProperCase = string


   
If (ivApp.Catalogs.Count = 0) Then
 MsgBox "Please launch iView MediaPro.", vbCritical, kMsgBoxTitle
Else
 Main
End If

Sub Main()
 Set ivCat = ivApp.ActiveCatalog
 For Each ivItem In ivCat.Selection
  If ivItem.Annotations.state <> "" Then
   ivItem.Annotations.state = ProperCase(ivItem.Annotations.state)
  End If
 Next
End Sub

Function ProperCase(string)
 string = Ucase(Left(string,1)) & Lcase(Mid(string,2))
 For bit = 2 To (Len(string)-1)
  If Mid(string,bit,1) = ";" Or Mid(string,bit,1) = " " Then
   string = Left(string,bit) & Ucase(Mid(string,bit+1,1)) & Mid(string,bit+2)
  End If
 Next
 ProperCase = string
End Function

but it gave me error
can you help me please?
Logged

Giovanni
ianw
Full Member
***
Posts: 162


View Profile
« Reply #5 on: December 31, 2009, 12:50:21 PM »

Try this script

Code:
'----------------------------------------------------------------------
' For selected images convert all "Place Finder" details to lower case
' and then capitalise the first letter only
'----------------------------------------------------------------------

Const kMsgBoxTitle = "Capitalise Place Finder"

Set ivApp = CreateObject("iView.Application")
   
If (ivApp.Catalogs.Count = 0) Then
 MsgBox "Please launch iView MediaPro.", vbCritical, kMsgBoxTitle
Else
 Main
End If

Sub Main()
 Set ivCat = ivApp.ActiveCatalog
 For Each ivItem In ivCat.Selection
  If ivItem.Annotations.Country <> "" Then
   ivItem.Annotations.Country = ProperCase(ivItem.Annotations.Country)
  End If
  If ivItem.Annotations.State <> "" Then
   ivItem.Annotations.State = ProperCase(ivItem.Annotations.State)
  End If
  If ivItem.Annotations.City <> "" Then
   ivItem.Annotations.City = ProperCase(ivItem.Annotations.City)
  End If
  If ivItem.Annotations.Location <> "" Then
   ivItem.Annotations.Location = ProperCase(ivItem.Annotations.Location)
  End If
 Next
End Sub

' Function to make string lower case and then capitalise the first letter only
Function ProperCase(string)
 string = Ucase(Left(string,1)) & Lcase(Mid(string,2))
 ProperCase = string
End Function

I still think this is not a good idea, as there is a big danger in degrading existing correct details - so run this with care.

Note that when you run the script and change any details you will get left with empty spaces in the Place Finder within iView.  Your image may be against Rome but the Place Finder could still have rome or ROME in it,although with less or no images against them.  That's why I think the best way to fix the incorrect details is to edit in situ within the Place Finder, either by renaming (only if new name doesn't exist) or by dragging all incorrect images to existing correct value.

Ian
Logged
mantra
Jr. Member
**
Posts: 57


View Profile
« Reply #6 on: December 31, 2009, 01:25:47 PM »

Try this script

Code:
'----------------------------------------------------------------------
' For selected images convert all "Place Finder" details to lower case
' and then capitalise the first letter only
'----------------------------------------------------------------------

Const kMsgBoxTitle = "Capitalise Place Finder"

Set ivApp = CreateObject("iView.Application")
   
If (ivApp.Catalogs.Count = 0) Then
 MsgBox "Please launch iView MediaPro.", vbCritical, kMsgBoxTitle
Else
 Main
End If

Sub Main()
 Set ivCat = ivApp.ActiveCatalog
 For Each ivItem In ivCat.Selection
  If ivItem.Annotations.Country <> "" Then
   ivItem.Annotations.Country = ProperCase(ivItem.Annotations.Country)
  End If
  If ivItem.Annotations.State <> "" Then
   ivItem.Annotations.State = ProperCase(ivItem.Annotations.State)
  End If
  If ivItem.Annotations.City <> "" Then
   ivItem.Annotations.City = ProperCase(ivItem.Annotations.City)
  End If
  If ivItem.Annotations.Location <> "" Then
   ivItem.Annotations.Location = ProperCase(ivItem.Annotations.Location)
  End If
 Next
End Sub

' Function to make string lower case and then capitalise the first letter only
Function ProperCase(string)
 string = Ucase(Left(string,1)) & Lcase(Mid(string,2))
 ProperCase = string
End Function

I still think this is not a good idea, as there is a big danger in degrading existing correct details - so run this with care.

Note that when you run the script and change any details you will get left with empty spaces in the Place Finder within iView.  Your image may be against Rome but the Place Finder could still have rome or ROME in it,although with less or no images against them.  That's why I think the best way to fix the incorrect details is to edit in situ within the Place Finder, either by renaming (only if new name doesn't exist) or by dragging all incorrect images to existing correct value.

Ian
i got it
thanks Ian
your script works like a charm
how do you correct with place finder??

by the way off topic is there a way to disable in geosetter to save the Time zone (system zone)

Happy new year
Logged

Giovanni
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!