Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Rearrange parser training modules (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringgaard authored Nov 18, 2019
1 parent 93541e9 commit 75452a3
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 107 deletions.
35 changes: 33 additions & 2 deletions sling/nlp/parser/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,43 @@ cc_library(
alwayslink = 1,
)

cc_library(
name = "frame-evaluation",
hdrs = ["frame-evaluation.h"],
srcs = ["frame-evaluation.cc"],
deps = [
"//sling/base",
"//sling/file",
"//sling/frame:object",
"//sling/frame:serialization",
"//sling/frame:store",
"//sling/nlp/document:document",
"//sling/nlp/document:document-corpus",
"//sling/string:strcat",
"//sling/string:printf",
],
)

cc_library(
name = "transition-generator",
hdrs = ["transition-generator.h"],
srcs = ["transition-generator.cc"],
deps = [
":parser-action",
"//sling/base",
"//sling/frame:object",
"//sling/frame:serialization",
"//sling/frame:store",
"//sling/nlp/document:document",
],
)

cc_library(
name = "parser-trainer",
srcs = ["parser-trainer.cc"],
hdrs = ["parser-trainer.h"],
deps = [
"frame-evaluation",
":parser-action",
":parser-features",
":roles",
Expand All @@ -148,7 +180,6 @@ cc_library(
"//sling/nlp/document:document-corpus",
"//sling/nlp/document:lexical-encoder",
"//sling/nlp/document:lexicon",
"//sling/nlp/parser/trainer:frame-evaluation",
"//sling/task:learner",
"//sling/util:mutex",
"//sling/util:unicode",
Expand All @@ -160,14 +191,14 @@ cc_library(
srcs = ["caspar-trainer.cc"],
deps = [
":parser-trainer",
":transition-generator",
"//sling/base",
"//sling/myelin:builder",
"//sling/myelin:flow",
"//sling/myelin:gradient",
"//sling/myelin:learning",
"//sling/nlp/document:document",
"//sling/nlp/document:document-corpus",
"//sling/nlp/parser/trainer:transition-generator",
],
alwayslink = 1,
)
Expand Down
2 changes: 1 addition & 1 deletion sling/nlp/parser/caspar-trainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "sling/myelin/learning.h"
#include "sling/nlp/parser/action-table.h"
#include "sling/nlp/parser/parser-trainer.h"
#include "sling/nlp/parser/trainer/transition-generator.h"
#include "sling/nlp/parser/transition-generator.h"

namespace sling {
namespace nlp {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "sling/nlp/parser/trainer/frame-evaluation.h"
#include "sling/nlp/parser/frame-evaluation.h"

#include <algorithm>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

// Frame evaluation.

#ifndef SLING_NLP_PARSER_TRAINER_FRAME_EVALUATION_H_
#define SLING_NLP_PARSER_TRAINER_FRAME_EVALUATION_H_
#ifndef SLING_NLP_PARSER_FRAME_EVALUATION_H_
#define SLING_NLP_PARSER_FRAME_EVALUATION_H_

#include <string>
#include <unordered_map>
Expand Down Expand Up @@ -225,4 +225,4 @@ class FrameEvaluation {
} // namespace nlp
} // namespace sling

#endif // SLING_NLP_PARSER_TRAINER_FRAME_EVALUATION_H_
#endif // SLING_NLP_PARSER_FRAME_EVALUATION_H_
2 changes: 1 addition & 1 deletion sling/nlp/parser/parser-trainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
#include "sling/nlp/document/document.h"
#include "sling/nlp/document/document-corpus.h"
#include "sling/nlp/document/lexical-encoder.h"
#include "sling/nlp/parser/frame-evaluation.h"
#include "sling/nlp/parser/parser-action.h"
#include "sling/nlp/parser/parser-features.h"
#include "sling/nlp/parser/roles.h"
#include "sling/nlp/parser/trainer/frame-evaluation.h"
#include "sling/task/learner.h"
#include "sling/util/mutex.h"

Expand Down
2 changes: 1 addition & 1 deletion sling/nlp/parser/tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cc_binary(
"//sling/nlp/document:document-tokenizer",
"//sling/nlp/document:lex",
"//sling/nlp/parser",
"//sling/nlp/parser/trainer:frame-evaluation",
"//sling/nlp/parser:frame-evaluation",
"//sling/string:printf",
],
)
Expand Down
2 changes: 1 addition & 1 deletion sling/nlp/parser/tools/parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
#include "sling/nlp/document/document-corpus.h"
#include "sling/nlp/document/document-tokenizer.h"
#include "sling/nlp/document/lex.h"
#include "sling/nlp/parser/frame-evaluation.h"
#include "sling/nlp/parser/parser.h"
#include "sling/nlp/parser/trainer/frame-evaluation.h"
#include "sling/string/printf.h"

DEFINE_string(parser, "", "Input file with flow model");
Expand Down
47 changes: 0 additions & 47 deletions sling/nlp/parser/trainer/BUILD

This file was deleted.

41 changes: 0 additions & 41 deletions sling/nlp/parser/trainer/generate-transitions.cc

This file was deleted.

2 changes: 1 addition & 1 deletion sling/nlp/parser/trainer/pytorch_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

from cascade import Delegate
from cascade import SoftmaxDelegate
from lexical_encoder import LexicalEncoder
from parser_state import ParserState
from trace import Trace

from sling.myelin.lexical_encoder import LexicalEncoder
import sling
import sling.myelin.nn as flownn
import sling.myelin.flow as flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "sling/nlp/parser/transition-generator.h"

#include <algorithm>
#include <deque>
#include <vector>

#include "sling/frame/object.h"
#include "sling/frame/store.h"
#include "sling/nlp/parser/trainer/transition-generator.h"

namespace sling {
namespace nlp {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef SLING_NLP_PARSER_TRAINER_TRANSITION_GENERATOR_H_
#define SLING_NLP_PARSER_TRAINER_TRANSITION_GENERATOR_H_
#ifndef SLING_NLP_PARSER_TRANSITION_GENERATOR_H_
#define SLING_NLP_PARSER_TRANSITION_GENERATOR_H_

#include <functional>

Expand All @@ -37,4 +37,4 @@ void Generate(const Document &document,
} // namespace nlp
} // namespace sling

#endif // SLING_NLP_PARSER_TRAINER_TRANSITION_GENERATOR_H_
#endif // SLING_NLP_PARSER_TRANSITION_GENERATOR_H_
2 changes: 1 addition & 1 deletion sling/pyapi/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ cc_library(
"//sling/nlp/kb:facts",
"//sling/nlp/kb:phrase-table",
"//sling/nlp/parser",
"//sling/nlp/parser/trainer:frame-evaluation",
"//sling/nlp/parser:frame-evaluation",
"//sling/nlp/wiki:wikidata-converter",
"//sling/task:dashboard",
"//sling/task:job",
Expand Down
2 changes: 1 addition & 1 deletion sling/pyapi/pyparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include "sling/nlp/document/document.h"
#include "sling/nlp/document/document-tokenizer.h"
#include "sling/nlp/document/lex.h"
#include "sling/nlp/parser/frame-evaluation.h"
#include "sling/nlp/parser/parser.h"
#include "sling/nlp/parser/trainer/frame-evaluation.h"
#include "sling/pyapi/pyframe.h"
#include "sling/pyapi/pystore.h"

Expand Down
1 change: 0 additions & 1 deletion tools/build-wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def sha256_content_checksum(data):
'python/myelin/__init__.py': '$DATA$/sling/myelin/__init__.py',
'python/myelin/builder.py': '$DATA$/sling/myelin/builder.py',
'python/myelin/flow.py': '$DATA$/sling/myelin/flow.py',
'python/myelin/lexical_encoder.py': '$DATA$/sling/myelin/lexical_encoder.py',
'python/myelin/nn.py': '$DATA$/sling/myelin/nn.py',
'python/myelin/tf.py': '$DATA$/sling/myelin/tf.py',

Expand Down
1 change: 0 additions & 1 deletion tools/buildall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ bazel build -c opt $* \
sling/nlp/ner:* \
sling/nlp/parser:* \
sling/nlp/parser/tools:* \
sling/nlp/parser/trainer:* \
sling/nlp/wiki:* \
sling/pyapi:* \
sling/stream:* \
Expand Down

0 comments on commit 75452a3

Please sign in to comment.