python_code stringlengths 0 4.04M | repo_name stringlengths 7 58 | file_path stringlengths 5 147 |
|---|---|---|
"""Fonduer paragraph 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 Paragraph
from fonduer.parse... | fonduer-master | src/fonduer/candidates/models/paragraph_mention.py |
"""Fonduer implicit span mention model."""
from typing import Any, Dict, List, Optional, Type
from sqlalchemy import Column, ForeignKey, Integer, String, UniqueConstraint
from sqlalchemy.dialects import postgresql
from sqlalchemy.orm import backref, relationship
from sqlalchemy.sql import text
from sqlalchemy.types im... | fonduer-master | src/fonduer/candidates/models/implicit_span_mention.py |
"""Fonduer's candidate model module."""
from fonduer.candidates.models.candidate import Candidate, candidate_subclass
from fonduer.candidates.models.caption_mention import CaptionMention
from fonduer.candidates.models.cell_mention import CellMention
from fonduer.candidates.models.document_mention import DocumentMention... | fonduer-master | src/fonduer/candidates/models/__init__.py |
"""Fonduer caption 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 Caption
from fonduer.parser.mo... | fonduer-master | src/fonduer/candidates/models/caption_mention.py |
"""Fonduer span mention model."""
from typing import Any, Dict, List, Optional, Type
from sqlalchemy import Column, ForeignKey, Integer, UniqueConstraint
from sqlalchemy.orm import backref, relationship
from sqlalchemy.types import PickleType
from fonduer.candidates.models.temporary_context import TemporaryContext
fr... | fonduer-master | src/fonduer/candidates/models/span_mention.py |
"""Fonduer candidate model."""
import logging
from typing import Any, Dict, List, Optional, Tuple, Type
from sqlalchemy import Column, ForeignKey, Integer, String, UniqueConstraint
from sqlalchemy.orm import backref, relationship
from fonduer.candidates.models.mention import Mention
from fonduer.meta import Meta
from... | fonduer-master | src/fonduer/candidates/models/candidate.py |
"""Fonduer section 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 Section
from fonduer.parser.mo... | fonduer-master | src/fonduer/candidates/models/section_mention.py |
"""Fonduer mention model."""
import logging
from typing import Any, Dict, List, Optional, Tuple, Type
from sqlalchemy import Column, ForeignKey, Integer, String, UniqueConstraint
from sqlalchemy.orm import backref, relationship
from fonduer.meta import Meta
from fonduer.parser.models import Context
from fonduer.utils... | fonduer-master | src/fonduer/candidates/models/mention.py |
"""Fonduer document 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 Document
from fonduer.parser.... | fonduer-master | src/fonduer/candidates/models/document_mention.py |
"""Fonduer temporary mention model."""
from builtins import object
from typing import Any, Dict, Type
from fonduer.parser.models.context import Context
class TemporaryContext(object):
"""Temporary Context class.
A context which does not incur the overhead of a proper ORM-based Context
object. The Tempor... | fonduer-master | src/fonduer/candidates/models/temporary_context.py |
"""Fonduer cell 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 Cell
from fonduer.parser.models.c... | fonduer-master | src/fonduer/candidates/models/cell_mention.py |
"""Customized MLflow model for Fonduer."""
import logging
import os
import sys
from io import BytesIO
from typing import Any, Callable, Dict, List, Optional, Union
import cloudpickle as pickle
import emmental
import numpy as np
import torch
import yaml
from emmental.model import EmmentalModel
from mlflow import pyfunc... | fonduer-master | src/fonduer/packaging/fonduer_model.py |
"""Fonduer's packaging module."""
from fonduer.packaging.fonduer_model import FonduerModel, log_model, save_model
__all__ = [
"FonduerModel",
"save_model",
"log_model",
]
| fonduer-master | src/fonduer/packaging/__init__.py |
"""Customized Emmental task for Fonduer."""
import logging
from functools import partial
from typing import Any, Dict, List, Optional, Union
from emmental.modules.embedding_module import EmbeddingModule
from emmental.modules.rnn_module import RNN
from emmental.modules.sparse_linear_module import SparseLinear
from emme... | fonduer-master | src/fonduer/learning/task.py |
"""Fonduer's learning module."""
| fonduer-master | src/fonduer/learning/__init__.py |
"""Fonduer dataset."""
import logging
from typing import Any, Dict, List, Optional, Tuple, Union
import numpy as np
import torch
from emmental.data import EmmentalDataset
from scipy.sparse import csr_matrix
from torch import Tensor
from fonduer.candidates.models import Candidate
from fonduer.learning.utils import mar... | fonduer-master | src/fonduer/learning/dataset.py |
"""Fonduer learning utils."""
import logging
from collections import Counter
from typing import Dict, List, Set, Tuple, Union
import numpy as np
from sqlalchemy.orm import Session
from fonduer.candidates.models import Candidate, Mention
from fonduer.learning.models.marginal import Marginal
logger = logging.getLogger... | fonduer-master | src/fonduer/learning/utils.py |
"""Fonduer's learning model module."""
from fonduer.learning.models.marginal import Marginal
from fonduer.learning.models.prediction import Prediction, PredictionKey
__all__ = ["Marginal", "Prediction", "PredictionKey"]
| fonduer-master | src/fonduer/learning/models/__init__.py |
"""Fonduer learning prediction model."""
from sqlalchemy import Column, Float
from fonduer.meta import Meta
from fonduer.utils.models.annotation import AnnotationKeyMixin, AnnotationMixin
class PredictionKey(AnnotationKeyMixin, Meta.Base):
"""A Prediction's annotation key."""
pass
class Prediction(Annotat... | fonduer-master | src/fonduer/learning/models/prediction.py |
"""Fonduer learning marginal model."""
from sqlalchemy import Boolean, Column, Float, ForeignKey, Integer, UniqueConstraint
from fonduer.meta import Meta
class Marginal(Meta.Base):
"""
A marginal probability corresponding to a (Candidate, value) pair.
Represents:
P(candidate = value) = probabil... | fonduer-master | src/fonduer/learning/models/marginal.py |
"""Fonduer's learning modules."""
| fonduer-master | src/fonduer/learning/modules/__init__.py |
"""Soft cross entropy loss."""
from typing import List
import torch
from torch import Tensor, nn as nn
from torch.nn import functional as F
class SoftCrossEntropyLoss(nn.Module):
"""Calculate the CrossEntropyLoss with soft targets.
:param weight: Weight to assign to each of the classes. Default: None
:p... | fonduer-master | src/fonduer/learning/modules/soft_cross_entropy_loss.py |
"""Concat linear."""
from typing import Any, Dict, List
import torch
from torch import Tensor, nn as nn
class ConcatLinear(nn.Module):
"""Concat different outputs and feed into a linear layer.
:param concat_output_keys: The keys of features to concat.
:param input_dim: The total sum of input dim.
:p... | fonduer-master | src/fonduer/learning/modules/concat_linear.py |
"""Fonduer featurizer."""
import itertools
import logging
from collections import defaultdict
from typing import (
Any,
Collection,
DefaultDict,
Dict,
Iterable,
List,
Optional,
Type,
Union,
)
from scipy.sparse import csr_matrix
from sqlalchemy.orm import Session
from fonduer.candid... | fonduer-master | src/fonduer/features/featurizer.py |
"""Fonduer's features module."""
from fonduer.features.feature_extractors import FeatureExtractor
from fonduer.features.featurizer import Featurizer
__all__ = ["Featurizer", "FeatureExtractor"]
| fonduer-master | src/fonduer/features/__init__.py |
"""Fonduer feature extractor."""
from typing import Callable, Dict, Iterator, List, Tuple, Union
from fonduer.candidates.models import Candidate
from fonduer.features.feature_libs.structural_features import (
extract_structural_features,
)
from fonduer.features.feature_libs.tabular_features import extract_tabular_... | fonduer-master | src/fonduer/features/feature_extractors.py |
"""Fonduer visual feature extractor."""
from typing import Dict, Iterator, List, Set, Tuple, Union
from fonduer.candidates.models import Candidate
from fonduer.candidates.models.span_mention import SpanMention, TemporarySpanMention
from fonduer.utils.data_model_utils import (
get_visual_aligned_lemmas,
is_horz... | fonduer-master | src/fonduer/features/feature_libs/visual_features.py |
"""Fonduer tabular feature extractor."""
from typing import Dict, Iterator, List, Set, Tuple, Union
from fonduer.candidates.models import Candidate
from fonduer.candidates.models.span_mention import SpanMention, TemporarySpanMention
from fonduer.utils.config import get_config
from fonduer.utils.data_model_utils import... | fonduer-master | src/fonduer/features/feature_libs/tabular_features.py |
"""Fonduer textual feature extractor."""
from builtins import range
from typing import Any, Callable, Dict, Iterator, List, Set, Tuple, Union
from treedlib import (
Children,
Compile,
Indicator,
LeftNgrams,
LeftSiblings,
Mention,
Ngrams,
Parents,
RightNgrams,
RightSiblings,
... | fonduer-master | src/fonduer/features/feature_libs/textual_features.py |
"""Fonduer's feature library module."""
from fonduer.features.feature_libs.structural_features import (
extract_structural_features,
)
from fonduer.features.feature_libs.tabular_features import extract_tabular_features
from fonduer.features.feature_libs.textual_features import extract_textual_features
from fonduer.... | fonduer-master | src/fonduer/features/feature_libs/__init__.py |
"""Fonduer tree structs."""
import re
from functools import lru_cache
from typing import Any, Dict, List, Optional, Union
from lxml import etree as et
from lxml.etree import _Element
from fonduer.parser.models import Sentence
from fonduer.utils.utils import get_as_dict
class XMLTree:
"""A generic tree represent... | fonduer-master | src/fonduer/features/feature_libs/tree_structs.py |
"""Fonduer structural feature extractor."""
from typing import Dict, Iterator, List, Set, Tuple, Union
from fonduer.candidates.models import Candidate
from fonduer.candidates.models.span_mention import SpanMention, TemporarySpanMention
from fonduer.utils.data_model_utils import (
common_ancestor,
get_ancestor_... | fonduer-master | src/fonduer/features/feature_libs/structural_features.py |
"""Fonduer's feature model module."""
from fonduer.features.models.feature import Feature, FeatureKey
__all__ = ["Feature", "FeatureKey"]
| fonduer-master | src/fonduer/features/models/__init__.py |
"""Fonduer feature model."""
from sqlalchemy import Column, Float
from sqlalchemy.dialects import postgresql
from fonduer.meta import Meta
from fonduer.utils.models.annotation import AnnotationKeyMixin, AnnotationMixin
class FeatureKey(AnnotationKeyMixin, Meta.Base):
"""A feature's key that identifies the defini... | fonduer-master | src/fonduer/features/models/feature.py |
"""Fonduer basic config and config utils."""
import logging
import os
from typing import Dict
import yaml
MAX_CONFIG_SEARCH_DEPTH = 25 # Max num of parent directories to look for config
logger = logging.getLogger(__name__)
default = {
"featurization": {
"textual": {
"window_feature": {"size"... | fonduer-master | src/fonduer/utils/config.py |
"""Fonduer visual utils."""
import warnings
from typing import NamedTuple
class Bbox(NamedTuple):
"""Bounding box."""
page: int
top: int
bottom: int
left: int
right: int
def bbox_from_span(span) -> Bbox: # type: ignore
"""Get bounding box from span.
:param span: The input span.
... | fonduer-master | src/fonduer/utils/utils_visual.py |
"""Fonduer tabular utils."""
import itertools
from builtins import range
from functools import lru_cache
from typing import List, Optional, Tuple, Union
from fonduer.parser.models.sentence import Sentence
from fonduer.parser.models.table import Cell
@lru_cache(maxsize=1024)
def _min_range_diff(coordinates: Tuple[Tup... | fonduer-master | src/fonduer/utils/utils_table.py |
"""Fonduer's utils module."""
| fonduer-master | src/fonduer/utils/__init__.py |
"""Fonduer parser utils."""
from typing import List, Optional, Tuple
def build_node(type: str, name: str, content: str) -> str:
"""
Wrap up content in to a html node.
:param type: content type (e.g., doc, section, text, figure)
:param name: content name (e.g., the name of the section)
:param name... | fonduer-master | src/fonduer/utils/utils_parser.py |
"""Fonduer UDF utils."""
import logging
from typing import (
Any,
Callable,
Dict,
Iterable,
Iterator,
List,
Optional,
Sequence,
Set,
Tuple,
Type,
Union,
)
import numpy as np
from scipy.sparse import csr_matrix
from sqlalchemy import String, Table
from sqlalchemy.dialects... | fonduer-master | src/fonduer/utils/utils_udf.py |
"""Fonduer utils."""
import re
from builtins import range
from typing import TYPE_CHECKING, Dict, Iterator, List, Set, Tuple, Type, Union
from fonduer.parser.models import Context, Document, Sentence
if TYPE_CHECKING: # to prevent circular imports
from fonduer.candidates.models import Candidate
def camel_to_un... | fonduer-master | src/fonduer/utils/utils.py |
"""Fonduer UDF."""
import logging
from multiprocessing import Manager, Process
from queue import Queue
from threading import Thread
from typing import Any, Collection, Dict, List, Optional, Set, Type, Union
from sqlalchemy import inspect
from sqlalchemy.orm import Session, scoped_session, sessionmaker
from fonduer.me... | fonduer-master | src/fonduer/utils/udf.py |
"""Fonduer visualizer."""
import logging
import os
import subprocess
import warnings
from builtins import object
from collections import defaultdict
from typing import DefaultDict, List, Optional, Tuple
from bs4 import BeautifulSoup
from IPython.display import DisplayHandle, display
from wand.color import Color
from w... | fonduer-master | src/fonduer/utils/visualizer.py |
"""Fonduer annotation model."""
from typing import Tuple
from sqlalchemy import Column, ForeignKey, Integer, String, UniqueConstraint
from sqlalchemy.dialects import postgresql
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import backref, relationship
from fonduer.utils.utils import camel_t... | fonduer-master | src/fonduer/utils/models/annotation.py |
"""Fonduer's utils model module."""
from fonduer.utils.models.annotation import AnnotationKeyMixin, AnnotationMixin
__all__ = ["AnnotationKeyMixin", "AnnotationMixin"]
| fonduer-master | src/fonduer/utils/models/__init__.py |
"""Fonduer structural modality utilities."""
import functools
from builtins import str
from typing import List, Optional, Tuple, Union
import numpy as np
from lxml import etree
from lxml.etree import _ElementTree
from lxml.html import HtmlElement, fromstring
from fonduer.candidates.models import Candidate, Mention
fr... | fonduer-master | src/fonduer/utils/data_model_utils/structural.py |
"""Fonduer textual modality utilities."""
from itertools import chain
from typing import Iterator, Union
from fonduer.candidates.models import Candidate, Mention
from fonduer.candidates.models.span_mention import TemporarySpanMention
from fonduer.utils.data_model_utils.utils import _to_span, _to_spans
from fonduer.uti... | fonduer-master | src/fonduer/utils/data_model_utils/textual.py |
"""Fonduer tabular modality utilities."""
from builtins import range
from collections import defaultdict
from functools import lru_cache
from itertools import chain
from typing import DefaultDict, Iterator, List, Optional, Set, Tuple, Union
import deprecation
from fonduer import __version__
from fonduer.candidates.mo... | fonduer-master | src/fonduer/utils/data_model_utils/tabular.py |
"""Fonduer's data model utils module."""
from fonduer.utils.data_model_utils.structural import (
common_ancestor,
get_ancestor_class_names,
get_ancestor_id_names,
get_ancestor_tag_names,
get_attributes,
get_next_sibling_tags,
get_parent_tag,
get_prev_sibling_tags,
get_tag,
lowest... | fonduer-master | src/fonduer/utils/data_model_utils/__init__.py |
"""Fonduer data model utils."""
import logging
from functools import lru_cache
from typing import Callable, Iterable, List, Set, Union
from fonduer.candidates.models import Candidate, Mention
from fonduer.candidates.models.span_mention import TemporarySpanMention
@lru_cache(maxsize=1024)
def _to_span(
x: Union[C... | fonduer-master | src/fonduer/utils/data_model_utils/utils.py |
"""Fonduer visual modality utilities."""
from builtins import range
from collections import defaultdict
from functools import lru_cache
from typing import Any, DefaultDict, Iterator, List, Set, Union
from fonduer.candidates.mentions import Ngrams
from fonduer.candidates.models import Candidate, Mention
from fonduer.ca... | fonduer-master | src/fonduer/utils/data_model_utils/visual.py |
"""Fonduer's logging module."""
from fonduer.utils.logging.tensorboard_writer import TensorBoardLogger
__all__ = ["TensorBoardLogger"]
| fonduer-master | src/fonduer/utils/logging/__init__.py |
"""Fonduer tensorboard logger."""
from tensorboardX import SummaryWriter
class TensorBoardLogger(object):
"""A class for logging to Tensorboard during training process."""
def __init__(self, log_dir: str):
"""Create a summary writer logging to log_dir."""
self.writer = SummaryWriter(log_dir)
... | fonduer-master | src/fonduer/utils/logging/tensorboard_writer.py |
"""Fonduer's parser module."""
from fonduer.parser.parser import Parser
__all__ = ["Parser"]
| fonduer-master | src/fonduer/parser/__init__.py |
"""Fonduer parser."""
import itertools
import logging
import re
import warnings
from builtins import range
from collections import defaultdict
from typing import (
Any,
Collection,
Dict,
Iterator,
List,
Optional,
Pattern,
Tuple,
Union,
)
import lxml.etree
import lxml.html
from lxml.... | fonduer-master | src/fonduer/parser/parser.py |
"""Fonduer document preprocessor."""
import glob
import os
import sys
from typing import Iterator, List
from fonduer.parser.models.document import Document
class DocPreprocessor(object):
"""An abstract class of a ``Document`` generator.
Unless otherwise stated by a subclass, it's assumed that there is one `... | fonduer-master | src/fonduer/parser/preprocessors/doc_preprocessor.py |
"""Fonduer hOCR document preprocessor."""
import codecs
import os
import re
import sys
from typing import Iterator, Optional, Tuple
from bs4 import BeautifulSoup
from bs4.element import Comment, NavigableString, Tag
from fonduer.parser.models import Document
from fonduer.parser.preprocessors.doc_preprocessor import D... | fonduer-master | src/fonduer/parser/preprocessors/hocr_doc_preprocessor.py |
"""Fonduer's parser preprocessor module."""
from fonduer.parser.preprocessors.csv_doc_preprocessor import CSVDocPreprocessor
from fonduer.parser.preprocessors.doc_preprocessor import DocPreprocessor
from fonduer.parser.preprocessors.hocr_doc_preprocessor import HOCRDocPreprocessor
from fonduer.parser.preprocessors.html... | fonduer-master | src/fonduer/parser/preprocessors/__init__.py |
"""Fonduer HTML document preprocessor."""
import codecs
import os
from typing import Iterator
from bs4 import BeautifulSoup
from fonduer.parser.models import Document
from fonduer.parser.preprocessors.doc_preprocessor import DocPreprocessor
class HTMLDocPreprocessor(DocPreprocessor):
"""A ``Document`` generator... | fonduer-master | src/fonduer/parser/preprocessors/html_doc_preprocessor.py |
"""Fonduer text document preprocessor."""
import codecs
import os
from typing import Iterator
from fonduer.parser.models import Document
from fonduer.parser.preprocessors.doc_preprocessor import DocPreprocessor
from fonduer.utils.utils_parser import build_node
class TextDocPreprocessor(DocPreprocessor):
"""A ``D... | fonduer-master | src/fonduer/parser/preprocessors/text_doc_preprocessor.py |
"""Fonduer CSV document preprocessor."""
import codecs
import csv
import os
import sys
from typing import Callable, Dict, Iterator, Optional
from fonduer.parser.models import Document
from fonduer.parser.preprocessors.doc_preprocessor import DocPreprocessor
from fonduer.utils.utils_parser import build_node, column_con... | fonduer-master | src/fonduer/parser/preprocessors/csv_doc_preprocessor.py |
"""Fonduer TSV document preprocessor."""
import codecs
import sys
from typing import Iterator
from fonduer.parser.models import Document
from fonduer.parser.preprocessors.doc_preprocessor import DocPreprocessor
from fonduer.utils.utils_parser import build_node
class TSVDocPreprocessor(DocPreprocessor):
"""A ``Do... | fonduer-master | src/fonduer/parser/preprocessors/tsv_doc_preprocessor.py |
"""A simple alternative tokenizer which parses text by splitting on whitespace."""
from typing import Any, Dict, Iterator
import numpy as np
from fonduer.parser.lingual_parser.lingual_parser import LingualParser
class SimpleParser(LingualParser):
"""Tokenizes text on whitespace only using split().
:param d... | fonduer-master | src/fonduer/parser/lingual_parser/simple_parser.py |
"""Fonduer's lingual parser module."""
from fonduer.parser.lingual_parser.lingual_parser import LingualParser
from fonduer.parser.lingual_parser.simple_parser import SimpleParser
from fonduer.parser.lingual_parser.spacy_parser import SpacyParser
__all__ = ["LingualParser", "SpacyParser", "SimpleParser"]
| fonduer-master | src/fonduer/parser/lingual_parser/__init__.py |
"""Fonduer Spacy parser."""
import importlib
import logging
from collections import defaultdict
from pathlib import Path
from string import whitespace
from typing import Any, Collection, Dict, Iterator, List, Optional
import spacy
from spacy import util
from spacy.cli import download
from spacy.language import Languag... | fonduer-master | src/fonduer/parser/lingual_parser/spacy_parser.py |
"""Fonduer lingual parser."""
from typing import Collection, Iterable, Iterator
from fonduer.parser.models import Sentence
class LingualParser(object):
"""Lingual parser."""
def split_sentences(self, text: str) -> Iterable[dict]:
"""
Split input text into sentences.
:param text: tex... | fonduer-master | src/fonduer/parser/lingual_parser/lingual_parser.py |
"""Fonduer webpage context model."""
from sqlalchemy import Column, ForeignKey, Integer, String
from fonduer.parser.models.context import Context
class Webpage(Context):
"""A Webpage Context enhanced with additional metadata."""
__tablename__ = "webpage"
#: The unique id of the ``Webpage``.
id = Co... | fonduer-master | src/fonduer/parser/models/webpage.py |
"""Fonduer figure context model."""
from sqlalchemy import Column, ForeignKey, Integer, String, UniqueConstraint
from sqlalchemy.orm import backref, relationship
from fonduer.parser.models.context import Context
class Figure(Context):
"""A figure Context in a Document.
Used to represent figures in a documen... | fonduer-master | src/fonduer/parser/models/figure.py |
"""Fonduer's parser model module."""
from fonduer.parser.models.caption import Caption
from fonduer.parser.models.context import Context
from fonduer.parser.models.document import Document
from fonduer.parser.models.figure import Figure
from fonduer.parser.models.paragraph import Paragraph
from fonduer.parser.models.se... | fonduer-master | src/fonduer/parser/models/__init__.py |
"""Fonduer section context model."""
from sqlalchemy import Column, ForeignKey, Integer, String, UniqueConstraint
from sqlalchemy.orm import backref, relationship
from fonduer.parser.models.context import Context
class Section(Context):
"""A Section Context in a Document.
.. note:: As of v0.6.2, each docume... | fonduer-master | src/fonduer/parser/models/section.py |
"""Fonduer caption context model."""
from sqlalchemy import Column, ForeignKey, Integer, String, UniqueConstraint
from sqlalchemy.orm import backref, relationship
from fonduer.parser.models.context import Context
class Caption(Context):
"""A Caption Context in a Document.
Used to represent figure or table c... | fonduer-master | src/fonduer/parser/models/caption.py |
"""Fonduer sentence context model."""
from builtins import object
from typing import Any, Dict
from sqlalchemy import Column, ForeignKey, Integer, String, Text, UniqueConstraint
from sqlalchemy.dialects import postgresql
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import backref, relations... | fonduer-master | src/fonduer/parser/models/sentence.py |
"""Fonduer context model."""
from sqlalchemy import Column, Integer, String
from fonduer.meta import Meta
class Context(Meta.Base):
"""A piece of content from which Candidates are composed.
This serves as the base class of the Fonduer document model.
"""
__tablename__ = "context"
#: The unique... | fonduer-master | src/fonduer/parser/models/context.py |
"""Utilities for constructing and splitting stable ids."""
from typing import List, Tuple
from fonduer.parser.models import Context
def construct_stable_id(
parent_context: Context,
polymorphic_type: str,
relative_char_offset_start: int,
relative_char_offset_end: int,
) -> str:
"""Construct Conte... | fonduer-master | src/fonduer/parser/models/utils.py |
"""Fonduer document context model."""
from sqlalchemy import Column, ForeignKey, Integer, String
from sqlalchemy.types import PickleType
from fonduer.parser.models.context import Context
class Document(Context):
"""A document Context.
Represents all the information of a particular document.
What becomes... | fonduer-master | src/fonduer/parser/models/document.py |
"""Fonduer paragraph context model."""
from sqlalchemy import Column, ForeignKey, Integer, String, UniqueConstraint
from sqlalchemy.orm import backref, relationship
from fonduer.parser.models.context import Context
class Paragraph(Context):
"""A paragraph Context in a Document.
Represents a grouping of adja... | fonduer-master | src/fonduer/parser/models/paragraph.py |
"""Fonduer table context model."""
from sqlalchemy import Column, ForeignKey, Integer, String, UniqueConstraint
from sqlalchemy.orm import backref, relationship
from fonduer.parser.models.context import Context
class Table(Context):
"""A Table Context in a Document.
Used to represent tables found in a docum... | fonduer-master | src/fonduer/parser/models/table.py |
"""Fonduer visual parser that parses visual information from hOCR."""
import itertools
import re
from typing import Dict, Iterable, Iterator, List, Pattern, Tuple, Union
import spacy
import spacy.gold
from packaging import version
from spacy.gold import align
from fonduer.parser.models import Sentence
from fonduer.pa... | fonduer-master | src/fonduer/parser/visual_parser/hocr_visual_parser.py |
"""Fonduer's visual parser module."""
from fonduer.parser.visual_parser.hocr_visual_parser import HocrVisualParser
from fonduer.parser.visual_parser.pdf_visual_parser import PdfVisualParser
from fonduer.parser.visual_parser.visual_parser import VisualParser
__all__ = ["VisualParser", "PdfVisualParser", "HocrVisualPars... | fonduer-master | src/fonduer/parser/visual_parser/__init__.py |
"""Fonduer visual parser that parses visual information from PDF."""
import logging
import os
import re
import shutil
import subprocess
from builtins import range, zip
from collections import OrderedDict, defaultdict
from operator import attrgetter
from typing import DefaultDict, Dict, Iterable, Iterator, List, Optiona... | fonduer-master | src/fonduer/parser/visual_parser/pdf_visual_parser.py |
"""Abstract visual parser."""
from abc import ABC, abstractmethod
from typing import Iterable, Iterator
from fonduer.parser.models import Sentence
class VisualParser(ABC):
"""Abstract visual parer."""
@abstractmethod
def parse(
self,
document_name: str,
sentences: Iterable[Senten... | fonduer-master | src/fonduer/parser/visual_parser/visual_parser.py |
"""Fonduer's supervision module."""
from fonduer.supervision.labeler import Labeler
__all__ = ["Labeler"]
| fonduer-master | src/fonduer/supervision/__init__.py |
"""Fonduer labeler."""
import logging
from collections import defaultdict
from typing import (
Any,
Callable,
Collection,
DefaultDict,
Dict,
Iterable,
Iterator,
List,
Optional,
Tuple,
Type,
Union,
)
import numpy as np
from sqlalchemy import Table
from sqlalchemy.orm impo... | fonduer-master | src/fonduer/supervision/labeler.py |
"""Fonduer's supervision model module."""
from fonduer.supervision.models.label import (
GoldLabel,
GoldLabelKey,
Label,
LabelKey,
StableLabel,
)
__all__ = ["GoldLabel", "GoldLabelKey", "Label", "LabelKey", "StableLabel"]
| fonduer-master | src/fonduer/supervision/models/__init__.py |
"""Fonduer label model."""
from sqlalchemy import Column, Integer, String
from sqlalchemy.dialects import postgresql
from fonduer.meta import Meta
from fonduer.utils.models.annotation import AnnotationKeyMixin, AnnotationMixin
class GoldLabelKey(AnnotationKeyMixin, Meta.Base):
"""Gold label key class.
A gol... | fonduer-master | src/fonduer/supervision/models/label.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import setuptools
setuptools.setup(
name="ctrl-benchmark",
version="0.0.3",
author="Tom Veniat, Ludovic Denoyer & Marc'Aurelio Ra... | CTrLBenchmark-master | setup.py |
from .streams import get_stream | CTrLBenchmark-master | ctrl/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import random
from collections import defaultdict
import torch
import torchvision
from sklearn.decomposition import ... | CTrLBenchmark-master | ctrl/tasks/task.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| CTrLBenchmark-master | ctrl/tasks/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import random
import time
from types import SimpleNamespace
import numpy as np
import torch
import torch.nn.function... | CTrLBenchmark-master | ctrl/tasks/task_generator.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from ctrl.transformations.transformation_tree import TransformationTree
from torch import nn
from tqdm import tqdm
class NoisyN... | CTrLBenchmark-master | ctrl/transformations/noisy_nn_transformation.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
class Transformation(object):
def __init__(self, transfo_pool, path, trans_descr):
assert path[0] == transfo_pool.r... | CTrLBenchmark-master | ctrl/transformations/transformation.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from functools import partial
import torch
from ctrl.transformations.transformation_tree import TransformationTree
from ctrl.transformations.... | CTrLBenchmark-master | ctrl/transformations/rainbow_transformation.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import abc
class TransformationPool(abc.ABC):
@abc.abstractmethod
def get_transformation(self, exclude_trans=None):
raise No... | CTrLBenchmark-master | ctrl/transformations/transformation_pool.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
from ctrl.transformations.transformation_tree import TransformationTree
from torchvision import transforms
from torchvisio... | CTrLBenchmark-master | ctrl/transformations/img_rotations.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .identity_transformation import IdentityTransformation
from .img_rotations import ImgRotationTransformationTree
from .noisy_nn_transforma... | CTrLBenchmark-master | ctrl/transformations/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
import torchvision.transforms.functional as F
from PIL import Image
from ctrl.transformations.transformation_t... | CTrLBenchmark-master | ctrl/transformations/identity_transformation.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
class BatchedTransformation(object):
def __init__(self, transfo, descr=None):
self.transfo = transfo
self.d... | CTrLBenchmark-master | ctrl/transformations/utils.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import random
from abc import ABC
from collections import defaultdict
from numbers import Number
import networkx as nx
from to... | CTrLBenchmark-master | ctrl/transformations/transformation_tree.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from ctrl.transformations.transformation_tree import TransformationTree
from ctrl.transformations.utils import BatchedTransformat... | CTrLBenchmark-master | ctrl/transformations/randperm_transformation.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.