コード例 #1
0
from utils import create_and_add_mapping, populate
import elasticsearch
from pprint import pprint

es = elasticsearch.Elasticsearch()
index_name = "my_index"

if es.indices.exists(index_name):
    es.indices.delete(index_name)


create_and_add_mapping(es, index_name)
populate(es, index_name)

results = es.search(
    index=index_name,
    body={"size": 0,
          "aggs": {
              "pterms": {"terms": {"field": "name", "size": 10}}
          }
          })
pprint(results)

results = es.search(
    index=index_name,
    body={"size": 0,
          "aggs": {
              "date_histo": {"date_histogram": {"field": "date", "interval": "month"}}
          }
          })
pprint(results)
コード例 #2
0
import elasticsearch
from pprint import pprint

es = elasticsearch.Elasticsearch()
index_name = "my_index"
type_name = "my_type"

if es.indices.exists(index_name):
    es.indices.delete(index_name)

from utils import create_and_add_mapping, populate

create_and_add_mapping(es, index_name, type_name)
populate(es, index_name, type_name)

results = es.search(index_name, type_name, {"query": {"match_all": {}}})
pprint(results)

results = es.search(index_name, type_name, {
    "query": {
        "term": {"name": {"boost": 3.0, "value": "joe"}}}
})
pprint(results)

results = es.search(index_name, type_name, {"query": {
    "bool": {
        "filter": {
            "bool": {
                "should": [
                    {"term": {"position": 1}},
                    {"term": {"position": 2}}]}
コード例 #3
0
ファイル: app.py プロジェクト: ppsirg/puj_dbs
    # show emails
    print(context['mails'])
    # require email for login
    email = input('ingrese email para iniciar: ')
    # show initial view
    print(f'bienvenido de nuevo {email}')
    context['email'] = email
    initialLoginView(context)
    # main loop to ask for queries
    stop = False
    while not stop:
        selection = instruction_menu()
        if not selection:
            continue
        elif selection == 'finish':
            stop = True
            continue
        else:
            selection(context)


if __name__ == "__main__":
    client = MongoClient()
    db = client['test-database']
    context = {'db': db}
    pdb.set_trace()
    # if no data, populate database
    mails = populate()
    context['mails'] = mails
    # run application
    ui(context)
コード例 #4
0
import elasticsearch
from pprint import pprint

es = elasticsearch.Elasticsearch()
index_name = "my_index"
type_name = "my_type"

from utils import create_and_add_mapping, populate

create_and_add_mapping(es, index_name, type_name)
populate(es, index_name, type_name)

results = es.search(index_name, type_name, {"query": {"match_all": {}}})
pprint(results)

results = es.search(index_name, type_name, {
    "query": {
        "query": {
            "term": {"name": {"boost": 3.0, "value": "joe"}}}
    }})
pprint(results)

results = es.search(index_name, type_name, {"query": {
    "filtered": {
        "filter": {
            "or": [
                {"term": {"position": 1}},
                {"term": {"position": 2}}]
        },
        "query": {"match_all": {}}}}})
pprint(results)
コード例 #5
0
EPOCHS = 20
BATCH_SIZE = [1, 2, 4, 8, 16, 32]
LR = [0.1, 0.01, 0.001, 0.0001]
LOSS = rmse
PATIENCE = 3
MAX_QUEUE_SIZE = 32
SHUFFLE = True

directory = '../dataset/training/'

if __name__ == '__main__':

    model_name = input("Enter a name for your model: ")

    dataset = {angle: [] for angle in range(MINIMUM_ANGLE, MAXIMUM_ANGLE + 1)}
    populate(dataset, directory, '.png')

    training_dataset, validation_dataset = split(
        dataset, training_size=TRAINING_SIZE, validation_size=VALIDATION_SIZE)

    distribution_hist('../visualizations/distribution_pre-balance.png',
                      training_dataset)

    balance(training_dataset,
            downsample_threshold=DOWNSAMPLE_THRESHOLD,
            upsample_threshold=UPSAMPLE_THRESHOLD)

    distribution_hist('../visualizations/distribution_post-balance.png',
                      training_dataset)

    training_data = unpack(training_dataset)
コード例 #6
0
ファイル: manager.py プロジェクト: n3storm/mailman-manager
 def remove(self, email):
     if isinstance(email, list) == False:
         email = [email,]
     file_name = populate('unsubscribe', email, self.name)
     raw = run(self.members_unsubscribe_cmd, file_name, self.name)