Age Suitability Prediction

Movie scirpt analysis modeling class

class pororo.tasks.age_suitability.PororoAgeSuitabilityFactory(task: str, lang: str, model: Optional[str])[source]

Bases: pororo.tasks.utils.base.PororoFactoryBase

Conduct Age Suitability task

English (roberta.base.en.movie)

  • dataset: Age Suitability Rating (Mahsa Shafaei et al. 2020)

  • metric for rating: F1 (82.0)

  • metric for emotion: Pearson & Spearman

    Emotion Type

    Pearson

    Spearman

    Nudity

    0.41

    0.41

    Violence

    0.46

    0.44

    Profanity

    0.52

    0.53

    Alcohol

    0.43

    0.39

    Frightening

    0.49

    0.47

    AVERAGE

    0.44

    0.43

Parameters

script – (str) input script

Returns

predicted rating and emotion of a given (movie) script

Return type

dict

Examples

>>> age_suitability = Pororo(task="age_suitability", lang="en")
>>> age_suitability("When I was a little girl ...")
{
    'rating': {
        'class':'R',
        'description':'Restricted. Under 17 requires accompanying parent or adult guardian.'
    },
    'emotion': {
        'nudity':'Low',
        'violence': 'Moderate',
        'profanity': 'Moderate',
        'alcohol': 'Mild',
        'frightening': 'Severe'
    }
}
static get_available_langs()[source]
static get_available_models()[source]
load(device: str)[source]

Load user-selected task-specific model

Parameters

device (str) – device information

Returns

User-selected task-specific model

Return type

object

class pororo.tasks.age_suitability.PororoBertMovie(model, config)[source]

Bases: pororo.tasks.utils.base.PororoSimpleBase

predict(script: str, **kwargs)dict[source]

Conduct (movie) script analysis

Parameters

script – (str) input script

Returns

predict rating and emotion of a given script

Return type

dict

Notes

Description of Movie Rating:

G: General Audiences. All ages admitted. PG: Parental Guidance Suggested. Some material may not be suitable for children. PG-13: Parents Strongly Cautioned. Some material may be inappropriate for children under 13. R: Restricted. Under 17 requires accompanying parent or adult guardian. NC-17: No Children. No one 17 and under admitted.

class pororo.tasks.age_suitability.RobertaEncoder(device, model_path, tokenizer, config, num_genre=24, num_rating=5, num_emotion=5)[source]

Bases: torch.nn.modules.module.Module

RoBERTa encoder.

forward(script: str)tuple[source]
Parameters

script (str) – input script

Returns

tuple of three logits

classmethod from_pretrained(device, model_path, tokenizer, config)[source]
training: bool