1// Copyright 2017 Google Inc. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Package results contains the result type returned by the classifier backend. 16// Placing the type into a separate module allows us to swap out backends and 17// still use the same datatype. 18package results 19 20// LicenseType is the assumed type of the unknown license. 21type LicenseType struct { 22 Filename string 23 Name string 24 Confidence float64 25 Offset int 26 Extent int 27} 28 29// LicenseTypes is a list of LicenseType objects. 30type LicenseTypes []*LicenseType 31 32func (lt LicenseTypes) Len() int { return len(lt) } 33func (lt LicenseTypes) Swap(i, j int) { lt[i], lt[j] = lt[j], lt[i] } 34func (lt LicenseTypes) Less(i, j int) bool { 35 if lt[i].Confidence > lt[j].Confidence { 36 return true 37 } 38 if lt[i].Confidence < lt[j].Confidence { 39 return false 40 } 41 return lt[i].Filename < lt[j].Filename 42} 43