Skip to content

Commit 067a49a

Browse files
committed
reorganize package structure
1 parent 5394a6c commit 067a49a

File tree

15 files changed

+21
-19
lines changed

15 files changed

+21
-19
lines changed

examples/custom_annotators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44

55
def extract_hitler(text):
6-
if "hitler" in text.lower():
7-
yield Entity("hitler", "bad_guy", source_text=text, data={
8-
"known_for": ["killing jews", "world war 2"]})
6+
if "hitler" in text.lower().split():
7+
yield Entity("hitler", "bad_guy", source_text=text,
8+
data={"known_for": ["killing jews", "world war 2"]})
99

1010

1111
ner = NERWrapper()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def package_files(directory):
1414

1515
setup(
1616
name='simple_NER',
17-
version='0.5.0',
17+
version='0.6.0',
1818
packages=['simple_NER', 'simple_NER.rules', 'simple_NER.annotators',
1919
'simple_NER.annotators.remote', 'simple_NER.annotators.utils',
2020
'simple_NER.annotators.utils.keywords'],

simple_NER/annotators/datetime_ner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from lingua_franca.lang.parse_en import _convert_words_to_numbers_en
77
from lingua_franca.format import nice_duration, nice_date
88
from lingua_franca import load_language
9-
from simple_NER.annotators.utils.diff import TextDiff
9+
from simple_NER.utils.diff import TextDiff
1010

1111

1212
load_language("en")

simple_NER/annotators/keyword_ner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from simple_NER.annotators import NERWrapper
22
from simple_NER import Entity
3-
from simple_NER.annotators.utils.keywords.rake import Rake
3+
from simple_NER.keywords.rake import Rake
44

55

66
class KeywordNER(NERWrapper):

simple_NER/annotators/locations_ner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from simple_NER.annotators import NERWrapper
22
from simple_NER import Entity
3-
from simple_NER.util import resolve_resource_file
3+
from simple_NER.utils import resolve_resource_file
44
import json
55

66

simple_NER/annotators/nltk_ner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
try:
55
import nltk
6-
76
nltk.download('punkt')
87
nltk.download('averaged_perceptron_tagger')
98
nltk.download('maxent_ne_chunker')

simple_NER/annotators/numbers_ner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from simple_NER import Entity
33
from lingua_franca.lang.parse_en import _convert_words_to_numbers_en
44
from lingua_franca import load_language
5-
from simple_NER.annotators.utils.diff import TextDiff
5+
from simple_NER.utils.diff import TextDiff
66

77
load_language("en")
88

simple_NER/annotators/utils/keywords/__init__.py

Whitespace-only changes.

simple_NER/annotators/utils/keywords/rake.py renamed to simple_NER/keywords/rake.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import operator
99
from simple_NER.settings import STOPLIST
1010

11+
1112
def is_number(s):
1213
try:
1314
float(s) if '.' in s else int(s)
@@ -43,7 +44,7 @@ def separate_words(text, min_word_return_size):
4344
# leave numbers in phrase, but don't count as words, since they tend to invalidate scores of their phrases
4445
if len(
4546
current_word) > min_word_return_size and current_word != '' and not is_number(
46-
current_word):
47+
current_word):
4748
words.append(current_word)
4849
return words
4950

@@ -104,7 +105,7 @@ def calculate_word_scores(phraseList):
104105
for item in word_frequency:
105106
word_score.setdefault(item, 0)
106107
word_score[item] = word_degree[item] / (
107-
word_frequency[item] * 1.0) # orig.
108+
word_frequency[item] * 1.0) # orig.
108109
# word_score[item] = word_frequency[item]/(word_degree[item] * 1.0) #exp.
109110
return word_score
110111

@@ -121,7 +122,7 @@ def generate_candidate_keyword_scores(phrase_list, word_score):
121122
return keyword_candidates
122123

123124

124-
class Rake(object):
125+
class Rake:
125126
def __init__(self, stop_words_path=STOPLIST):
126127
self.stop_words_path = stop_words_path
127128
self.__stop_words_pattern = build_stop_word_regex(stop_words_path)
@@ -179,4 +180,5 @@ def run(self, text):
179180
rake = Rake("SmartStoplist.txt")
180181
keywords = rake.run(text)
181182
from pprint import pprint
183+
182184
pprint(keywords)

0 commit comments

Comments
 (0)