Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #182: Word Sleuthing

soha-elghany
8 - Asteroid
 
Carlithian
11 - Bolide
11 - Bolide

Looks like im not getting the same output

Shreyasi
6 - Meteoroid
 
AndrewS
11 - Bolide
Spoiler
Used a regex replace formula REGEX_Replace([Field_1], "\W", " ") and then text to columns split rows using \s delimiter.
PeterA
Alteryx Alumni (Retired)

Here is a python based alternative that leverages some of the built in functions from the NLTK.

#################################
# List all non-standard packages to be imported by your 
# script here (only missing packages will be installed)
from ayx import Package, Alteryx
Package.installPackages(['nltk'])


#################################

import urllib
import pandas as pd
import nltk 


#################################
# Load data (from url)
data = urllib.request.urlopen('https://norvig.com/big.txt').read().decode('utf-8')

# Load data (from canvas)
#canvasInput = Alteryx.read("#1")
#data = canvasInput.Field_1.str.cat(sep=' ')

# Split into words
tokens = nltk.word_tokenize(data)

# Convert tokens to lowercase
tokens = [w.lower() for w in tokens]

# Remove puncuation
words = [word for word in tokens if word.isalpha()]

# Take a quick look
print(words[:50])

# Calculate our frequency distribution
fd = nltk.FreqDist(words)


#################################
# Prepare ouput (sorted by decending frequency)
ayx_output=pd.DataFrame(list(fd.most_common()), columns = ["Word","Frequency"])

# Append total word count
ayx_output.loc[:,'Total'] = fd.N()

Alteryx.write(ayx_output,1)

 

Spoiler
Python based ApproachPython based Approach

 

danicahui
8 - Asteroid
Spoiler
Challenge 182 2019-12-09.jpg
sachinw
8 - Asteroid

My Solution:

Gloriadewaal
6 - Meteoroid

I'm with everyone else  - I couldn't get the totals to match.

 

Spoiler
Challenge 182 - photo.PNG
fmvizcaino
17 - Castor
17 - Castor

Done!!!

 

Spoiler
fmvizcaino_0-1577383642295.png
Ivyin702
7 - Meteor
Spoiler
Spoiler
Please find the attached solution file
Spoiler
Ivyin702_0-1577433961702.png