Skip to content

License incorrectly identified as any-OSI #27

Description

@AjaiKN

When I run spdx-license-matcher on the following file, it says that the license is any-OSI, which is clearly incorrect:

This data made available by Google, Inc. under the Creative Commons Attribution 4.0 International license.
https://creativecommons.org/licenses/by/4.0/

The problem seems to be the normalization step:

from spdx_license_matcher.normalize import normalize

text = '''This data made available by Google, Inc. under the Creative Commons Attribution 4.0 International license.
https://creativecommons.org/licenses/by/4.0/
'''

normalize(text) # => 'normalized/url'

license = "Pick your favourite OSI approved license :)\n\nhttp://www.opensource.org/licenses/alphabetical\n"

normalize(license) # => 'normalized/url'

In both cases, the URL is replaced with normalized/url, then the first line is deleted because it contains the word "license":

# To remove the license name or title present at the beginning of the license text.
if 'license' in licenseText.split('\n')[0]:
licenseText = '\n'.join(licenseText.split('\n')[1:])

Because the normalized versions are exactly the same, the score is 1.0, so spdx-license-matcher skips the more thorough matching (which would be done by checkTextStandardLicense) and says there's an exact match:

elif all(score == 1.0 for score in list(matches.values())):
matchingString = 'The following license ID(s) match: ' + ", ".join(list(matches.keys()))
return matchingString
else:
for licenseID in matches:
listedLicense = getListedLicense(licenseID)
isTextStandard = checkTextStandardLicense(listedLicense, inputText)
if not isTextStandard:
matchingString = 'The following license ID(s) match: ' + licenseID
return matchingString
else:
return ''

Thanks a lot, by the way! I've been finding the SPDX tools very useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions