<commit_before>// --------------------------------------------------------
// Code generated by Papyrus C++
// --------------------------------------------------------

#define Annotator_AnnotatorLib_Object_BODY

/************************************************************
 Object class body
 ************************************************************/

// include associated header file
#include <algorithm>
#include <assert.h>
#include "AnnotatorLib/Object.h"
#include "AnnotatorLib/Annotation.h"

// Derived includes directives

namespace AnnotatorLib {

// static attributes (if any)

static long lastId = 10000;

/**
 *
 * @return id
 */
Object::Object() : id(genId()) { }

Object::Object(unsigned long id) : id(id) { }

unsigned long Object::genId() {
    lastId += 3;
    return lastId;
}

unsigned long Object::getId() const
{
    return id;
}

std::string Object::getName()
{
    return name;
}

void Object::setName(std::string name)
{
    this->name = name;
}

Class *Object::getClass() const
{
    return objectClass;
}

void Object::setClass(Class *c)
{
    this->objectClass = c;
}

std::vector<Attribute *> Object::getAttributes() const
{
    return attributes;
}

bool Object::addAttribute(Attribute *attribute)
{
    if (attribute != nullptr && std::find(attributes.begin(), attributes.end(), attribute) == attributes.end()) {
        attributes.push_back(attribute);
        return true;
    }
    return false;
}

bool Object::removeAttribute(Attribute *attribute)
{
    std::vector<Attribute *>::const_iterator position = std::find(attributes.begin(), attributes.end(), attribute);
    if (position != attributes.end()){
        attributes.erase(position);
        return true;
    }
    return false;
}

Annotation *Object::getFirstAnnotation() const
{
    if(annotations.size() == 0)
        return nullptr;
    return annotations[0]->getFirst();
}

Annotation *Object::getFirstAnnotation(Frame *frame) const
{
    Annotation *annotation = this->getFirstAnnotation();
    while(annotation != nullptr && !annotation->isLast()){

        if(annotation->getFrame()->getNumber() < frame->getNumber()){
            annotation = annotation->getNext();

        } else if (annotation->getFrame()->getNumber() == frame->getNumber()){
            return annotation;

        } else if (annotation->getFrame()->getNumber() > frame->getNumber()){
            if(annotation->isFirst())
                return nullptr;
            else
                return annotation->getPrevious();
        }
    }
    return nullptr;
}

std::vector<Annotation *> Object::getAnnotations() const
{
    return annotations;
}

bool Object::addAnnotation(Annotation *annotation)
{
    if (annotation != nullptr && std::find(annotations.begin(), annotations.end(), annotation) == annotations.end()) {
        annotations.push_back(annotation);
        annotation->setObject(this);
        return true;
    }
    return false;
}

bool Object::removeAnnotation(Annotation *annotation)
{
    std::vector<Annotation *>::const_iterator position = std::find(annotations.begin(), annotations.end(), annotation);
    if (position != annotations.end()){
        annotations.erase(position);
        return true;
    }
    return false;
}

std::vector<Frame *> Object::getFrames() const
{
    return frames;
}

bool Object::addFrame(Frame *frame)
{
    if (frame != nullptr && std::find(frames.begin(), frames.end(), frame) == frames.end()) {
        frames.push_back(frame);
        return true;
    }
    return false;
}

bool Object::removeFrame(Frame *frame)
{
    std::vector<Frame *>::const_iterator position = std::find(frames.begin(), frames.end(), frame);
    if (position != frames.end()){
        frames.erase(position);
        return true;
    }
    return false;
}

bool Object::appearsInFrame(Frame *frame) const
{
    if(annotations.size() > 0)
    {
        Annotation *annotation = annotations[0];
        Annotation *first = annotation->getFirst();
        assert(first);
        Annotation *last = annotation->getLast();
        assert(last);
        if(first->getFrame()->getNumber() <= frame->getNumber()
                && last->getFrame()->getNumber() >= frame->getNumber())
            return true;
        if(first->getFrame()->getNumber() <= frame->getNumber()
                && !last->isFinished())
            return true;
    }
    return false;
}

} // of namespace AnnotatorLib<commit_msg>remove frame from Object if it doesn't contain any annotations<commit_after>// --------------------------------------------------------
// Code generated by Papyrus C++
// --------------------------------------------------------

#define Annotator_AnnotatorLib_Object_BODY

/************************************************************
 Object class body
 ************************************************************/

