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
CaBERT-SLU
CaBERT-SLU-main/__MACOSX/CaBERT-SLU-main/baseline_stackprop/utils/._loader.py
Mac OS X  2ATTR<<com.apple.quarantineq/0081;6067ce05;Chrome;EB6190ED-75B9-4A04-87B2-88BD2FC5C689
207
207
207
py
CaBERT-SLU
CaBERT-SLU-main/__MACOSX/CaBERT-SLU-main/baseline_stackprop/utils/._module.py
Mac OS X  2ATTR<<com.apple.quarantineq/0081;6067ce05;Chrome;EB6190ED-75B9-4A04-87B2-88BD2FC5C689
207
207
207
py
CaBERT-SLU
CaBERT-SLU-main/__MACOSX/CaBERT-SLU-main/data/._dialogue_data.py
Mac OS X  2ATTR<<com.apple.quarantineq/0081;6067ce05;Chrome;EB6190ED-75B9-4A04-87B2-88BD2FC5C689
207
207
207
py
CaBERT-SLU
CaBERT-SLU-main/__MACOSX/CaBERT-SLU-main/model/._baseline_multi.py
Mac OS X  2ATTR<<com.apple.quarantineq/0081;6067ce05;Chrome;EB6190ED-75B9-4A04-87B2-88BD2FC5C689
207
207
207
py
CaBERT-SLU
CaBERT-SLU-main/__MACOSX/CaBERT-SLU-main/model/._CHAN.py
Mac OS X  2ATTR<<com.apple.quarantineq/0081;6067ce05;Chrome;EB6190ED-75B9-4A04-87B2-88BD2FC5C689
207
207
207
py
CaBERT-SLU
CaBERT-SLU-main/__MACOSX/CaBERT-SLU-main/model/._bert_model_context.py
Mac OS X  2ATTR<<com.apple.quarantineq/0081;6067ce05;Chrome;EB6190ED-75B9-4A04-87B2-88BD2FC5C689
207
207
207
py
CaBERT-SLU
CaBERT-SLU-main/__MACOSX/CaBERT-SLU-main/model/.___init__.py
Mac OS X  2ATTR<<com.apple.quarantineq/0081;6067ce05;Chrome;EB6190ED-75B9-4A04-87B2-88BD2FC5C689
207
207
207
py
CaBERT-SLU
CaBERT-SLU-main/__MACOSX/CaBERT-SLU-main/model/._transformer_new.py
Mac OS X  2ATTR<<com.apple.quarantineq/0081;6067ce05;Chrome;EB6190ED-75B9-4A04-87B2-88BD2FC5C689
207
207
207
py
CaBERT-SLU
CaBERT-SLU-main/__MACOSX/CaBERT-SLU-main/model/._transformer.py
Mac OS X  2ATTR<<com.apple.quarantineq/0081;6067ce05;Chrome;EB6190ED-75B9-4A04-87B2-88BD2FC5C689
207
207
207
py
CaBERT-SLU
CaBERT-SLU-main/__MACOSX/CaBERT-SLU-main/model/._torchcrf.py
Mac OS X  2ATTR<<com.apple.quarantineq/0081;6067ce05;Chrome;EB6190ED-75B9-4A04-87B2-88BD2FC5C689
207
207
207
py
CaBERT-SLU
CaBERT-SLU-main/__MACOSX/CaBERT-SLU-main/model/._mia.py
Mac OS X  2ATTR<<com.apple.quarantineq/0081;6067ce05;Chrome;EB6190ED-75B9-4A04-87B2-88BD2FC5C689
207
207
207
py
CaBERT-SLU
CaBERT-SLU-main/__MACOSX/CaBERT-SLU-main/model/._baseline_eca.py
Mac OS X  2ATTR<<com.apple.quarantineq/0081;6067ce05;Chrome;EB6190ED-75B9-4A04-87B2-88BD2FC5C689
207
207
207
py
CaBERT-SLU
CaBERT-SLU-main/baseline_stackprop/utils_bert.py
import random import torch import torch.nn as nn from torch.autograd import Variable from torch.optim import Adam, RMSprop from keras.preprocessing.sequence import pad_sequences from sklearn.model_selection import train_test_split import pickle import copy import numpy as np import collections from tqdm import tqdm fr...
5,829
34.120482
115
py
CaBERT-SLU
CaBERT-SLU-main/baseline_stackprop/train.py
""" @Author : Lee, Qin @StartTime : 2018/08/13 @Filename : train.py @Software : Pycharm @Framework : Pytorch @LastModify : 2019/05/07 """ from utils.module import ModelManager from utils.loader import DatasetManager ###### from utils.process import Processo...
3,585
36.747368
103
py
CaBERT-SLU
CaBERT-SLU-main/baseline_stackprop/utils/module.py
""" @Author : Lee, Qin @StartTime : 2018/08/13 @Filename : module.py @Software : Pycharm @Framework : Pytorch @LastModify : 2019/05/07 """ import math import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.utils.rnn import pack_pa...
17,569
38.483146
111
py
CaBERT-SLU
CaBERT-SLU-main/baseline_stackprop/utils/miulab.py
""" Copy file (including metric) from MiuLab: https://github.com/MiuLab/SlotGated-SLU """ # compute f1 score is modified from conlleval.pl def __startOfChunk(prevTag, tag, prevTagType, tagType, chunkStart=False): if prevTag == 'B' and tag == 'B': chunkStart = True if prevTag == 'I' and tag == 'B': chunkStart ...
4,131
25.487179
92
py
CaBERT-SLU
CaBERT-SLU-main/baseline_stackprop/utils/__init__.py
__author__ = "Lie Pleased"
26
26
26
py
CaBERT-SLU
CaBERT-SLU-main/baseline_stackprop/utils/process.py
""" @Author : Lee, Qin @StartTime : 2018/08/13 @Filename : process.py @Software : Pycharm @Framework : Pytorch @LastModify : 2019/05/07 """ import torch import torch.nn as nn import torch.optim as optim from torch.autograd import Variable import pickle imp...
18,042
39.364653
123
py
CaBERT-SLU
CaBERT-SLU-main/baseline_stackprop/utils/loader.py
""" @Author : Lee, Qin @StartTime : 2018/08/13 @Filename : loader.py @Software : Pycharm @Framework : Pytorch @LastModify : 2019/05/07 """ import os import numpy as np from copy import deepcopy from collections import Counter from collections import Ordered...
13,758
32.31477
112
py
CaBERT-SLU
CaBERT-SLU-main/data/dialogue_data.py
import torch as t from torch.autograd import Variable import numpy as np import pandas as pd import re import pickle import h5py import json import os import csv import spacy from nltk.tokenize import word_tokenize from transformers import BertTokenizer, BertModel, BertForMaskedLM import time class Data: def __...
22,069
38.837545
145
py
CaBERT-SLU
CaBERT-SLU-main/model/transformer_new.py
"""Transformer module with masks""" import torch import torch.nn as nn import numpy as np class ScaledDotProductAttention(nn.Module): """Scaled dot-product attention mechanism. """ def __init__(self, attention_dropout=0.0): super(ScaledDotProductAttention, self).__init__() self.dropout = n...
3,804
32.672566
76
py
CaBERT-SLU
CaBERT-SLU-main/model/baseline_multi.py
import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F import numpy as np from transformers import BertTokenizer, BertModel class MULTI(nn.Module): def __init__(self, opt, num_labels=2, num_slot_labels=10): super(MULTI, self).__init__() self.device = tor...
4,648
39.426087
107
py
CaBERT-SLU
CaBERT-SLU-main/model/CHAN.py
import os.path import math import copy import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import CrossEntropyLoss from torch.nn import CosineEmbeddingLoss ffscores = [] class MultiHeadAttention(nn.Module): def __init__(self, heads, d_model, dropout=0.1): s...
6,881
33.238806
104
py
CaBERT-SLU
CaBERT-SLU-main/model/baseline_eca.py
import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F import numpy as np from transformers import BertTokenizer, BertModel class ECA(nn.Module): def __init__(self, opt, num_labels=2, num_slot_labels=10): super(ECA, self).__init__() self.device = torch.d...
4,601
37.033058
122
py
CaBERT-SLU
CaBERT-SLU-main/model/transformer.py
"""Transformer module with masks""" import math import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import TransformerEncoder, TransformerEncoderLayer class TransformerModel(nn.Module): def __init__(self, ninp, nhead, nhid, nlayers, dropout=0.5): super(TransformerModel, self)....
1,979
36.358491
100
py
CaBERT-SLU
CaBERT-SLU-main/model/mia.py
import os.path import math import copy import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import CrossEntropyLoss from torch.nn import CosineEmbeddingLoss class MultiHeadAttention(nn.Module): def __init__(self, heads, d_model, dropout=0.1): super().__init__...
4,445
32.428571
103
py
CaBERT-SLU
CaBERT-SLU-main/model/__init__.py
from .bert_model_context import BertContextNLU from .baseline_multi import MULTI from .baseline_eca import ECA
111
27
46
py
CaBERT-SLU
CaBERT-SLU-main/model/torchcrf.py
"""SOURCE CODE FROM PYTORCH-CRF """ from typing import List, Optional import torch import torch.nn as nn class CRF(nn.Module): """Conditional random field. This module implements a conditional random field [LMP01]_. The forward computation of this class computes the log likelihood of the given sequence of...
14,331
43.098462
95
py
CaBERT-SLU
CaBERT-SLU-main/model/bert_model_context.py
import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F import numpy as np from transformers import BertTokenizer, BertModel from model.transformer import TransformerModel from model.transformer_new import Transformer from model.CHAN import ContextAttention from model.torchcrf imp...
8,750
41.072115
127
py
conversational-datasets
conversational-datasets-master/tools/tfrutil.py
# -*- coding: utf-8 -*- """Command line utilities for manipulating tfrecords files. Usage: To count the number of examples in a tfrecord file: python tfrutil.py size train-00999-of-01000.tfrecords To sample 10000 examples from a file pattern to an output file: python tfrutil.py sample 10000 train-*-of-0100...
4,832
28.469512
77
py
conversational-datasets
conversational-datasets-master/tools/__init__.py
0
0
0
py
conversational-datasets
conversational-datasets-master/reddit/create_data.py
"""A Dataflow script for creating datasets from reddit. For usage see README.md. """ import argparse import hashlib import json import logging import os import re import uuid from collections import defaultdict, namedtuple from functools import partial import apache_beam as beam import tensorflow as tf from apache_...
10,906
30.341954
79
py
conversational-datasets
conversational-datasets-master/reddit/__init__.py
0
0
0
py
conversational-datasets
conversational-datasets-master/reddit/create_data_test.py
"""Tests for create_data.py.""" import copy import json import shutil import tempfile import unittest from glob import glob from os import path import tensorflow as tf from reddit import create_data class CreateDataPipelineTest(unittest.TestCase): """Test running the pipeline end-to-end.""" def setUp(self...
12,907
33.148148
79
py
conversational-datasets
conversational-datasets-master/amazon_qa/create_data.py
"""A Dataflow script for creating Amazon question/answer data. For usage see README.md. """ import argparse import ast import hashlib import json import logging import os import uuid from functools import partial import apache_beam as beam import tensorflow as tf from apache_beam import pvalue from apache_beam.io.t...
7,954
31.206478
79
py
conversational-datasets
conversational-datasets-master/amazon_qa/__init__.py
0
0
0
py
conversational-datasets
conversational-datasets-master/amazon_qa/create_data_test.py
"""Tests for create_data.py.""" import json import shutil import tempfile import unittest from glob import glob from os import path import tensorflow as tf from amazon_qa import create_data _TEST_DATA = [ { 'question': "A A A", 'answer': "B B B", 'asin': "3", # gets put in test set. ...
6,788
30.576744
79
py
conversational-datasets
conversational-datasets-master/baselines/run_baseline.py
"""Evaluate baseline models on conversational datasets. For usage see README.md. """ import argparse import csv import enum import random import glog import numpy as np import tensorflow as tf from tqdm import tqdm from baselines import keyword_based, vector_based def _parse_args(): """Parse command-line args...
9,760
36.398467
76
py
conversational-datasets
conversational-datasets-master/baselines/method.py
"""Abstract class to define a baseline response selection method.""" import abc class BaselineMethod(object): """Abstract class to define a baseline response selection method.""" __metaclass__ = abc.ABCMeta @abc.abstractmethod def train(self, examples): """Perform any training steps using th...
1,289
33.864865
79
py
conversational-datasets
conversational-datasets-master/baselines/vector_based_test.py
"""Tests for vector_based.py.""" import os import tempfile import unittest import mock import numpy as np import tensorflow as tf from mock import patch from baselines import vector_based class TfHubEncoderTest(unittest.TestCase): @patch("tensorflow_hub.Module") def test_encode_context(self, mock_module_cl...
8,741
34.681633
79
py
conversational-datasets
conversational-datasets-master/baselines/keyword_based.py
"""Baseline response ranking methods using keyword matching.""" import numpy as np import scipy.sparse as sp from sklearn.feature_extraction.text import (HashingVectorizer, TfidfTransformer, _document_frequency) from sklearn.util...
4,593
38.947826
89
py
conversational-datasets
conversational-datasets-master/baselines/vector_based.py
"""Methods for conversational response ranking based on vector comparisons.""" import abc import itertools import shutil import tempfile import glog import numpy as np import tensorflow as tf import tensorflow_hub import tensorflow_text # NOQA: required for PolyAI encoders. import tf_sentencepiece # NOQA: it is use...
21,348
37.605787
79
py
conversational-datasets
conversational-datasets-master/baselines/__init__.py
0
0
0
py
conversational-datasets
conversational-datasets-master/baselines/keyword_based_test.py
"""Tests for keyword_based.py.""" import unittest from baselines import keyword_based class TfIdfMethodTest(unittest.TestCase): def test_train_test(self): """Check that it can correctly rank a simple example.""" method = keyword_based.TfIdfMethod() method.train( ["hello how a...
1,722
26.790323
69
py
conversational-datasets
conversational-datasets-master/opensubtitles/create_data.py
"""A Dataflow script for creating sentence pair data from text files. For usage see README.md. """ import argparse import hashlib import json import logging import os import re import uuid from functools import partial from os import path import apache_beam as beam import tensorflow as tf from apache_beam import pv...
8,838
31.141818
78
py
conversational-datasets
conversational-datasets-master/opensubtitles/__init__.py
0
0
0
py
conversational-datasets
conversational-datasets-master/opensubtitles/create_data_test.py
"""Tests for create_data.py.""" import json import shutil import tempfile import unittest from glob import glob from os import path import tensorflow as tf from opensubtitles import create_data _TRAIN_FILE = "\n".join([ "matt: AAAA", # words followed by colons are stripped. "[skip]", # text in brackets is...
6,519
32.435897
76
py
mcbeth
mcbeth-master/mcbeth/python/setup.py
import os from setuptools import find_packages, setup name = 'mcl' version = '0.1.0.dev' description = 'A programming language for the measurement calculus' long_description = open('README.md', encoding='utf-8').read() reqs = open('requirements.txt').readlines() requirements = [r.strip() for r in reqs] packs = (['m...
563
22.5
67
py
mcbeth
mcbeth-master/mcbeth/python/CirqBuilder.py
import cirq import sys import json import numpy as np class XBasisMeasurementSignal(cirq.SingleQubitGate): """Custom measurement signal to measure in the X-basis with specified angle. These will signal to the program where measurements need to go at the end of the program. This method DOES NOT handle any m...
9,250
31.233449
92
py
mcbeth
mcbeth-master/mcbeth/python/ZXBuilder.py
import pyzx as zx import sys import json """NOTE: ZXBuilder class should be read-only now. Using Cirq to handle all QASM input and output should suffice, and we can read in that QASM input to build ZX diagrams. """ class ZXBuilder: CMD_MAP = { 'Prep': zx.gates.HAD, 'XCorrect': zx.gates.NOT, 'ZCorrect': ...
2,538
27.52809
84
py
mcbeth
mcbeth-master/mcbeth/python/mcl/__init__.py
import os import sys import shutil # Rough way to add to the Python path. # TODO: find a cleaner way to implement this. You have to switch # directories currently to find it. for src in ["ocaml.so", "../_build/default/python/ocaml.so"]: if os.path.exists(src): shutil.copyfile(src, "mcl/ocaml.so") sys.path.append...
757
30.583333
64
py
marmot
marmot-master/marmot/__init__.py
0
0
0
py
marmot
marmot-master/marmot/evaluation/evaluation_metrics.py
from __future__ import division # return the f1 for (y_predicted, y_actual) # use sklearn.metrics.f1_score with average='weighted' for evaluation from sklearn.metrics import f1_score, accuracy_score import logging import numpy as np from marmot.experiment.import_utils import list_of_lists from marmot.experiment.prepr...
11,031
39.410256
175
py
marmot
marmot-master/marmot/evaluation/evaluate.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function, division import sys, codecs import numpy as np from sklearn import metrics from marmot.evaluation.evaluation_metrics import weighted_fmeasure import logging logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', lev...
8,375
41.30303
142
py
marmot
marmot-master/marmot/evaluation/evaluate_task2_WMT2014.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, codecs import numpy as np issues_accuracy = ['Terminology', 'Mistranslation', 'Omission', 'Addition', 'Untranslated', 'Accuracy'] issues_fluency = ['Agreement', 'Capitalization', 'Fluency', 'Function_words', 'Grammar', 'Morphology_(wor...
10,974
34.633117
128
py
marmot
marmot-master/marmot/evaluation/evaluate_task1_WMT2016.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """ evaluate_wmt16_task1 ~~~~~~~~~~~~~~~~~~~~ Evaluation script for Task 1 of the WMT Quality Estimation challenge. :copyright: (c) 2016 by Fabio Kepler :licence: MIT Usage: evaluate_wmt16_task1 [options] REFERENCE_FILE SUBMISSION_FILE... evaluate_wmt16_task1 (-h | -...
6,708
38.233918
144
py
marmot
marmot-master/marmot/evaluation/evaluation_utils.py
from __future__ import print_function, division from sklearn.metrics import f1_score def write_res_to_file(test_file, test_predictions, output_file=''): if output_file == '': output_file = test_file+'.predictions' output = open(output_file, 'w') try: for idx, line in enumerate(open(test_...
2,264
36.131148
104
py
marmot
marmot-master/marmot/evaluation/__init__.py
0
0
0
py
marmot
marmot-master/marmot/evaluation/check_error_types.py
from __future__ import division, print_function import codecs import argparse from itertools import groupby def get_error_distribution(error_file): with codecs.open(error_file, encoding='utf8') as tsv: # remove newlines row_data = [ l.rstrip().split('\t') for l in tsv ] class_data = [ {'pr...
1,124
42.269231
108
py
marmot
marmot-master/marmot/evaluation/tests/test_evaluate.py
# test the evaluation functions import unittest import os from marmot.evaluation.evaluate import significance_test, get_scores, read_wmt_annotation, evaluate_wmt, evaluate_hashed_predictions class TestEvaluate(unittest.TestCase): def setUp(self): module_path = os.path.dirname(__file__) gold_stand...
2,221
39.4
132
py
marmot
marmot-master/marmot/evaluation/tests/test_evaluation_utils.py
# test the evaluation functions import unittest import os from marmot.evaluation.evaluation_utils import compare_vocabulary class TestEvaluate(unittest.TestCase): def test_compare_vocabulary(self): dataset1 = [['this', 'is', 'sentence', 'number', 'one'], ['another', 'list', 'comes', 'next', '.']] ...
794
32.125
109
py
marmot
marmot-master/marmot/evaluation/tests/test_evaluation_metrics.py
import unittest from marmot.evaluation.evaluation_metrics import get_spans, intersect_spans, sequence_correlation class TestEvaluationUtils(unittest.TestCase): def setUp(self): self.predictions = [] cur_pred = [] for line in open('test_data/hyp'): if line.strip() == '': ...
2,260
35.467742
118
py
marmot
marmot-master/marmot/features/target_token_left_feature_extractor.py
from marmot.features.feature_extractor import FeatureExtractor from marmot.util.ngram_window_extractor import left_context, right_context class TargetTokenLeftFeatureExtractor(FeatureExtractor): ''' Target features: - target token - left and right windows of the target token ''' def __ini...
697
30.727273
125
py
marmot
marmot-master/marmot/features/gaussian_feature_extractor.py
import numpy as np import sys from marmot.features.feature_extractor import FeatureExtractor from scipy.stats import norm #generate features from distributions of some existing set of examples class GaussianFeatureExtractor(FeatureExtractor): def __init__(self, features): # the distribution for each feat...
981
41.695652
140
py
marmot
marmot-master/marmot/features/google_translate_feature_extractor.py
from goslate import Goslate from nltk import word_tokenize import ipdb from marmot.features.feature_extractor import FeatureExtractor from marmot.exceptions.no_data_error import NoDataError class GoogleTranslateFeatureExtractor(FeatureExtractor): def __init__(self, lang='en'): self.lang = lang def ...
893
29.827586
97
py
marmot
marmot-master/marmot/features/pos_feature_extractor.py
import sys from subprocess import Popen, PIPE from marmot.features.feature_extractor import FeatureExtractor from marmot.exceptions.no_data_error import NoDataError from marmot.exceptions.no_resource_error import NoResourceError class POSFeatureExtractor(FeatureExtractor): """ POS for source and target words...
2,564
40.370968
118
py
marmot
marmot-master/marmot/features/feature_extractor.py
# an abstract class representing a feature extractor # a feature extractor takes an object like # { 'token': <token>, index: <idx>, 'source': [<source toks>]', 'target': [<target toks>], 'tag': <tag>} # and extracts features for that instance # IMPORTANT - different feature extractors require different fields in the c...
1,259
38.375
140
py
marmot
marmot-master/marmot/features/word2vec_feature_extractor.py
import numpy as np import sys import logging from gensim.models import Word2Vec from marmot.features.feature_extractor import FeatureExtractor logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) logger = logging.getLogger('experiment_logger') def left_context(token_list, toke...
4,647
41.642202
144
py
marmot
marmot-master/marmot/features/lm_left_feature_extractor.py
from __future__ import print_function import codecs from subprocess import call import os from collections import defaultdict from marmot.features.feature_extractor import FeatureExtractor from marmot.util.ngram_window_extractor import extract_window, left_context, right_context from marmot.experiment.import_utils imp...
3,824
36.135922
139
py
marmot
marmot-master/marmot/features/tfidf_feature_extractor.py
# build a tfidf index in def __init__(corpus_file_name)
55
55
55
py
marmot
marmot-master/marmot/features/token_count_feature_extractor.py
from __future__ import print_function, division import numpy as np from marmot.features.feature_extractor import FeatureExtractor import logging logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) logger = logging.getLogger('testlogger') class TokenCountFeatureExtractor(Featur...
1,542
38.564103
118
py
marmot
marmot-master/marmot/features/previous_tag_feature_extractor.py
from __future__ import print_function from marmot.features.feature_extractor import FeatureExtractor from marmot.exceptions.no_data_error import NoDataError class PreviousTagFeatureExtractor(FeatureExtractor): ''' Extracts the tag of the previous token ''' def __init__(self): pass def g...
721
25.740741
90
py
marmot
marmot-master/marmot/features/pseudo_reference_feature_extractor.py
from nltk import word_tokenize from marmot.features.feature_extractor import FeatureExtractor from marmot.exceptions.no_data_error import NoDataError class PseudoReferenceFeatureExtractor(FeatureExtractor): ''' A feature that extracts the pseudo-reference feature for pseudo-references provided in a file...
953
33.071429
100
py
marmot
marmot-master/marmot/features/lm_feature_extractor.py
from __future__ import print_function import codecs from subprocess import call import os from collections import defaultdict from marmot.features.feature_extractor import FeatureExtractor from marmot.util.ngram_window_extractor import extract_window, left_context, right_context from marmot.experiment.import_utils imp...
4,560
40.09009
150
py
marmot
marmot-master/marmot/features/dictionary_feature_extractor.py
import string import nltk from marmot.features.feature_extractor import FeatureExtractor class DictionaryFeatureExtractor(FeatureExtractor): ''' Extract binary features indicating that the word belongs to a list of special tokens: - stopwords - punctuation symbols - proper names - numbers ...
1,159
37.666667
152
py
marmot
marmot-master/marmot/features/__init__.py
0
0
0
py
marmot
marmot-master/marmot/features/target_token_feature_extractor.py
from marmot.features.feature_extractor import FeatureExtractor from marmot.util.ngram_window_extractor import left_context, right_context class TargetTokenFeatureExtractor(FeatureExtractor): ''' Target features: - target token - left and right windows of the target token ''' def __init__(...
845
35.782609
127
py
marmot
marmot-master/marmot/features/syntactic_feature_extractor.py
from marmot.features.feature_extractor import FeatureExtractor import sys # get word's parent def get_parent(dependencies, word_id, sentence_length, context_obj): for head in dependencies: if len(dependencies[head]) == 0: continue for dep in dependencies[head]: if dep['id']...
4,907
44.444444
168
py
marmot
marmot-master/marmot/features/source_word2vec_feature_extractor.py
import numpy as np import sys import logging from gensim.models import Word2Vec from marmot.features.feature_extractor import FeatureExtractor logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) logger = logging.getLogger('experiment_logger') def left_context(token_list, toke...
6,892
47.886525
152
py
marmot
marmot-master/marmot/features/source_lm_feature_extractor.py
import codecs from subprocess import call import os from collections import defaultdict from marmot.features.feature_extractor import FeatureExtractor from marmot.util.ngram_window_extractor import left_context, right_context from marmot.experiment.import_utils import mk_tmp_dir from marmot.exceptions.no_data_error im...
3,413
40.634146
119
py
marmot
marmot-master/marmot/features/wordnet_feature_extractor.py
from __future__ import print_function import sys from nltk import wordnet as wn from collections import defaultdict from marmot.features.feature_extractor import FeatureExtractor class WordnetFeatureExtractor(FeatureExtractor): def __init__(self, src_lang, tg_lang, wordnet_pos=None): # there's a bug in...
2,330
42.166667
156
py
marmot
marmot-master/marmot/features/alignment_feature_extractor.py
from __future__ import print_function import os import sys import errno from marmot.features.feature_extractor import FeatureExtractor from marmot.util.alignments import train_alignments, align_sentence from marmot.util.ngram_window_extractor import left_context, right_context from marmot.exceptions.no_data_error imp...
3,353
44.945205
162
py
marmot
marmot-master/marmot/features/unbabel/bias_feature_extractor.py
from marmot.features.feature_extractor import FeatureExtractor class BiasFeatureExtractor(FeatureExtractor): def get_features(self, context_obj): return [1] def get_feature_names(self): return ['bias']
230
20
62
py
marmot
marmot-master/marmot/features/unbabel/paired_feature_extractor.py
from marmot.features.feature_extractor import FeatureExtractor from marmot.util.ngram_window_extractor import left_context, right_context class PairedFeatureExtractor(FeatureExtractor): ''' Paired features: - target token + left context - target token + right context - target token + s...
1,309
39.9375
111
py
marmot
marmot-master/marmot/features/unbabel/trilexical_left_feature_extractor.py
from marmot.features.feature_extractor import FeatureExtractor from marmot.util.ngram_window_extractor import left_context class TrilexicalLeftFeatureExtractor(FeatureExtractor): ''' Trilexical features: - target token + left context + source token - target token + right context + source token...
858
32.038462
109
py
marmot
marmot-master/marmot/features/unbabel/paired_left_feature_extractor.py
from marmot.features.feature_extractor import FeatureExtractor from marmot.util.ngram_window_extractor import left_context, right_context class PairedLeftFeatureExtractor(FeatureExtractor): ''' Paired features: - target token + left context - target token + right context - target token...
1,165
36.612903
109
py
marmot
marmot-master/marmot/features/unbabel/token_count_feature_extractor.py
from __future__ import print_function, division import numpy as np from marmot.features.feature_extractor import FeatureExtractor import logging logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) logger = logging.getLogger('testlogger') class TokenCountFeatureExtractor(Featur...
1,542
38.564103
118
py
marmot
marmot-master/marmot/features/unbabel/trilexical_feature_extractor.py
from marmot.features.feature_extractor import FeatureExtractor from marmot.util.ngram_window_extractor import left_context, right_context class TrilexicalFeatureExtractor(FeatureExtractor): ''' Trilexical features: - target token + left context + source token - target token + right context + s...
1,044
37.703704
111
py
marmot
marmot-master/marmot/features/unbabel/__init__.py
0
0
0
py
marmot
marmot-master/marmot/features/phrase/num_translations_feature_extractor.py
from __future__ import division import sys import numpy as np from collections import defaultdict from nltk import FreqDist from gensim.corpora import TextCorpus from marmot.features.feature_extractor import FeatureExtractor class NumTranslationsFeatureExtractor(FeatureExtractor): # .f2e file def __init__(...
2,228
41.865385
91
py
marmot
marmot-master/marmot/features/phrase/nouns_bigram_feature_extractor.py
from collections import defaultdict from marmot.features.feature_extractor import FeatureExtractor def get_nouns(language): nouns = defaultdict(str) nouns['english'] = ['NN'] nouns['spanish'] = ['NC', 'NMEA', 'NMON', 'NP'] return nouns[language] class VerbsBigramFeatureExtractor(FeatureExtractor): ...
1,434
28.285714
72
py
marmot
marmot-master/marmot/features/phrase/pos_context_left_feature_extractor.py
from marmot.features.feature_extractor import FeatureExtractor from marmot.exceptions.no_data_error import NoDataError from marmot.util.ngram_window_extractor import left_context, right_context class POSContextLeftFeatureExtractor(FeatureExtractor): ''' same as POSContextFeatureExtractor, but without right co...
1,329
50.153846
175
py
marmot
marmot-master/marmot/features/phrase/ngram_frequencies_feature_extractor.py
from __future__ import division import os import sys from subprocess import call from collections import defaultdict from marmot.features.feature_extractor import FeatureExtractor class NgramFrequenciesFeatureExtractor(FeatureExtractor): def __init__(self, tmp_dir, ngram_count_file=None, corpus=None, srilm=None)...
4,810
46.633663
181
py
marmot
marmot-master/marmot/features/phrase/pos_feature_extractor.py
from __future__ import division from collections import defaultdict import logging from marmot.features.feature_extractor import FeatureExtractor logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) logger = logging.getLogger('testlogger') # collections of content tags for so...
6,043
44.104478
137
py
marmot
marmot-master/marmot/features/phrase/context_left_feature_extractor.py
import sys from marmot.features.feature_extractor import FeatureExtractor from marmot.util.ngram_window_extractor import left_context, right_context class ContextLeftFeatureExtractor(FeatureExtractor): ''' Same as ContextFeatureExtractor, but without right target context ''' def get_features(self, co...
1,163
43.769231
147
py
marmot
marmot-master/marmot/features/phrase/oov_feature_extractor.py
import sys from marmot.features.feature_extractor import FeatureExtractor from gensim.corpora import TextCorpus class OOVFeatureExtractor(FeatureExtractor): ''' Feature that indicates presence of OOV words in the source phrase. Values: 0 -- no OOV words 1 -- 1 or more OOV words ''' ...
1,079
29.857143
86
py
marmot
marmot-master/marmot/features/phrase/context_lm_left_feature_extractor.py
import os import sys import codecs from subprocess import call from collections import defaultdict from marmot.features.feature_extractor import FeatureExtractor from marmot.util.ngram_window_extractor import left_context, right_context from marmot.experiment.import_utils import mk_tmp_dir class ContextLMLeftFeatureE...
3,745
35.368932
150
py
marmot
marmot-master/marmot/features/phrase/context_lm_feature_extractor.py
import os import codecs from subprocess import call from collections import defaultdict from marmot.features.feature_extractor import FeatureExtractor from marmot.util.ngram_window_extractor import left_context, right_context from marmot.experiment.import_utils import mk_tmp_dir class ContextLMFeatureExtractor(Featur...
4,057
38.398058
155
py
marmot
marmot-master/marmot/features/phrase/ne_feature_extractor.py
import sys from marmot.features.feature_extractor import FeatureExtractor class NEFeatureExtractor(FeatureExtractor): ''' Presence/absence of named entities in source and target phrases. Named entity = word with 1st capital letter ''' def get_features(self, context_obj): #sys.stderr.write...
786
30.48
68
py
marmot
marmot-master/marmot/features/phrase/pos_context_feature_extractor.py
from marmot.features.feature_extractor import FeatureExtractor from marmot.exceptions.no_data_error import NoDataError from marmot.util.ngram_window_extractor import left_context, right_context class POSContextFeatureExtractor(FeatureExtractor): def get_features(self, context_obj): if 'target_pos' not in...
1,445
59.25
175
py