세 번째 목록의 항목과 부분적으로 일치하는 다른 목록의 목록 항목을 추출하는 방법은 무엇입니까?다음 목록이 있습니다.
bigList = {"CD_CORN_1", "ICS_CORN_6", "IPEK21_S00R_P37_2", "CURR_S009_P37_2", "CD_CORN_2", "Ig_RF", "Cmax03_4C230RF", "NG"};
smallList1 = {"CD_CORN_", "CD_CORN_", "CD_CORN_"}; //note these are repeats and that is how I get them
smallList2 = {"IDS_CORN_", "IPEK21_S00R_", "CURR_S009_"};
smallList3 = {"RF", "IPEK21_S00R_", "CURR_S009_", "NG"};사용하여 빅리스트 그리고 작은 목록1 , 난 갖길 원해
sbigList1 = {"CD_CORN_1", "CD_CORN_2"};
사용하여 빅리스트 그리고 작은 목록2 , 난 갖길 원해
sbigList2 = {"ICS_CORN_6", "IPEK21_S00R_P37_2", "CURR_S009_P37_2"};사용하여 빅리스트 그리고 작은 목록3 , 난 갖길 원해
sbigList3 = {"IPEK21_S00R_P37_2", "CURR_S009_P37_2", "Ig_RF", "Cmax03_4C230RF", "NG"};JSL을 통해 이를 수행하는 방법은 무엇입니까?
(sbiglist의 항목 순서는 중요하지 않습니다)
자동화 및 스크립팅윈도우Re: 세 번째 목록의 항목과 부분적으로 일치하는 다른 목록의 목록 항목을 추출하는 방법은 무엇입니까?내가 할 방법은 다음과 같습니다.
Names default to here(1);
bigList = {"CD_CORN_1", "ICS_CORN_6", "IPEK21_S00R_P37_2", "CURR_S009_P37_2", "CD_CORN_2", "Ig_RF", "Cmax03_4C230RF", "NG"};
smallList1 = {"CD_CORN_"}; //note these are repeats and that is how I get them
smallList2 = {"IDS_CORN_", "IPEK21_S00R_", "CURR_S009_"};
smallList3 = {"RF", "IPEK21_S00R_", "CURR_S009_", "NG"};
foundList = {};
For Each( {theList}, bigList,
For Each( {sublist}, smallList1,
if(contains(theList,sublist),
insert into(foundlist, theList)
)
);
For Each( {sublist}, smallList2,
if(contains(theList,sublist),
insert into(foundlist, theList)
)
);
For Each( {sublist}, smallList3,
if(contains(theList,sublist),
insert into(foundlist, theList)
)
);
);
bigList의 각 개별 요소는 개별적으로 평가되어야 합니다.
Re: 세 번째 목록의 항목과 부분적으로 일치하는 다른 목록의 목록 항목을 추출하는 방법은 무엇입니까?나는 아마도 이와 같은 기능을 만들 것입니다
Names Default To Here(1);
bigList = {"CD_CORN_1", "ICS_CORN_6", "IPEK21_S00R_P37_2", "CURR_S009_P37_2", "CD_CORN_2", "Ig_RF", "Cmax03_4C230RF", "NG"};
smallList1 = {"CD_CORN_", "CD_CORN_", "CD_CORN_"};
smallList2 = {"IDS_CORN_", "IPEK21_S00R_", "CURR_S009_"};
smallList3 = {"RF", "IPEK21_S00R_", "CURR_S009_", "NG"};
get_partial_matches = function({to_list, with_list}, {Default Local},
/*""" Get partial matches to_list using with_list
Args:
from_list (list(str)): list to compare to
to_list (list(str)): list to compare with
Returns:
list(str): List with partial matches in alphabetical order
"""*/
matches = Associative Array(); // associative array to avoid duplicates
For Each({to_item}, to_list,
For Each({with_item}, with_list,
If(Contains(to_item, with_item),
Insert Into(matches, to_item);
);
);
);
return(matches << get keys); // << get keys to get result in a list
);
list1 = get_partial_matches(bigList, smallList1);
list2 = get_partial_matches(bigList, smallList2);
list3 = get_partial_matches(bigList, smallList3);
show(list1, list2, list3);
다른 옵션은 이와 같을 것입니다. 하지만 저는 이전 옵션을 사용하는 편이 훨씬 낫습니다.
get_partial_matches2 = function({to_list, with_list}, {Default Local},
matches = Associative Array();
pattern = Concat Items(with_list, "|");
For Each({to_item}, to_list,
res = Regex(to_item, pattern);
If(!IsMissing(res),
Insert Into(matches, to_item);
);
);
return(matches << get keys);
);
list1 = get_partial_matches2(bigList, smallList1);
list2 = get_partial_matches2(bigList, smallList2);
list3 = get_partial_matches2(bigList, smallList3);
show(list1, list2, list3);