Semantic Modelling of Ship Behavior in Harbor Based on Ontology and Dynamic Bayesian Network

Recognizing ship behavior is important for maritime situation awareness and intelligent transportation management. Some scholars extracted ship behaviors from massive trajectory data by statistical analysis. However, the meaning of the behaviors, i.e., semantic meanings of behaviors and their relationships, are not explicit. Ship behaviors are affected by navigational area and traffic rules, so their meanings can be obtained only in specific maritime situations. The work establishes the semantic model of ship behavior (SMSB) to represent and reason the meaning of the behaviors. Firstly, a semantic network is built based on maritime traffic rules and good seamanship. The corresponding detection methods are then proposed to identify basic ship behaviors in various maritime scenes, including dock, anchorage, traffic lane, and general scenes. After that, dynamic Bayesian network (DBN) is used to reason potential ship behaviors. Finally, trajectory annotation and semantic query of the model are validated in the different scenes of harbor. The basic behaviors and potential behaviors in all typical scenes of any harbor can be obtained accurately and expressed conveniently using the proposed model. The model facilitates the ships behavior research, contributing to the semantic trajectory analysis.


Introduction
The maritime data from multi-sources has rich meaning in the big data era, especially the meaning of ship behaviors [1]. As the carrier of maritime transportation, ships are the decisive factors of maritime safety [2]. Its dynamic behaviors are difficult to be recognized in a complex situation, even with the improvement of storage, indexing, and querying of trajectory data [3]. Most of the existing studies focus on the data analysis in the ships behavior research [4,5], but there are some problems-the semantic meanings of behaviors and their relationships are not explicit; the data from different sources or dimensions cannot be connected; and the traffic rules are difficult to consider [6]. This has led to the development of semantic ship behaviors based on the semantic trajectory [7].
The original ship trajectories are difficult to interpret, query, or visually identify [8]. The main reason is that the raw data cannot express the semantic meanings of behaviors and their relationships. The semantic meanings are the refined, standardized concepts and relationships extracted from original proposed. The simple event model (SEM), proposed by Van Hage [7], is used in ship trajectories to bridge the gap between the behaviors and semantics. It may be the first systematic study of the ship's semantic trajectory. The ship behaviors are obtained from the trajectory by a piecewise linear segmentation. Different facets are used in the SEM to represent the ship behaviors. A system (RMSAS), proposed by Brüggemann S [27], combines static data from different sources using semantic techniques. Its applications verify that the system can increase the value of data and improve the processing workflow in the maritime domain. Considering the semantic trajectory as the "first-class citizen", the datAcron project proposed the datAcron ontology to advance the integrated exploitation and management of massive and heterogeneous data in the maritime domain [1]. The critical points of the trajectory are kept after using the data-summarization techniques. Then, the trajectories are revisited with the datAcron ontology, represented at the semantic level.
Some literature focus on the maritime big data integration and fusion tasks using semantic technologies, and involve the ship's semantic behavior. Dividino et al. [28] presented a data architecture for real-time data representation, integration, and querying over a multitude of data streams from AIS station, climate station, and ice station. The marine behaviors, such as approaching heavy weather condition areas and approaching areas of heavy ice, can be queried based on these data. In 2015, Santipantakis et al. [29] presented two ontology-based data integration systems for the recognition of maritime behaviors. The concepts of low and high level behaviors are defined, with some behavior examples. In 2018, Santipantakis et al. [10] proposed the novel framework based on their previous work, providing a unified representation of mobility data and other data sources. Some basic behaviors, such as stops and changes in speed and heading are recognized in the proposed framework. Claramunt et al. [30] summarized recent literature of maritime data integration and analysis, believing that the early recognition of behaviors is crucial to safety and operations at sea.
However, some aspects are not considered in the mentioned literature. Most studies refer to the ship behaviors based on the ship trajectory without context information (such as geographic information and traffic rules). Since the behaviors in typical scenes of harbor are not proposed in these literatures, they cannot be conveniently used in the harbor. Meanwhile, due to few studies on inherent relationships of ship states and behaviors, the high-level ship behaviors are mined by complex algorithms that are not universally applied to various scenes. Last but not least, the advantages of the semantic model have not been fully exploited, for example, the natural language can be expressed to users based on semantic query.

