Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
be7a8999
Commit
be7a8999
authored
Jul 21, 2016
by
calberti
Committed by
GitHub
Jul 21, 2016
Browse files
SyntaxNet cleanups (#281)
Cleanup changes for syntaxnet.
parent
0a40f8d5
Changes
38
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
49 additions
and
49 deletions
+49
-49
syntaxnet/syntaxnet/populate_test_inputs.h
syntaxnet/syntaxnet/populate_test_inputs.h
+3
-3
syntaxnet/syntaxnet/proto_io.h
syntaxnet/syntaxnet/proto_io.h
+4
-4
syntaxnet/syntaxnet/reader_ops.cc
syntaxnet/syntaxnet/reader_ops.cc
+3
-3
syntaxnet/syntaxnet/registry.cc
syntaxnet/syntaxnet/registry.cc
+1
-1
syntaxnet/syntaxnet/registry.h
syntaxnet/syntaxnet/registry.h
+7
-7
syntaxnet/syntaxnet/sentence_batch.h
syntaxnet/syntaxnet/sentence_batch.h
+3
-3
syntaxnet/syntaxnet/sentence_features.h
syntaxnet/syntaxnet/sentence_features.h
+4
-4
syntaxnet/syntaxnet/sentence_features_test.cc
syntaxnet/syntaxnet/sentence_features_test.cc
+2
-2
syntaxnet/syntaxnet/shared_store.h
syntaxnet/syntaxnet/shared_store.h
+3
-3
syntaxnet/syntaxnet/shared_store_test.cc
syntaxnet/syntaxnet/shared_store_test.cc
+2
-2
syntaxnet/syntaxnet/tagger_transitions.cc
syntaxnet/syntaxnet/tagger_transitions.cc
+2
-2
syntaxnet/syntaxnet/tagger_transitions_test.cc
syntaxnet/syntaxnet/tagger_transitions_test.cc
+1
-1
syntaxnet/syntaxnet/task_context.h
syntaxnet/syntaxnet/task_context.h
+3
-3
syntaxnet/syntaxnet/term_frequency_map.h
syntaxnet/syntaxnet/term_frequency_map.h
+3
-3
syntaxnet/syntaxnet/text_formats.cc
syntaxnet/syntaxnet/text_formats.cc
+1
-1
syntaxnet/syntaxnet/unpack_sparse_features.cc
syntaxnet/syntaxnet/unpack_sparse_features.cc
+1
-1
syntaxnet/syntaxnet/utils.h
syntaxnet/syntaxnet/utils.h
+3
-3
syntaxnet/syntaxnet/workspace.h
syntaxnet/syntaxnet/workspace.h
+3
-3
No files found.
syntaxnet/syntaxnet/populate_test_inputs.h
View file @
be7a8999
...
...
@@ -58,8 +58,8 @@ limitations under the License.
//
// See also creators.Add() for more convenience functions.
#ifndef
$TARGETDIR
_POPULATE_TEST_INPUTS_H_
#define
$TARGETDIR
_POPULATE_TEST_INPUTS_H_
#ifndef
SYNTAXNET
_POPULATE_TEST_INPUTS_H_
#define
SYNTAXNET
_POPULATE_TEST_INPUTS_H_
#include <functional>
#include <string>
...
...
@@ -150,4 +150,4 @@ class PopulateTestInputs {
}
// namespace syntaxnet
#endif //
$TARGETDIR
_POPULATE_TEST_INPUTS_H_
#endif //
SYNTAXNET
_POPULATE_TEST_INPUTS_H_
syntaxnet/syntaxnet/proto_io.h
View file @
be7a8999
...
...
@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef
$TARGETDIR
_PROTO_IO_H_
#define
$TARGETDIR
_PROTO_IO_H_
#ifndef
SYNTAXNET
_PROTO_IO_H_
#define
SYNTAXNET
_PROTO_IO_H_
#include <iostream>
#include <memory>
...
...
@@ -194,7 +194,7 @@ class TextReader {
private:
string
filename_
;
int
sentence_count_
=
0
;
std
::
unique_ptr
<
tensorflow
::
RandomAccessFile
>
file_
;
std
::
unique_ptr
<
tensorflow
::
RandomAccessFile
>
file_
;
// must outlive buffer_
std
::
unique_ptr
<
tensorflow
::
io
::
InputBuffer
>
buffer_
;
std
::
unique_ptr
<
DocumentFormat
>
format_
;
};
...
...
@@ -241,4 +241,4 @@ class TextWriter {
}
// namespace syntaxnet
#endif //
$TARGETDIR
_PROTO_IO_H_
#endif //
SYNTAXNET
_PROTO_IO_H_
syntaxnet/syntaxnet/reader_ops.cc
View file @
be7a8999
...
...
@@ -15,17 +15,17 @@ limitations under the License.
#include <math.h>
#include <deque>
#include <unordered_map>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "syntaxnet/base.h"
#include "syntaxnet/feature_extractor.h"
#include "syntaxnet/parser_state.h"
#include "syntaxnet/parser_transitions.h"
#include "syntaxnet/sentence_batch.h"
#include "syntaxnet/sentence.pb.h"
#include "syntaxnet/sentence_batch.h"
#include "syntaxnet/shared_store.h"
#include "syntaxnet/sparse.pb.h"
#include "syntaxnet/task_context.h"
...
...
@@ -206,7 +206,7 @@ class ParsingReader : public OpKernel {
int
additional_output_index
()
const
{
return
feature_size_
+
1
;
}
ParserState
*
state
(
int
i
)
const
{
return
states_
[
i
].
get
();
}
const
ParserTransitionSystem
&
transition_system
()
const
{
return
*
transition_system_
.
get
()
;
return
*
transition_system_
;
}
// Parser task context.
...
...
syntaxnet/syntaxnet/registry.cc
View file @
be7a8999
...
...
@@ -18,7 +18,7 @@ limitations under the License.
namespace
syntaxnet
{
// Global list of all component registries.
RegistryMetadata
*
global_registry_list
=
NULL
;
RegistryMetadata
*
global_registry_list
=
nullptr
;
void
RegistryMetadata
::
Register
(
RegistryMetadata
*
registry
)
{
registry
->
set_link
(
global_registry_list
);
...
...
syntaxnet/syntaxnet/registry.h
View file @
be7a8999
...
...
@@ -50,8 +50,8 @@ limitations under the License.
// Function *f = Function::Lookup("cos");
// double result = f->Evaluate(arg);
#ifndef
$TARGETDIR
_REGISTRY_H_
#define
$TARGETDIR
_REGISTRY_H_
#ifndef
SYNTAXNET
_REGISTRY_H_
#define
SYNTAXNET
_REGISTRY_H_
#include <string.h>
#include <string>
...
...
@@ -70,7 +70,7 @@ class ComponentMetadata {
class_name_
(
class_name
),
file_
(
file
),
line_
(
line
),
link_
(
NULL
)
{}
link_
(
nullptr
)
{}
// Returns component name.
const
char
*
name
()
const
{
return
name_
;
}
...
...
@@ -131,7 +131,7 @@ struct ComponentRegistry {
:
ComponentMetadata
(
type
,
class_name
,
file
,
line
),
object_
(
object
)
{
// Register registry in master registry if this is the first registered
// component of this type.
if
(
registry
->
components
==
NULL
)
{
if
(
registry
->
components
==
nullptr
)
{
RegistryMetadata
::
Register
(
new
RegistryMetadata
(
registry
->
name
,
registry
->
class_name
,
registry
->
file
,
registry
->
line
,
...
...
@@ -160,8 +160,8 @@ struct ComponentRegistry {
// Finds registrar for named component in registry.
const
Registrar
*
GetComponent
(
const
char
*
type
)
const
{
Registrar
*
r
=
components
;
while
(
r
!=
NULL
&&
strcmp
(
type
,
r
->
type
())
!=
0
)
r
=
r
->
next
();
if
(
r
==
NULL
)
{
while
(
r
!=
nullptr
&&
strcmp
(
type
,
r
->
type
())
!=
0
)
r
=
r
->
next
();
if
(
r
==
nullptr
)
{
LOG
(
FATAL
)
<<
"Unknown "
<<
name
<<
" component: '"
<<
type
<<
"'."
;
}
return
r
;
...
...
@@ -240,4 +240,4 @@ class RegisterableInstance {
}
// namespace syntaxnet
#endif //
$TARGETDIR
_REGISTRY_H_
#endif //
SYNTAXNET
_REGISTRY_H_
syntaxnet/syntaxnet/sentence_batch.h
View file @
be7a8999
...
...
@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef
$TARGETDIR
_SENTENCE_BATCH_H_
#define
$TARGETDIR
_SENTENCE_BATCH_H_
#ifndef
SYNTAXNET
_SENTENCE_BATCH_H_
#define
SYNTAXNET
_SENTENCE_BATCH_H_
#include <memory>
#include <string>
...
...
@@ -75,4 +75,4 @@ class SentenceBatch {
}
// namespace syntaxnet
#endif //
$TARGETDIR
_SENTENCE_BATCH_H_
#endif //
SYNTAXNET
_SENTENCE_BATCH_H_
syntaxnet/syntaxnet/sentence_features.h
View file @
be7a8999
...
...
@@ -17,8 +17,8 @@ limitations under the License.
// in this header so they may be re-used via composition into other more
// advanced feature classes.
#ifndef
$TARGETDIR
_SENTENCE_FEATURES_H_
#define
$TARGETDIR
_SENTENCE_FEATURES_H_
#ifndef
SYNTAXNET
_SENTENCE_FEATURES_H_
#define
SYNTAXNET
_SENTENCE_FEATURES_H_
#include "syntaxnet/affix.h"
#include "syntaxnet/feature_extractor.h"
...
...
@@ -103,7 +103,7 @@ class TermFrequencyMapFeature : public TokenLookupFeature {
void
Init
(
TaskContext
*
context
)
override
;
// Number of unique values.
virtual
int64
NumValues
()
const
{
return
term_map_
->
Size
()
+
1
;
}
int64
NumValues
()
const
override
{
return
term_map_
->
Size
()
+
1
;
}
// Special value for strings not in the map.
FeatureValue
UnknownValue
()
const
{
return
term_map_
->
Size
();
}
...
...
@@ -314,4 +314,4 @@ typedef FeatureExtractor<Sentence, int> SentenceExtractor;
}
// namespace syntaxnet
#endif //
$TARGETDIR
_SENTENCE_FEATURES_H_
#endif //
SYNTAXNET
_SENTENCE_FEATURES_H_
syntaxnet/syntaxnet/sentence_features_test.cc
View file @
be7a8999
...
...
@@ -18,14 +18,14 @@ limitations under the License.
#include <string>
#include <vector>
#include <gmock/gmock.h>
#include "syntaxnet/utils.h"
#include "syntaxnet/feature_extractor.h"
#include "syntaxnet/populate_test_inputs.h"
#include "syntaxnet/sentence.pb.h"
#include "syntaxnet/task_context.h"
#include "syntaxnet/task_spec.pb.h"
#include "syntaxnet/utils.h"
#include "syntaxnet/workspace.h"
#include <gmock/gmock.h>
using
testing
::
UnorderedElementsAreArray
;
...
...
syntaxnet/syntaxnet/shared_store.h
View file @
be7a8999
...
...
@@ -15,8 +15,8 @@ limitations under the License.
// Utility for creating read-only objects once and sharing them across threads.
#ifndef
$TARGETDIR
_SHARED_STORE_H_
#define
$TARGETDIR
_SHARED_STORE_H_
#ifndef
SYNTAXNET
_SHARED_STORE_H_
#define
SYNTAXNET
_SHARED_STORE_H_
#include <functional>
#include <string>
...
...
@@ -231,4 +231,4 @@ class SharedStoreUtils {
}
// namespace syntaxnet
#endif //
$TARGETDIR
_SHARED_STORE_H_
#endif //
SYNTAXNET
_SHARED_STORE_H_
syntaxnet/syntaxnet/shared_store_test.cc
View file @
be7a8999
...
...
@@ -17,8 +17,8 @@ limitations under the License.
#include <string>
#include <gmock/gmock.h>
#include "syntaxnet/utils.h"
#include <gmock/gmock.h>
#include "tensorflow/core/lib/core/threadpool.h"
using
::
testing
::
_
;
...
...
@@ -98,7 +98,7 @@ class PointerSet {
class
SharedStoreTest
:
public
testing
::
Test
{
protected:
~
SharedStoreTest
()
{
~
SharedStoreTest
()
override
{
// Clear the shared store after each test, otherwise objects created
// in one test may interfere with other tests.
SharedStore
::
Clear
();
...
...
syntaxnet/syntaxnet/tagger_transitions.cc
View file @
be7a8999
...
...
@@ -53,7 +53,7 @@ class TaggerTransitionState : public ParserTransitionState {
}
// Reads gold tags for each token.
void
Init
(
ParserState
*
state
)
{
void
Init
(
ParserState
*
state
)
override
{
tag_
.
resize
(
state
->
sentence
().
token_size
(),
-
1
);
gold_tag_
.
resize
(
state
->
sentence
().
token_size
(),
-
1
);
for
(
int
pos
=
0
;
pos
<
state
->
sentence
().
token_size
();
++
pos
)
{
...
...
@@ -150,7 +150,7 @@ class TaggerTransitionSystem : public ParserTransitionSystem {
}
// Reads tag map and tag to category map.
void
Init
(
TaskContext
*
context
)
{
void
Init
(
TaskContext
*
context
)
override
{
const
string
tag_map_path
=
TaskContext
::
InputFile
(
*
input_tag_map_
);
tag_map_
=
SharedStoreUtils
::
GetWithDefaultName
<
TermFrequencyMap
>
(
tag_map_path
,
0
,
0
);
...
...
syntaxnet/syntaxnet/tagger_transitions_test.cc
View file @
be7a8999
...
...
@@ -16,7 +16,6 @@ limitations under the License.
#include <memory>
#include <string>
#include "syntaxnet/utils.h"
#include "syntaxnet/parser_state.h"
#include "syntaxnet/parser_transitions.h"
#include "syntaxnet/populate_test_inputs.h"
...
...
@@ -24,6 +23,7 @@ limitations under the License.
#include "syntaxnet/task_context.h"
#include "syntaxnet/task_spec.pb.h"
#include "syntaxnet/term_frequency_map.h"
#include "syntaxnet/utils.h"
#include "tensorflow/core/lib/core/status.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/test.h"
...
...
syntaxnet/syntaxnet/task_context.h
View file @
be7a8999
...
...
@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef
$TARGETDIR
_TASK_CONTEXT_H_
#define
$TARGETDIR
_TASK_CONTEXT_H_
#ifndef
SYNTAXNET
_TASK_CONTEXT_H_
#define
SYNTAXNET
_TASK_CONTEXT_H_
#include <string>
#include <vector>
...
...
@@ -77,4 +77,4 @@ class TaskContext {
}
// namespace syntaxnet
#endif //
$TARGETDIR
_TASK_CONTEXT_H_
#endif //
SYNTAXNET
_TASK_CONTEXT_H_
syntaxnet/syntaxnet/term_frequency_map.h
View file @
be7a8999
...
...
@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef
$TARGETDIR
_TERM_FREQUENCY_MAP_H_
#define
$TARGETDIR
_TERM_FREQUENCY_MAP_H_
#ifndef
SYNTAXNET
_TERM_FREQUENCY_MAP_H_
#define
SYNTAXNET
_TERM_FREQUENCY_MAP_H_
#include <stddef.h>
#include <memory>
...
...
@@ -114,4 +114,4 @@ class TagToCategoryMap {
}
// namespace syntaxnet
#endif //
$TARGETDIR
_TERM_FREQUENCY_MAP_H_
#endif //
SYNTAXNET
_TERM_FREQUENCY_MAP_H_
syntaxnet/syntaxnet/text_formats.cc
View file @
be7a8999
...
...
@@ -92,7 +92,7 @@ class CoNLLSyntaxFormat : public DocumentFormat {
// Split line into tab-separated fields.
fields
.
clear
();
fields
=
utils
::
Split
(
lines
[
i
],
'\t'
);
if
(
fields
.
size
()
==
0
)
continue
;
if
(
fields
.
empty
()
)
continue
;
// Skip comment lines.
if
(
fields
[
0
][
0
]
==
'#'
)
continue
;
...
...
syntaxnet/syntaxnet/unpack_sparse_features.cc
View file @
be7a8999
...
...
@@ -20,8 +20,8 @@ limitations under the License.
#include <utility>
#include <vector>
#include "syntaxnet/utils.h"
#include "syntaxnet/sparse.pb.h"
#include "syntaxnet/utils.h"
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/tensor.h"
...
...
syntaxnet/syntaxnet/utils.h
View file @
be7a8999
...
...
@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef
$TARGETDIR
_UTILS_H_
#define
$TARGETDIR
_UTILS_H_
#ifndef
SYNTAXNET
_UTILS_H_
#define
SYNTAXNET
_UTILS_H_
#include <functional>
#include <string>
...
...
@@ -168,4 +168,4 @@ void NormalizeDigits(string *form);
}
// namespace utils
}
// namespace syntaxnet
#endif //
$TARGETDIR
_UTILS_H_
#endif //
SYNTAXNET
_UTILS_H_
syntaxnet/syntaxnet/workspace.h
View file @
be7a8999
...
...
@@ -17,8 +17,8 @@ limitations under the License.
// specifically, the registry machinery is thread-safe, as long as each thread
// performs feature extraction on a different Sentence object.
#ifndef
$TARGETDIR
_WORKSPACE_H_
#define
$TARGETDIR
_WORKSPACE_H_
#ifndef
SYNTAXNET
_WORKSPACE_H_
#define
SYNTAXNET
_WORKSPACE_H_
#include <string>
#include <typeindex>
...
...
@@ -212,4 +212,4 @@ class VectorVectorIntWorkspace : public Workspace {
}
// namespace syntaxnet
#endif //
$TARGETDIR
_WORKSPACE_H_
#endif //
SYNTAXNET
_WORKSPACE_H_
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment