Skip to content

Commit

Permalink
Merge branch 'docs'
Browse files Browse the repository at this point in the history
  • Loading branch information
wehlutyk committed Aug 12, 2016
2 parents 51644d5 + c051050 commit 34cbc6d
Show file tree
Hide file tree
Showing 64 changed files with 612 additions and 72,800 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.egg-info
.cache
data/clearpond
data/figures
data/FreeAssociation
data/MemeTracker
data/notebooks
docs/_build
docs/data
Dockerfile
.git
.ipynb_checkpoints
**/__pycache__
treetagger
90 changes: 90 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
FROM ubuntu:16.04
MAINTAINER Sébastien Lerique <sl@mehho.net>

# Install all the system and build dependencies.
ENV PYTHON_VERSION 3.5
ENV PG_VERSION 9.5
RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
git \
libfreetype6-dev \
libpng12-0 \
libpng12-dev \
locales \
pkg-config \
postgresql-${PG_VERSION} \
postgresql-server-dev-${PG_VERSION} \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
python3 \
python3-pip \
sudo \
unzip \
wget \
&& rm -rf /var/lib/apt/lists/*

# Make the "en_US.UTF-8" locale so postgres and python Click will be utf-8
# enabled by default.
RUN set -x \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LC_ALL en_US.utf8
ENV LANG en_US.utf8

# Set up postgres with user and analysis and test databases for brainscopypaste.
RUN set -x \
&& service postgresql start \
&& sudo -u postgres psql -c 'create user brainscopypaste;' \
&& sudo -u postgres psql -c 'create database brainscopypaste;' \
&& sudo -u postgres psql -c 'alter database brainscopypaste owner to brainscopypaste;' \
&& sudo -u postgres psql -c 'create database brainscopypaste_test;' \
&& sudo -u postgres psql -c 'alter database brainscopypaste_test owner to brainscopypaste;' \
&& sed -i 's/^\(\(local\|host\) \+all \+all \+.* \+\)\(peer\|md5\)$/\1trust/g' /etc/postgresql/${PG_VERSION}/main/pg_hba.conf

# Copy the originating repository, and install requirements.
COPY . /home/brainscopypaste
RUN set -x \
&& cd /home/brainscopypaste \
&& pip3 install --upgrade pip setuptools \
&& pip install $(cat requirements.txt | grep "^numpy") \
&& pip install -r requirements.txt \
&& pip install --editable .

# Configure the brainscopypaste user.
RUN set -x \
&& useradd brainscopypaste \
&& echo "brainscopypaste ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/brainscopypaste \
&& chown -R brainscopypaste:brainscopypaste /home/brainscopypaste
USER brainscopypaste

# Install treetagger and datasets.
RUN set -x \
&& cd /home/brainscopypaste \
&& ./install_treetagger.sh \
&& ./install_datasets.sh

# Clean up to reduce image size.
RUN set -x \
&& sudo rm -rf /root/.cache/pip \
&& sudo apt-get purge -y --auto-remove \
build-essential \
ca-certificates \
libfreetype6-dev \
libpng12-dev \
pkg-config \
postgresql-server-dev-${PG_VERSION} \
python${PYTHON_VERSION}-dev \
python3-pip \
unzip \
wget

# Check the software runs its tests.
RUN set -x \
&& cd /home/brainscopypaste \
&& sudo service postgresql restart \
&& py.test

# Use the CLI tool, for easier use.
CMD ["/home/brainscopypaste/dockerstart.sh"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ The latex source (along with compiled pdf) for the paper is at [wehlutyk/brainsc

TODO/OUTDATED: See the [documentation](https://brainscopypaste.readthedocs.org/en/latest/) if you want to install, run, or understand any of this.

## Licence
## License

GNU/GPLv3.
4 changes: 4 additions & 0 deletions brainscopypaste/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Toolchain for analysing word substitutions in online quotes from the
MemeTracker dataset.
"""
5 changes: 5 additions & 0 deletions brainscopypaste/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""CLI tool for stepping through the analysis.
"""


from os.path import exists, basename, split, join
from os import remove
import logging
Expand Down
6 changes: 6 additions & 0 deletions brainscopypaste/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""Manage settings from :mod:`.settings`, allowing overriding
of some values.
"""


import logging
import importlib
from contextlib import contextmanager
Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Test fixtures.
"""


from datetime import datetime, timedelta

import pytest
Expand Down
7 changes: 5 additions & 2 deletions brainscopypaste/db.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Database models and related utilities.
"""


import re
from io import StringIO
import logging
Expand Down Expand Up @@ -325,8 +330,6 @@ def lemmas(self):


def _copy(string, table, columns):
from brainscopypaste.utils import session_scope

string.seek(0)
with session_scope() as session:
cursor = session.connection().connection.cursor()
Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/db_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Tests for :mod:`.db`.
"""


from datetime import datetime, timedelta

from sqlalchemy.exc import DataError
Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/features.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Features for words in substitutions.
"""


import logging
from csv import DictReader, reader as csvreader
import warnings
Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/features_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Tests for :mod:`.features`.
"""


from os.path import exists
import pickle

Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/filter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Filter clusters and quotes to clean to MemeTracker dataset.
"""


from datetime import timedelta
import logging

Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/filter_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Tests for :mod:`.filter`.
"""


from datetime import datetime, timedelta

import pytest
Expand Down
4 changes: 3 additions & 1 deletion brainscopypaste/load.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Load data from the MemeTracker dataset."""
"""Load data from the MemeTracker dataset.
"""


from datetime import datetime
Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/load_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Tests for :mod:`.load`.
"""


import os
from tempfile import mkstemp
from datetime import timedelta
Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/mine.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Mine substitutions with various mining models.
"""


from enum import Enum, unique
from datetime import timedelta, datetime
import logging
Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/mine_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Tests for :mod:`.mine`.
"""


import os
from tempfile import mkstemp
from datetime import datetime
Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""General settings for the analysis.
"""


from os.path import abspath, join


Expand Down
4 changes: 3 additions & 1 deletion brainscopypaste/tagger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Tag and tokenize sentences and quotes."""
"""Tag and tokenize sentences and quotes.
"""


from treetaggerwrapper import TreeTagger, TreeTaggerError
Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/tagger_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Tests for :mod:`.tagger`.
"""


from brainscopypaste.tagger import tag, tags, tokens, lemmas


Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Miscellaneous utilities.
"""


import logging
import pickle
from contextlib import contextmanager
Expand Down
5 changes: 5 additions & 0 deletions brainscopypaste/utils_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Tests for :mod:`.utils`.
"""


import pickle
from tempfile import mkstemp
import os
Expand Down
4 changes: 3 additions & 1 deletion data/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.pickle
FreeAssociation/
MemeTracker/
clearpond/

0 comments on commit 34cbc6d

Please sign in to comment.