Binary Erlang,提取hashtag

Binary Erlang,提取hashtag,binary,erlang,extract,hashtag,Binary,Erlang,Extract,Hashtag,我正在尝试从使用 推特api 我使用它来提取标签: case extract(<<"entities">>, L) of {found, {TE}} -> {found, Hashtags} = extract(<<"hashtags">>, TE); not_found -> Hashtags = hash_not_found end, extract(K, L) -> case lists

我正在尝试从使用 推特api

我使用它来提取标签:

case extract(<<"entities">>, L) of 
   {found, {TE}} ->
       {found, Hashtags} = extract(<<"hashtags">>, TE);
   not_found -> Hashtags = hash_not_found
   end,

extract(K, L) ->
 case lists:keyfind(K, 1, L) of
   {_, M} -> {found, M};
   false  -> not_found
 end.
这给了我一个如下格式的标签:

[{[{<<"text">>,<<"London">>},{<<"indices">>,[120,127]}]}]
我只想从中提取标签,在本例中是伦敦。 每次我提取推文时,这个标签都会有所不同。 任何想法或建议都将不胜感激

我不想更改以前的代码,除非我真的必须这样做。我更愿意学习如何从列表中提取我需要的内容。

猜测提取函数的作用,类似这样的功能应该可以工作:

case extract(<<"hashtags">>, TE) of
  {found, Hashtags} ->
    case extract(<<"text">>, Hashtags) of 
      {found, HashtagTexts} -> HashtagTexts;
      not_found -> hash_not_found
    end;
  not_found -> hash_not_found
end

另请参见标准库中的模块。

除非我能在代码中为{found,[]}添加某种子句,否则该模块不起作用。如上所述,它取决于提取的实现方式。not_found和{found,[]}之间有什么区别?我的代码已经编辑过了。如果有帮助的话,我添加了提取函数。