-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Martin Lööf
committed
Feb 7, 2014
1 parent
5a18195
commit 3c01d86
Showing
11 changed files
with
99,321 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Define the compiler and the linker. The linker must be defined since | ||
# the implicit rule for linking uses CC as the linker. g++ can be | ||
# changed to clang++. | ||
CXX = g++ | ||
CC = g++ | ||
|
||
# Define preprocessor, compiler, and linker flags. Uncomment the # lines | ||
# if you use clang++ and wish to use libc++ instead of GNU's libstdc++. | ||
# -g is for debugging. | ||
CPPFLAGS = -std=c++11 | ||
CXXFLAGS = -O2 -Wall -Wextra -pedantic-errors -Wold-style-cast | ||
CXXFLAGS += -std=c++11 | ||
CXXFLAGS += -g | ||
LDFLAGS = -g | ||
#CPPFLAGS += -stdlib=libc++ | ||
#CXXFLAGS += -stdlib=libc++ | ||
#LDFLAGS += -stdlib=libc++ | ||
|
||
# Targets | ||
PROGS = preprocessor | ||
|
||
all: $(PROGS) | ||
|
||
# Targets rely on implicit rules for compiling and linking | ||
preprocessor: preprocessor.o | ||
|
||
|
||
# Phony targets | ||
.PHONY: all clean | ||
|
||
# Standard clean | ||
clean: | ||
rm -f *.o $(PROGS) | ||
|
||
# Generate dependencies in *.d files | ||
%.d: %.cc | ||
@set -e; rm -f $@; \ | ||
$(CPP) -MM $(CPPFLAGS) $< > $@.$$$$; \ | ||
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ | ||
rm -f $@.$$$$ | ||
|
||
# Include the *.d files | ||
SRC = $(wildcard *.cc) | ||
include $(SRC:.cc=.d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <string> | ||
#include <vector> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <algorithm> | ||
#include "word.h" | ||
#include "dictionary.h" | ||
|
||
using namespace std; | ||
|
||
Dictionary::Dictionary() { | ||
} | ||
|
||
bool Dictionary::contains(const string& word) const { | ||
return true; | ||
} | ||
|
||
vector<string> Dictionary::get_suggestions(const string& word) const { | ||
vector<string> suggestions; | ||
return suggestions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dictionary.o dictionary.d : dictionary.cc word.h dictionary.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef DICTIONARY_H | ||
#define DICTIONARY_H | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
class Dictionary { | ||
public: | ||
Dictionary(); | ||
bool contains(const std::string& word) const; | ||
std::vector<std::string> get_suggestions(const std::string& word) const; | ||
private: | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
preprocessor.o preprocessor.d : preprocessor.cc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <algorithm> | ||
#include <vector> | ||
#include <cctype> | ||
#include "dictionary.h" | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
Dictionary dict; | ||
string word; | ||
while (cin >> word) { | ||
transform(word.begin(), word.end(), word.begin(), ::tolower); | ||
if (dict.contains(word)) { | ||
cout << "Correct." << endl; | ||
} else { | ||
vector<string> suggestions = dict.get_suggestions(word); | ||
if (suggestions.empty()) { | ||
cout << "Wrong, no suggestions." << endl; | ||
} else { | ||
cout << "Wrong. Suggestions:" << endl; | ||
for (const auto& w : suggestions) { | ||
cout << " " << w << endl; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
spell.o spell.d : spell.cc dictionary.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <string> | ||
#include <vector> | ||
#include "word.h" | ||
|
||
using namespace std; | ||
|
||
Word::Word(const string& w, const vector<string>& t) {} | ||
|
||
string Word::get_word() const { | ||
return string(); | ||
} | ||
|
||
unsigned int Word::get_matches(const vector<string>& t) const { | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
word.o word.d : word.cc word.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef WORD_H | ||
#define WORD_H | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
class Word { | ||
public: | ||
/* Creates a word w with the sorted trigrams t */ | ||
Word(const std::string& w, const std::vector<std::string>& t); | ||
|
||
/* Returns the word */ | ||
std::string get_word() const; | ||
|
||
/* Returns how many of the trigrams in t that are present | ||
in this word's trigram vector */ | ||
unsigned int get_matches(const std::vector<std::string>& t) const; | ||
private: | ||
}; | ||
|
||
#endif |
Oops, something went wrong.