英文からSVO（主語・動詞・目的語）のTriple Setをタプルに包んで返す関数を見つけた

##見つけたGitHubリポジトリ

####以下で公開されている資源が、手元のMacBookPro実機で問題なく動きました。

・ [（GitHub）peter3125/enhanced-subject-verb-object-extraction ](https://github.com/peter3125/enhanced-subject-verb-object-extraction)

__*git clone*でローカルにダウンロード__

```bash:Terminal
% git clone https://github.com/peter3125/enhanced-subject-verb-object-extraction.git
% cd enhanced-subject-verb-object-extraction
% pip3 install -r requirements.txt
% python3 -m spacy download en_core_web_sm
% python3
```

__iPythonの対話型シェルで、挙動を確認__

__（ 問題なく動いた！ ）__

```Python3:Python3.9.0
>>> from subject_verb_object_extract import findSVOs, nlp
>>> tokens = nlp("Seated in Mission Control, Chris Kraft neared the end of a tedious Friday afternoon as he monitored a seemingly interminable ground test of the Apollo 1 spacecraft.")
>>> 
>>> svos = findSVOs(tokens)
>>> print(svos)
[('Chris Kraft', 'neared', 'the end of a tedious Friday afternoon'), ('he', 'monitored', 'a interminable ground test of the Apollo spacecraft')]
>>> 
```

####BBC Newsサイトの以下の記事から英文テキストを抜粋

・ https://www.bbc.com/news/52937766

```Python3:ipython対話型インタラクティブシェル
In [1]: from subject_verb_object_extract import findSVOs, nlp

   ...: It's mainly a matter of substance.
   ...: 
   ...: Outstanding issues
   ...: If a free trade deal is agreed now, it won't be a particularly ambitious one. There hasn't been time to go for much more than a basic model.
   ...: 
   ...: But even with these limited aims, negotiators have hit a brick wall on some fundamental issues.
   ...: 
   ...: First of all, there is what is known as the level playing field. That means measures to ensure businesses on one side don't have an unfair ad
   ...: vantage over their competitors on the other.
   ...: 
   ...: All trade agreements have such measures, but the EU wants the UK to stick particularly closely to EU rules on things like workers' rights, en
   ...: vironmental regulations and, especially, state aid (financial assistance given by government to businesses).
   ...: 
   ...: The UK, on the other hand, says the whole point of Brexit was to break free from following common rules.
   ...: 
   ...: Brexit trade deal: What do the UK and the EU want?
   ...: Who really owns UK fishing quotas?
   ...: Then there is fisheries: the EU is pushing for maximum access for its boats to continue fishing in UK waters.
   ...: 
   ...: British negotiators say the UK is now an independent coastal state and it will prioritise its own boats. But if there is no agreement on acce
   ...: ss to fishing waters, the UK won't get full access to the EU market to sell its fish there.
   ...: 
   ...: Even though fishing makes up only a tiny part of the economy on both sides, it was a big part of the Leave campaign that won the Brexit refer
   ...: endum in the UK in 2016."""

In [3]: tokens = nlp(document)

In [4]: print(type(tokens))
<class 'spacy.tokens.doc.Doc'>

In [5]: svos = findSVOs(tokens)

In [6]: print(type(svos))
<class 'list'>

In [7]: print(len(svos))
25

In [8]: from pprint import pprint

In [9]: print(svos)
[('the wire', 'go', 'The Brexit trade talks between'), ('the EU', 'leave', 'The UK'), ('31 January', 'leave', 'The UK'), ('the same', 'stay', 'all the rules , regulations'), ('the coronavirus crisis', 'overshadow', 'The talks'), ('the beginning had', 'overshadow', 'The talks'), ('place', 'take', 'the beginning had'), ('video link', 'take', 'the beginning had'), ('months of negotiations', 'remain', 'big disagreements'), ('much more than a basic model', 'go', 'time'), ('a brick wall', 'hit', 'negotiators'), ('some fundamental issues', 'hit', 'negotiators'), ('businesses', 'ensure', 'measures'), ('one side', 'ensure', 'measures'), ('EU rules on things like workers rights , regulations', 'stick', 'the UK'), ('government', 'give', 'financial assistance'), ('businesses', 'give', 'financial assistance'), ('UK fishing quotas', 'own', 'Who'), ('maximum access', 'push', 'the EU'), ('UK waters', 'fish', 'its boats'), ('UK waters', 'fish', 'maximum access'), ('its own boats', 'prioritise', 'it'), ('only a tiny part of on both sides', 'make', 'fishing'), ('the Brexit referendum in', 'win', 'the Leave campaign'), ('2016', 'win', 'the Leave campaign')]

In [10]: pprint(svos)
[('the wire', 'go', 'The Brexit trade talks between'),
 ('the EU', 'leave', 'The UK'),
 ('31 January', 'leave', 'The UK'),
 ('the same', 'stay', 'all the rules , regulations'),
 ('the coronavirus crisis', 'overshadow', 'The talks'),
 ('the beginning had', 'overshadow', 'The talks'),
 ('place', 'take', 'the beginning had'),
 ('video link', 'take', 'the beginning had'),
 ('months of negotiations', 'remain', 'big disagreements'),
 ('much more than a basic model', 'go', 'time'),
 ('a brick wall', 'hit', 'negotiators'),
 ('some fundamental issues', 'hit', 'negotiators'),
 ('businesses', 'ensure', 'measures'),
 ('one side', 'ensure', 'measures'),
 ('EU rules on things like workers rights , regulations', 'stick', 'the UK'),
 ('government', 'give', 'financial assistance'),
 ('businesses', 'give', 'financial assistance'),
 ('UK fishing quotas', 'own', 'Who'),
 ('maximum access', 'push', 'the EU'),
 ('UK waters', 'fish', 'its boats'),
 ('UK waters', 'fish', 'maximum access'),
 ('its own boats', 'prioritise', 'it'),
 ('only a tiny part of on both sides', 'make', 'fishing'),
 ('the Brexit referendum in', 'win', 'the Leave campaign'),
 ('2016', 'win', 'the Leave campaign')]

In [12]: 
```

___

##日本語のテキストを扱えるように改変 （失敗）

__19行目の以下の部分を__

```Python
# use spacy small model
nlp = en_core_web_sm.load()
```

__以下に変更。ファイル名を*subject_verb_object_extract_ja.py*に変更。__

```Python
# use spacy Japanese language model
nlp = spacy.load('ja_ginza')
```

__空の配列が返ってきてしまった。__

```Python:
>>> from subject_verb_object_extract_ja import findSVOs, nlp
>>> tokens = nlp("日本の探査機「はやぶさ2」が、小惑星の砂が入ったとみられるカプセルを日本時間の来月6日の未明にオーストラリアの砂漠地帯に帰還させる計画です。初号機に続いて小惑星の砂を持ち帰ることができるか世界から注目されていて、現地に入ったチームが回収の準備を進めています。")
>>> svos = findSVOs(tokens)
>>> print(svos)
[]
>>> 
>>> tokens = nlp("日本 の 探査機 「はやぶさ2」 が、 小惑星 の 砂 が 入った と みられる カプセル を 日本時間 の 来月6日 の 未明 に オーストラリア の 砂漠地帯 に 帰還 させる 計画 です。 初号機 に 続いて 小惑星 の 砂 を 持ち帰る こと が できる か 世界 から 注目 されて いて、 現地 に 入った チーム が回収 の 準備 を 進めて います。")
>>> svos = findSVOs(tokens)
>>> print(svos)
[]
>>>
```

日本語の場合は、"nsubj", "nsubjpass", "csubj", "csubjpass", "agent", "expl"などが異なる体系なのかもしれない。

__*nlp = spacy.load('ja_ginza')*__をしておくことで、__*spacy*__が動くことは確認済みです。

```Python:
>>> import spacy
>>> 
>>> nlp = spacy.load('ja_ginza')
>>> doc = nlp("日本の探査機「はやぶさ2」が、小惑星の砂が入ったとみられるカプセルを日本時間の来月6日の未明にオーストラリアの砂漠地帯に帰還させる計画です。初号機に続いて小惑星の砂を持ち帰ることができるか世界から注目されていて、現地に入ったチームが回収の準備を進めています。")
>>> 
>>> for token in doc:
...     print(token.text, token.pos_, token.dep_)
... 
日本 PROPN compound
の ADP case
探査機 NOUN compound
「 PUNCT punct
はやぶさ NOUN compound
2 NUM nsubj
」 PUNCT punct
が ADP case
、 PUNCT punct
小惑星 NOUN nmod
の ADP case
砂 NOUN nsubj
が ADP case
入っ VERB advcl
た AUX aux
と ADP case
み VERB acl
られる AUX aux
カプセル NOUN obj
を ADP case
日本 PROPN compound
時間 NOUN nmod
の ADP case
来月 NOUN compound
6 NUM nummod
日 NOUN nmod
の ADP case
未明 NOUN obl
に ADP case
オーストラリア PROPN nmod
の ADP case
砂漠 NOUN compound
地帯 NOUN obl
に ADP case
帰還 VERB acl
さ AUX aux
せる AUX aux
計画 NOUN ROOT
です AUX cop
。 PUNCT punct
初号 NOUN compound
機 NOUN obl
に ADP case
続い VERB advcl
て SCONJ mark
小惑星 NOUN nmod
の ADP case
砂 NOUN obj
を ADP case
持ち帰る VERB nsubj
こと NOUN compound
が ADP case
できる AUX aux
か ADP case
世界 NOUN nmod
から ADP case
注目 VERB advcl
さ AUX aux
れ AUX aux
て SCONJ mark
い AUX aux
て SCONJ mark
、 PUNCT punct
現地 NOUN iobj
に ADP case
入っ VERB acl
た AUX aux
チーム NOUN nsubj
が ADP case
回収 NOUN nmod
の ADP case
準備 NOUN obj
を ADP case
進め VERB ROOT
て SCONJ mark
い AUX aux
ます AUX aux
。 PUNCT punct
>>> 
```