Skip to content

Commit

Permalink
run isort
Browse files Browse the repository at this point in the history
  • Loading branch information
felixgwu committed Oct 14, 2022
1 parent 9d9a14c commit cb582ed
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 79 deletions.
26 changes: 8 additions & 18 deletions bert_score/score.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
import os
import pathlib
import sys
import time
import pathlib
import torch
from collections import defaultdict

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
import numpy as np
import pandas as pd

from collections import defaultdict
import torch
from mpl_toolkits.axes_grid1 import make_axes_locatable
from transformers import AutoTokenizer

from .utils import (
get_model,
get_tokenizer,
get_idf_dict,
bert_cos_score_idf,
get_bert_embedding,
lang2model,
model2layers,
get_hash,
cache_scibert,
sent_encode,
)

from .utils import (bert_cos_score_idf, cache_scibert, get_bert_embedding,
get_hash, get_idf_dict, get_model, get_tokenizer,
lang2model, model2layers, sent_encode)

__all__ = ["score", "plot_example"]

Expand Down
27 changes: 9 additions & 18 deletions bert_score/scorer.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
import os
import pathlib
import sys
import time
import pathlib
import torch
import warnings
from collections import defaultdict

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
import numpy as np
import pandas as pd
import warnings

from collections import defaultdict
import torch
from mpl_toolkits.axes_grid1 import make_axes_locatable
from transformers import AutoTokenizer

from .utils import (
get_model,
get_tokenizer,
get_idf_dict,
bert_cos_score_idf,
get_bert_embedding,
lang2model,
model2layers,
get_hash,
cache_scibert,
sent_encode,
)
from .utils import (bert_cos_score_idf, cache_scibert, get_bert_embedding,
get_hash, get_idf_dict, get_model, get_tokenizer,
lang2model, model2layers, sent_encode)


class BERTScorer:
Expand Down
22 changes: 11 additions & 11 deletions bert_score/utils.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import sys
import os
import torch
from math import log
import sys
from collections import Counter, defaultdict
from functools import partial
from itertools import chain
from collections import defaultdict, Counter
from math import log
from multiprocessing import Pool
from functools import partial
from tqdm.auto import tqdm
from torch.nn.utils.rnn import pad_sequence
from packaging import version

from transformers import BertConfig, XLNetConfig, XLMConfig, RobertaConfig
from transformers import AutoModel, GPT2Tokenizer, AutoTokenizer
import torch
from packaging import version
from torch.nn.utils.rnn import pad_sequence
from tqdm.auto import tqdm
from transformers import (AutoModel, AutoTokenizer, BertConfig, GPT2Tokenizer,
RobertaConfig, XLMConfig, XLNetConfig)
from transformers import __version__ as trans_version

from . import __version__
from transformers import __version__ as trans_version

__all__ = []

Expand Down
3 changes: 2 additions & 1 deletion bert_score_cli/score.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import os
import argparse
import os

import torch

import bert_score
Expand Down
5 changes: 3 additions & 2 deletions bert_score_cli/visualize.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python
import argparse
import os
import time
import argparse
import torch
from collections import defaultdict

import torch

import bert_score


Expand Down
16 changes: 9 additions & 7 deletions get_rescale_baseline/get_rescale_baseline.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import argparse
import gzip
import os
from random import shuffle

import matplotlib
import matplotlib.pyplot as plt
import bert_score
import torch
from random import shuffle
import sacrebleu
import numpy as np
import pandas as pd
import sacrebleu
import torch
from tqdm.auto import tqdm
import os
import argparse
import gzip

import bert_score


def get_data(lang="en"):
Expand Down
13 changes: 6 additions & 7 deletions reproduce/get_wmt17_sys_results.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import numpy as np
import pandas as pd
import argparse
import os
import pickle as pkl
from collections import defaultdict
import os
import torch
import argparse

from tqdm.auto import tqdm, trange
from collections import defaultdict
import numpy as np
import pandas as pd
import torch
from scipy.stats import pearsonr
from tqdm.auto import tqdm, trange

import bert_score

Expand Down
13 changes: 6 additions & 7 deletions reproduce/get_wmt18_seg_results.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import numpy as np
import pandas as pd
import argparse
import os
import pickle as pkl
from collections import defaultdict
import os
import torch
import argparse

from tqdm.auto import tqdm, trange
from collections import defaultdict
import numpy as np
import pandas as pd
import torch
from scipy.stats import pearsonr
from tqdm.auto import tqdm, trange

import bert_score

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from io import open

from setuptools import find_packages, setup

setup(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_score_function.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import unittest
import bert_score

from transformers import __version__ as ht_version

import bert_score
from tests.custom_assertions import CustomAssertions


cands = [
"28-year-old chef found dead in San Francisco mall",
"A 28-year-old chef who recently moved to San Francisco was found dead in the staircase of a local shopping center.",
Expand Down
3 changes: 2 additions & 1 deletion tests/test_scorer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import unittest

from transformers import __version__ as ht_version
import bert_score

import bert_score
from tests.custom_assertions import CustomAssertions

cands = [
Expand Down
10 changes: 5 additions & 5 deletions tune_layers/tune_layers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import argparse
import os
import re
import argparse
import torch
import numpy as np

from tqdm.auto import tqdm, trange
from collections import defaultdict

import numpy as np
import torch
from scipy.stats import pearsonr
from tqdm.auto import tqdm, trange

import bert_score

Expand Down

0 comments on commit cb582ed

Please sign in to comment.