// include associated header file
#include <algorithm>
#include <assert.h>
#include "AnnotatorLib/Object.h"
#include "AnnotatorLib/Annotation.h"

// Derived includes directives

namespace AnnotatorLib {

// static attributes (if any)

static long lastId = 10000;

/**
 *
 * @return id
 */
Object::Object() : id(genId()) { }

Object::Object(unsigned long id) : id(id) { }

unsigned long Object::genId() {
    lastId += 3;
    return lastId;
}

unsigned long Object::getId() const
{
    return id;
}

std::string Object::getName()
{
    return name;
}

void Object::setName(std::string name)
{
    this->name = name;
}

Class *Object::getClass() const
{
    return objectClass;
}

void Object::setClass(Class *c)
{
    this->objectClass = c;
}

std::vector<Attribute *> Object::getAttributes() const
{
    return attributes;
}

bool Object::addAttribute(Attribute *attribute)
{
    if (attribute != nullptr && std::find(attributes.begin(), attributes.end(), attribute) == attributes.end()) {
        attributes.push_back(attribute);
        return true;
    }
    return false;
}

bool Object::removeAttribute(Attribute *attribute)
{
    std::vector<Attribute *>::const_iterator position = std::find(attributes.begin(), attributes.end(), attribute);
    if (position != attributes.end()){
        attributes.erase(position);
        return true;
    }
    return false;
}

Annotation *Object::getFirstAnnotation() const
{
    if(annotations.size() == 0)
        return nullptr;
    return annotations[0]->getFirst();
}

Annotation *Object::getFirstAnnotation(Frame *frame) const
{
    Annotation *annotation = this->getFirstAnnotation();
    while(annotation != nullptr && !annotation->isLast()){

        if(annotation->getFrame()->getFrameNumber() < frame->getFrameNumber()){
            annotation = annotation->getNext();

        } else if (annotation->getFrame()->getFrameNumber() == frame->getFrameNumber()){
            return annotation;

        } else if (annotation->getFrame()->getFrameNumber() > frame->getFrameNumber()){
            if(annotation->isFirst())
                return nullptr;
            else
                return annotation->getPrevious();
        }
    }
    return nullptr;
}

std::vector<Annotation *> Object::getAnnotations() const
{
    return annotations;
}

bool Object::addAnnotation(Annotation *annotation)
{
    if (annotation != nullptr && std::find(annotations.begin(), annotations.end(), annotation) == annotations.end()) {
        annotations.push_back(annotation);
        annotation->setObject(this);
        return true;
    }
    return false;
}

bool Object::removeAnnotation(Annotation *annotation)
{
    std::vector<Annotation *>::const_iterator position = std::find(annotations.begin(), annotations.end(), annotation);
    if (position != annotations.end()){
        Frame* frame = annotation->getFrame();
        if (frame) {
            frame->removeAnnotation(annotation);
            if (!frame->hasAnnotations()) this->removeFrame(frame);
        }
        annotations.erase(position);
        return true;
    }
    return false;
}

std::vector<Frame *> Object::getFrames() const
{
    return frames;
}

bool Object::addFrame(Frame *frame)
{
    if (frame != nullptr && std::find(frames.begin(), frames.end(), frame) == frames.end()) {
        frames.push_back(frame);
        return true;
    }
    return false;
}

bool Object::removeFrame(Frame *frame)
{
    std::vector<Frame *>::const_iterator position = std::find(frames.begin(), frames.end(), frame);
    if (position != frames.end()){
        frames.erase(position);
        return true;
    }
    return false;
}

bool Object::appearsInFrame(Frame *frame) const
{
    if(annotations.size() > 0)
    {
        Annotation *annotation = annotations[0];
        Annotation *first = annotation->getFirst();
        assert(first);
        Annotation *last = annotation->getLast();
        assert(last);
        if(first->getFrame()->getFrameNumber() <= frame->getFrameNumber()
                && last->getFrame()->getFrameNumber() >= frame->getFrameNumber())
            return true;
        if(first->getFrame()->getFrameNumber() <= frame->getFrameNumber()
                && !last->isFinished())
            return true;
    }
    return false;
}

} // of namespace AnnotatorLib
{'fraction_non_alphanumeric': 0.19313445931125248, 'fraction_numerical': 0.0021934634788330775, 'mean_word_length': 3.010114335971856, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 89, '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': '655859', 'n_tokens_mistral': 2527, 'n_tokens_neox': 2447, 'n_words': 541}