Skip to content

Commit

Permalink
No issue: Add more license headers and address linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
reckart committed Jan 7, 2024
1 parent cab7e10 commit 1f64d99
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 16 deletions.
2 changes: 0 additions & 2 deletions ariadne/contrib/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
AutoTokenizer,
AutoConfig,
AutoModelForTokenClassification,
AutoModelForSequenceClassification,
AutoModelWithHeads,
BertModelWithHeads,
)

from ariadne.classifier import Classifier
Expand Down
1 change: 0 additions & 1 deletion ariadne/contrib/nltk.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import nltk


from ariadne.classifier import Classifier
from ariadne.contrib.inception_util import create_prediction, TOKEN_TYPE

Expand Down
4 changes: 2 additions & 2 deletions ariadne/contrib/simalign.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
# limitations under the License.
from cassis import Cas

import jieba
from simalign import SentenceAligner

from ariadne.classifier import Classifier
from ariadne.contrib.inception_util import create_prediction, SENTENCE_TYPE
from ariadne.contrib.inception_util import SENTENCE_TYPE


class SimAligner(Classifier):
def __init__(self):
Expand Down
1 change: 1 addition & 0 deletions ariadne/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import logging


def setup_logging(level=logging.DEBUG):
log_fmt = "%(process)d-%(thread)d %(asctime)s - %(name)s - %(levelname)s - %(message)s"
logging.basicConfig(level=level, format=log_fmt)
Expand Down
33 changes: 22 additions & 11 deletions scripts/convert_imdb_reviews.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Licensed to the Technische Universität Darmstadt under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The Technische Universität Darmstadt
# licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import random
from pathlib import Path
import tarfile
Expand Down Expand Up @@ -32,28 +47,24 @@ def main():

if not PATH_DATASETS_IMDB_EXTRACTED.exists():
with tarfile.open(PATH_DATASETS_IMDB) as mytar:

import os

def is_within_directory(directory, target):

abs_directory = os.path.abspath(directory)
abs_target = os.path.abspath(target)

prefix = os.path.commonprefix([abs_directory, abs_target])

return prefix == abs_directory

def safe_extract(tar, path=".", members=None, *, numeric_owner=False):

for member in tar.getmembers():
member_path = os.path.join(path, member.name)
if not is_within_directory(path, member_path):
raise Exception("Attempted Path Traversal in Tar File")

tar.extractall(path, members, numeric_owner=numeric_owner)



tar.extractall(path, members, numeric_owner=numeric_owner)

safe_extract(mytar, PATH_DATASETS_IMDB_EXTRACTED)

positive = [(p, "positive") for p in (PATH_DATASETS_IMDB_TRAIN / "pos").iterdir()]
Expand Down
15 changes: 15 additions & 0 deletions scripts/convert_sentiment_labelled_sentences.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Licensed to the Technische Universität Darmstadt under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The Technische Universität Darmstadt
# licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import html
from pathlib import Path
import zipfile
Expand Down
15 changes: 15 additions & 0 deletions scripts/tester.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Licensed to the Technische Universität Darmstadt under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The Technische Universität Darmstadt
# licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import json
import urllib.request
Expand Down
15 changes: 15 additions & 0 deletions scripts/util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Licensed to the Technische Universität Darmstadt under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The Technische Universität Darmstadt
# licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from pathlib import Path
from typing import List
Expand Down

0 comments on commit 1f64d99

Please sign in to comment.