Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing error in reading yml vocabulary (descriptors) #2

Closed
wants to merge 2 commits into from

Conversation

hcjghr
Copy link

@hcjghr hcjghr commented Nov 3, 2016

Hi @rmsalinas

I noticed in the code that when you read the yml vocabulary file in DescManip::fromString you use the initial descriptor string (including "dbw3") to recover the type and number of elements in descriptor:

stringstream ss(s);
ss >>type>>cols;

This was the "dbw3" tag is still at the beginning of the descriptor string causing wrong assignment of both type and cols variables. A simple solution I did was to remove the initial part of the string (up to the space after the "dbw3" tag) and process the string as before.

If I overlooked something and this doesnt make sense I apologize :)

Klemen

@rmsalinas
Copy link
Owner

Hi, I do not get it. In the DescManip::fromString, you should go through line 170 in case of dbow3 and 180 else. Can you show me a yml file generating the problem you indicate?

@hcjghr
Copy link
Author

hcjghr commented Nov 3, 2016

Yes that part is true, but in line 181 you parse string that still contains the "dbw3" tag at the beginning so (line 182) ss >>type>>cols; is not successful as it assumes that the line starts directly with the type value.

I also attached an example where descriptor is type float and consists of 64 values. I couldnt attach .yml file so I zipped it.
vocabulary.yml.zip

An example:
std::string s = "dbw3 5 64 -0.00142846 -0.02756 0.0566433 0.114906 0.00011779 -0.0575029 0.0815183 0.189798 0.000543079 -0.0580601 0.0775293 0.188821 0.000751047 -0.0280006 0.0554974 0.111604 -0.013912 0.0345256 0.0911163 0.21553 -0.00830576 0.0672882 0.148553 0.384244 0.00822493 0.0679617 0.141701 0.388572 0.0122683 0.0356759 0.0921844 0.223511 0.00137967 0.0260256 0.0736804 0.126578 0.00771763 0.0539473 0.131055 0.211926 0.00168524 0.0577368 0.123819 0.212277 -0.00331527 0.0333572 0.0724055 0.132682 0.00167913 -0.00227244 0.044362 0.0608483 0.00520334 -0.00421484 0.0714293 0.0897383 0.00154904 -0.00463355 0.0688653 0.0875579 -0.00118802 -0.00236599 0.0406788 0.0564163"

As "dbw3" is found in line 169 in goes to line 180 . There the string s is parsed and type gets value 0 and cols -578578680 (as first word in the string is still "dbw3").

With my proposed change type = 5 and cols = 64.

Hope I explained it ok.

cheers

@animetrics
Copy link

This does look like an issue?

To avoid an additional find and copy, I would suggest just keeping line 181 as is and changing 182 to:

string format;
ss >>format>>type>>cols;

@rmsalinas rmsalinas closed this Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants