pyknp_eventgraph.eventgraph¶
-
class
pyknp_eventgraph.eventgraph.
EventGraph
[source]¶ Bases:
pyknp_eventgraph.component.Component
EventGraph provides a high-level interface that facilitates NLP application development. The core concept of EventGraph is event, a language information unit that is closely related to predicate-argument structure but more application-oriented. Events are linked to each other based on their syntactic and semantic relations.
-
document
: Document¶ A document on which this EventGraph is built.
-
classmethod
build
(blist)[source]¶ Build an EventGraph from language analysis by KNP.
- Parameters
blist (
List
[BList
]) – A list of bunsetsu lists, each of which is a result of analysis performed by KNP on a sentence.
Example:
from pyknp import KNP from pyknp_eventgraph import EventGraph # Parse a document. document = ['彼女は海外勤務が長いので、英語がうまいに違いない。', '私はそう確信していた。'] knp = KNP() blists = [knp.parse(sentence) for sentence in document] # Build an EventGraph. evg = EventGraph.build(blists)
- Return type
-
classmethod
load
(f, binary=False)[source]¶ Deserialize an EventGraph.
- Parameters
Example:
from pyknp_eventgraph import EventGraph # Load an EventGraph serialized in a JSON format. with open('evg.json', 'r') as f: evg = EventGraph.load(f, binary=False) # Load an EventGraph serialized by Python's pickle utility. with open('evg.pkl', 'rb') as f: evg = EventGraph.load(f, binary=True)
Caution
EventGraph deserialized from a JSON file loses several functionality. To keep full functionality, use Python’s pickle utility for serialization.
- Return type
-