Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ASR-lab-ws20
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonathan Moritz Kunstwald
ASR-lab-ws20
Commits
03ee379e
Unverified
Commit
03ee379e
authored
4 years ago
by
Jonathan Kunstwald
Browse files
Options
Downloads
Patches
Plain Diff
Fix modify-during-iteration bug
parent
452416cf
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.cc
+15
-3
15 additions, 3 deletions
src/main.cc
with
15 additions
and
3 deletions
src/main.cc
+
15
−
3
View file @
03ee379e
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
#define ASR_COUNTOF(_arr_) (sizeof(_arr_) / sizeof(_arr_[0]))
#define ASR_COUNTOF(_arr_) (sizeof(_arr_) / sizeof(_arr_[0]))
#define ASR_USE_SMALL_FILE
1
#define ASR_USE_SMALL_FILE
0
#define ASR_SKIP_SLOW_NAIVE_TASK3 1
#define ASR_SKIP_SLOW_NAIVE_TASK3 1
...
@@ -247,14 +247,26 @@ struct ngram_statistics
...
@@ -247,14 +247,26 @@ struct ngram_statistics
// zero occurence prefixed n-grams are a little more involved
// zero occurence prefixed n-grams are a little more involved
// amount of v-prefixed n-grams theoretically existing (for a given v)
// amount of v-prefixed n-grams theoretically existing (for a given v)
this
->
max_num_prefixed_ngrams
=
std
::
pow
(
vocab_size
,
n
-
1
);
this
->
max_num_prefixed_ngrams
=
std
::
pow
(
vocab_size
,
n
-
1
);
// two loops- just to not modify the map while iterating over it
// this could be theoretically avoided by over-reserving the underlying vector but this is a little cleaner
for
(
auto
const
&
cc_prefix_node
:
prefixed_count_counts
.
_nodes
)
{
prefixed_count_key
key
;
key
.
prefix_v_hash
=
cc_prefix_node
.
key
.
prefix_v_hash
;
key
.
occurence
=
0
;
// just hit the value once, default to max_num_prefixed_ngrams
(
void
)
prefixed_count_counts
.
get_value
(
key
,
max_num_prefixed_ngrams
);
}
for
(
auto
const
&
cc_prefix_node
:
prefixed_count_counts
.
_nodes
)
for
(
auto
const
&
cc_prefix_node
:
prefixed_count_counts
.
_nodes
)
{
{
prefixed_count_key
key
;
prefixed_count_key
key
;
key
.
prefix_v_hash
=
cc_prefix_node
.
key
.
prefix_v_hash
;
key
.
prefix_v_hash
=
cc_prefix_node
.
key
.
prefix_v_hash
;
key
.
occurence
=
0
;
key
.
occurence
=
0
;
// the trick here is to provide the theoretical maximum as a default, instead of 0
// subtract the amount of v-prefixed n-grams that have some (nonzero) occurence from the theoretical max
// subtract the amount of v-prefixed n-grams that have some (nonzero) occurence from the theoretical max
prefixed_count_counts
.
get_value
(
key
,
max_num_prefixed_ngrams
)
-=
cc_prefix_node
.
val
;
prefixed_count_counts
.
get_value
_no_miss
(
key
)
-=
cc_prefix_node
.
val
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment