diff --git a/.gitignore b/.gitignore index a4a208bd0d5fddd08c6a927323ca50b9cb71b993..dfdd933bfa51e3fa536f7100a6ec008a4bcfc70c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,259 +1,2 @@ -## Core latex/pdflatex auxiliary files: -*.aux -*.lof -*.log -*.lot -*.fls -*.out -*.toc -*.fmt -*.fot -*.cb -*.cb2 -.*.lb - -## Intermediate documents: -*.dvi -*.xdv -*-converted-to.* -# these rules might exclude image files for figures etc. -# *.ps -# *.eps -# *.pdf - -## Generated if empty string is given at "Please type another file name for output:" -.pdf - -## Bibliography auxiliary files (bibtex/biblatex/biber): -*.bbl -*.bcf -*.blg -*-blx.aux -*-blx.bib -*.run.xml - -## Build tool auxiliary files: -*.fdb_latexmk -*.synctex -*.synctex(busy) -*.synctex.gz -*.synctex.gz(busy) -*.pdfsync - -## Build tool directories for auxiliary files -# latexrun -latex.out/ - -## Auxiliary and intermediate files from other packages: -# algorithms -*.alg -*.loa - -# achemso -acs-*.bib - -# amsthm -*.thm - -# beamer -*.nav -*.pre -*.snm -*.vrb - -# changes -*.soc - -# comment -*.cut - -# cprotect -*.cpt - -# elsarticle (documentclass of Elsevier journals) -*.spl - -# endnotes -*.ent - -# fixme -*.lox - -# feynmf/feynmp -*.mf -*.mp -*.t[1-9] -*.t[1-9][0-9] -*.tfm - -#(r)(e)ledmac/(r)(e)ledpar -*.end -*.?end -*.[1-9] -*.[1-9][0-9] -*.[1-9][0-9][0-9] -*.[1-9]R -*.[1-9][0-9]R -*.[1-9][0-9][0-9]R -*.eledsec[1-9] -*.eledsec[1-9]R -*.eledsec[1-9][0-9] -*.eledsec[1-9][0-9]R -*.eledsec[1-9][0-9][0-9] -*.eledsec[1-9][0-9][0-9]R - -# glossaries -*.acn -*.acr -*.glg -*.glo -*.gls -*.glsdefs - -# gnuplottex -*-gnuplottex-* - -# gregoriotex -*.gaux -*.gtex - -# htlatex -*.4ct -*.4tc -*.idv -*.lg -*.trc -*.xref - -# hyperref -*.brf - -# knitr -*-concordance.tex -# TODO Comment the next line if you want to keep your tikz graphics files -*.tikz -*-tikzDictionary - -# listings -*.lol - -# makeidx -*.idx -*.ilg -*.ind -*.ist - -# minitoc -*.maf -*.mlf -*.mlt -*.mtc[0-9]* -*.slf[0-9]* -*.slt[0-9]* -*.stc[0-9]* - -# minted -_minted* -*.pyg - -# morewrites -*.mw - -# nomencl -*.nlg -*.nlo -*.nls - -# pax -*.pax - -# pdfpcnotes -*.pdfpc - -# sagetex -*.sagetex.sage -*.sagetex.py -*.sagetex.scmd - -# scrwfile -*.wrt - -# sympy -*.sout -*.sympy -sympy-plots-for-*.tex/ - -# pdfcomment -*.upa -*.upb - -# pythontex -*.pytxcode -pythontex-files-*/ - -# tcolorbox -*.listing - -# thmtools -*.loe - -# TikZ & PGF -*.dpth -*.md5 -*.auxlock - -# todonotes -*.tdo - -# vhistory -*.hst -*.ver - -# easy-todo -*.lod - -# xcolor -*.xcp - -# xmpincl -*.xmpi - -# xindy -*.xdy - -# xypic precompiled matrices -*.xyc - -# endfloat -*.ttt -*.fff - -# Latexian -TSWLatexianTemp* - -## Editors: -# WinEdt -*.bak -*.sav - -# Texpad -.texpadtmp - -# LyX -*.lyx~ - -# Kile -*.backup - -# KBibTeX -*~[0-9]* - -# auto folder when using emacs and auctex -./auto/* -*.el - -# expex forward references with \gathertags -*-tags.tex - -# standalone packages -*.sta \ No newline at end of file +*.csv +*.RDS \ No newline at end of file diff --git a/README.md b/README.md index f56e3bce991f5279c69975bff8f6dd06611993fd..d888f68a590ffe5cf311171fe76d5b0ccc086170 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,16 @@ python -m rasa_core.run -d models/dialogue -u models/current/nlu ``` +# R Scripts + +### PhysicistsList.R + +Will crawl wikipedias [List of Physicists](https://en.wikipedia.org/wiki/List_of_physicists) for all physicist names and save them in a file *Physicists.txt* in the data directory. +Use that file to generate xml dump at wikipedias [Export page](https://en.wikipedia.org/wiki/Special:Export) + +### ExtractFromXML.Rasa + +Will read in the xml file from the data directory and extract the title and text of the pages in the dump. Will then write them to *texte.csv* in the data directory, use `read.table` to import. For convenience will also create a texte.RDS file, load with `texte <- readRDS("../data/texte.RDS")`. +**NOTE:** For the script to work, the first line of the xml needs to be replaced with `<mediawiki xml:lang="en">`. + + diff --git a/data/Wikipedia-20181120103842.xml b/data/Wikipedia-20181120103842.xml index 5659353397b37325e0eba64f724a618314e55b93..b0ed542e6437c3378490bf6f2ba9d68ff976a807 100644 --- a/data/Wikipedia-20181120103842.xml +++ b/data/Wikipedia-20181120103842.xml @@ -1,4 +1,4 @@ -<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-0.10.xsd" version="0.10" xml:lang="en"> +<mediawiki xml:lang="en"> <siteinfo> <sitename>Wikipedia</sitename> <dbname>enwiki</dbname> diff --git a/docs/protokolle/2018-11-20.md b/docs/protokolle/2018-11-20.md new file mode 100644 index 0000000000000000000000000000000000000000..e1e8eab3398833337ef78ffc7f8dec7ae2b7622f --- /dev/null +++ b/docs/protokolle/2018-11-20.md @@ -0,0 +1,74 @@ +# Treffen 20.11.2018 + +* Ort: P90x IR-Lab +* Anwesende: alle +* Beginn 10:00 Uhr +* Ende 12:00 Uhr + +## Agenda: + + * Rasa lokal zum laufen bringen + * Daten sichten + * Intents für Rasa sammeln + * Ausblick + + +## Rasa zum Laufen bringen + + * Die Gruppenmitglieder testen eine Rasa-Version auf ihren Laptops + +## Daten sichten + + * Der Bot soll für englische Sprache gebaut werden + * Das Thema sind "Physiker" + + * Ziel: automatisiert Daten runterladen + +### Akquise-Möglichkeit 1 + + * Wikipedia export - eine person muss ganzen Wikipedia Dumb runterladen + * Daraus nur die Physiker extrahieren und unter den Gruppenmitgliedern verteilen + +### Akquise-Möglichkeit 2 + + * https://en.wikipedia.org/wiki/Special:Export + * David wird über diese Schnittstelle ein `xml` File zu grob 900 Physikern runterladen + * Das XML ist bereits runtergeladen und in der Slack-Gruppe verfügbar + +## Intents aufschreiben + + * Die Gruppe diskutiert über Intents + * Was meinen wir mit dem was wir dem Bot sagen? + * Was wollen wir von dem Bot als Antwort hören? + +### Ein paar Ideen zu Intents + + * Jonas erstellt eine Datei im repo, in der Intents gespeichert werden sollen + * In die Datei sollen die Gruppenmitglieder Beispiel-Intents reinschreiben + * Dabei soll sich an die [Vorlage von Rasa](https://rasa.com/docs/nlu/dataformat/) gehalten werden + + * Eltern + * Ausbildungsstelle + * Lehrstuhl + * Preise (Nobelpreis) bzw. Ehrungen + * Forschungsschwerpunkte + +### Die Gruppe sammelt gemeinsam Intents + + * die oben erwähnte Datei wird mit Intents am Beispiel `Albert Einstein` erstellt + +## Ausblick + +### Zu verteilende Aufgaben + + * Überprüfen, ob Rasa NLU die gesammelten Intents richtig erkennen kann + * evtl auch mit mehr Beispielnahmen als nur Albert Einstein (Lukas) + + * Anschauen, wie man das XML in R reinbekommt und Wissen extrahieren kann oder das Dokument strukturieren kann (David, Leonard) + * Ziel dabei: Wissensgrundlage erstellen + +### Nächstes Treffen + + * 26.11. ab 17:00 Uhr in der neunten Etage + + diff --git a/r/ExtractFromXML.R b/r/ExtractFromXML.R new file mode 100755 index 0000000000000000000000000000000000000000..5bf23a51d14703c15316410a7eaf704fc1bf5299 --- /dev/null +++ b/r/ExtractFromXML.R @@ -0,0 +1,20 @@ +#!/usr/bin/env Rscript + +library(xml2) + +data <- read_xml("../data/Wikipedia-20181120103842.xml") + +title.nodes <- xml_find_all(data, ".//title") + +titles <- sapply(title.nodes, xml_text) + +text.nodes <- xml_find_all(data, ".//text") + +texts <- sapply(text.nodes, xml_text) + +df.out <- data.frame(Title = titles, + Text = texts) + +saveRDS(df.out, "../data/texte.RDS") + +write.table(df.out, "../data/texte.csv") \ No newline at end of file diff --git a/r/Master.R b/r/Master.R new file mode 100644 index 0000000000000000000000000000000000000000..068ac043b6b44878260ef8907aa8fd9d14f9be50 --- /dev/null +++ b/r/Master.R @@ -0,0 +1,59 @@ +#!/usr/bin/env Rscript + + +### This script consolidates everything + +## Librarys + +#library(SomeLibrary) + +## Load Scripts + +cat("Sourcing R scripts... ") + +source("r/GetData.R") +#source("r/getBirthday.R") +#source("r/getSomethingElse.R") + +cat("Done.\n") + +## Fetch data + +cat("Starting data import...\n") + +articles <- getData(use.cache = TRUE) + +## Data processing + +cat("Processing data...\n") + +results <- lapply(articles, function(data) { + ## Data cleaning + + # cleaned.text <- someCleanFunctioN(data$Text) + + ## Data preprocessing/annotating + + # annotated.text <- annotationFunction(data$Text) + + ## Extract information from Text + + # someFact <- getFactFromTextFunctioN(annotated.text) + + # someOtherFact <- getOtherFactFromText(data$Text) + + ## Create Results + + # data.frame(Name = x$Name, + # FactOne = someFact, + # FactTwo = someOtherFact) + +}) + +results <- do.call(rbind, results) + +## Results are now in results + +## Format for rasa + +# someFormatFunction(results) diff --git a/r/PhysicistsList.R b/r/PhysicistsList.R index 474e56548e9a95812be25054144ceba51da099e9..bd776bcb99e28b4b4f7381cc9bd6fb24cc487a00 100644 --- a/r/PhysicistsList.R +++ b/r/PhysicistsList.R @@ -1,3 +1,5 @@ +#!/usr/bin/env Rscript + ### Extract list of pyhsicists from wikipedia article library(rvest) @@ -17,5 +19,5 @@ physicists <- physicists[nchar(physicists) > 5] length(physicists) <- length(physicists) - 3 # Done -write(physicists, "physicists.txt") +write(physicists, "../data/physicists.txt")