Semantic Network of Ship Behavior
As defined by Sowa [31], a semantic network is a graphic notation for representing knowledge in patterns of interconnected nodes and arcs. In the work, the semantic network is the network of classes/individuals (nodes) and the properties (arcs). The OWL API [32] is used to construct the semantic network, and Java is the programming language. To meet the current demand for the ship behavior research, the semantic network should • express the concepts and the implicit correlations of ship behaviors in typical scenes clearly and comply with the rules; • store the historical behaviors for reasoning, trajectory annotation, and semantic query; • contain the reasoning method to obtain the potential behavior from the basic behavior.

Framework of the Semantic Network
The semantic network is in the form of triple: where SN is the semantic network; C = {C 1 , C 2 , . . . , C n } is the Class (all semantic terms in the semantic network are italic in the work), which contains the ship behaviors and the other concepts;

2.
Place can be represented by name, latitude and longitude, or relative position of other geographical locations. It can be related to other ontologies such as GeoNames [33].

3.
Time should be consistent with the W3C standard, such as 2018-06-25 T11:55:56+08:00. If the behavior is not finished or the start time is unknown, Time will be ambiguous. It has subclasses Begin Time and End Time, which connect with Type and Trajectory Segment.

4.
Type indicates the type of ship, including Container Ship, Ferry, and High Speed Ship. The same ship may have different types at different time, e.g., a ship is a tug over a period and a towed ship over another period. Therefore, Type has the properties of has Begin Time and has End Time.

5.
State (basic behavior) is the information obtained from the trajectory data and the context data directly. It is usually at a certain moment, such as the turning direction and the location. States in all typical scenes of harbor are recognized in Section 4.

6.
Behavior (potential behavior) usually occurs over a period, such as Turn to Starboard and Speed Down. Behaviors are reasoned from States by DBN, as shown in Section 5.

7.
Trajectory Segment is part of the trajectory. There is has Filiation property that represents a filiation relationship between two Trajectory Segments, which can guarantee the continuity of trajectory segments. Trajectory Segment connects Behavior by has Behavior because the behavior usually lasts for a period and covers multiple consecutive trajectory points (except for the Enter/Leave behavior in Figure 2, it connects a special Trajectory Segment with only one trajectory point). In contrast, as each trajectory point has its own state, the Trajectory Point always connects State by has State. In this way, the ship's behaviors and states are stored in the semantic model, which can facilitate reasoning and querying.
conditional probability and the transfer matrix in the DBN, respectively.
The Data Type Property is the data description or data restriction of the Class or Individual, e.g., the probability of Speed Up is 0.73. The Behavior is reasoned by DBN to get the probability, so it has a Data Type Property named has Probability. Figure 2 shows State and Behavior in the semantic network. According to the International Regulations for Preventing Collisions at Sea (COLREGS), the local Vessel Traffic Services (VTS) rules and the good seamanship, the inherent relationships of States and Behaviors can be obtained. The States and Behaviors in all typical scenes of harbor are introduced as follows. When the behavior is influenced by historical behaviors, there will be the hasI property on itself.  There are the Property has Characteristic (hasC) between the behaviors at the same time, and has Inter-Slice Influence (hasI) between the behaviors in adjacent time. hasC and hasI are the conditional probability and the transfer matrix in the DBN, respectively.

State and Behavior in the Semantic Network
The Data Type Property is the data description or data restriction of the Class or Individual, e.g., the probability of Speed Up is 0.73. The Behavior is reasoned by DBN to get the probability, so it has a Data Type Property named has Probability.

Property:
There are hasC properties between Speed Change and five historical states (turning t-4-t) because the result will be inaccurate if only one Trajectory Point is used. The work chooses five as the threshold through a large amount of data validation. The Turning behavior is as same as Speed Change behavior. The property between Enter/Leave behavior and i/o state is hasC because the they are in the same time slice.

