Monday, January 9, 2017

why declare a pointer of type char instead of a variable in C++?

char *variable = "Some string here"; Is it declaring a pointer to type char instead of variable of type char, because the char datatype in C has a size of one byte, and more memory needs to be allocated than a char variable allows? The pointer is actually to an array of type char? http://stackoverflow.com/questions/4826481/c-char-vs-string

Sunday, January 8, 2017

Main function in C++ -- or at least what works

/* A C listing with something odd - */
/* using a square() function twice */
#include <stdio.h>
#include <stdlib.h>

int main (void) {
return 0;
}

I was studying OOP with polymorphism, inheritance, and encapsulation. For some reason I picked up a book on C with C++. It's fun comparing to my memory of Daniel Shiffman's OOP and PHP's OOP.

Also, this is what happens if you compile a C++ program as a C program.

gcc square.c -o square-c.o
square.c:25:6: error: conflicting types for ‘square’
void square( int topleftX, int topleftY, int bottomleftX, int bottomleftY)

^ square.c:7:6: note: previous definition of ‘square’ was here
void square( int topleftX, int topleftY, long width)

^ square.c: In function ‘main’:
square.c:54:4: error: too few arguments to function ‘square’
square( pt_x3, pt_y3, side);

^ square.c:25:6: note: declared here
void square( int topleftX, int topleftY, int bottomleftX, int bottomleftY)


^ With polymorphism in C++ I can have multiple declarations of a function and the program figures out which one to use. Whereas with C, I cannot. This example illustrates function or method overloading.
See: https://en.wikipedia.org/wiki/Function_overloading

Saturday, January 7, 2017

Discovery compiling a C++ program from a 2003 book

In listing B3.1 on page 666 of "Sam's Teaching Yourself C in 24 hours", Change

#include <iostream.h> to #include <iostream>

Add the line

using namespace std;

See: http://stackoverflow.com/questions/13103108/why-cant-g-find-iostream-h

compile using

g++ endtime.cpp -o endtime.o

or

g++ endtime.cpp

Using gcc instead of g++ you have: endtime.cpp: In function ‘int main(int, char**)’: endtime.cpp:24:3: error: expected ‘;’ before ‘end_time’ end_time.minutes = 11; ^ endtime.cpp: In function ‘void print_time(time)’: endtime.cpp:39:48: error: expected ‘;’ before ‘tm’ cout << tm.hours << ":" << tm.minutes << ":" tm.seconds; See: http://stackoverflow.com/questions/28236870/undefined-reference-to-stdcout

This post also took advantage of escape sequences for the less than and greater than symbols. http://www.theukwebdesigncompany.com/articles/entity-escape-characters.php

Semantic Web Courses / Resources

Indiana.edu Semantic  Course:

http://info.slis.indiana.edu/~dingying/Z636Fall2014.html

University of Edinbergh Semantic Web Systems book

https://www.inf.ed.ac.uk/teaching/courses/sws/

University of Georgia Semantic Web Course

http://lsdis.cs.uga.edu/SemWebCourse_files/SemWebCourse.htm

FAU Semantic Web Course

http://semanticweb.fau.edu/

Lehigh University Semantic Web Course

http://www.cse.lehigh.edu/~heflin/courses/sw-2013/

UNB Semantic Web Techniques Course

https://www.cs.unb.ca/~boley/cs6795swt/syllabus.html

Université Jean-Monnet Semantic Web Course

http://www.emse.fr/~zimmermann/Teaching/SemWeb/

Linked Data Tools.com Semantic Web Basics

http://www.linkeddatatools.com/semantic-web-basics

University of Mannheim Semantic Web Technologies Course

http://dws.informatik.uni-mannheim.de/en/teaching/courses-for-master-candidates/cs660semanticwebtechnologies/

Finland Semantic Web and Ontology Engineering Course

http://www.cs.jyu.fi/ai/vagan/itks544.html

TDT-44 Semantic Web Course

https://www.ntnu.no/wiki/display/idiemner/TDT-44+Semantic+Web

University of Rome -Knowledge Representation and Semantic Technologies

http://www.dis.uniroma1.it/~rosati/krst/

University of Koblenz Semantic Web Course

