model

package
v0.0.0-...-8f4005c Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debugger = lib.NewCondLogger("newsfetch:model:article")

Functions

func FilterArticleURLsBySection

func FilterArticleURLsBySection(urls []string, section string) []string

Types

type Article

type Article struct {
	Id          bson.ObjectId  `bson:"_id,omitempty" json:"_id"`
	ArticleId   int            `bson:"article_id" json:"article_id"`
	Headline    string         `bson:"headline" json:"headline`
	Subheadline string         `bson:"subheadline" json:"subheadline"`
	Section     string         `bson:"section" json:"section"`
	Subsection  string         `bson:"subsection" json:"subsection"`
	Sections    []string       `bson:"sections" json"sections"`
	Source      string         `bson:"source" json:"source"`
	Created_at  time.Time      `bson:"created_at" json:"created_at"`
	Updated_at  time.Time      `bson:"updated_at" json:"updated_at"`
	Timestamp   time.Time      `bson:"timestamp" json:"timestamp"`
	Url         string         `bson:"url" json:"url"`
	Photo       *Photo         `bson:"photo" json:"photo"`
	BodyText    string         `bson:"body" json:"body"`
	Visits      []TimeInterval `body:"visits" json:"visits"`
}

func (*Article) Save

func (article *Article) Save(session *mgo.Session) (bool, error)

func (*Article) String

func (a *Article) String() string

type ExtractedBody

type ExtractedBody struct {
	Text       string
	RecipeData RecipeExtractionResult
	Messages   *Messages
}

func (*ExtractedBody) String

func (e *ExtractedBody) String() string

type ExtractedSection

type ExtractedSection struct {
	Section    string
	Subsection string
	Sections   []string
}

TODO only use the Sections array for this, don't have section/subsection distinction

type Messages

type Messages struct {
	Errors   []string
	Warnings []string
}

func (*Messages) AddError

func (msg *Messages) AddError(message string)

func (*Messages) AddErrorf

func (msg *Messages) AddErrorf(format string, args ...interface{})

func (*Messages) AddMessages

func (msg *Messages) AddMessages(context string, other *Messages)

func (*Messages) AddWarning

func (msg *Messages) AddWarning(message string)

func (*Messages) AddWarningf

func (msg *Messages) AddWarningf(format string, args ...interface{})

func (*Messages) String

func (m *Messages) String() string

type NutritionData

type NutritionData struct {
	Text string `json:"text" bson:"text"`
}

func (NutritionData) AddToRecipe

func (f NutritionData) AddToRecipe(r *Recipe)

func (NutritionData) Mark

func (f NutritionData) Mark(tag RecipeFragmentTag)

func (NutritionData) Tag

type ParagraphFragment

type ParagraphFragment struct {
	RawHtml string
	Text    string
	TagF    RecipeFragmentTag
}

func (ParagraphFragment) AddToRecipe

func (f ParagraphFragment) AddToRecipe(r *Recipe)

func (*ParagraphFragment) Mark

func (f *ParagraphFragment) Mark(tag RecipeFragmentTag)

func (ParagraphFragment) Tag

type Photo

type Photo struct {
	Caption   string    `bson:"caption"`
	Credit    string    `bson:"credit"`
	Full      PhotoInfo `bson:"full"`
	Thumbnail PhotoInfo `bson:"thumbnail"`
}

type PhotoInfo

type PhotoInfo struct {
	Url    string `bson:"url"`
	Width  int    `bson:"width"`
	Height int    `bson:"height"`
}

type Recipe

type Recipe struct {
	Id        bson.ObjectId `json:"_id" bson:"_id,omitempty"`
	ArticleId int           `json:"article_id" bson:"article_id,omitempty"`
	Url       string        `json:"url" bson:"url,omitempty"`

	Title string `json:"title" bson:"title"`

	Photo *RecipePhoto `json:"photo" bson:"photo,omitempty"`

	ServingSize     string          `json:"serving_size" bson:"serving_size,omitempty"`
	PreparationTime *RecipeDuration `json:"prep_time" bson:"prep_time,omitempty"`
	TotalTime       *RecipeDuration `json:"total_time" bson:"total_time,omitempty"`

	Ingredients  []RecipeIngredient  `json:"ingredients" bson:"ingredients"`
	Instructions []RecipeInstruction `json:"instructions" bson:"instructions"`
	Nutrition    *NutritionData      `json:"nutrition" bson:"nutrition,omitempty"`
}

func NewRecipe

func NewRecipe() *Recipe

func (Recipe) PlainLines

func (r Recipe) PlainLines() []string

func (Recipe) String

func (r Recipe) String() string

type RecipeDuration

type RecipeDuration struct {
	Text string `json:"text" bson:"text"`
}

type RecipeExtractionResult

type RecipeExtractionResult struct {
	Recipes             []*Recipe
	UnusedParagraphs    []RecipeFragment
	EmbeddedArticleUrls []string
}

type RecipeFragment

type RecipeFragment interface {
	Tag() RecipeFragmentTag
	Mark(tag RecipeFragmentTag)
	AddToRecipe(recipe *Recipe)
}

type RecipeFragmentTag

type RecipeFragmentTag int
const (
	NoTag RecipeFragmentTag = iota
	TitleTag
	PossibleTitleTag

	ParagraphTag
	ShortParagraphTag // paragraph that might as well be an ingredient
	InstructionTag
	IngredientsSubtitleTag
	DirectionsSubtitleTag

	PossibleIngredientSubdivisionTag // normal paragraph unless proven otherwise

	TimingTag
	ServingSizeAltTimingTag // “This recipe serves ...”, found in the body of the article
	IngredientTag
	IngredientSubdivisionTag
	PossibleIngredientTag
	NutritionDataTag

	SignatureTag
	CopyrightTag
	EndMarkerTag
)

type RecipeImage

type RecipeImage struct {
	Url string `json:"url" bson:"url"`
}

type RecipeIngredient

type RecipeIngredient struct {
	Text string `json:"text" bson:"text"`
}

type RecipeInstruction

type RecipeInstruction struct {
	RawHtml string `json:"raw_html" bson:"raw_html,omitempty"`
	Text    string `json:"text" bson:"text"`
}

type RecipeMarkerFragment

type RecipeMarkerFragment struct {
	TagF RecipeFragmentTag
}

func (RecipeMarkerFragment) AddToRecipe

func (f RecipeMarkerFragment) AddToRecipe(recipe *Recipe)

func (RecipeMarkerFragment) Mark

func (RecipeMarkerFragment) Tag

type RecipePhoto

type RecipePhoto struct {
	FullSizeImage *RecipeImage `json:"full" bson:"full,omitempty"`
	SmallImage    *RecipeImage `json:"small" bson:"small,omitempty"`
}

type RecipeTimingFragment

type RecipeTimingFragment struct {
	TagF            RecipeFragmentTag
	ServingSize     string
	PreparationTime *RecipeDuration
	TotalTime       *RecipeDuration
}

func (RecipeTimingFragment) AddToRecipe

func (f RecipeTimingFragment) AddToRecipe(r *Recipe)

func (RecipeTimingFragment) Mark

func (RecipeTimingFragment) Tag

type TimeInterval

type TimeInterval struct {
	Max       int       `bson:"max"`
	Timestamp time.Time `bson:"timestamp"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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