3

次のような名前の列があります。

  • クアリア、ピエトロ・パオロ
  • クレールヴォーのバーナード、サン、または
  • .E.、カルビン F.
  • スウィングル、M アバーテ、アゴスティーノ、アセレート
  • アントニオ・アバティ
  • 10-NA)\u, Ferraro, Giuseppe, ed, Biblioteca comunale ariostea. さん (エステリ

openrefine を使用してカスタム テキスト ファセットを作成し、名前を 1 つのコンマで「true」としてマークし、他のすべての名前を「false」としてマークして、最後の名前 (「.E., Calvin F.」は問題、私は後でそれを扱います)。

「カスタムテキストファセット」とこの式を使用しようとしています:

if(value.match(/([^,]+),([^,]+)/), "true", "false")

しかし、結果はすべて偽です。間違っている部分は何ですか?

4

3 に答える 3

2

使用している表現:

if(value.match(/([^,]+),([^,]+)/), "true", "false")

'match' 関数の出力は配列または null であるため、常に false と評価されます。「if」によって評価される場合、配列も「null」も true に評価されません。

一致関数を「isNonBlank」などでラップしてブール値の true/false を取得すると、「if」関数が必要に応じて機能します。ただし、ブール値の真/偽の結果が得られると、その唯一の機能はブール値の真/偽を文字列「真」または「偽」に変換することであるため、「if」は冗長になります。値関数に違いはありません。カスタム テキスト ファセットの。

そう:

isNonBlank(value.match(/([^,]+),([^,]+)/))

match を使用して目的の結果が得られるはずです

于 2016-02-18T09:50:05.640 に答える
1

Instead of using 'match' you could use 'split' to split the string into an array using the comma as a split character. If you measure the length of the resulting array, it will give you the number of commas in the string (i.e. number of commas = length-1).

So your custom text facet expression becomes:

value.split(",").length()==2

This will give you true/false

If you want to break down the data based on the number of commas that appear, you could leave off the '==2' to get a facet which just gives you the length of the resulting array.

于 2016-02-17T13:09:02.003 に答える