Dock:
Behavior:  Property: If a ship berths, it has the Speed Down behavior apparently; in contrast, when the ship leaves the dock, it has the Speed Up behavior. Thus, there are hasC between Arrival/Departure and Speed Change, and hasI between Berth/Anchor and Speed Change. The Berth behavior is reasoned by the ship in a Dock and speed = 0, so there is the hasC property between Berth and Dock/speed = 0. The ship must be moored at a dock suitable for its type, so there is hasC between Type and Arrival/Berth.

Anchorage:
Behavior:  Property: As the speed may be greater than 0 (but usually less than 1) when a ship is anchoring, the Anchor behavior has the hasC with s < 1. If a ship enters a harbor area, and anchors in the Anchorage, it will Approach the traffic lane, and finally choose to Join or Cross the traffic lane. Therefore, there is Property hasI among the Behaviors around Anchorage. The ship should Cross with a Right Angle or Join with a Small Angle under COLREGS rule 10, so there is hasC between the Behavior and State around anchorage.

Traffic Lane:
Behavior:  Property: There is hasC property between the Deviate behavior and historical deviate states, as same as the Turning and Speed Change behavior. The Deviate, in General Direction, and Keep Clear have hasC property with the Should Turn to. They also have the hasC property with is Safe, which represents the safety index.

Recognition of State
The State should be recognized from raw data accurately. Based on it, the high-level potential behavior can be reasoned by DBN.

Recognition of States in General Scene, Dock and Anchorage
Speed change and turning: Figure 3a shows the state turning is recognized by the vector product  Other States can be obtained from raw data easily. The method to determine a ship in a Place (containing Anchorage, Dock, and Traffic Lane) is to judge a point in the polygon. Judging whether the ship Approaches the fairway at Small Angle or Right Angle is through calculating the angle between the ship's heading and the traffic lane's boundary.

deviate:
The deviate state is recognized by deviation length (DL). The DL is the trajectory length between the ship's current position and the position when the ship crosses the boundary. If DL exceeds the threshold (given by the experienced ship officers or pilots familiar with the ship condition and sailing area), the ship has the deviate state. The deviation length considers the ship's real-time position, movement status, and boundary shape, so DL can be used as a quantitative In/out: Figure 3b shows if the states of adjacent points e and f is the out Λ in, then the ship has Enter behavior, and the other combinations can be found in Section 6. This method can be used in area as long as it is a closed area. In addition to dock, traffic lane and anchorage, it can be used in the bridge area, foul area, fish trap area, fish haven, precautionary area, and prohibited area. If a ship enters a "no entry" area, such as the environment protection area and military area, the early warning can be given to the ship. Other States can be obtained from raw data easily. The method to determine a ship in a Place (containing Anchorage, Dock, and Traffic Lane) is to judge a point in the polygon. Judging whether the ship Approaches the fairway at Small Angle or Right Angle is through calculating the angle between the ship's heading and the traffic lane's boundary.

