<commit_before>__author__ = 'Alva'

# This model supports user labeling of resources in various ways.
# For a User u, this instantiates a subobject u.ulabels (like u.uaccess)
# that contains all the labeling functions.
#
# Functions include:
# - u.ulabels.label_resource(r, label)
#   instantiates a label for a resource. Resources can have multiple labels.
# - u.ulabels.unlabel_resource(r, label)
#   removes a label; there can be many labels.
# - u.ulabels.clear_resource_labels(r)
#   removes all labels for a resource
# - u.ulabels.favorite_resource(r)
#   favorites a resource
# - u.ulabels.unfavorite_resource(r)
#   removes a favorite
# - u.ulabels.file_resource(r, folder_name)
#   adds a folder name for a resource
# - u.ulabels.unfile_resource(r)
#   remove folder name
#
# and the reporting functions
# - u.ulabels.labeled_resources
#   A queryset of resources that are labeled.
# - u.ulabels.filed_resources (trivial, not yet implemented, available tomorrow)
#   A queryset of resources that are filed in folders
# - u.ulabels.favorite_resources (trivial, not yet implemented, available tomorrow)
#   A queryset of resources that have been favorited
# - u.ulabels.get_resources_with_label(label)
#   Get a queryset of resources possessing a specific label.
# - u.ulabels.get_resources_in_folder(folder)
#   Get a queryset of resources in a specific folder.

# For a BaseResource r, this also adds a subobject rlabels that reports on labels for resources
# -	r.rlabels.get_folder(u)
# - r.rlabels.get_labels(u)
# - r.rlabels.is_favorite(u) (trivial, not yet implemented, tomorrow)

import re

from django.contrib.auth.models import User
from django.db import models

from hs_core.models import BaseResource

######################################
######################################
# Labeling and annotation subsystem
######################################
######################################

# A "label" is something that is assigned by a person other than the original creator.
# It is not part of metadata. Labels include
# 1) making something a favorite.
# 2) assigning a folder
# 3) assigning a keyword

######################################
# Exceptions specific to access control:
# b) Usage Exception: bad parameters
######################################
<commit_msg>[#774] comments changed to docstring<commit_after>__author__ = 'Alva'

"""
 This model supports user labeling of resources in various ways.
 For a User u, this instantiates a subobject u.ulabels (like u.uaccess)
 that contains all the labeling functions.

 Functions include:
 - u.ulabels.label_resource(r, label)
   instantiates a label for a resource. Resources can have multiple labels.
 - u.ulabels.unlabel_resource(r, label)
   removes a label; there can be many labels.
 - u.ulabels.clear_resource_labels(r)
   removes all labels for a resource
 - u.ulabels.favorite_resource(r)
   favorites a resource
 - u.ulabels.unfavorite_resource(r)
   removes a favorite
 - u.ulabels.file_resource(r, folder_name)
   adds a folder name for a resource
 - u.ulabels.unfile_resource(r)
   remove folder name

 and the reporting functions
 - u.ulabels.labeled_resources
   A queryset of resources that are labeled.
 - u.ulabels.filed_resources (trivial, not yet implemented, available tomorrow)
   A queryset of resources that are filed in folders
 - u.ulabels.favorite_resources (trivial, not yet implemented, available tomorrow)
   A queryset of resources that have been favorited
 - u.ulabels.get_resources_with_label(label)
   Get a queryset of resources possessing a specific label.
 - u.ulabels.get_resources_in_folder(folder)
   Get a queryset of resources in a specific folder.

 For a BaseResource r, this also adds a subobject rlabels that reports on labels for resources
 -	r.rlabels.get_folder(u)
 - r.rlabels.get_labels(u)
 - r.rlabels.is_favorite(u) (trivial, not yet implemented, tomorrow)
"""

import re

from django.contrib.auth.models import User
from django.db import models

from hs_core.models import BaseResource

######################################
######################################
# Labeling and annotation subsystem
######################################
######################################

# A "label" is something that is assigned by a person other than the original creator.
# It is not part of metadata. Labels include
# 1) making something a favorite.
# 2) assigning a folder
# 3) assigning a keyword

######################################
# Exceptions specific to access control:
# b) Usage Exception: bad parameters
######################################

{'fraction_non_alphanumeric': 0.1655773420479303, 'fraction_numerical': 0.00196078431372549, 'mean_word_length': 4.7894073139974775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '69758', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1269, 'n_words': 470}