byline

package
v0.0.0-...-e72d39b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2018 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	Name, Location, JobTitle, Email string
}

func Parse

func Parse(txt string) []Author

Parse attempts to parse a byline into distinct authors, each with name/jobtitle/location/email etc...

Example
bylines := []string{
	"By Matthew Garrahan in Los Angeles and Tim Bradshaw in San Francisco",
	"Fred Blogs, in Washington and Bubba jo-bob Brain, chief cheese editor in Mouseland",
	"Sports Reporter",
	"Fred Smith",
	"By SARA KARL. Special to amNewYork April 24, 2014",
	"By Lucy Hyslop, Special to The Sun",
	"Daniel Wittenberg for Metro.co.uk",
	"Author: Dieter Shirley", // http://axioms.io/zen/2014-11-06-swift-go/
	"By TOM NEWTON DUNN, Political Editor",
}

for _, byl := range bylines {
	authors := Parse(byl)
	names := make([]string, len(authors))
	for i, a := range authors {
		names[i] = a.Name
	}
	fmt.Println(strings.Join(names, "|"))
}
Output:

Matthew Garrahan|Tim Bradshaw
Fred Blogs|Bubba jo-bob Brain

Fred Smith
SARA KARL
Lucy Hyslop
Daniel Wittenberg
Dieter Shirley
TOM NEWTON DUNN

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL