dbpreader

package module
v0.0.0-...-609b6b4 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: MIT Imports: 6 Imported by: 0

README

dbpreader

Read dbpedia pages into golang type and structs. Simple and easy to use.

Install
go get -u github.com/Navid2zp/dbpreader
Example

Page: http://dbpedia.org/page/Go_(programming_language)

import (
	"fmt"
	"dbpreader"
)

func main() {
	results, err := dbpreader.Query("Go_(programming_language)")
	if err != nil {
		panic(err)
	}
	fmt.Println(results)

	fmt.Println("Exact Resource:")
	resource := results.FindResource("Go_(programming_language)")
	fmt.Println(resource)

	fmt.Println("WikiData Item:")
	fmt.Println(resource.GetWikiDataItem())
}
Methods:

There is some small useful methods that you can use. I might add more along the way.

FindResource:

The json version of dbpedia returns a list of results This method will find and return the exact resource

resource := results.FindResource("Go_(programming_language)")
fmt.Println(resource)

GetWikiDataItem:

Finds the wikidata item url

resource.GetWikiDataItem()

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBPediaProperty

type DBPediaProperty struct {
	Type     string      `json:"type"`
	Value    interface{} `json:"value"`
	Lang     string      `json:"lang"`
	DataType string      `json:"datatype"`
}

type DBPediaResource

type DBPediaResource map[string][]DBPediaProperty

func (DBPediaResource) GetWikiDataItem

func (r DBPediaResource) GetWikiDataItem() string

Finds the wikidata item url

type DBPediaResult

type DBPediaResult map[string]DBPediaResource

func Query

func Query(query string) (*DBPediaResult, error)

Queries the json version of dbpedia Return a map of results returned by dbpedia Results might be contain resources that you didn't ask for Use FindResource() method to extract the exact resource

func (DBPediaResult) FindResource

func (r DBPediaResult) FindResource(name string) DBPediaResource

The json version of dbpedia returns a set of results This method will find and return the exact resource

Jump to

Keyboard shortcuts

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