aboutsummaryrefslogtreecommitdiffstats
path: root/skate/map.go
diff options
context:
space:
mode:
Diffstat (limited to 'skate/map.go')
-rw-r--r--skate/map.go27
1 files changed, 22 insertions, 5 deletions
diff --git a/skate/map.go b/skate/map.go
index f812464..a06b5ae 100644
--- a/skate/map.go
+++ b/skate/map.go
@@ -24,16 +24,16 @@ type TitleDoc struct {
Title string `json:"title"`
}
-// ContainerNameDoc is a document with a container title.
+// ContainerNameDoc is a (ref) document with a container title.
type ContainerNameDoc struct {
Biblio struct {
ContainerName string `json:"container_name"`
} `json:"biblio"`
}
-// PartialDoc for ref docs, that do not have DOI or title. E.g. we found 49701699
-// (NCVY), 36401044 (NCVYU), 29668363 (NCUY), and so on. Some examples: XXX
-type PartialDoc struct {
+// PartialRef for ref docs, that do not have DOI or title. E.g. we found 49701699
+// (NCVY), 36401044 (NCVYU), 29668363 (NCUY), and so on. Some examples: XXX.
+type PartialRef struct {
ContainerName string `json:"container_name"`
Contribs []struct {
// XXX: Need a way to sensibly compare sets of author names.
@@ -200,7 +200,7 @@ func MapperTitleSandcrawler(p []byte) (fields [][]byte, err error) {
// MapperContainerName extracts (container_name, doc).
func MapperContainerName(p []byte) ([][]byte, error) {
var (
- doc PartialDoc
+ doc PartialRef
key []byte
)
if err := json.Unmarshal(p, &doc); err != nil {
@@ -240,6 +240,23 @@ func MapperURLFromRef(p []byte) (fields [][]byte, err error) {
return fields, nil
}
+// MapperReleaseContainerName extracts a normalized container name.
+func MapperReleaseContainerName(p []byte) (fields [][]byte, err error) {
+ var (
+ doc Release
+ key []byte
+ )
+ if err := json.Unmarshal(p, &doc); err != nil {
+ return nil, err
+ }
+ if doc.Container.Name != "" {
+ key = []byte(sandcrawlerSlugify(wsReplacer.Replace(strings.TrimSpace(doc.Container.Name))))
+ } else if doc.ContainerName != "" {
+ key = []byte(sandcrawlerSlugify(wsReplacer.Replace(strings.TrimSpace(doc.ContainerName))))
+ }
+ return [][]byte{key, p}, nil
+}
+
// MapperPartial works on partial documents.
func MapperPartial(p []byte) (fields [][]byte, err error) {
return nil, nil