C :: Textual Analysis - Pattern Matching
Feb 11, 2014
I am looking to write a program that, given a particular word, looks at a plain text document and gives a list of words that appear within x words of the given word along with a count of how many times it appears.
Do I need to use regex to do the pattern matching here? Is there a particular data structure that I should use that is particularly suited to a task like this? I don't want to reinvent the wheel, it seems like there should be libraries that would already do this sort of thing but searches have turned up nothing.
View 5 Replies
ADVERTISEMENT
Mar 25, 2015
#include <iostream>
#include <vector>
#include <list>
[Code].....
The problem is it's not finding the shortest path.
View 1 Replies
View Related
Mar 25, 2015
Undirected graph G = {V, E} is given by the list next to the DS. Let u, v of V. Construction of two paths algorithm A1 (u, v) and A2 (u, v) such that no edge in common and have the shortest total length.
View 1 Replies
View Related
Oct 30, 2013
I have the problem of trying to find the smallest natural number that makes two consecutive terms in single precision floating point notation in the riemann zeta function equal. So basically the riemann function of 2 is given by:
sum of 1/(k^2) from k=1 until infinity, so : 1/(1^2) + 1/(2^2) + 1/(3^2) + ...... until infinity.
Now the question asks to stop at the smallest natural number n, at which the sum 1/1^2 + 1/2^2 + ......+ 1/(n^2) is equal to the sum 1/1^2 + 1/2^2 + ..... + 1/((n+1)^2) in single precision floating point notation.
Now well the obvious way to look for n would be on this way:
float i = 1.0;
float n = 1/(i);
float n1 = 1/(i+1.0);
while ( n != n1){
i += 1.0;
n = 1/i;
n1 = 1/(i+1.0);}
But first of all this is obviously completely inefficient and I dont think it will yield a valid answer for any float variable, i.e. I dont think the sum until 1/n^2 and 1/(n+1)^2 will ever differ. I tried it out with the largest possible value of a variable of type float and the values were still seen as unequal in C++. How to do this? Will C++ find a value for n for which the condition holds? Is the compiler or my hardware important for this, i.e. would I get different results on a different pc?
View 2 Replies
View Related
Mar 4, 2013
I have a text file which consists of 907 objects and 1000 feature vector for each object. Is there any Library (Eigen/Boost) to calculate Principle Component Analysis(PCA)?
View 1 Replies
View Related
Feb 16, 2014
I am working on my second c++ project that is a statistical analysis of a vector data set of integers. I created a struct called range with a maximum value, minimum value and count for occurrence. The frequencies are stored in a vector<range>.
I have tried messing around with the increment to get the high range test above the maximum element, though my ranges cumulatively increase by 9.9. I'm not sure how the professor's program has the distance between high and low ranges as 10 instead of 9.9, which is the increment. I'm also unsure why half way through his buckets, the ranges appear as 9.99 briefly and then return to 10 after (40.00 - 49.99 then 49.99 - 59.99). I feel like I am missing something very obvious on line 04 or 10 in my code.
Here is the code for the frequency that accepts a vector reference for my data set of integers.
void frequency(vector<int>& data_set){
double max = findMax(data_set);
double min = findMin(data_set);
double increment = (max - min) / 10;
double percentage = 0.0;
[Code] ....
View 1 Replies
View Related
Aug 25, 2014
I have this code which performs the analysis part of discrete wavelet transform. It works pretty well. However, I wish to reduce the time that it consumes even further. I did use reserve() and it worked upto few msec.
int rows = signal.size();
int cols = signal[0].size();
int cols_lp1 =(int) ceil( (double) cols / 2);
vector<vector<double> > lp_dn1(rows, vector<double>(cols_lp1));
vector<double> temp_row;
temp_row.reserve(512);
[Code] ....
View 5 Replies
View Related
Feb 11, 2013
Here is my first program, I had to use a lot of if/ else statements. For some reason the last "else" (bolded) is giving me an error and not letting me run the program.
#include <iostream>
using namespace std;
const float MILES_PER_KM = 1.0 / 1.61;
const float KM_PER_MILE = 1.61;
const float FREEZING_F = 32.0;
const float FAHR_PER_CELSIUS = 9.0 / 5.0;
const float CELSIUS_PER_FAHR = 5.0 / 9.0;
const float MAX_F_TEMP = 100.0;
const float MIN_F_TEMP = 0.0;
[Code] ....
And yes, the if else's are indented properly, because there are no errors for the first 3 unit types, only for the last one ( 'F' ), and i have them all exactly in the same format.
View 5 Replies
View Related
Mar 5, 2013
This is the error I keep getting, but I'm not sure how to resolve it.
assignment7.cpp:11: error: no matching function for call to 'Time::display() '
Time.h:18: note: candidates are: void Time::display(int, int)
Code:
#include "Time.h"
int main() {
Time tm;
tm.set(12,53);
dt.display(); //Should display 7/4/1776
[Code] .....
View 2 Replies
View Related
Mar 27, 2014
When the number is guessed correctly the program doesn't print "You guessed right" ....
Code:
#include"stdafx.h"
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<string>
usingnamespace std;
[Code] ....
View 4 Replies
View Related
Sep 28, 2013
I have this error.
Code:
int isOperand(char a) {
if(a<='9'&&a>='0')
return 1;
else
return 0;
}
Code:
Error C2143: syntax error : missing ';' before 'type'
Error C2181: illegal else without matching if this error was pointing on that func.
This is from my postfix evaluation using stack.
View 4 Replies
View Related
Jun 1, 2013
no matching function for call to `getline(std::string&, char&)' Why is this error occuring?
My Aim is to copy each character or integer to an array
MY PROGRAM:-
#include <fstream>
#include <iostream>
#include<conio.h>
#include<string.h>
[Code].....
View 2 Replies
View Related
Sep 6, 2013
The random method in here should return a random value inside given array.
The program constantly crashes when I send the array object as full.
It will only allow for you to choose the first 4 objects in the array, if you choose object number 8, for example, the program crashes.
So Im trying to send the pointer to the array instead. But now the compiler claims not to know of any such function.
static string getRandom(string* avalible[]){
cout << "Get random";
cout << "index: " << (*avalible)->length() << endl;
int index = random((*avalible)->length()-1);
cout << "returned" + index;
[Code] .....
I can remove the "10" from the string first[10] but it doesn't make a difference.What is wrong with this?
View 2 Replies
View Related
Dec 7, 2014
In this project a user needs to enter a numeric month and a year. The output is a single calendar month with the name of the month followed by a grid of the days. My issue is that my day alignment is off. for example: if you enter the month of December (12) and this year 2014 it says the month started on a Wednesady when in fact it started on a Monday. I am not sure if its my leap year calculaion or what.
#include<iostream>
using namespace std;
#define TRUE 1
#define FALSE 0
char *months[] = {
" ",
[Code] ....
View 6 Replies
View Related
Dec 11, 2014
I need to call one function on my C++ program. I made one root calculator for functions, but, this doesn't work.
// FUNCION QUE CALCULA LA DIFERENCIA ENTRE 2 VECTORES
real mn_error_vectores(Array1D< real > &u, Array1D< real > &v) {
int i;
if(u.dim()!=v.dim()){
printf("mn_error_vectores() : arrays of different dimensions
[Code] ....
View 4 Replies
View Related
Nov 4, 2014
I'm having this pain in the ass error (No matching function for call to Data::Data() ) on this block of code:
Etapa::Etapa(string nm, float dist, string loc, Data dt) {
nome = nm;
distancia = dist;
local = loc;
data = dt;
}
[Code].....
I guess this is happening because I'm trying to give Etapa an argument of Data type and I can't do it or put it in a variable since it has 3 parameteres (mes, dia, ano).
View 2 Replies
View Related
Sep 10, 2013
I'm making a number guessing game program and I keep getting the error: C2181: illegal else without matching if.
View 5 Replies
View Related
Jul 3, 2013
I have a problem with the parameters of two of my functions:
typedef List<int> Dlist;
template<class T>
Dlist concat(Dlist L1, Dlist L2) {
Dlist L;
elem<T> *temp1, *temp2;
temp1 = L1.Start_ptr;
temp2 = L1.Start_ptr;
[Code] ....
Here are the errors:
no matches converting function `concat' to type `class Dlist (*)(class List<int>, class List<int>)'
error candidates are: template<class T> Dlist concat(Dlist, Dlist)
no matching function for call to `concat(Dlist&, Dlist&)'
I can't understand what the compiler is trying to tell me.
View 4 Replies
View Related
Nov 18, 2014
I am trying to create a `std::map` from `std:: string` to a pointer to member function type. I'm initializing the `map` with an initializer list (braced). When I compile, I get a message from the compiler: No matching constructor for initialization.
Example: [URL] .....
View 4 Replies
View Related
Oct 7, 2013
This is my code for the quadratic equation. It keeps telling me that my else is illegal since no matching if statement and my else statement is missing a statement
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;
int main() {
string Name;
[Code] .....
View 3 Replies
View Related
Dec 14, 2013
This code from [URL] as it is gives compile error I can't understand.
#include <iostream>
using namespace std;
class Rectangle {
int width, height;
[Code] ....
Gives error
(g++ first.cpp)
first.cpp: In function ‘int main()’:
first.cpp:14:38: error: no matching function for call to ‘Rectangle::Rectangle(<brace-enclosed initialiser list>)’
View 3 Replies
View Related
Apr 1, 2015
I have developed the following code for a PIC18 micro-controller. The object of the program is to compare a input value (presumably from a magnetic swipe card), represented here as scan_id, to a list of valid access ID's represented by the array valid_id. If there is a match the program will drive an output pin high to light a green LED for 20 seconds. If there is not a match the program will drive an output pin high to light a red led for 20 seconds.
The issue that I am having is that when the program is executed, the "else" case for the red LED is always selected regardless of the value for scan_id. If I change the "if" statement from == to = then the case for the green LED is always selected regardless of the value for scan_id.
#include <p18f452.h>
#include <stdlib.h>
#include <stdio.h>
#include <delays.h>
void main () {
TRISA=0xFF; /* Configure PORTA<7:0> pins as inputs */
TRISB=0x00; /*Configure PORTD<7:0> pins as outputs */
[Code] ....
View 10 Replies
View Related
Jul 4, 2014
I've been working on this code that should be looking like
1 3 5 3 1
3 5 7 5 3
5 7 9 7 5
3 5 7 5 3
1 3 5 3 1
but mine appears like this
1 3 5 3 1
3 5 7 5 3
5 7 9 7 5
3 3 5 7 9
1 3 1 3 5
This is the code I've got for now, I just don't know which logic I need to fix
int main(){
int r;
cout << "Rows?" << endl;
cin >> r;
for (int i = 1; i <= r; i+=2){
for (int j = i; j <= r+i; j+=2){
cout << j<< " ";
} for (int k = i+2; k >= i-1; k-=2){
[code]....
View 2 Replies
View Related
Sep 26, 2014
We are generating emails for freshman students, however, the system probably due to server overload fails to generate some emails. So I'm working on this c code( probably was a wrong choice) to search for regexp matching the generated emails and deleting from the list of students and propective emails.
I"m currently at the stage of making sure the code can find all the matching regexp from the student list file before deleting! But the code fails to read all matching regexp?
Code:
//Filename: SearchReplace.c
//Usage: This searches for lines in a file containing a particular work and deletes the lines.
//Licence: GNU P.L.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
[code] .....
What I'm missing. It recognizes some regexp and fails to recognise some. Been staring for hours!
View 4 Replies
View Related
Aug 8, 2014
#include <iostream>
#include <string>
std::ostream& operator<<(std::ostream& os, const std::string& str) {
os << '[';
[Code].....
In the above program, I define an operator<< function in global namespace which has exactly the same signature as the one define in <string> header : [URL] . In the main function, I call operator<< on cout and a string, after which I guess it would cause ambiguity. The result is out of my anticipation, it compiles and prints [hi]. So I guess my function is a better match because it does not require argument-dependent lookup (ADL). Moreover, even if I add using namespace std; at the beginning of the main function, the program still compiles and prints [hi].
In short, I have two question:
#1 : Why is my function a better match (therefore no ambiguity) in the two cases respectively (with and without using namespace std;)?
#2 : Does using namespace affect ADL? Is ADL still performed after applying using namespace, or is it not performed because the function is thrown into global namespace?
View 3 Replies
View Related
Apr 10, 2014
I am creating a matching game, using US States and a 2-dim array.
As you can see, when the below code runs, some of the grid tiles appear offset, and when selected by pressing spacebar, do not appear.
Here is the .h file:
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
[Code]....
View 3 Replies
View Related