Recognition of States in Traffic Lanes
Deviate: The deviate state is recognized by deviation length (DL). The DL is the trajectory length between the ship's current position and the position when the ship crosses the boundary. If DL exceeds the threshold (given by the experienced ship officers or pilots familiar with the ship condition and sailing area), the ship has the deviate state. The deviation length considers the ship's real-time position, movement status, and boundary shape, so DL can be used as a quantitative indicator of deviate.
The bow (position A in Figure 4) crosses the boundary when the ship deviates, and the Automatic Identification System (AIS) or radar data only has antenna installation position (position K in Figure 4). Therefore, the bow position should be calculated based on the position of AIS or radar data. d is the distance between A and K, whose specific value is determined by the ship type and antenna position; β is the heading of the ship.  A's position is calculated by Equation (2) when β According to the reasoning result of Turning behavior, when the ship has Go Straight behavior, the ship motion status is considered as a uniform linear motion. When the ship has Turn to Starboard/Turn to Port behavior, the ship motion is considered as a uniform circular motion (see Figure 5). The instantaneous trajectory radius of points A and K are denoted by av R and kv R , respectively. The bearing of A and K's instantaneous linear velocity direction are ϕ a and ϕ k respectively, and ω β ϕ A's position is calculated by Equation (2) when x a = x k + d sin β y a = y k + d cos β According to the reasoning result of Turning behavior, when the ship has Go Straight behavior, the ship motion status is considered as a uniform linear motion. When the ship has Turn to Starboard/Turn to Port behavior, the ship motion is considered as a uniform circular motion (see Figure 5). The instantaneous trajectory radius of points A and K are denoted by R av and R kv , respectively. The bearing of A and K's instantaneous linear velocity direction are ϕ a and ϕ k respectively, and ω = |β − ϕ k |.   The boundary of the traffic lane is generally a straight line in open waters and the smooth curve in some coastal waters and inland curved channel. The curved boundary is considered as connections of several curve segments that are arcs in the work. Moreover, the curved boundary may be the convex boundary or concave boundary, so there are six combinations of the boundary and Turning behavior (See Figure 6).  The work gives the calculation methods of Figure 6a,d, and the methods of other combinations are similar. Figure 6a shows the ship Runs near the convex boundary. Wherein, C is the point at which the ship crosses the boundary; O the circle center of the boundary; W the point of intersection of the line AO and the boundary; and θ the acute angle between the trajectory direction of A and the tangent of the boundary. The following relationship exists in Figure 6a.
DL is the length of line segment AC as follows. Figure 6d shows the ship has Turn to Starboard/Turn to Port behavior near the convex boundary, and O v represents the circle center of the trajectory of the bow.
In the AOO v and COO v , according to the cosine theorem, Then DL can be calculated as In General Direction and Keep Clear: The in General Direction is recognized by calculating the angle between Course over Ground (COG) and the direction of the traffic lane. The Keep Clear is recognized by calculating the distance between the ship position and traffic separation line/zone. The degree of the two behaviors is classified in Figure 7.
In the △AOOv and △COOv, according to the cosine theorem, Then DL can be calculated as in

Mapping Recognised States to Semantic Network
After the recognition of State, every Trajectory Point will have at least two States, i.e., speed change and turning. The running example (See Figure 8) shows the recognized Individuals of the

Mapping Recognised States to Semantic Network
After the recognition of State, every Trajectory Point will have at least two States, i.e., speed change and turning. The running example (See Figure 8)

Semantic Reasoning of Ship Behavior Using DBN
There are some traditional reasoners based on logical reasoning in the semantic web, such as Racer, Fact++, Pellet and Hermit, which can be used to check the inconsistency of the ontology [34]. However, the reasoners are difficult to deal with the uncertainty and dynamic characteristics of ship behaviors. Therefore, a reasoning method is needed to adapt to the ship behavior characteristics.
Bayesian network is a graphical model of probabilistic inference, widely used in domains that need to handle the uncertain knowledge [35]. If the Bayesian network is used to reason the probability of ship behavior, the result will be more specific and accurate than the logical reasoning. When the source data is inaccurate or incomplete, the Bayesian network can give credible inference results based on the information of other nodes and its historical state, without missing results like logical reasoning. At the same time, the water traffic situation and the ship's navigation state are changing with time, so DBN is required to infer the probability of current ship behavior under the time series dynamically.
The network structure of the semantic network and the DBN has high similarity, so the mutual conversion can be realized [36]. The semantic network and the DBN can be combined to make up their defects and give full play to their advantages.

Definition of DBN
DBN can be defined as an initial network and a transfer network (See Figure 9). Specifically, Figure 10 shows the DBN when the ship is in the Dock.