https://west.uni-koblenz.de/en/studium/lehrveranstaltungen/ss14/semantic-web/semantic-web

Euclid Project
http://euclid-project.eu/
Dr. Harald Sack, Linked Data Engineering - OpenHPI
https://open.hpi.de/courses/semanticweb2016
Linked Data Book - Tom Heath, Christian Bizer
http://linkeddatabook.com/editions/1.0/
What is Linked Data? - Manu Sporny
https://www.youtube.com/watch?v=4x_xzT5eF5Q&t=108s

Friday, January 6, 2017

Understanding Python

I wanted to understand how to build a search engine. Daniel Shiffman implements his TFIDF index in JavaScript. Arden Dertat implements his search engine with TFIDF in Python.

I want to implement everything in JavaScript. To use Arden's code, it might be useful to learn Python. I found "How to Learn Python in Five Minutes - Daniel Moniz" on YouTube. (https://www.youtube.com/watch?v=ohr6O78jGzs) .

His code gives me the idea to try to implement the waypaver scraping script in python https://github.com/bshambaugh/waypaver-lsi/blob/master/scraper-four.php . I don't need it in Python, but such an exercise would teach me a bit about python in addition to making refactoring the PHP script to a more OOP scheme more interesting. Python is all about objects. Everything in Python is an object. If I wanted to go further, he mentioned coderbyte (https://coderbyte.com/) which offers some challenges as well as asking and answering questions on stackoverflow.

Resolving the programmers page at python.org (https://wiki.python.org/moin/BeginnersGuide/Programmers) leads me to a resource at (http://www.afterhoursprogramming.com/tutorial/Python/Overview/).  I even found a tutorial about a web crawler if I want it (https://code.tutsplus.com/courses/crawl-the-web-with-python).

Looking at my scraper tells me I need to retrieve web pages. The Requests gives me some idea: http://docs.python-requests.org/en/master/ . If I believe the good words about it, it may be a good idea.

Doing this would also lead me to understand the code in SWAP (if I care to understand it). http://www.w3.org/2000/10/swap.doc




Throwing Clay at a Wall

Above is page 18 of "Semantically Enhanced Information Retrieval: An Ontology- Based Approach" by Miriam F. Sanchez. (tangent: she worked with Enrico Motta: http://people.kmi.open.ac.uk/motta/)

I'm trying to figure out how to do a natural language query (nlq) that uses the hierarchical and relational structure found in an ontology to return documents that are semantically related to the query, nlq triples which are instances of the ontologies used, and a graph of these instances in addition to related triples by SPARQL that use the subject or object of the nlq triples as the subject. Below is a query result of results from the query "Car Projects with Brent Shambaugh".

I seem to recall that this thesis uses a document index, an ontology index, and an annotation index (between terms that are instances of ontologies in the documents and the ontologies). So I guess you could say this document contains these terms that are described by these ontologies.

What I really want most is something like: this query contains terms that are described by these ontologies, and the terms are described by these triples.

I think I might be able to back this out of the query in this Sanchez's work, even though its aim was to get documents.

At the moment, I know typical search uses TFIDF. I know this from taking a Big Data (or at least starting) course in 2013. I also found a book called Mining Massive DataSets that contains a lot of the information from the course (http://infolab.stanford.edu/~ullman/mmds/book.pdf).  Understanding it makes sense. Up to this point, I've struggled implementing it, resorting to things like Lucene and Solr coupled with Stanbol for nlp (this works for tagging). Fortunately, within the past few weeks I discovered Daniel Shiffman's coding rainbow videos. He explains how to do TFIDF (Coding Challenge $40.3: TF-IDF) https://www.youtube.com/watch?v=RPMYV-eb6lI .

I explored how to implement a search engine and I came across some blog posts by Arden Dertat :

How to Implement a Search Engine Part 1: Create Index
How to Implement a Search Engine Part 2: Query Index
How to Implement a Search Engine Part 3: Ranking tf-idf
He gives some links to his code.

Mr. Dertat also references a book on Information Retrieval: (http://nlp.stanford.edu/IR-book/information-retrieval-book.html)


Monday, January 2, 2017

Latest Photogate Pictures



Calibrated by dropping an object, and comparing to calculations from the kinematic equation. The distance between the two sensors is 1.13 m.