Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 0b8c743

Browse files
author
Peter Izsak
authored
Merge branch 'master' into peter/documentation
2 parents eaf11b1 + 52ab9cf commit 0b8c743

File tree

23 files changed

+141
-83
lines changed

23 files changed

+141
-83
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: 'bug: [short bug description]'
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
Model/procedure: what model or procedure were you running?
13+
14+
**To Reproduce**
15+
Steps to reproduce the behavior:
16+
1.
17+
2.
18+
3.
19+
4.
20+
21+
**Expected behavior**
22+
23+
**Environment setup: **
24+
- OS (Linux/Mac OS):
25+
- Python version:
26+
- Backend:
27+
28+
**Additional context**
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Feature request/improvement
3+
about: Suggest an idea for this project or an improvement to an existing feature
4+
title: 'improvement: [short improvement/feature topic]'
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a model or library usage/experience? Please describe.**
11+
12+
**Describe why the feature addition/improvement should be added.**
13+
14+
**Describe the solution you'd like**
15+
16+
**Additional context**

.github/ISSUE_TEMPLATE/question.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Question
3+
about: template for asking questions regarding models or library usage
4+
title: 'question: [question topic]'
5+
labels: question
6+
assignees: ''
7+
8+
---
9+
10+
<!-- a question regarding models or library usage -->

.jenkins/Jenkinsfile

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,6 @@
22
* NLP Architect Jenkinsfile
33
*/
44