Semantic Reasoning of Ship Behavior Using DBN
There are some traditional reasoners based on logical reasoning in the semantic web, such as Racer, Fact++, Pellet and Hermit, which can be used to check the inconsistency of the ontology [34]. However, the reasoners are difficult to deal with the uncertainty and dynamic characteristics of ship behaviors. Therefore, a reasoning method is needed to adapt to the ship behavior characteristics.
Bayesian network is a graphical model of probabilistic inference, widely used in domains that need to handle the uncertain knowledge [35]. If the Bayesian network is used to reason the probability of ship behavior, the result will be more specific and accurate than the logical reasoning. When the source data is inaccurate or incomplete, the Bayesian network can give credible inference results based on the information of other nodes and its historical state, without missing results like logical reasoning. At the same time, the water traffic situation and the ship's navigation state are changing with time, so DBN is required to infer the probability of current ship behavior under the time series dynamically.
The network structure of the semantic network and the DBN has high similarity, so the mutual conversion can be realized [36]. The semantic network and the DBN can be combined to make up their defects and give full play to their advantages.

Definition of DBN
DBN can be defined as an initial network and a transfer network (See Figure 9). Specifically, Figure 10 shows the DBN when the ship is in the Dock.  In the t-th time slice (t = 0), the semantic network is transformed into the initial network, and the probability distribution ( ) On the one hand, the nodes in the t-th time slice ( > 0 t ) may be affected by the nodes in the previous time slice. On the other hand, the probability of the next time slice node may be predicted by the probability of the previous time slice node, so the transfer network needs to be defined. Assuming that the DBN conforms to the first-order Markov process, the transfer network is a Bayesian network that contains two adjacent time slices. Between the time slices, there are the  In the t-th time slice (t = 0), the semantic network is transformed into the initial network, and the probability distribution ( ) 0 P X of the initial time is defined. The subclasses belonging to State and Behavior in the semantic network are converted into the nodes of the DBN. The node corresponds to random variable i X with probability value ( ) i P X . Individual corresponds to the value of random variable i X , and all the values are discrete. Properties between subclasses correspond to directed arcs between nodes, indicating the direct influence between nodes, with corresponding conditional probabilities. The joint probability of all nodes within the initial network is Pa X are all the parent nodes of any node i X . If there is no parent node, then i X is the root node, and ( ( )) ( ) i i i P X | Pa X = P X (indicating its prior probability).
On the one hand, the nodes in the t-th time slice ( > 0 t ) may be affected by the nodes in the previous time slice. On the other hand, the probability of the next time slice node may be predicted by the probability of the previous time slice node, so the transfer network needs to be defined. Assuming that the DBN conforms to the first-order Markov process, the transfer network is a Bayesian network that contains two adjacent time slices. Between the time slices, there are the In the t-th time slice (t = 0), the semantic network is transformed into the initial network, and the probability distribution P(X 0 ) of the initial time is defined. The subclasses belonging to State and Behavior in the semantic network are converted into the nodes of the DBN. The node corresponds to random variable X i with probability value P(X i ). Individual corresponds to the value of random variable X i , and all the values are discrete. Properties between subclasses correspond to directed arcs between nodes, indicating the direct influence between nodes, with corresponding conditional probabilities. The joint probability of all nodes within the initial network is where Pa(X i ) are all the parent nodes of any node X i . If there is no parent node, then X i is the root node, and P(X i |Pa(X i )) = P(X i ) (indicating its prior probability). On the one hand, the nodes in the t-th time slice (t > 0) may be affected by the nodes in the previous time slice. On the other hand, the probability of the next time slice node may be predicted by the probability of the previous time slice node, so the transfer network needs to be defined. Assuming that the DBN conforms to the first-order Markov process, the transfer network is a Bayesian network that contains two adjacent time slices. Between the time slices, there are the influences between the Behavior nodes. The conditional distribution of the t-th time slice under all previous time slices is where B m t is the m-th Behavior node (m = 1, 2, . . . , n) in the t-th time slice; Pa(B m t ) the parent node of B m t , which can be in the same time slice or the previous time slice. The conditional probability of the State node is P(S t |B 0:t−1 , S 0:t−1 ) = P(S t |B t ) (10) DBN can be expanded to the T-th time slice by the initial network and the transfer network. The joint probability distribution from the 0-th time slice to the T-th time slice is

