Skip to content

Commit

Permalink
Renamed to PyCobalt
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Bermeitinger committed Mar 20, 2017
1 parent af35280 commit 96acefe
Show file tree
Hide file tree
Showing 10 changed files with 267 additions and 23 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
examples/
.gitignore
README.md
__pycache__/
.idea/
tests/
run.py
.git/
build/
21 changes: 8 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@ FROM python:3.6.0
MAINTAINER Open Semantics Group <osemantics@gmail.com>

# update old version
RUN pip list --local --outdated --format=freeze | cut -d= -f 1 | xargs -n1 pip install -U
RUN pip list --local --outdated --format=freeze | cut -d= -f 1 | xargs -n1 pip install -U && \
pip install 'uwsgi==2.0.14'

# add application
ADD . /app/
WORKDIR /app
ADD requirements.txt /app/

# Project requirements
RUN pip install -r requirements.txt
# .. plus some NLTK corpora
RUN python -m nltk.downloader names punkt

# Deployment requirements
RUN pip install 'uwsgi==2.0.14'

# finally add application
ADD pycobalt/ service.py uwsgi.ini /app/
RUN pip install -r requirements.txt \
&& python -m nltk.downloader names punkt
RUN python setup.py install

# Go!
CMD [ "uwsgi", "--ini", "uwsgi.ini" ]
CMD [ "uwsgi", "--ini", "uwsgi.ini" ]
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0-beta.1
1.1.0-beta.3
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3'

services:

coreference:
depends_on:
- corenlp
build:
context: .
dockerfile: Dockerfile
environment:
- PYCOBALT_CORENLP=http://corenlp:9000
ports:
- "5128:5128"
links:
- corenlp

corenlp:
image: "corenlp:370"
expose:
- "9000"
193 changes: 193 additions & 0 deletions examples/Paris.input.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pycobalt/resolving.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def __first_name_mention(name_references: List[NameReference],
entity_tokens = []
for token in sentence.tokens:
if len(token.word) > 0 and token.word[0].isupper():
entity_tokens.append(token.word)
entity_tokens.append(token)
else:
return NameReference(sentence_index=0,
tokens=entity_tokens,
Expand Down
9 changes: 5 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
joblib==0.11
pycorenlp==0.3.0
Flask==0.12
nose
nltk
joblib
pycorenlp
Flask
nose
1 change: 1 addition & 0 deletions service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

import datetime
import sys

from flask import Flask, jsonify, make_response, request

Expand Down
13 changes: 13 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python

from distutils.core import setup

with open('VERSION', 'r') as i:
version = i.read().strip()

setup(name='PyCobalt',
version=version,
description='Coreference Resolution',
author='Bernhard Bermeitinger',
packages=['pycobalt'],
)
22 changes: 18 additions & 4 deletions tests/test_WikiArticle.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import unittest
import nose

import os

Expand All @@ -8,11 +9,11 @@
logging.getLogger('requests').setLevel(logging.WARNING)


class TestResolverForBarackObama(unittest.TestCase):
class TestResolverWithActualData(unittest.TestCase):
def setUp(self):
self.maxDiff = None

def test_resolver_for_first_paragraphs(self):
def test_resolver_for_first_paragraphs_BarackObama(self):
with open(os.path.join('examples', 'short_input.txt')) as i:
sentences = [l for l in i]

Expand All @@ -34,7 +35,7 @@ def test_resolver_for_first_paragraphs(self):
for s, e in zip(substituted, expected):
self.assertEquals(s, e)

def test_resolver_for_full_article(self):
def test_resolver_for_article_BarackObama(self):
with open(os.path.join('examples', 'Barack_Obama.input.txt')) as i:
sentences = [l for l in i]

Expand All @@ -56,6 +57,19 @@ def test_resolver_for_full_article(self):
for s, e in zip(substituted, expected):
self.assertEquals(s, e)

def test_resolver_for_full_article_Paris(self):
with open(os.path.join('examples', 'Paris.input.txt')) as i:
text = i.read()

self.assertIsNotNone(text)

sentences, substitutions = resolve(text, "")

self.assertIsNotNone(sentences)
self.assertEquals(len(sentences), 657)
self.assertIsNotNone(substitutions)
self.assertGreater(len(substitutions), 100)


if __name__ == '__main__':
unittest.main()
nose.main()

0 comments on commit 96acefe

Please sign in to comment.