ssld

package module
v0.0.0-...-5abc355 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: MIT Imports: 12 Imported by: 0

README

libssld

Golang library for interfacing with the Swedish Sign Language Dictionary

Due to the nature of the SSLD, and it not providing its data in a static, computer-friendly format, this library will break with no prior warning. That's the nature of parsing ever-changing browser documents.

Purpose

This library is meant to interact with the live version of SSLD, for archival and conversion into machine consumable formats.

License

This library is under the MIT license. Do whatever you want with it, no warranties, and don't hold me liable.

The data it obtains from the SSLD is licensed under a Creative Commons BY-NC-SA license.

Method

This library parses HTML, which is a horrible way to obtain data. However, there seems to be no other public way to get it.

Other projects, such as zrajm/teckentranskription get their data in CSV form emailed to them by su.se. That's not good enough. From what I can tell, this data also lacks some of the relations such as alternate meanings for a given sign - data available on the website.

The long-term goal of this library is to serve in a tool that (slowly, kindly) backs up the contents of the SSLD into something an API can serve.

Installation

go get github.com/MarkOtzen/libssld

Usage

See sample/sample.go.

user@datan $ ./sample | jq .
{
  "word": "Björn",
  "id": 10,
  "topics": [
    "Djur / Däggdjur"
  ],
  "description": "Flata handen, uppåtriktad och vänstervänd, förs först nedåt och sedan vänsterriktad och nedåtvänd åt höger framför ansiktet",
  "english": "bear, teddy, bruin",
  "pictures": [
    "https://teckensprakslexikon.su.se/photos/00/bjorn-00010-photo-1-medium.jpg",
    "https://teckensprakslexikon.su.se/photos/00/bjorn-00010-photo-2-medium.jpg",
    "https://teckensprakslexikon.su.se/photos/00/bjorn-00010-photo-3-medium.jpg"
  ],
  "video": "https://teckensprakslexikon.su.se/movies/00/bjorn-00010-tecken.mp4",
  "glosa-lexicon": "BJÖRN(J^J)",
  "updated": "2020-03-03T00:00:00Z",
  "examples": [
    {
      "video": "https://teckensprakslexikon.su.se/movies/00/bjorn-00010-fras-1.mp4",
      "textcontent": "På ett zoo finns det olika typer av björnar."
    },
    {
      "video": "https://teckensprakslexikon.su.se/movies/00/bjorn-00010-fras-2.mp4",
      "textcontent": "I Norrland finns det gott om björn men jag undrar finns det björn i Örebro?"
    },
    {
      "video": "https://teckensprakslexikon.su.se/movies/04/nervos-04233-fras-1.mp4",
      "textcontent": "Bäst jag gick i skogen fick jag syn på en björn som kom lufsande. Jag blev helt skärrad!"
    },
    {
      "video": "https://teckensprakslexikon.su.se/movies/05/bjorn-05034-fras-1.mp4",
      "textcontent": "Jag har sett en livs levande björn uppe i Norrland. Vad rädd jag blev!"
    },
    {
      "video": "https://teckensprakslexikon.su.se/movies/05/tva-ganger-05437-fras-2.mp4",
      "textcontent": "Jag har sett Björn Skifs vid två tillfällen."
    },
    {
      "video": "https://teckensprakslexikon.su.se/movies/00/snall-00053-fras-2.mp4",
      "textcontent": "Min pappa kan verka bister och farlig men egentligen är han snäll som en björn."
    }
  ],
  "transcription": "􌤆􌤢􌤵􌤶􌥧􌥠􌤆􌤢􌥓􌥙􌥣",
  "also-means": [
    {
      "id": 6152,
      "word": "Bjärnum",
      "pictures": [
        "https:/teckensprakslexikon.su.se/photos/06/bjarnum-06152-photo-1-small.jpg",
        "https:/teckensprakslexikon.su.se/photos/06/bjarnum-06152-photo-2.jpg"
      ],
      "topics": [
        "Geografi"
      ]
    },
    {
      "id": 10,
      "word": "björn",
      "pictures": [
        "https:/teckensprakslexikon.su.se/photos/00/bjorn-00010-photo-1-small.jpg",
        "https:/teckensprakslexikon.su.se/photos/00/bjorn-00010-photo-2.jpg"
      ],
      "topics": [
        "Djur"
      ]
    },
    {
      "id": 6153,
      "word": "Björna",
      "pictures": [
        "https:/teckensprakslexikon.su.se/photos/06/bjorna-06153-photo-1-small.jpg",
        "https:/teckensprakslexikon.su.se/photos/06/bjorna-06153-photo-2.jpg"
      ],
      "topics": [
        "Geografi"
      ]
    },
    {
      "id": 2451,
      "word": "nalle",
      "pictures": [
        "https:/teckensprakslexikon.su.se/photos/02/nalle-02451-photo-1-small.jpg",
        "https:/teckensprakslexikon.su.se/photos/02/nalle-02451-photo-2.jpg"
      ],
      "topics": [
        "Djur",
        "Barn"
      ]
    },
    {
      "id": 6582,
      "word": "Värmland",
      "pictures": [
        "https:/teckensprakslexikon.su.se/photos/06/varmland-06582-photo-1-small.jpg",
        "https:/teckensprakslexikon.su.se/photos/06/varmland-06582-photo-2.jpg"
      ],
      "topics": [
        "Geografi"
      ]
    }
  ],
  "signs-with-same-meaning": [
    {
      "id": 10,
      "word": "björn",
      "pictures": [
        "https:/teckensprakslexikon.su.se/photos/00/bjorn-00010-photo-1-small.jpg",
        "https:/teckensprakslexikon.su.se/photos/00/bjorn-00010-photo-2.jpg"
      ],
      "topics": [
        "Djur"
      ]
    },
    {
      "id": 1651,
      "word": "björn",
      "pictures": [
        "https:/teckensprakslexikon.su.se/photos/01/bjorn-01651-photo-1-small.jpg",
        "https:/teckensprakslexikon.su.se/photos/01/bjorn-01651-photo-2.jpg"
      ],
      "topics": [
        "Djur"
      ],
      "comment": "Tecknet är mindre vanligt"
    },
    {
      "id": 5034,
      "word": "björn",
      "pictures": [
        "https:/teckensprakslexikon.su.se/photos/05/bjorn-05034-photo-1-small.jpg",
        "https:/teckensprakslexikon.su.se/photos/05/bjorn-05034-photo-2.jpg"
      ],
      "topics": [
        "Djur"
      ]
    },
    {
      "id": 9338,
      "word": "björn",
      "pictures": [
        "https:/teckensprakslexikon.su.se/photos/09/bjorn-09338-photo-1-small.jpg"
      ],
      "topics": [
        "Djur"
      ]
    }
  ]
}