Parameter Learning
The conditional probability in the initial network and the transfer matrix in the transfer network are parameters θ in the DBN, and need to be given before reasoning. The work uses the maximum likelihood estimation method for parameter learning. Nodes in the DBN are all discrete random variables, and their distribution law is as follows.
Then, the parameter value that maximizes the likelihood function is chosen as the estimated value of the unknown parameter θ, and the likelihood equation is Thus, the maximum likelihood estimateθ i is obtained.

Dynamic Reasoning
The reasoning of a network with T time slices is to calculate the conditional probability of potential Behaviors under the observed States: where u = 1, 2, . . . , T; v = 1, 2, . . . , m; p = 1, 2, . . . , T; q = 1, 2, . . . , n; B q p is an actual value B q p ; Pa(S v u ) the set of parent nodes of the evidence variable S v u . Based on it, the inference is transformed into the calculation of the known conditional probabilities, and the probability of the behavior can be inferred. Figure 11 shows the reasoned Behaviors when KUOTAI arrives at Xiamen Dock. The Speed Down Behavior is reasoned by five speed down States, and the Arrival Behavior is reasoned by Speed Down (Behavior) and Container (Type) and Xiamen Dock (Place). The Xiamen Dock is a container dock, so the ship has the Arrival behavior only when the ship's type is Container. There is the hasI Property between Berth and Arrival and Speed Down, which means that the ship will have the Berth Behavior at the dock if it has Arrival and Speed Down Behaviors at the dock.  m  1  2  n  1  2  m  1  2  T  1  2  T  1  2  n  1  2 Figure 11 shows the reasoned Behaviors when KUOTAI arrives at Xiamen Dock. The Speed Down Behavior is reasoned by five speed down States, and the Arrival Behavior is reasoned by Speed Down (Behavior) and Container (Type) and Xiamen Dock (Place). The Xiamen Dock is a container dock, so the ship has the Arrival behavior only when the ship's type is Container. There is the hasI Property between Berth and Arrival and Speed Down, which means that the ship will have the Berth Behavior at the dock if it has Arrival and Speed Down Behaviors at the dock.

Application Examples
The dataset, consisting of AIS data from 514 ships and geospatial data, has been used for examples in the Xiamen harbor of China on 13 April 2016. These ships all have the same type (container), similar weight (10,000-20,000 t), and length (100-200 m). The information of the traffic lanes, anchorages, and dock is obtained from Route Regulations of Xiamen VTS Area. The data of the ship named KUOTAI is mainly used to verify the accuracy and practicality. Table 1 shows the types of AIS data, and the geospatial data types are longitude and latitude. Figure 12 shows KUOTAI's trajectory in Xiamen harbor.

Application Examples
The dataset, consisting of AIS data from 514 ships and geospatial data, has been used for examples in the Xiamen harbor of China on 13 April 2016. These ships all have the same type (container), similar weight (10,000-20,000 t), and length (100-200 m). The information of the traffic lanes, anchorages, and dock is obtained from Route Regulations of Xiamen VTS Area. The data of the ship named KUOTAI is mainly used to verify the accuracy and practicality. Table 1 shows the types of AIS data, and the geospatial data types are longitude and latitude. Figure 12 shows KUOTAI's trajectory in Xiamen harbor. After being marked by simple judgment and manual labelling, the AIS dataset is used as the parameter learning sample of DBN. The probability is shown in Tables 2, 3, and 4, omitting the probability of some highly correlated behaviors (for example, if the t-1-th time slice has a Berth behavior, then the t-th time slice has a high probability of Berth behavior).

