repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
ngmm_tools
ngmm_tools-master/Analyses/Code_Verification/preprocessing/CreateMergedCatalogNGAWest3CA.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jun 29 13:58:20 2021 @author: glavrent """ # %% Required Packages # ====================================== #load libraries import os import sys import pathlib import glob import re #regular expression package import warnings #arithmetic librar...
15,940
42.673973
165
py
ngmm_tools
ngmm_tools-master/Analyses/Code_Verification/preprocessing/CreateCatalogNewEvents2021Lite.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jun 27 16:12:57 2021 @author: glavrent """ # Required Packages # ====================================== #load libraries import os import sys import pathlib import glob import re #regular expression package #arithmetic libraries import numpy as...
12,697
41.610738
162
py
ngmm_tools
ngmm_tools-master/Examples/example1/regression_inla_postprocessing.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Mar 27 12:20:36 2022 @author: glavrent """ # Working directory and Packages # --------------------------- #load packages import sys import pathlib import glob import re #regular expression package import pickle from joblib import cpu_count #a...
3,583
27
130
py
ngmm_tools
ngmm_tools-master/Examples/example1/create_examp_data.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Mar 26 16:01:54 2022 @author: glavrent """ # Working directory and Packages # --------------------------- #load packages import os import sys import pathlib import numpy as np import pandas as pd from scipy import sparse from scipy import linalg as scip...
5,227
27.259459
120
py
ngmm_tools
ngmm_tools-master/Examples/example1/regression_stan.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Mar 27 12:20:36 2022 @author: glavrent """ # Working directory and Packages # --------------------------- #load packages import os import sys import pathlib import glob import re #regular expression package import pickle from joblib import cp...
9,279
31.561404
130
py
ngmm_tools
ngmm_tools-master/Examples/example2/comparison_posterior.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Aug 17 07:00:55 2022 @author: glavrent """ # Load Packages # --------------------------- #arithmetic libraries import numpy as np from scipy import stats #statistics libraries import pandas as pd #plottign libraries import matplotlib as mpl from matplo...
5,270
33.907285
111
py
ngmm_tools
ngmm_tools-master/Examples/example2/create_reg_dataset.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Mar 26 16:01:54 2022 @author: glavrent """ # Working directory and Packages # --------------------------- import os import sys import pathlib #load packages import numpy as np import pandas as pd #plottign libraries import matplotlib as mpl from matplot...
1,674
19.180723
65
py
ngmm_tools
ngmm_tools-master/Examples/example2/regression_stan.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Mar 27 12:20:36 2022 @author: glavrent """ # Working directory and Packages # --------------------------- #load packages import os import sys import pathlib import glob import re #regular expression package import pickle from joblib import cp...
6,923
27.85
118
py
PT-M2
PT-M2-main/errant_score.py
from copy import deepcopy import math from tqdm import tqdm def get_ref(edits, src): cnt = 0 src = src.split() e_s = src for edit in edits: s_idx, e_idx, rep_tok = edit s_idx = cnt + s_idx e_idx = cnt + e_idx e_s = e_s[:s_idx] + rep_tok.split() + e_s[e_idx:] if rep_tok e...
22,995
39.062718
187
py
PT-M2
PT-M2-main/evaluate.py
import argparse import torch import os from utils import load_file, load_dir, write_to_csv from metrics import PTM2 def main(): parser = argparse.ArgumentParser("PT-M2") parser.add_argument("--source", type=str, default="source file path") parser.add_argument("--reference", type=str, default="reference f...
2,143
43.666667
124
py
PT-M2
PT-M2-main/utils.py
import os import sys import csv import random import numpy as np import torch sys.path.append("m2scorer") def load_file(src_file): sources = [] with open(src_file, "r", encoding="utf8") as fr: for line in fr: sources.append(line.strip("\n")) return sources def load_dir(ref_dir): ...
945
23.25641
59
py
PT-M2
PT-M2-main/bart_score.py
# %% import torch import torch.nn as nn import traceback from transformers import BartTokenizer, BartForConditionalGeneration from typing import List import numpy as np class BARTScorer: def __init__(self, device='cuda:0', max_length=1024, checkpoint='facebook/bart-large-cnn'): # Set up model self...
4,219
36.678571
97
py
PT-M2
PT-M2-main/metrics.py
from tqdm import tqdm import numpy as np import sys sys.path.append("m2score") from m2score.m2scorer import load_annotation from m2score.util import smart_open from m2score.levenshtein import batch_multi_pre_rec_f1, batch_multi_pre_rec_f1_sent from errant_score import batch_multi_pre_rec_f1_errant, batch_multi_pre_rec...
4,065
44.177778
140
py
PT-M2
PT-M2-main/bert_score/score.py
import os import sys import time import pathlib import torch 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 from transformers import AutoTokenizer from .utils import ( get_model, get_tokenizer, ...
11,254
35.781046
112
py
PT-M2
PT-M2-main/bert_score/scorer.py
import os import sys import time import pathlib import torch 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 from transformers import AutoTokenizer from .utils import ( get_model, ...
11,730
35.095385
133
py
PT-M2
PT-M2-main/bert_score/utils.py
import sys import os import torch from math import log from itertools import chain from collections import defaultdict, Counter from multiprocessing import Pool from functools import partial from tqdm.auto import tqdm from torch.nn.utils.rnn import pad_sequence from distutils.version import LooseVersion from transform...
28,789
44.553797
173
py
PT-M2
PT-M2-main/bert_score/__init__.py
__version__ = "0.3.11" from .score import * from .scorer import *
66
15.75
22
py
PT-M2
PT-M2-main/m2score/token_offsets.py
import sys import re import os from util import * from Tokenizer import PTBTokenizer assert len(sys.argv) == 1 # main # loop over sentences cum annotation tokenizer = PTBTokenizer() sentence = '' for line in sys.stdin: line = line.decode("utf8").strip() if line.startswith("S "): sentence = line[2:...
1,233
28.380952
96
py
PT-M2
PT-M2-main/m2score/levenshtein.py
from optparse import OptionParser from util import uniq import re import sys import math from copy import deepcopy from tqdm import tqdm from util import compute_weight_edits # batch evaluation of a list of sentences def batch_precision(candidates, sources, gold_edits, max_unchanged_words=2, beta=0.5, ignore_whites...
38,568
38.761856
187
py
PT-M2
PT-M2-main/m2score/combiner.py
import sys import levenshtein from getopt import getopt from util import paragraphs from util import smart_open def load_annotation(gold_file): source_sentences = [] gold_edits = [] fgold = smart_open(gold_file, 'r') puffer = fgold.read() fgold.close() puffer = puffer.decode('utf8') for ...
3,436
38.505747
154
py
PT-M2
PT-M2-main/m2score/m2scorer.py
import sys import levenshtein from getopt import getopt from util import paragraphs from util import smart_open def load_annotation(gold_file): source_sentences = [] gold_edits = [] fgold = smart_open(gold_file, 'r') puffer = fgold.read() fgold.close() # puffer = puffer.decode('utf8') f...
4,440
37.95614
171
py
PT-M2
PT-M2-main/m2score/util.py
import operator import random import math import re def smart_open(fname, mode = 'r'): if fname.endswith('.gz'): import gzip # Using max compression (9) by default seems to be slow. # Let's try using the fastest. ...
7,012
30.308036
127
py
PT-M2
PT-M2-main/m2score/__init__.py
0
0
0
py
PT-M2
PT-M2-main/m2score/Tokenizer.py
import re import sys class DummyTokenizer(object): def tokenize(self, text): return text.split() class PTBTokenizer(object): def __init__(self, language="en"): self.language = language self.nonbreaking_prefixes = {} self.nonbreaking_prefixes_numeric = {} self.non...
6,383
39.923077
98
py