No BSD License  

Highlights from
headline

Be the first to rate this file! 1 Download (last 30 days) File Size: 9.18 KB File ID: #12433

headline

by David Fass

 

28 Sep 2006 (Updated 09 Oct 2006)

Convert a string to "headline" format (initial capitals on key words).

| Watch this File

File Information
Description

HEADLINE Convert string to "headline" format (initial capitals on key words).

B = HEADLINE(A) converts the initial letter of all words (except prepositions and conjunctions) in A to capitals. A must be a string. Any letters placed in curly braces "{}" will be left unaltered (i.e., in their original case).

B = HEADLINE, with no inputs, produces the default list of prepositions and conjunctions that are not capitalized. This list can be modified using the following syntax:

B = HEADLINE(...,addList,delList) adds the words in cell array addList to the default list of of words, and deletes the words in cell array delList from the default list of of words. Use empty brackets [] for addList if you wish only to specify delList. (The function does not check whether added words already exist on the list, since this would be unnecessary computation. Words to be deleted must match entries in the default list exactly.)

The default list of prepositions can also be modified simply by editing the M-file. The default list has been extracted from the Wikipedia entry for English Prepositions:

http://en.wikipedia.org/wiki/List_of_English_prepositions

Examples:

A = 'life, don''t talk to me about life.'
y = headline(A)
y =
    Life, Don't Talk to Me about Life.

y = headline(A,'don''t')
y =
    Life, don't Talk to Me about Life.

y = headline(A,'don''t','about')
y =
    Life, don't Talk to Me About Life.

B = '{l}ife, don''t talk to {me} about life.'
y = headline(B)
y =
   life, Don't Talk to me about Life.

See also UPPER, LOWER, INITIALCAPS.

MATLAB release MATLAB 7.1.0 (R14SP3)
Other requirements INITIALCAPS.M, also available on FTP.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
28 Sep 2006

Bug fix: Function changed caps on prepositions occuring as part of other words, i.e., "the" in "theory". Hopefully this won't happen anymore.

09 Oct 2006

Bug fix.

Tag Activity for this File
Tag Applied By Date/Time
strings David Fass 22 Oct 2008 08:41:29
headline David Fass 22 Oct 2008 08:41:29
initial capitals David Fass 22 Oct 2008 08:41:29
capitalization David Fass 22 Oct 2008 08:41:29
upper case David Fass 22 Oct 2008 08:41:29
lower case David Fass 22 Oct 2008 08:41:29
ti David Fass 22 Oct 2008 08:41:29

Contact us at files@mathworks.com