1*46c4c49dSIbrahim Kanouche// Copyright 2017 Google Inc. 2*46c4c49dSIbrahim Kanouche// 3*46c4c49dSIbrahim Kanouche// Licensed under the Apache License, Version 2.0 (the "License"); 4*46c4c49dSIbrahim Kanouche// you may not use this file except in compliance with the License. 5*46c4c49dSIbrahim Kanouche// You may obtain a copy of the License at 6*46c4c49dSIbrahim Kanouche// 7*46c4c49dSIbrahim Kanouche// http://www.apache.org/licenses/LICENSE-2.0 8*46c4c49dSIbrahim Kanouche// 9*46c4c49dSIbrahim Kanouche// Unless required by applicable law or agreed to in writing, software 10*46c4c49dSIbrahim Kanouche// distributed under the License is distributed on an "AS IS" BASIS, 11*46c4c49dSIbrahim Kanouche// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*46c4c49dSIbrahim Kanouche// See the License for the specific language governing permissions and 13*46c4c49dSIbrahim Kanouche// limitations under the License. 14*46c4c49dSIbrahim Kanouche 15*46c4c49dSIbrahim Kanouchepackage licenseclassifier 16*46c4c49dSIbrahim Kanouche 17*46c4c49dSIbrahim Kanoucheimport "regexp" 18*46c4c49dSIbrahim Kanouche 19*46c4c49dSIbrahim Kanouchevar ( 20*46c4c49dSIbrahim Kanouche reCCBYNC = regexp.MustCompile(`(?i).*\bAttribution NonCommercial\b.*`) 21*46c4c49dSIbrahim Kanouche reCCBYNCND = regexp.MustCompile(`(?i).*\bAttribution NonCommercial NoDerivs\b.*`) 22*46c4c49dSIbrahim Kanouche reCCBYNCSA = regexp.MustCompile(`(?i).*\bAttribution NonCommercial ShareAlike\b.*`) 23*46c4c49dSIbrahim Kanouche 24*46c4c49dSIbrahim Kanouche // forbiddenRegexps are regular expressions we expect to find in 25*46c4c49dSIbrahim Kanouche // forbidden licenses. If we think we have a forbidden license but 26*46c4c49dSIbrahim Kanouche // don't find the equivalent phrase, then it's probably just a 27*46c4c49dSIbrahim Kanouche // misclassification. 28*46c4c49dSIbrahim Kanouche forbiddenRegexps = map[string]*regexp.Regexp{ 29*46c4c49dSIbrahim Kanouche AGPL10: regexp.MustCompile(`(?i).*\bAFFERO GENERAL PUBLIC LICENSE\b.*`), 30*46c4c49dSIbrahim Kanouche AGPL30: regexp.MustCompile(`(?i).*\bGNU AFFERO GENERAL PUBLIC LICENSE\b.*`), 31*46c4c49dSIbrahim Kanouche CCBYNC10: reCCBYNC, 32*46c4c49dSIbrahim Kanouche CCBYNC20: reCCBYNC, 33*46c4c49dSIbrahim Kanouche CCBYNC25: reCCBYNC, 34*46c4c49dSIbrahim Kanouche CCBYNC30: reCCBYNC, 35*46c4c49dSIbrahim Kanouche CCBYNC40: reCCBYNC, 36*46c4c49dSIbrahim Kanouche CCBYNCND10: regexp.MustCompile(`(?i).*\bAttribution NoDerivs NonCommercial\b.*`), 37*46c4c49dSIbrahim Kanouche CCBYNCND20: reCCBYNCND, 38*46c4c49dSIbrahim Kanouche CCBYNCND25: reCCBYNCND, 39*46c4c49dSIbrahim Kanouche CCBYNCND30: reCCBYNCND, 40*46c4c49dSIbrahim Kanouche CCBYNCND40: regexp.MustCompile(`(?i).*\bAttribution NonCommercial NoDerivatives\b.*`), 41*46c4c49dSIbrahim Kanouche CCBYNCSA10: reCCBYNCSA, 42*46c4c49dSIbrahim Kanouche CCBYNCSA20: reCCBYNCSA, 43*46c4c49dSIbrahim Kanouche CCBYNCSA25: reCCBYNCSA, 44*46c4c49dSIbrahim Kanouche CCBYNCSA30: reCCBYNCSA, 45*46c4c49dSIbrahim Kanouche CCBYNCSA40: reCCBYNCSA, 46*46c4c49dSIbrahim Kanouche WTFPL: regexp.MustCompile(`(?i).*\bDO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE\b.*`), 47*46c4c49dSIbrahim Kanouche } 48*46c4c49dSIbrahim Kanouche) 49