How to form a feature vector from text file?
    4 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Hi, hope anyone can help me, truly appreciated. I have 10 features inside my text file ('Dataset1_Permission.txt') and its' row by row. What I wanted is, if my AndroidManifest.txt exist this feature then output as 1, if not output as 0. So, let say I only have 1 feature inside my Dataset1_Permission.txt file, It should output like..
0010000000
text = fileread('AndroidManifest.txt'); % read input manifest file
text2 = fileread('Dataset1_Permission.txt'); % read android permission list dataset
matchStr = regexpi(text,'\"android.permission.\w*\"','match') %extract the keyword in manifest file
0 件のコメント
採用された回答
  Walter Roberson
      
      
 2017 年 3 月 11 日
        
      編集済み: Walter Roberson
      
      
 2017 年 3 月 12 日
  
      text1 = fileread('AndroidManifest.txt'); % read input manifest file
text2 = regexp(fileread('Dataset1_Permission.txt'), '\r?\n', 'split'); % read android permission list dataset
features = ~cellfun(@isempty,regexp(text1,text2));
2 件のコメント
  Walter Roberson
      
      
 2017 年 3 月 12 日
				
      編集済み: Walter Roberson
      
      
 2017 年 3 月 12 日
  
			I have corrected the code. I made a typing mistake when I was changing your variable "text" to something else to avoid conflict with the important MATLAB plotting routine text().
Note: this code assumes that the first input to regexp() is a single string, not a cell array of strings. The error message you got would occur if you tried to use a cell array of strings.
If you have a cell array of strings to test, then you need to define whether you want one feature vector per cell member, or if you want the feature vector to reflect whether the substrings occur in any of the cell members.
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Characters and Strings についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

