0
$\begingroup$

FindTextualAnswer

When I export a CSV file using the code above, I get something like this:

Row

I'd like to export the answers / text on the right column without "Row[{}]" but just the raw text. Is this possible?

Code:

answer[question_, numberofanswers_] := 
  Export[StringJoin[question, ".csv"], 
   FindTextualAnswer[articles, question, 
    numberofanswers, {"Probability",     
      "HighlightedSentence"}]]

articles = WikipediaData /@    
  WikipediaSearch["Content" -> question];

answer["What model occurs in all the sciences?", 1000]

Furthermore, is it possible to export corresponding Wiki page titles and links next to these answers or no?

$\endgroup$
2
  • 1
    $\begingroup$ please post the code itself in a Markdown code block, not an image, so that people can copy it and try to modify it easily! :) $\endgroup$
    – thorimur
    Commented Jun 21, 2020 at 2:45
  • $\begingroup$ @thorimur Great point! So sorry about that! Done. $\endgroup$
    – Youssef A
    Commented Jun 21, 2020 at 3:59

1 Answer 1

1
$\begingroup$

I cannot try your code in version 10.1 but I suspect this is similar:

table = {{0.1, Row[{"first", "row"}, " "]}, {0.2, 
    Row[{"second", "row"}, " "]}, {0.3, Row[{"third", "row"}, " "]}};

ExportString[table, "CSV"]
0.1,Row[{"first", "row"}, " "]
0.2,Row[{"second", "row"}, " "]
0.3,Row[{"third", "row"}, " "]

An adjustment:

ExportString[table /. r_Row :> ToString[r], "CSV"]
0.1,first row
0.2,second row
0.3,third row
$\endgroup$
1
  • $\begingroup$ That worked! Thank you so much! For those who stumble upon this, here's what I added to get it to export a CSV file: answer[question_, numberofanswers_] := WriteString[CreateFile[StringJoin[question, ".csv"]], ExportString[FindTextualAnswer[articles, question, numberofanswers, {"Probability", "HighlightedSentence"] /. r_Row :> ToString[r], "CSV"]] $\endgroup$
    – Youssef A
    Commented Jun 21, 2020 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.