in src/ct/relation/relation.go [290:329]
func (r *Relation) Split() Relations {
variableCatalog := variables.Get()
names := strings.Split(r.Name, "/")
if len(names) != 2 {
return Relations{r}
}
slice.TrimSpace(names)
id0, ok0 := variableCatalog.ID(names[0])
id1, ok1 := variableCatalog.ID(names[1])
if !(ok0 && ok1) {
return Relations{r}
}
r0 := &Relation{ID: id0, Name: names[0], Unit: r.Unit, VariableType: r.VariableType, Score: r.Score}
r1 := &Relation{ID: id1, Name: names[1], Unit: r.Unit, VariableType: r.VariableType, Score: r.Score}
if r.Lower != nil {
values := strings.Split(r.Lower.Value, "/")
slice.TrimSpace(values)
switch len(values) {
case 1:
r0.Lower = &Limit{Incl: r.Lower.Incl, Value: values[0]}
r1.Lower = &Limit{Incl: r.Lower.Incl, Value: values[0]}
case 2:
r0.Lower = &Limit{Incl: r.Lower.Incl, Value: values[0]}
r1.Lower = &Limit{Incl: r.Lower.Incl, Value: values[1]}
}
}
if r.Upper != nil {
values := strings.Split(r.Upper.Value, "/")
slice.TrimSpace(values)
switch len(values) {
case 1:
r0.Upper = &Limit{Incl: r.Upper.Incl, Value: values[0]}
r1.Upper = &Limit{Incl: r.Upper.Incl, Value: values[0]}
case 2:
r0.Upper = &Limit{Incl: r.Upper.Incl, Value: values[0]}
r1.Upper = &Limit{Incl: r.Upper.Incl, Value: values[1]}
}
}
return Relations{r0, r1}
}