python_code stringlengths 0 4.04M | repo_name stringlengths 7 58 | file_path stringlengths 5 147 |
|---|---|---|
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import xpress as xp
# Wrap is the xpress solver (https://pypi.org/project/xpress/, doc available at
# https://www.f... | CL-LNS-main | xpress_solver.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import os
import os.path
import tarfile
import zipfile
import ecole
import geco
import geco.generator
import glob
imp... | CL-LNS-main | instance_loader.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import multiprocessing
import os
import re
import subprocess
import sys
import sysconfig
from distutils.version impo... | CL-LNS-main | setup.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import submitit
import os
import argparse
from graph_datasets.bipartite_graph_loader import BipartiteGraphLoader
impo... | CL-LNS-main | train_neural_LNS.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from graph_datasets.bipartite_graph import *
from graph_datasets.bipartite_graph_dataset import BipartiteGraphDataset... | CL-LNS-main | LNS.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import pyscipopt as scip
# Wrap is the scip solver under a common API
class ScipSolver:
def __init__(self, time... | CL-LNS-main | scip_solver.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import torch_geometric
import torch
import torch.nn.init as init
#from neural_nets import prenorm
# GINConv network... | CL-LNS-main | neural_nets/gin_convolution.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import torch_geometric
import torch
import torch.nn.init as init
from neural_nets import prenorm
# GATConvolution... | CL-LNS-main | neural_nets/gat_convolution.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import torch
class LogScoreLoss(torch.nn.Module):
"""
Loss function to weight sample loss by confidence in ... | CL-LNS-main | neural_nets/losses.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import torch
import torch.nn.init as init
from neural_nets import gat_convolution
from neural_nets import gin_convol... | CL-LNS-main | neural_nets/gnn_policy.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import torch
class PrenormOld(torch.nn.Module):
def __init__(self, num_features, shift=True, scale=True, eps=1e... | CL-LNS-main | neural_nets/prenorm.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import torch_geometric
import torch
import torch.nn.init as init
from neural_nets import prenorm
# Implements the ... | CL-LNS-main | neural_nets/gasse_convolution.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
| CL-LNS-main | ml4co/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import hypothesis
import hypothesis.strategies as st
import unittest
import torch
import torch.nn.functional as F
f... | CL-LNS-main | ml4co/ops/split_and_pad_test.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import hypothesis
import hypothesis.strategies as st
import unittest
import torch
from ml4co.ops.prenorm import Pre... | CL-LNS-main | ml4co/ops/prenorm_test.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
| CL-LNS-main | ml4co/ops/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import os
import torch
import ml4co
torch.ops.load_library(
os.path.join(os.path.dirname(os.path.dirname(ml4co.... | CL-LNS-main | ml4co/ops/split_and_pad.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import os
import torch
import ml4co
torch.ops.load_library(
os.path.join(os.path.dirname(os.path.dirname(ml4co.... | CL-LNS-main | ml4co/ops/prenorm.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import ecole
import ilp_model
import numpy as np
import torch
from typing import Any, Callable, Optional, Tuple
im... | CL-LNS-main | ml4co/rl/env/ecole_wrapper.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import unittest
import numpy as np
import string
import random
import os
import sys
import graph_datasets.evaluation... | CL-LNS-main | graph_datasets/evaluation_data_test.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import sqlite3
import pickle
from pathlib import Path
import hashlib
import string
import random
import base64
import... | CL-LNS-main | graph_datasets/solved_milp_dataset.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import ecole
import torch
import numpy as np
import math
import time
def augment_variable_features_with_dynamic_ones... | CL-LNS-main | graph_datasets/bipartite_graph_observations.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import ecole.typing
class DualBound(ecole.typing.InformationFunction):
def __init__(self):
super().__in... | CL-LNS-main | graph_datasets/informations.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import unittest
import torch
import random
import string
import os
import graph_datasets.bipartite_graph as bg
impor... | CL-LNS-main | graph_datasets/bipartite_graph_loader_test.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from pyscipopt import Eventhdlr
from pyscipopt import SCIP_EVENTTYPE
class DualBoundEventHandler(Eventhdlr):
def... | CL-LNS-main | graph_datasets/event_handlers.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import sqlite3
from pathlib import Path
import hashlib
import string
import random
import functools
from collections ... | CL-LNS-main | graph_datasets/evaluation_data.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import torch_geometric
import sqlite3
import pickle
import base64
import random
from pathlib import Path
from graph_d... | CL-LNS-main | graph_datasets/bipartite_graph_dataset.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import unittest
import ecole
import torch
import torch_geometric
import numpy as np
import pyscipopt
import graph_dat... | CL-LNS-main | graph_datasets/featurization_test.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
| CL-LNS-main | graph_datasets/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import graph_datasets.bipartite_graph_dataset as bgd
import torch_geometric
#import dgl
import random
import torch
... | CL-LNS-main | graph_datasets/bipartite_graph_loader.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import torch_geometric
import torch
import numpy as np
import networkx as nx
class BipartiteGraph(torch_geometric.d... | CL-LNS-main | graph_datasets/bipartite_graph.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import ecole.typing
import competition.common.rewards as competition_rewards
# Returns the relative improvement in ... | CL-LNS-main | graph_datasets/step_rewards.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import unittest
import ilp_solver
import random
import string
from graph_datasets.solved_milp_dataset import SolvedMi... | CL-LNS-main | graph_datasets/solved_milp_dataset_test.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import unittest
import ecole
import torch
import torch_geometric
import numpy as np
import string
import random
impor... | CL-LNS-main | graph_datasets/bipartite_graph_dataset_test.py |
# coding=utf-8
# Copyright (c) Facebook, Inc. and its affiliates.
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in ... | accentor-main | run_language_modeling.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import json
import random
import argparse
import os
def clean(x):
return x.replace("\n", "").replace("\r", "").replace("\t", " ").strip()
parser = argparse.ArgumentParser()
parser.add_argument("--data", default="./accentor-sgd/", type=str, required=False, help="... | accentor-main | gen_parlai_data.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import json
import os
from utils import bleuscorer
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--inference", default="dev.inference.gpt2_10epoch_1e-3_fp16.json", type=str, required=False, help='inference file')
pars... | accentor-main | gen_predict.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import json
import os
import copy
import random
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--all", default=False, type=bool, required=False, help="use all dialogues rather than only augmented dialogues")
parser.add... | accentor-main | gen_delex.py |
# Copyright (c) Facebook, Inc. and its affiliates.
from transformers import GPT2LMHeadModel, GPT2Tokenizer
import torch
import argparse
import numpy as np
import json
from tqdm import tqdm
def set_seed(args):
np.random.seed(args.seed)
torch.manual_seed(args.seed)
if args.n_gpu > 0:
torch.cuda.manu... | accentor-main | run_generation.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import json
import random
import argparse
import os
parser = argparse.ArgumentParser()
parser.add_argument("--data", default="./simpletod/", type=str, required=False, help="path to delexed & augmented SGD")
args = parser.parse_args()
def clean(x):
return x.repla... | accentor-main | gen_arranger_input.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import nltk
def bleuscorer(hyps, refs):
#print(hyps, refs)
bleu = []
for hyp, ref in zip(hyps, refs):
hyp = hyp.split()
ref = [a.split() for a in ref]
#hyp = nltk.word_tokenize(hyp)
#ref = [nltk.word_tokenize(a) for a in re... | accentor-main | utils.py |
# coding=utf-8
# Copyright (c) Facebook, Inc. and its affiliates.
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in ... | accentor-main | run_multiple_choice.py |
# coding=utf-8
# Copyright (c) Facebook, Inc. and its affiliates.
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in ... | accentor-main | utils_multiple_choice.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import json
for fns in [["./lm.input.dev.eval.txt", "./lm.output.dev.cc.txt", "./dev.inference.gpt2_10epoch_1e-3_fp16.json", "lm.input.dev.eval.ff.txt"],
["./lm.input.test.eval.txt", "./lm.output.test.cc.txt", "./test.inference.gpt2_10epoch_1e-3_fp16.json... | accentor-main | gen_rewriter_data.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import json
with open("./acc_arranger_roberta_base_3epoch/is_test_true_eval_logits.txt", "r") as f:
model_outputs = f.read().strip().split("\n")
for i in range(len(model_outputs)):
model_outputs[i] = model_outputs[i].split()
for j in range(len... | accentor-main | gen_arranger_output.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import json
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--source", default="./MultiWOZ_2.1/data.json", type=str, required=False, help="Path to the MultiWOZ dataset.")
args = parser.parse_args()
... | accentor-main | v1.0/accentor-multiwoz.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import json
import argparse
import os
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--source", default="./dstc8-schema-guided-dialogue", type=str, required=False, help="Path to the SGD dataset.")
parser.add_argument("-... | accentor-main | v1.0/accentor-sgd.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# Implementation adapted from Slimmable - https://github.com/JiahuiYu/slimmable_networks
import torch
class CrossEntropyLossSoft(torch.nn.modules.loss._Loss):
""" inplace distillation for image classification """
def forward(self, output, ... | AlphaNet-main | loss_ops.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import random
import torch
import torch.nn as nn
import torch.distributed as dist
import torch.multiprocessing as mp
import models
from utils.config import setup
import utils.comm as comm
import utils.saver as saver
from data.dat... | AlphaNet-main | parallel_supernet_evo_search.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# Modified from AttentiveNAS (https://github.com/facebookresearch/AttentiveNAS)
import argparse
import builtins
import math
import os
import random
import shutil
import time
import warnings
import sys
import operator
from datetime import date
imp... | AlphaNet-main | train_alphanet.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# Modified from AttentiveNAS (https://github.com/facebookresearch/AttentiveNAS)
import argparse
import builtins
import math
import os
import random
import shutil
import time
import warnings
import sys
from datetime import date
import torch
import ... | AlphaNet-main | test_alphanet.py |
"""For pip."""
from glob import glob
from os.path import basename, splitext
from setuptools import find_packages, setup
exec(open("src/fonduer/_version.py").read())
setup(
name="fonduer",
version=__version__,
description="Knowledge base construction system for richly formatted data.",
long_description... | fonduer-master | setup.py |
"""conftest.py file that defines shared fixture functions.
See https://docs.pytest.org/en/stable/fixture.html#conftest-py-sharing-fixture-functions
"""
import os
import psycopg2
import pytest
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
from fonduer.meta import Meta
DB = "fonduer_test"
if "CI" in os.... | fonduer-master | tests/conftest.py |
"""Fonduer unit tests."""
| fonduer-master | tests/__init__.py |
"""Test Fonduer meta."""
import logging
import os
import psycopg2
import pytest
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
from sqlalchemy.exc import OperationalError
from fonduer import Meta
from fonduer.candidates.models import mention_subclass
from tests.conftest import CONN_STRING, DB
logger = lo... | fonduer-master | tests/test_meta.py |
"""Unit tests that involve postgres access."""
import logging
from fonduer.candidates import CandidateExtractor, MentionExtractor, MentionFigures
from fonduer.candidates.matchers import LambdaFunctionFigureMatcher
from fonduer.candidates.models import (
Candidate,
Mention,
candidate_subclass,
mention_s... | fonduer-master | tests/test_postgres.py |
"""Fonduer unit tests for extracting candidates."""
import logging
import pickle
from typing import Optional
import pytest
from fonduer.candidates import (
CandidateExtractor,
MentionCaptions,
MentionCells,
MentionDocuments,
MentionExtractor,
MentionFigures,
MentionNgrams,
MentionParag... | fonduer-master | tests/candidates/test_candidates.py |
"""Fonduer candidate unit tests."""
| fonduer-master | tests/candidates/__init__.py |
"""Fonduer unit tests for matchers."""
from unittest.mock import Mock
import pytest
from nltk.stem.porter import PorterStemmer
from fonduer.candidates.matchers import (
Concat,
DateMatcher,
DictionaryMatch,
Intersect,
Inverse,
LambdaFunctionFigureMatcher,
LambdaFunctionMatcher,
Locatio... | fonduer-master | tests/candidates/test_matchers.py |
"""Fonduer MLflow unit tests."""
import os
from pathlib import Path
from typing import Any, Dict, List
from unittest.mock import MagicMock
import emmental.meta
import mlflow
import mlflow.pyfunc
import numpy as np
import pandas as pd
import pytest
import yaml
from emmental.model import EmmentalModel
from packaging imp... | fonduer-master | tests/packaging/test_fonduer_model.py |
"""Fonduer packaging unit tests."""
| fonduer-master | tests/packaging/__init__.py |
"""Fonduer learning utils' unit tests."""
from fonduer.candidates.models import Candidate
from fonduer.learning.utils import confusion_matrix
def test_confusion_matrix():
"""Test the confusion matrix."""
# Synthesize candidates
cand1 = Candidate(id=1, type="type")
cand2 = Candidate(id=2, type="type")
... | fonduer-master | tests/learning/test_utils.py |
"""Fonduer learning unit tests."""
| fonduer-master | tests/learning/__init__.py |
"""Fonduer featurization unit tests."""
import itertools
import logging
import pytest
from fonduer.candidates import MentionNgrams
from fonduer.candidates.candidates import CandidateExtractorUDF
from fonduer.candidates.mentions import MentionExtractorUDF
from fonduer.candidates.models import candidate_subclass, menti... | fonduer-master | tests/features/test_features.py |
"""Fonduer feature unit tests."""
| fonduer-master | tests/features/__init__.py |
"""Fonduer table utils' tests."""
import logging
from fonduer.utils.utils_table import _min_range_diff
def test_min_range_diff(caplog):
"""Test the minimum range calculation for table utils."""
caplog.set_level(logging.INFO)
assert _min_range_diff(((0, 5), (0, 5))) == 0
assert _min_range_diff(((1, 5... | fonduer-master | tests/utils/test_utils_table.py |
"""Fonduer visualizer unit tests."""
from fonduer.candidates import MentionNgrams
from fonduer.candidates.candidates import CandidateExtractorUDF
from fonduer.candidates.matchers import OrganizationMatcher
from fonduer.candidates.mentions import MentionExtractorUDF
from fonduer.candidates.models import candidate_subcla... | fonduer-master | tests/utils/test_visualizer.py |
"""Fonduer unit tests' utils."""
| fonduer-master | tests/utils/__init__.py |
"""Fonduer load config unit tests."""
import os
from fonduer.utils.config import get_config
def test_load_config():
"""Simple sanity check for loading feature config."""
# Check that default is loaded
defaults = get_config()
assert defaults["featurization"]["textual"]["window_feature"]["size"] == 3
... | fonduer-master | tests/utils/test_config.py |
"""Fonduer UDF utils' unit tests."""
import logging
import numpy as np
from fonduer.utils.utils_udf import shift_label_matrix, unshift_label_matrix
def test_shift_label_matrix(caplog):
"""Test the label matrix shifter and unshifter."""
caplog.set_level(logging.INFO)
"""
L is a dense label matrix (A... | fonduer-master | tests/utils/test_utils_udf.py |
"""Fonduer data model's visual utils' unit tests."""
import pytest
from fonduer.candidates.mentions import MentionNgrams
from fonduer.parser.lingual_parser.spacy_parser import SpacyParser
from fonduer.parser.models import Document, Sentence
from fonduer.utils.data_model_utils.visual import get_horz_ngrams, get_vert_ng... | fonduer-master | tests/utils/data_model_utils/test_visual.py |
"""Fonduer data model's tabular utils' unit tests."""
import pytest
from fonduer.candidates import MentionNgrams
from fonduer.parser.preprocessors import HTMLDocPreprocessor
from fonduer.parser.visual_parser import PdfVisualParser
from fonduer.utils.data_model_utils.tabular import (
get_aligned_ngrams,
get_cel... | fonduer-master | tests/utils/data_model_utils/test_tabular.py |
"""Fonduer data model's structural utils unit tests."""
import pytest
from fonduer.candidates.mentions import MentionNgrams
from fonduer.parser.models import Document
from fonduer.parser.parser import ParserUDF
from fonduer.utils.data_model_utils import common_ancestor, lowest_common_ancestor_depth
def get_parser_ud... | fonduer-master | tests/utils/data_model_utils/test_structural.py |
"""Hardware labeling functions."""
import re
from itertools import chain
from fonduer.utils.data_model_utils import (
get_aligned_ngrams,
get_left_ngrams,
get_row_ngrams,
overlap,
)
from tests.shared.hardware_utils import ABSTAIN, FALSE, TRUE
def LF_storage_row(c):
"""Return True if temp mention'... | fonduer-master | tests/shared/hardware_lfs.py |
"""Hardware FonduerModel."""
import pickle
import numpy as np
from emmental.data import EmmentalDataLoader
from pandas import DataFrame
from fonduer.learning.dataset import FonduerDataset
from fonduer.packaging import FonduerModel
from fonduer.parser.models import Document
from tests.shared.hardware_lfs import TRUE
f... | fonduer-master | tests/shared/hardware_fonduer_model.py |
"""Fonduer shared modules for unit tests."""
| fonduer-master | tests/shared/__init__.py |
"""Hardware throttlers."""
import re
from fonduer.utils.data_model_utils import (
get_horz_ngrams,
get_vert_ngrams,
is_horz_aligned,
is_vert_aligned,
same_table,
)
from tests.shared.hardware_spaces import expand_part_range
def temp_throttler(c):
"""Temperature throttler."""
(part, attr) =... | fonduer-master | tests/shared/hardware_throttlers.py |
"""Hardware mention/candidate subclasses."""
from fonduer.candidates.models import candidate_subclass, mention_subclass
Part = mention_subclass("Part")
Temp = mention_subclass("Temp")
Volt = mention_subclass("Volt")
PartTemp = candidate_subclass("PartTemp", [Part, Temp])
PartVolt = candidate_subclass("PartVolt", [Par... | fonduer-master | tests/shared/hardware_subclasses.py |
"""Hardware matchers."""
import csv
from fonduer.candidates.matchers import (
DictionaryMatch,
Intersect,
LambdaFunctionMatcher,
RegexMatchSpan,
Union,
)
from fonduer.utils.data_model_utils import get_row_ngrams, overlap
temp_matcher = RegexMatchSpan(rgx=r"(?:[1][5-9]|20)[05]", longest_match_only=... | fonduer-master | tests/shared/hardware_matchers.py |
"""Hardware mention spaces."""
import logging
import re
from builtins import chr, range, str
from difflib import SequenceMatcher
from fonduer.candidates import MentionNgrams
from fonduer.candidates.models.implicit_span_mention import TemporaryImplicitSpanMention
logger = logging.getLogger(__name__)
def expand_part_... | fonduer-master | tests/shared/hardware_spaces.py |
"""Hardware utils."""
import codecs
import csv
import logging
from builtins import range
from fonduer.candidates.models import Candidate
from fonduer.learning.utils import confusion_matrix
try:
from IPython import get_ipython
if "IPKernelApp" not in get_ipython().config:
raise ImportError("console")
... | fonduer-master | tests/shared/hardware_utils.py |
"""Fonduer parser unit tests."""
import logging
import os
from typing import List
import pytest
from sqlalchemy.orm import Session
from fonduer.parser import Parser
from fonduer.parser.lingual_parser import SpacyParser
from fonduer.parser.models import Document
from fonduer.parser.parser import ParserUDF, SimpleParse... | fonduer-master | tests/parser/test_parser.py |
"""Fonduer simple parser unit tests."""
from fonduer.parser.lingual_parser import SimpleParser
def test_simple_parser_support():
"""Unit test of simple parser support."""
lingual_parser = SimpleParser()
assert lingual_parser.has_tokenizer_support()
assert not lingual_parser.has_NLP_support()
def tes... | fonduer-master | tests/parser/test_simple_parser.py |
"""Fonduer spacy parser unit tests."""
import os
import pytest
from fonduer.parser.lingual_parser.spacy_parser import (
SpacyParser,
TokenPreservingTokenizer,
set_custom_boundary,
)
from fonduer.parser.models import Sentence
@pytest.mark.skipif(
"CI" not in os.environ, reason="Only run non-English t... | fonduer-master | tests/parser/test_spacy_parser.py |
"""Fonduer parser unit tests."""
| fonduer-master | tests/parser/__init__.py |
"""Unit tests for preprocessors."""
from bs4 import BeautifulSoup
from fonduer.parser.preprocessors.hocr_doc_preprocessor import HOCRDocPreprocessor
def test_hocrpreprocessor():
"""Test hOCRDocPreprocessor with a simple hOCR."""
path = "tests/data/hocr_simple/md.hocr"
preprocessor = HOCRDocPreprocessor(p... | fonduer-master | tests/parser/test_preprocessor.py |
"""Fonduer visual_parser unit tests."""
import random
from operator import attrgetter
import pytest
from bs4 import BeautifulSoup
from fonduer.parser.preprocessors import HTMLDocPreprocessor
from fonduer.parser.visual_parser import PdfVisualParser
from tests.parser.test_parser import get_parser_udf
def test_visual_... | fonduer-master | tests/parser/test_visual_linker.py |
"""Fonduer e2e tests."""
| fonduer-master | tests/e2e/__init__.py |
"""Fonduer incremental e2e test."""
import logging
import os
import pytest
from snorkel.labeling import labeling_function
from fonduer.candidates import CandidateExtractor, MentionExtractor
from fonduer.candidates.models import Candidate
from fonduer.features import Featurizer
from fonduer.features.models import Feat... | fonduer-master | tests/e2e/test_incremental.py |
"""Fonduer e2e test."""
import logging
import os
import pickle
import emmental
import numpy as np
import pytest
from emmental.data import EmmentalDataLoader
from emmental.learner import EmmentalLearner
from emmental.model import EmmentalModel
from emmental.modules.embedding_module import EmbeddingModule
from snorkel.l... | fonduer-master | tests/e2e/test_e2e.py |
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/stable/config
# -- Path setup ------------------------------------------------------------... | fonduer-master | docs/conf.py |
"""Fonduer version."""
__version__ = "0.9.0+dev"
| fonduer-master | src/fonduer/_version.py |
"""Fonduer package."""
from fonduer._version import __version__
from fonduer.meta import Meta, init_logging
__all__ = ["__version__", "Meta", "init_logging"]
| fonduer-master | src/fonduer/__init__.py |
"""Fonduer meta class."""
import logging
import os
import tempfile
from builtins import object
from datetime import datetime
from typing import Any, Optional, Type
from urllib.parse import urlparse
import sqlalchemy
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlal... | fonduer-master | src/fonduer/meta.py |
"""Fonduer's candidate module."""
from fonduer.candidates.candidates import CandidateExtractor
from fonduer.candidates.mentions import (
MentionCaptions,
MentionCells,
MentionDocuments,
MentionExtractor,
MentionFigures,
MentionNgrams,
MentionParagraphs,
MentionSections,
MentionSenten... | fonduer-master | src/fonduer/candidates/__init__.py |
"""Fonduer mention."""
import logging
import re
from builtins import map, range
from typing import Any, Collection, Dict, Iterable, Iterator, List, Optional, Set, Union
from sqlalchemy.orm import Session
from fonduer.candidates.matchers import _Matcher
from fonduer.candidates.models import Candidate, Mention
from fon... | fonduer-master | src/fonduer/candidates/mentions.py |
"""Fonduer matcher."""
import re
from typing import Iterator, Set
from fonduer.candidates.models.figure_mention import TemporaryFigureMention
from fonduer.candidates.models.span_mention import TemporarySpanMention
from fonduer.candidates.models.temporary_context import TemporaryContext
WORDS = "words"
class _Matche... | fonduer-master | src/fonduer/candidates/matchers.py |
"""Fonduer candidate."""
import logging
from builtins import range
from itertools import product
from typing import (
Any,
Callable,
Collection,
Iterable,
List,
Optional,
Tuple,
Type,
Union,
)
from sqlalchemy.orm import Session
from fonduer.candidates.models import Candidate, Menti... | fonduer-master | src/fonduer/candidates/candidates.py |
"""Fonduer figure mention model."""
from typing import Any, Dict, Type
from sqlalchemy import Column, ForeignKey, Integer, UniqueConstraint
from sqlalchemy.orm import relationship
from fonduer.candidates.models.temporary_context import TemporaryContext
from fonduer.parser.models import Figure
from fonduer.parser.mode... | fonduer-master | src/fonduer/candidates/models/figure_mention.py |
"""Fonduer table mention model."""
from typing import Any, Dict, Type
from sqlalchemy import Column, ForeignKey, Integer, UniqueConstraint
from sqlalchemy.orm import relationship
from fonduer.candidates.models.temporary_context import TemporaryContext
from fonduer.parser.models import Table
from fonduer.parser.models... | fonduer-master | src/fonduer/candidates/models/table_mention.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.