TODO

  • Implement searching

Documentation

Index

Constants

View Source
const (
	BaseScheme = "https"
	BaseHost   = "teckensprakslexikon.su.se"
	BaseURL    = BaseScheme + "://" + BaseHost + "/"
	BaseIDURL  = BaseURL + "ord/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Example

type Example struct {
	VideoURL    string `json:"video,omitempty"`
	TextContent string `json:"textcontent,omitempty"`
}

type Sign

type Sign struct {
	Word          string          `json:"word,omitempty"`
	ID            int             `json:"id,omitempty"`
	Topics        []string        `json:"topics,omitempty"`
	Description   string          `json:"description,omitempty"`
	English       string          `json:"english,omitempty"`
	PictureURLs   []string        `json:"pictures,omitempty"`
	VideoURL      string          `json:"video,omitempty"`
	GlosaKorpus   string          `json:"glosa-korpus,omitempty"`
	GlosaLexicon  string          `json:"glosa-lexicon,omitempty"`
	Updated       time.Time       `json:"updated,omitempty"`
	Examples      []Example       `json:"examples,omitempty"`
	Transcription string          `json:"transcription,omitempty"`
	AlsoMeans     []SignReference `json:"also-means,omitempty"`
	SameMeaning   []SignReference `json:"signs-with-same-meaning,omitempty"`
	// contains filtered or unexported fields
}

func SignFromID

func SignFromID(id int) (*Sign, error)

Populates and returns a Sign matching the provided ID.

type SignReference

type SignReference struct {
	ID          int      `json:"id,omitempty"`
	Word        string   `json:"word,omitempty"`
	PictureURLs []string `json:"pictures,omitempty"`
	Topics      []string `json:"topics,omitempty"`
	Comment     string   `json:"comment,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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