Reasoning of Behavior Using DBN
After being marked by simple judgment and manual labelling, the AIS dataset is used as the parameter learning sample of DBN. The probability is shown in Tables 2-4, omitting the probability of some highly correlated behaviors (for example, if the t-1-th time slice has a Berth behavior, then the t-th time slice has a high probability of Berth behavior).  Table 5 shows the number and proportion of ship behaviors on that day. Based on the reasoned ship behaviors, the behavioral patterns can be mined.
The line charts in Figure 13 illustrate how the probability of KUOTAI's behaviors varies in typical scenes of the harbor. The following describes the probability changes of Figure 13a.
Initially, the Speed Down behavior increases sharply until it reaches 1, followed by the Arrival behavior due to the hasI property. Then the probability of Run/Stop behavior increases when the probability of Speed Down and Arrival behavior decreases, because the ship will Berth at the Dock. Over the following 130 time slices, in spite of some minor ups and downs, the probability almost remains unchanged in all behaviors except probability of Departure increases slowly for the hasI property between Departure and Berth. After that, the probability of Departure still maintains an upward trend, and the Speed Up behavior shows great similarity with a more rapid rise. After a period of stability, the ship leaves the Dock, and the probability of Speed Up and Departure gradually drops to zero. In short, all behaviors are accurately inferred, and have specific probability values at all time slices.  Every trajectory point has a time slice, and when the probability of Behavior exceeds 0.7, it is annotated to the trajectory (See Figure 14). Figure 14c shows when KUOTAI has abnormal behavior, Every trajectory point has a time slice, and when the probability of Behavior exceeds 0.7, it is annotated to the trajectory (See Figure 14). Figure 14c shows when KUOTAI has abnormal behavior, the Deviate, is Unsafe, and Should Turn to behaviors are inferred. These behaviors can give the ship clear instruction as Figure 14c.

Semantic Query Using SPARQL
The users can query anything from the semantic network using the Simple Protocol and RDF Query Language (SPARQL), which is a query language and data transmission protocol in semantic engineering [37]. The query mainly contains two clauses-SELECT and WHERE. The variable

Semantic Query Using SPARQL
The users can query anything from the semantic network using the Simple Protocol and RDF Query Language (SPARQL), which is a query language and data transmission protocol in semantic engineering [37]. The query mainly contains two clauses-SELECT and WHERE. The variable behind the SELECT clause represents the returned variable after the query. The specific content to be queried is behind the WHERE clause. In addition to some solution sequence modifiers (such as ORDER BY, DISTINCT, and LIMIT), other commonly used queries are as follows: In FILTER query, the corresponding result can only be returned when the return value is true. The ships that have Speed Up behavior can be obtained by the following query. The LIMIT modifier is used to limit the number of returned results. Based on the semantic query, semantic information can be expressed as the natural language to users with limited semantic background. In the emergency situation, the natural language can be sent to the user as a warning. Examples in different situations are given as follows:

Discussion
In the work, a model named semantic model of ship behavior (SMSB) was proposed to extract ship behaviors from trajectory data in the semantic layer rather than in the data layer. As Table 6 shows, in the existing models, there are few systematic studies on the semantic modeling of ship behaviors. Compared to other models, the SMSB proposes recognition methods of states in all typical scenes as well as the reasoning method of the potential behavior. The proposed model benefits users (such as ship officers, pilots, VTS operators and decision makers) with maritime traffic management and collision avoidance, as well as the smart ship to make quick decisions within a limited time. It can be used for trajectory annotation and semantic query in all typical scenes of harbor. The semantic network contains all the necessary semantic information from trajectory data, thus making the smart ship fully perceive the behaviors of the surrounding ships to analyze the traffic situation. At the same time, since the ontology is in a machine-readable form and easy to share and query, the semantic model enables smart ships to obtain information services efficiently. In addition, the ontology can be reused, which greatly reduces the repetitive calculations of raw trajectory data.
In the future, the semantic database of trajectory data will be constructed. Therein, the potential semantic information will be mined, such as accident-prone areas, and economic analysis between ports. Meanwhile, we will study behaviors in natural environment, including the wind, wave, and current. Then, more meaningful behaviors will be extracted from the trajectory data, such as behaviors in different weather.