Unverified Commit bbea0f2d authored by Radovan Bast's avatar Radovan Bast Committed by GitHub
Browse files

Merge pull request #1 from coderefinery/radovan/aalborg-changes

Changes used at the Aalborg workshop
parents 731c8e82 bd86c858
MIT License
Copyright (c) 2019, CodeRefinery
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# Build both steps required for executing the character count example # directory containing source data
all: processed_data/abyss.dat results/abyss.png results/results.txt SRCDIR := data
# Count words (Step 1) # directory containing intermediate data
processed_data/abyss.dat: data/abyss.txt source/wordcount.py TMPDIR := processed_data
python source/wordcount.py data/abyss.txt processed_data/abyss.dat
# Create Bar chart (Step 2) # results directory
results/abyss.png: processed_data/abyss.dat source/plotcount.py RESDIR := results
python source/plotcount.py processed_data/abyss.dat results/abyss.png
# Test Zipf's law # all source files (book texts)
results/results.txt: processed_data/abyss.dat source/zipf_test.py SRCS = $(wildcard $(SRCDIR)/*.txt)
python source/zipf_test.py processed_data/abyss.dat > results/results.txt
# all intermediate data files
DATA = $(patsubst $(SRCDIR)/%.txt,$(TMPDIR)/%.dat,$(SRCS))
# all images
IMAGES = $(patsubst $(SRCDIR)/%.txt,$(RESDIR)/%.png,$(SRCS))
all: $(DATA) $(IMAGES) $(RESDIR)/results.txt
$(TMPDIR)/%.dat: $(SRCDIR)/%.txt source/wordcount.py
python source/wordcount.py $< $@
$(RESDIR)/%.png: $(TMPDIR)/%.dat source/plotcount.py
python source/plotcount.py $< $@
$(RESDIR)/results.txt: $(DATA) source/zipf_test.py
python source/zipf_test.py $(DATA) > $@
clean:
@$(RM) $(TMPDIR)/*
@$(RM) $(RESDIR)/*
.PHONY: clean directories
SRCDIR := data
TMPDIR := processed_data
RESDIR := results
SRCS = $(wildcard $(SRCDIR)/*.txt)
OBJS = $(patsubst $(SRCDIR)/%.txt,$(TMPDIR)/%.dat,$(SRCS))
OBJS += $(patsubst $(SRCDIR)/%.txt,$(RESDIR)/%.png,$(SRCS))
OBJS += $(RESDIR)/results.txt
DATA = $(patsubst $(SRCDIR)/%.txt,$(TMPDIR)/%.dat,$(SRCS))
all: $(OBJS)
$(TMPDIR)/%.dat: $(SRCDIR)/%.txt source/wordcount.py
python source/wordcount.py $< $@
$(RESDIR)/%.png: $(TMPDIR)/%.dat source/plotcount.py
python source/plotcount.py $< $@
$(RESDIR)/results.txt: $(DATA) source/zipf_test.py
python source/zipf_test.py $(DATA) > $@
clean:
@$(RM) $(TMPDIR)/*
@$(RM) $(RESDIR)/*
.PHONY: clean directories
...@@ -33,13 +33,11 @@ rule count_words: ...@@ -33,13 +33,11 @@ rule count_words:
''' '''
# create a plot for each book # create a plot for each book
# shows example usage of the resources keyword
rule make_plot: rule make_plot:
input: input:
plotcount='source/plotcount.py', plotcount='source/plotcount.py',
book='processed_data/{file}.dat' book='processed_data/{file}.dat'
output: 'results/{file}.png' output: 'results/{file}.png'
resources: gpu=1
shell: 'python {input.plotcount} {input.book} {output}' shell: 'python {input.plotcount} {input.book} {output}'
# generate summary table # generate summary table
......
...@@ -7,17 +7,17 @@ Usage ...@@ -7,17 +7,17 @@ Usage
How to clone the code How to clone the code
--------------------- ---------------------
To clone the source code run following commands:: Write me ...
$ git clone https://github.com/advelex/word-count
Make Make
---- ----
Generate all results:: Generate all results:
::
$ make -f Makefile_all $ make
Snakemake Snakemake
......
## Instructional Material
All CodeRefinery instructional material is made available under the
[Creative Commons Attribution-ShareAlike license](https://creativecommons.org/licenses/by-sa/4.0/).
The following is a human-readable summary of (and not a substitute for)
the [full legal text of the CC BY-SA 4.0 license](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
You are free:
- to **Share** - copy and redistribute the material in any medium or format
- to **Adapt** - remix, transform, and build upon the material
for any purpose, even commercially. The licensor cannot revoke these freedoms as long as you follow these license terms:
- **Attribution** - You must give appropriate credit
(mentioning that your work is derived from work that is Copyright
(c) CodeRefinery and, where practical, linking to
http://coderefinery.org), provide
a [link to the license](https://creativecommons.org/licenses/by-sa/4.0/),
and indicate if changes were made. You may do so in any
reasonable manner, but not in any way that suggests the licensor
endorses you or your use.
- **ShareAlike** - If you remix, transform, or build upon the material, you
must distribute your contributions under the same license as the original.
**No additional restrictions** - You may not apply legal terms or technological
measures that legally restrict others from doing anything the license permits.
With the understanding that:
- You do not have to comply with the license for elements of the material in
the public domain or where your use is permitted by an applicable exception
or limitation.
- No warranties are given. The license may not give you all of the
permissions necessary for your intended use. For example, other
rights such as publicity, privacy, or moral rights may limit how
you use the material.
## Software
Except where otherwise noted, the example programs and other software provided
by CodeRefinery are made available under the
[OSI](http://opensource.org)-approved [MIT
license](http://opensource.org/licenses/mit-license.html):
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
numpy numpy==1.16.4
matplotlib matplotlib==3.1.0
git+https://github.com/pytries/datrie.git@3e22a27ca0104fe3c62b3251c0b75c281f089e43
snakemake==5.5.0
# to check python code style # to check python code style
pycodestyle pycodestyle
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment