Skip to content

Remove unneeded entries from datacheckfps.csv #59

Open

Description

@jteresco

Since VISIBLE_DISTANCE errors are no longer flagged for active routes, we have a lot of unmatched fps in unmatchedfps.log. It would be good to automate a one-time cleanup of the fp list.

Activity

  1. self-assigned this
    on Aug 8, 2017
  2. yakra commented on Oct 13, 2017

    @yakra
    Contributor
  3. yakra commented on Oct 13, 2017

    @yakra
    Contributor

    I only removed VISIBLE_DISTANCE entries, and not all unmatchedfps.

  4. yakra commented on Oct 14, 2017

    @yakra
    Contributor

    That was, in the strictest sense, a "a one-time cleanup". :)
    I can easily do that again, and it may be worthwhile...

    There are now only 49 (make that 48, actually...) unmatchedfps, for a much better signal-to-noise ratio.
    Three of these are nearmatchfps, and may be helpful for contributors correcting those. The rest, I suppose it may be better to leave to the authors of the respective regions to deal with as appropriate.
    So, I erred on the side of caution and didn't cull these along with the VISIBLE_DISTANCE unmatchedfps.

    More to the point, though, there are still 3139 VISIBLE_DISTANCE FPs marked in preview and devel systems, which may slowly filter into unmatchedfps.log as more systems go live (unless the author gets rid of them when activating the systems).

    TL;DR, future cleanups may still be necessary. I guess I'll leave it to @jteresco whether to close or leave this issue open.

  5. jteresco commented on Oct 14, 2017

    @jteresco
    ContributorAuthor

    I'll leave it open, since I think something more automated is a worthy future goal.

  6. michihdeu commented on Oct 14, 2017

    @michihdeu
    Contributor

    More to the point, though, there are still 3139 VISIBLE_DISTANCE FPs marked in preview and devel systems

    Out of more than 5,000 FPs in total...

    👍

  7. yakra commented on Oct 15, 2017

    @yakra
    Contributor

    How's this? :D

    using namespace std;
    #include <fstream>
    #include <iostream>
    
    class entry
    {	public:
    	string text;
    	bool cull;
    	entry *prev, *next;
    
    	// init alpha
    	entry() {prev = 0; next = 0; cull = 0;}
    	// insertions
    	entry(entry *cursor) // cursor, in this case, is a pointer to the prev entry
    	{	prev = cursor;
    		next = 0;
    		cull = 0;
    	}
    };
    
    bool find(string needle, entry *haystack)
    {	while (haystack)
    	{	if (needle == haystack->text) return 1;
    		haystack = haystack->next;
    	}
    	return 0;
    }
    
    int main(int argc, char *argv[])
    {	entry *cList = new entry;
    	entry *fList = new entry;
    	entry *cursor;
    	if (argc != 4) { cout << "usage: ./fpcull CullFile FullFile OutputFile\n"; return 0; }
    	// init ifstreams
    	ifstream cFile(argv[1], ios::in);
    	if (!cFile.is_open())	{ cout << argv[1] << " file not found!" << endl; return 0; }
    	ifstream fFile(argv[2], ios::in);
    	if (!fFile.is_open())	{ cout << argv[2] << " file not found!" << endl; return 0; }
    
    	// create cull list
    	cFile >> cList->text; //TODO: enclose in an IF in case hell breaks loose (IE, no text in cFile) //FIXME: see below
    	cursor = new entry(cList);
    	while (cFile >> cursor->text) //FIXME: This expects every line to be one text string and every text string to be one line. This will not always be the case.
    	// For example, see line 6613 of https://github.com/TravelMapping/HighwayData/blob/d33d0f6e93eec8ce7f71f31af94336a473161e5f/datacheckfps.csv
    	{	cursor->prev->next = cursor;
    		cursor = new entry(cursor);
    	}
    	delete cursor;
    
    	// create full list
    	fFile >> fList->text; //TODO: enclose in an IF in case hell breaks loose (IE, no text in fFile) //FIXME: see below
    	cursor = new entry(fList);
    	while (fFile >> cursor->text) //FIXME: This expects every line to be one text string and every text string to be one line. This will not always be the case.
    	// For example, see line 6613 of https://github.com/TravelMapping/HighwayData/blob/d33d0f6e93eec8ce7f71f31af94336a473161e5f/datacheckfps.csv
    	{	cursor->prev->next = cursor;
    		cursor = new entry(cursor);
    	}
    	delete cursor;
    
    	// flag unmatchedfps as to-be-culled
    	for (cursor = fList; cursor; cursor = cursor->next)
    		if (find(cursor->text, cList)) cursor->cull = 1;
    
    	// output
    	ofstream oFile(argv[3]);
    	cursor = fList;
    	while (cursor)
    	{	if (!cursor->cull) oFile << cursor->text << endl;
    		cursor = cursor->next;
    	}
    }

    It's not perfect; it choked on the line that Si removed from line 6613 of this commit (because it expects every line to be one text string and every text string to be one line), but it does a pretty bang-up job. Just requires a little manual checking.

  8. jteresco commented on Oct 15, 2017

    @jteresco
    ContributorAuthor

    Looks better than the nonexistent one we had before! Could you put in a pull request adding this to a directory like "CullDatacheckFPs" in this repository?

  9. yakra commented on Oct 16, 2017

    @yakra
    Contributor

    Could you put in a pull request adding this to a directory like "CullDatacheckFPs" in this repository?

    #66

  10. self-assigned this
    on Nov 6, 2018
  11. yakra commented on Nov 6, 2018

    @yakra
    Contributor

    It choked on [a malformed line] (because it expects every line to be one text string and every text string to be one line)

    (Lines containing whitespace would have been split into multiple lines, instead of being left alone.)

    Fixed in #124 -- and basically rewritten altogether. That earlier version was a bit of an embarrassment.

  12. yakra commented on Nov 23, 2019

    @yakra
    Contributor

    shell script to produce a list of VISIBLE_DISTANCE entries in active systems (replace the file & directory paths in the first 2 lines with what's appropriate on your system):

    unmatchedlog="/home/yakra/TravelMapping/yakra/DataProcessing/siteupdate/cplusplus/logs/unmatchedfps.log"
    repo="/home/yakra/TravelMapping/yakra/HighwayData"
    
    CSVs=`ls $repo/hwy_data/_systems/*.csv | grep -v '_con\.csv$'`
    
    entries=`cat $unmatchedlog | grep VISIBLE_DISTANCE 2>&1`
    for entry in $entries; do
        root=`echo $entry | cut -f1 -d';'`
        hs=`egrep "^.+;.+;.+;.*;.*;.*;$root;.*$" $CSVs | cut -f1 -d. | sed 's~.*/\(.*\)~\1~'`
        if [ `echo $hs | wc -w` -gt 0 ]; then
            level=`grep -v '^#' $repo/systems.csv | grep "^$hs;" | cut -f6 -d';' 2>&1`
            if [ `echo $level | wc -w` = '1' ]; then
                if [ $level = active ]; then
                    echo $entry
                fi
            fi
        fi
    done

    You can even have its output masquerade as a file; and use it as an argument to fpcull:

    /home/yakra/TravelMapping/yakra/DataProcessing/fpcull/fpcull <(./ActiveSysVisDist.sh) /home/yakra/TravelMapping/yakra/HighwayData/datacheckfps.csv /home/yakra/TravelMapping/yakra/HighwayData/datacheckfps.csv

    ...shown here as if it were saved as a .sh file, for brevity and ease of understanding.


    ...Or, more verbosely:

    /home/yakra/TravelMapping/yakra/DataProcessing/fpcull/fpcull <(unmatchedlog="/home/yakra/TravelMapping/yakra/DataProcessing/siteupdate/cplusplus/logs/unmatchedfps.log" repo="/home/yakra/TravelMapping/yakra/HighwayData" CSVs=`ls $repo/hwy_data/_systems/*.csv | grep -v '_con\.csv$'` entries=`cat $unmatchedlog | grep VISIBLE_DISTANCE 2>&1` for entry in $entries; do root=`echo $entry | cut -f1 -d';'` hs=`egrep "^.+;.+;.+;.*;.*;.*;$root;.*$" $CSVs | cut -f1 -d. | sed 's~.*/\(.*\)~\1~'` if [ `echo $hs | wc -w` -gt 0 ]; then level=`grep -v '^#' $repo/systems.csv | grep "^$hs;" | cut -f6 -d';' 2>&1` if [ `echo $level | wc -w` = '1' ]; then if [ $level = active ]; then echo $entry fi fi fi done) /home/yakra/TravelMapping/yakra/HighwayData/datacheckfps.csv /home/yakra/TravelMapping/yakra/HighwayData/datacheckfps.csv

    You don't even need to save it as a file.

  13. added a commit that references this issue on Nov 23, 2019
  14. jteresco commented on Dec 31, 2022

    @jteresco
    ContributorAuthor

    Still anything in this issue we might want to pursue further?

  15. michihdeu commented on Dec 31, 2022

    @michihdeu
    Contributor

    Still anything in this issue we might want to pursue further?

    Yep, the initial issue still exists:

    we have a lot of unmatched fps in unmatchedfps.log. It would be good to automate a one-time cleanup of the fp list.

    We have 328 unmatched FPs right now: https://travelmapping.net/logs/unmatchedfps.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions