dashwood.net -

Ryan Stefan's Micro Blog

Sharing and Flask Dev

Nov 102018

Added NTFS folder sharing over the network without actually having user permission of the folder. Here's how I enabled, adding usershare owner only = false below [global]

sudo nano /etc/samba/smb.conf

# Any line which starts with a ; (semi-colon) or a # (hash) 
# is a comment and is ignored. In this example we will use a #
# for commentary and a ; for parts of the config file that you
# may wish to enable
#
# NOTE: Whenever you modify this file you should run the command
# "testparm" to check that you have not made any basic syntactic 
# errors. 
#

#======================= Global Settings =======================

[global]

usershare owner only = false

## Browsing/Identification ###

ctrl + o

Fix NTFS Permissions

Found some hopfully looking insight on how to give user access to mounted drives.

If you mount a partition to a folder within /home/user it will be owned by the user. Here's the line I added to my /etc/fstab.

UUID=9e5bb53c-4443-4124-96a8-baeb804da204 /home/fragos/Data ext4 errors=remount-ro 0 1

Keyword Raking / Splitting

Going to rake keywords from the comments and then use a 1 sentence lexsum of all of the titles for loop display and other stuff.

# Rake keywords
rake = Rake(min_length=2, max_length=6,
ranking_metric=Metric.DEGREE_TO_FREQUENCY_RATIO) rake.extract_keywords_from_text(textjoin) sumkeywords.append(' : '.join(rake.get_ranked_phrases()))

Source: https://github.com/csurfer/rake-nltk

I had to change the word tokenizer in the class to the nltk twitter tokenizer so that it wouldn't split words by apostrophes.

from nltk.tokenize import wordpunct_tokenize, TweetTokenizer
tknzr = TweetTokenizer()

...

word_list = [word.lower() for word in tknzr.tokenize(sentence)]

I've also decided to use ' : ' as my official list of terms splitting format. Commas are too common and might add complications in the future.

Flask Dev

I turned the CSV file generated from the lexsum generator to preview the summaries and keyword extraction in the flask app.

# load data and create sub dataframe for product asin
data = pd.read_csv('./static/data/sample-products.csv', index_col=0)
product_comments = data.loc[data['asin'] == asin]

# create variables for each rating
for number in range(1,6):
    current = product_comments.loc[product_comments['rating'] == number]
    product['{}_keywords'.format(number)] = current['keywords'].tolist()[0]
    product['{}_title'.format(number)] = current['title'].tolist()[0]
    product['{}_text'.format(number)] = current['text'].tolist()[0]

# load variables inside flask template
<p>{{product['4_text']}}</p>
<p><strong>{{product['4_keywords']}}</strong></p>

undefined

Comments