Skip to content

Commit d5017b5

Browse files
alexottalenegro81
authored andcommitted
get rid of the sys.path.append
use PYTHONPATH instead
1 parent 54b41cd commit d5017b5

13 files changed

+11
-24
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/ch11/stanfordnlp_resources/
22
*.pyc
33
/ch11/masc_word_sense_sentence_corpus.V1.0/
4+
/.venv/
5+
/.idea/

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ Once created it needs to be activated
3131
source .venv/bin/activate
3232
```
3333

34+
You also need to set the `PYTHONPATH` environment variable, so Python will able to find auxiliary libraries (in the top-level directory of the project):
35+
36+
```sh
37+
export PYTHONPATH="$(pwd):$PYTHONPATH"
38+
```
39+
3440
The commands above run on Linux/Unix sheels for more details and for other operating systems refers to the Python documentation available [here](https://docs.python.org/3/library/venv.html).
3541

3642
As reminder the environment must be activated everytime a new shel is opened.

ch05/recommendation/collaborative_filtering/recommender.py

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
from neo4j import GraphDatabase, Transaction
66

7-
import sys,os
8-
sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..', '..', '..')))
97
from util.fixed_heapq import FixedHeap
108
from util.sparse_vector import cosine_similarity
119

ch06/recommendation/session_based_recommendation_iknn_approach.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
from neo4j import GraphDatabase
33

4-
import sys,os
5-
sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..', '..')))
64
from util.sparse_vector import cosine_similarity
75

86

ch06/recommendation/session_based_recommendation_iknn_approach_advanced.py

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
from neo4j import GraphDatabase
33
import time
44

5-
import sys,os
6-
sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..', '..')))
7-
85
from util.sparse_matrix import SparseMatrix
96
from util.lsh import LSH
107
from statistics import mean

ch06/recommendation/session_based_recommendation_sknn_approach.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
from neo4j import GraphDatabase
33

4-
import sys,os
5-
sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..', '..')))
64
from util.sparse_vector import cosine_similarity
75

86

ch06/recommendation/session_based_recommendation_sknn_approach_advanced.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from annoy import AnnoyIndex
22
from neo4j import GraphDatabase
33
import time
4-
import sys,os
5-
sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..', '..')))
64
from util.sparse_matrix import SparseMatrix
75
from statistics import mean
86
import gc

ch07/recommendations/context_aware_recommendation_approach.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from neo4j import GraphDatabase
22

3-
import sys,os
4-
sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..', '..')))
53
from util.sparse_vector import cosine_similarity
64

75

ch12/04_spacy_ner_schema.py

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
from neo4j import GraphDatabase
33
from spacy.lang.en.stop_words import STOP_WORDS
44

5-
import sys,os
6-
sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..')))
75
from ch12.text_processors import TextProcessor
86
from util.query_utils import executeNoException
97

ch12/05_spacy_coref_schema.py

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
from neo4j import GraphDatabase
33
import neuralcoref
44

5-
import sys,os
6-
sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..')))
75
from ch12.text_processors import TextProcessor
86
from util.query_utils import executeNoException
97

ch12/06_spacy_entity_relationship_extraction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from spacy.matcher import Matcher, DependencyMatcher
99

1010
import sys,os
11-
sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..')))
11+
1212
from ch12.text_processors import TextProcessor
1313
from util.query_utils import executeNoException
1414

ch12/07_process_larger_corpus.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
from neo4j import GraphDatabase
33
import neuralcoref
44
import pandas as pd
5-
65
import sys,os
7-
sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..')))
8-
from ch12.text_processors import TextProcessor
6+
97
from util.query_utils import executeNoException
108

119

ch12/08_spacy_textrank_extraction.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
import neuralcoref
44
import pytextrank
55
import pandas as pd
6-
import sys
7-
86
import sys,os
9-
sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..')))
7+
108
from util.query_utils import executeNoException
119
from ch12.text_processors import TextProcessor
1210

0 commit comments

Comments
 (0)