Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Summarizer ¶
type Summarizer struct {
// contains filtered or unexported fields
}
Summarizer instance, used for extracting summary from raw texts and urls
func CreateFromText ¶
func CreateFromText(text string) *Summarizer
CreateFromText creates summarizer instance, using the text parameter for summarizing
Example ¶
var unsummarizedText = "unsummarized text" var s = CreateFromText(unsummarizedText) // Do something with s s.Summarize()
Output:
func CreateFromURL ¶
func CreateFromURL(url string) *Summarizer
CreateFromURL creates summarizer instance, using the url parameter for summarizing
Example ¶
var urlToSummarize = "http://testurl.test/" var s = CreateFromURL(urlToSummarize) // Do something with s s.Summarize()
Output:
func (*Summarizer) GetMainTextFromURL ¶
func (s *Summarizer) GetMainTextFromURL() (string, error)
GetMainTextFromURL parses the summarizer object URL property and returns the main text from the website without ads, unnecessary images and other not important data
func (*Summarizer) GetSummaryInfo ¶
func (s *Summarizer) GetSummaryInfo() (string, error)
GetSummaryInfo returns summary information statistics if the text is summarized and an error if not
Example ¶
var s = CreateFromText("first sentence. second sentence") s.Summarize() summaryInfo, err := s.GetSummaryInfo() if err != nil { fmt.Println("Error occurred: ", err.Error()) } fmt.Println(summaryInfo)
Output: Summary info: - Original length: 31 symbols - Summary length: 14 symbols - Summary ratio: 54.84%
func (*Summarizer) IsSummarized ¶
func (s *Summarizer) IsSummarized() bool
IsSummarized checks if the instance was already summarized
Example ¶
var s = CreateFromText("test") fmt.Println(s.IsSummarized())
Output: false
Example (Second) ¶
var s = CreateFromText("first sentence. second sentence") s.Summarize() fmt.Println(s.IsSummarized())
Output: true
func (*Summarizer) StoreToFile ¶
func (s *Summarizer) StoreToFile(filePath string) (bool, error)
StoreToFile stores the summarized text to the file from the given path
Example ¶
var s = CreateFromText("first sentence. second sentence") s.Summarize() stored, err := s.StoreToFile("/test-file.txt") if err != nil { fmt.Println("Error occurred: ", err.Error()) } fmt.Println(stored)
Output: true
func (*Summarizer) Summarize ¶
func (s *Summarizer) Summarize() (string, error)
Summarize returns summary of the text, extracted from the url or the saved text
Example ¶
var customNewsStory = `SpaceX has succeeded in launch a Falcon 9 rocket from Vandenberg Air Force Base in California, its first launch since a Falcon 9 rocket exploded on a launch pad in pre-flight procedures in September 2016. The launch took place at 9:54 AM PT Saturday, during an instant launch window. This mission is the first in a series for client Iridium, that will see it deploy 70 satellites in a network for voice and data communication. It’s also a green light for SpaceX in terms of the company pursuing its aggressive launch schedule, which is something the private launch provider needs to do in order to continue locking in new contracts and working towards its goal of decreasing the cost of launches even further still. In 2016, SpaceX completed only 8 of a planned 20 launches, due to the September 1 explosion that halted all new launches for four months. That has not been good for the company’s bottom line, resulting in a year that likely saw it exacerbate a reported $250 million loss in 2015. SpaceX also had to push back its timelines for test launches of its Dragon crew capsule as a result of the September incident. The original target date for a Dragon test launch with people on board was 2017, but it’s now been pushed back to 2018. The company still hopes to fly a mission without crew on board by the last quarter of this year, however. Crewed mission capabilities will help SpaceX expand its ability to serve contracts, since it can then serve the ISS for more than just supply runs. It also sets the stage for SpaceX’s future goals of providing missions to Mars, with a target initial date for those aspirations still set for 2024.` var s = CreateFromText(customNewsStory) summary, err := s.Summarize() if err != nil { fmt.Println("Error occurred: ", err.Error()) } fmt.Println(summary)
Output: SpaceX has succeeded in launch a Falcon 9 rocket from Vandenberg Air Force Base in California, its first launch since a Falcon 9 rocket exploded on a launch pad in pre-flight procedures in September 2016 It’s also a green light for SpaceX in terms of the company pursuing its aggressive launch schedule, which is something the private launch provider needs to do in order to continue locking in new contracts and working towards its goal of decreasing the cost of launches even further still. SpaceX also had to push back its timelines for test launches of its Dragon crew capsule as a result of the September incident
Example (Second) ¶
var customNewsStoryURL = `https://techcrunch.com/2017/01/14/spacex-successfully-returns-to-launch-with-iridium-1-next-falcon-9-mission/` var s = CreateFromURL(customNewsStoryURL) summary, err := s.Summarize() if err != nil { fmt.Println("Error occurred: ", err.Error()) } fmt.Println(summary)
Output: SpaceX successfully returns to launch with Iridium-1 NEXT Falcon 9 mission It’s a huge victory for SpaceX, which has had to delay its launch schedule since the explosion. The launch also resulted in a successful recovery of the Falcon 9 rocket’s first stage, which marks the seventh time SpaceX has succeed in landing this stage back for potential later re-use It’s also a green light for SpaceX in terms of the company pursuing its aggressive launch schedule, which is something the private launch provider needs to do in order to continue locking in new contracts and working towards its goal of decreasing the cost of launches even further still. In 2016, SpaceX completed only 8 of a planned 20 launches, due to the September 1 explosion that halted all new launches for four months SpaceX also had to push back its timelines for test launches of its Dragon crew capsule as a result of the September incident It also sets the stage for SpaceX’s future goals of providing missions to Mars, with a target initial date for those aspirations still set for 2024. All satellites were successfully deployed as of 11:13 AM PT / 2:12 PM PT, signalling a successful mission for the space company’s first flight back.