5-
/*
6-
// Constant Variables for Build
7-
static final Map slackColorMap = [
8-
'FAILURE': 'danger',
9-
'UNSTABLE': 'warning',
10-
'SUCCESS': 'good'
11-
]
12-
13-
// Common Closures for Build
14-
def slackStartMessage = {
15-
try {
16-
slackSend message: "Build ${env.JOB_NAME} started (<${env.BUILD_URL}|LINK>)"
17-
} catch (err) {
18-
echo "BUILD WARNING - Failed to send Slack Message: ${err}"
19-
}
20-
}
21-
def slackEndMessage = {
22-
try {
23-
slackSend color: slackColorMap[currentBuild.currentResult], message: "Build ${env.JOB_NAME} finished with result: ${currentBuild.currentResult} (<${env.BUILD_URL}|LINK>)"
24-
} catch (err) {
25-
echo "BUILD WARNING - Failed to send Slack Message: ${err}"
26-
}
27-
}
28-
*/
29-
305
pipeline {
316
agent {
327
node {
@@ -57,6 +32,7 @@ pipeline {
5732
pip3 install -r requirements.txt
5833
pip3 install -r dev-requirements.txt
5934
pip3 install -e .
35+
python -m spacy download en
6036
"""
6137
}
6238
}
@@ -68,7 +44,7 @@ pipeline {
6844
. .nlp_architect_env/bin/activate
6945
export LC_ALL=en_US.UTF-8
7046
export LANG=en_US.UTF-8
71-
nlp_architect test
47+
pytest ./tests -rs -vv --cov=nlp_architect --junit-xml=pytest_unit.xml
7248
"""
7349
}
7450
post {
@@ -86,7 +62,7 @@ pipeline {
8662
steps {
8763
sh """
8864
. .nlp_architect_env/bin/activate
89-
nlp_architect style --only-flake
65+
./scripts/check_flake.sh
9066
"""
9167
}
9268
post {
@@ -101,7 +77,7 @@ pipeline {
10177
steps {
10278
sh """
10379
. .nlp_architect_env/bin/activate
104-
nlp_architect style --only-pylint
80+
./scripts/check_pylint.sh
10581
"""
10682
}
10783
post {
@@ -126,8 +102,8 @@ pipeline {
126102
currentBuild.result = 'FAILURE'
127103
}
128104
}
129-
cleanup {
105+
always {
130106
deleteDir()
131107
}
132108
}
133-
}
109+
}

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@ A Deep Learning NLP/NLU library by <a href="https://www.intel.ai/research/">Inte
88
</h2>
99
<p align="center">
1010
<a href="https://github.com/NervanaSystems/nlp-architect/blob/master/LICENSE">
11-
<img alt="GitHub" src="https://img.shields.io/github/license/NervanaSystems/nlp-architect.svg?color=blue&style=popout">
11+
<img alt="GitHub" src="https://img.shields.io/github/license/NervanaSystems/nlp-architect.svg?color=blue&style=flat-square">
1212
</a>
1313
<a href="http://nlp_architect.nervanasys.com">
14-
<img alt="Website" src="https://img.shields.io/website/http/nlp_architect.nervanasys.com.svg?down_color=red&down_message=offline&style=popout&up_message=online">
15-
</a>
16-
<a href="https://doi.org/10.5281/zenodo.1477518">
17-
<img src="https://zenodo.org/badge/DOI/10.5281/zenodo.1477518.svg" alt="DOI">
18-
</a>
19-
<a href="https://pepy.tech/project/nlp-architect">
20-
<img src="https://pepy.tech/badge/nlp-architect"/>
14+
<img alt="Website" src="https://img.shields.io/website/http/nlp_architect.nervanasys.com.svg?down_color=red&down_message=offline&style=flat-square&up_message=online">
2115
</a>
2216
<a href="https://github.com/NervanaSystems/nlp-architect/blob/master/LICENSE">
23-
<img alt="GitHub release" src="https://img.shields.io/github/release/NervanaSystems/nlp-architect.svg?style=popout">
17+
<img alt="GitHub release" src="https://img.shields.io/github/release/NervanaSystems/nlp-architect.svg?style=flat-square">
2418
</a>
2519
</p>
2620

examples/reading_comprehension/prepare_data.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from nlp_architect.utils.io import validate_existing_directory
2424
from nlp_architect.utils.text import SpacyInstance
2525

26+
sep = os.sep
2627
PAD = "<pad>"
2728
SOS = "<sos>"
2829
UNK = "<unk>"
@@ -72,10 +73,10 @@ def get_glove_matrix(vocabulary_list, download_path):
7273
"""
7374
Function to obtain preprocessed glove embeddings matrix
7475
"""
75-
save_file_name = download_path + "glove.trimmed.300"
76+
save_file_name = download_path + sep + "glove.trimmed.300"
7677
if not os.path.exists(save_file_name + ".npz"):
7778
vocab_len = len(vocabulary_list)
78-
glove_path = os.path.join(download_path + "glove.6B.300d.txt")
79+
glove_path = os.path.join(download_path + sep + "glove.6B.300d.txt")
7980
glove_matrix = np.zeros((vocab_len, 300))
8081
count = 0
8182
with open(glove_path) as f:
@@ -253,13 +254,13 @@ def get_ids_list(data_list, vocab):
253254
dev_para_ids = get_ids_list(dev_para, vocab_dict)
254255
dev_question_ids = get_ids_list(dev_question, vocab_dict)
255256

256-
final_data_dict = {"train.ids.context": train_para_ids,
257-
"train.ids.question": train_question_ids,
258-
"dev.ids.context": dev_para_ids,
259-
"dev.ids.question": dev_question_ids,
260-
"vocab.dat": vocab_list,
261-
"train.span": train_ans,
262-
"dev.span": dev_ans}
257+
final_data_dict = {sep + "train.ids.context": train_para_ids,
258+
sep + "train.ids.question": train_question_ids,
259+
sep + "dev.ids.context": dev_para_ids,
260+
sep + "dev.ids.question": dev_question_ids,
261+
sep + "vocab.dat": vocab_list,
262+
sep + "train.span": train_ans,
263+
sep + "dev.span": dev_ans}
263264

264265
print("writing data to files")
265266
write_to_file(final_data_dict, data_path)

nlp_architect/cli/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515
# ******************************************************************************
1616
import argparse
17-
import logging
17+
import logging
1818

1919
# register all procedures by importing
2020
import nlp_architect.procedures # noqa: F401
@@ -28,6 +28,7 @@
2828
datefmt='%m/%d/%Y %H:%M:%S',
2929
level=logging.INFO)
3030

31+
3132
def run_cli():
3233
""" Run nlp_architect command line application
3334
"""

nlp_architect/cli/cli_commands.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
# ******************************************************************************
16+
# CLI definition
1617
from argparse import _SubParsersAction
1718

1819
from nlp_architect.cli.cmd_registry import CMD_REGISTRY
@@ -34,11 +35,6 @@ def generic_cmd(cmd_name: str, subtitle: str, description: str, subparsers: _Sub
3435
parser.set_defaults(func=lambda _: parser.print_help())
3536

3637

37-
"""
38-
cli commands definition
39-
"""
40-
41-
4238
def cli_train_cmd(subparsers: _SubParsersAction):
4339
generic_cmd('train',
4440
'Available models',

nlp_architect/models/matchlstm_ansptr.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -525,15 +525,15 @@ def inference_mode(self, session, valid, vocab_tuple, num_examples, dropout=1.0,
525525
else:
526526
# Print Paragraph
527527
print("\n")
528-
print("Paragraph Number:", idx)
529-
test_paragraph = [vocab_forward[ele] for ele in valid[idx][0] if ele != 0]
528+
print("Paragraph Number AA:", idx)
529+
test_paragraph = [vocab_forward[ele].replace(" ", "") for ele in valid[idx][0] if ele != 0]
530530
para_string = " ".join(map(str, test_paragraph))
531-
print(re.sub(r'\s([?.!,"](?:\s|$))', r'\1', para_string))
531+
print(para_string)
532532

533533
# Print corresponding Question
534-
test_question = [vocab_forward[ele] for ele in valid[idx][1] if ele != 0]
534+
test_question = [vocab_forward[ele].replace(" ", "") for ele in valid[idx][1] if ele != 0]
535535
ques_string = " ".join(map(str, test_question))
536-
print("Question:", re.sub(r'\s([?.!"",])', r'\1', ques_string))
536+
print("Question:", ques_string)
537537
question_ids = valid[idx][1]
538538
question_length = valid[idx][3]
539539
ques_mask = valid[idx][6]
@@ -555,7 +555,7 @@ def inference_mode(self, session, valid, vocab_tuple, num_examples, dropout=1.0,
555555
answer_ind = valid[idx][0][start_idx[0]:end_idx[0] + 1]
556556

557557
# Print answer
558-
req_ans = [vocab_forward[ele] for ele in answer_ind if ele != 0]
558+
req_ans = [vocab_forward[ele].replace(" ", "") for ele in answer_ind if ele != 0]
559559
ans_string = " ".join(map(str, req_ans))
560560
answer = re.sub(r'\s([?.!",])', r'\1', ans_string)
561561
print("Answer:", answer)

nlp_architect/models/tagging.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ def evaluate(self, data_set: DataLoader):
297297
logits = self.model(**inputs)
298298
if 'labels' in inputs:
299299
if self.use_crf:
300-
loss = -1.0 * self.crf(logits, inputs['labels'], mask=inputs['mask'] != 0.0)
300+
loss = -1.0 * self.crf(logits, inputs['labels'],
301+
mask=inputs['mask'] != 0.0)
301302
else:
302303
loss_fn = CrossEntropyLoss(ignore_index=0)
303304
loss = loss_fn(logits.view(-1, self.num_labels), inputs['labels'].view(-1))

0 commit comments

Comments
 (0)